Skip to content

Commit 7a93ebe

Browse files
committed
Using redesigned checkboxes rather than toggle switches
1 parent f0a9d02 commit 7a93ebe

File tree

3 files changed

+68
-72
lines changed

3 files changed

+68
-72
lines changed

src/components/addons.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ const AddonsItem = ({ inputId, inputChecked, onInputChange, Options, onIconClick
1212
return (
1313
<>
1414
<div className="py-2 flex justify-start items-center text-sm sm:text-lg">
15-
<label htmlFor={inputId} className="cursor-pointer flex items-center">
15+
<label htmlFor={inputId} className="checkbox-label flex items-center">
1616
<input
17-
type="checkbox"
1817
id={inputId}
18+
type="checkbox"
19+
className="checkbox-label__input"
1920
checked={inputChecked}
2021
onChange={onInputChange}
2122
/>
23+
<span class="checkbox-label__control" />
2224
<span className="pl-4">{props.children}</span>
2325
</label>
2426
{Options && (

src/components/skills.js

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,27 @@ const Skills = props => {
99
const inputRef = React.createRef()
1010
const createSkill = skill => {
1111
return (
12-
<div
13-
className="skillCheckbox w-1/3 sm:w-1/4 my-6 flex items-center"
14-
key={skill}>
15-
<input
16-
type="checkbox"
17-
id={skill}
18-
className="offscreen"
19-
checked={props.skills[skill]}
20-
onChange={event => props.handleSkillsChange(skill)}
21-
/>
22-
<label htmlFor={skill} className="switch cursor-pointer" />
23-
<img
24-
className="ml-4 w-8 h-8 sm:w-10 sm:h-10 cursor-pointer"
25-
onClick={event => props.handleSkillsChange(skill)}
26-
src={icons[skill]}
27-
alt={skill}
28-
/>
29-
<span className="tooltiptext">{skill}</span>
30-
</div>
12+
<div className="w-1/3 sm:w-1/4 my-6" key={skill}>
13+
<label
14+
htmlFor={skill}
15+
className="checkbox-label flex items-center justify-start"
16+
>
17+
<input
18+
id={skill}
19+
type="checkbox"
20+
className="checkbox-label__input"
21+
checked={props.skills[skill]}
22+
onChange={event => props.handleSkillsChange(skill)}
23+
/>
24+
<span class="checkbox-label__control" />
25+
<img
26+
className="ml-4 w-8 h-8 sm:w-10 sm:h-10"
27+
src={icons[skill]}
28+
alt={skill}
29+
/>
30+
<span className="tooltiptext">{skill}</span>
31+
</label>
32+
</div>
3133
)
3234
}
3335

@@ -101,4 +103,4 @@ const Skills = props => {
101103
)
102104
}
103105

104-
export default Skills
106+
export default Skills

src/pages/index.css

Lines changed: 42 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@import url("https://fonts.googleapis.com/css2?family=Lato&display=swap");
22
@import url("https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@300;400&display=swap");
3+
34
:root {
45
--grey-05: #f5f6f7;
56
--grey-10: #dfdfe2;
@@ -25,12 +26,45 @@ body {
2526
color: var(--grey-90);
2627
}
2728

28-
[type="checkbox"] {
29-
-webkit-box-shadow: 0 1px 1px var(--grey-90) !important;
30-
-moz-box-shadow: 0 1px 1px var(--grey-90) !important;
31-
box-shadow: 0 1px 1px var(--grey-90) !important;
29+
input[type="checkbox"] {
30+
box-sizing: border-box;
31+
padding: 0;
32+
}
33+
34+
.checkbox-label {
3235
cursor: pointer;
33-
border-radius: 0px !important;
36+
}
37+
.checkbox-label:hover .tooltiptext {
38+
visibility: visible;
39+
}
40+
.checkbox-label__input {
41+
position: absolute;
42+
opacity: 0;
43+
}
44+
.checkbox-label__control {
45+
position: relative;
46+
display: inline-block;
47+
width: 24px;
48+
height: 24px;
49+
margin-right: 12px;
50+
vertical-align: middle;
51+
background-color: var(--grey-05);
52+
border: 2px solid var(--grey-90);
53+
transform: scale(0.75);
54+
}
55+
.checkbox-label__input:checked + .checkbox-label__control:after {
56+
position: absolute;
57+
display: block;
58+
content: "";
59+
top: 5px;
60+
left: 5px;
61+
width: 10px;
62+
height: 10px;
63+
background-color: var(--dark-purple);
64+
}
65+
.checkbox-label__input:hover + .checkbox-label__control,
66+
.checkbox-label__input:focus + .checkbox-label__control {
67+
box-shadow: 0 0 0 10px rgba(10, 10, 35, .1);
3468
}
3569

3670
.section {
@@ -79,51 +113,6 @@ a {
79113
padding: 2% 5%;
80114
font-size: 14px;
81115
}
82-
83-
.skillCheckbox:hover .tooltiptext {
84-
visibility: visible;
85-
}
86-
87-
.switch {
88-
position: relative;
89-
display: inline-block;
90-
width: 40px;
91-
height: 20px;
92-
background-color: rgba(0, 0, 0, 0.25);
93-
border-radius: 20px;
94-
transition: all 0.25s;
95-
}
96-
.switch::after {
97-
content: '';
98-
position: absolute;
99-
width: 16px;
100-
height: 16px;
101-
border-radius: 16px;
102-
background-color: #fff;
103-
top: 2px;
104-
left: 2px;
105-
transition: all 0.25s;
106-
}
107-
108-
input[type='checkbox']:checked+.switch::after {
109-
transform: translateX(20px);
110-
}
111-
input[type='checkbox']:checked+.switch {
112-
background-color: var(--light-green);
113-
}
114-
input[type='checkbox']:focus+.switch {
115-
background-color: var(--blue);
116-
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
117-
}
118-
input[type='checkbox']:checked:focus+.switch {
119-
background-color: var(--light-green);
120-
}
121-
122-
.offscreen {
123-
position: absolute;
124-
left: -9999px;
125-
}
126-
127116
.tooltiptext::after {
128117
content: " ";
129118
position: absolute;
@@ -135,6 +124,7 @@ input[type='checkbox']:checked:focus+.switch {
135124
border-style: solid;
136125
border-color: transparent var(--grey-90) transparent transparent;
137126
}
127+
138128
.workflow {
139129
margin-left: 2%;
140130
padding: 1%;
@@ -160,9 +150,11 @@ input[type='checkbox']:checked:focus+.switch {
160150
.tooltiptext {
161151
display: none;
162152
}
153+
163154
.warning {
164155
font-size: 10px;
165156
}
157+
166158
.workflow {
167159
font-size: 12px;
168160
}

0 commit comments

Comments
 (0)