forked from ontoportal/ontoportal_web_ui
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the design of the switch component
- Loading branch information
1 parent
8c2dcaf
commit e10b7e7
Showing
4 changed files
with
74 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
@import 'chips'; | ||
@import 'card_message' | ||
@import 'card_message'; | ||
@import "switch"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
|
||
.switch-filter{ | ||
display:flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
margin-bottom: 20px; | ||
} | ||
.switch-filter p{ | ||
font-size: 16px; | ||
color: #666666; | ||
margin-bottom: 0; | ||
margin-right: 10px; | ||
} | ||
|
||
|
||
|
||
/* Toggle switch css */ | ||
.switch { | ||
position: relative; | ||
display: inline-block; | ||
width: 40px; | ||
height: 20px; | ||
margin-bottom: 0; | ||
} | ||
.switch input { | ||
opacity: 0; | ||
width: 0; | ||
height: 0; | ||
} | ||
.slider { | ||
position: absolute; | ||
cursor: pointer; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
background-color: #ccc; | ||
-webkit-transition: .4s; | ||
transition: .4s; | ||
border-radius: 34px; | ||
} | ||
.slider:before { | ||
position: absolute; | ||
content: ""; | ||
height: 13px; | ||
width: 13px; | ||
left: 4px; | ||
bottom: 4px; | ||
background-color: white; | ||
-webkit-transition: .4s; | ||
transition: .4s; | ||
border-radius: 50%; | ||
} | ||
input:checked + .slider { | ||
background-color: var(--primary-color); | ||
} | ||
input:focus + .slider { | ||
box-shadow: 0 0 1px var(--primary-color); | ||
} | ||
input:checked + .slider:before { | ||
-webkit-transform: translateX(19px); | ||
-ms-transform: translateX(19px); | ||
transform: translateX(19px); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 7 additions & 4 deletions
11
app/components/switch_input_component/switch_input_component.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
%div.custom-control.custom-switch | ||
%div.switch-filter | ||
- if @boolean_switch | ||
= hidden_field_tag @name, @value | ||
= check_box_tag check_box_name, @value, @checked, class: 'custom-control-input', id: check_box_id, onChange: "#{boolean_switch_action}" | ||
%label.custom-control-label{for: check_box_id} | ||
= content || @label | ||
- if content || [email protected]? | ||
%p | ||
= content || @label | ||
%label.switch{for: check_box_id} | ||
= check_box_tag check_box_name, @value, @checked, class: '', id: check_box_id, onChange: "#{boolean_switch_action}" | ||
%span.slider |