Skip to content

Commit

Permalink
🐛 fix active/checked state on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann committed Dec 13, 2024
1 parent 28ba2e4 commit 64f4747
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
11 changes: 4 additions & 7 deletions packages/@ourworldindata/components/src/Checkbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,21 @@
svg {
font-size: 10px;
padding-left: 0.75px;
display: none;
}
}

input:focus-visible + .custom {
outline: 2px solid $controls-color;
}

input:active + .custom {
background: $active-fill;
}

input:checked + .custom {
background: $active-fill;
border-color: $active-fill;
}

input:checked:active + .custom {
background: white;
svg {
display: block;
}
}

.label {
Expand Down
2 changes: 1 addition & 1 deletion packages/@ourworldindata/components/src/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class Checkbox extends React.Component<{
onChange={onChange}
/>
<div className="custom">
{checked && <FontAwesomeIcon icon={faCheck} />}
<FontAwesomeIcon icon={faCheck} />
</div>
<div className="label">{label}</div>
</label>
Expand Down
6 changes: 6 additions & 0 deletions packages/@ourworldindata/components/src/RadioButton.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,19 @@
height: math.div($radio-size, 2);
background-color: $active-fill;
border-radius: 50%;
display: none;
}
}

input:focus-visible + .outer {
outline: 2px solid $controls-color;
}

input:active + .outer .inner,
input:checked + .outer .inner {
display: block;
}

.label {
@include grapher_label-2-regular;
padding-left: $radio-size + 8px;
Expand Down
2 changes: 1 addition & 1 deletion packages/@ourworldindata/components/src/RadioButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class RadioButton extends React.Component<{
onChange={onChange}
/>
<div className="outer">
{checked && <div className="inner" />}
<div className="inner" />
</div>
<div className="label">{label}</div>
</label>
Expand Down

0 comments on commit 64f4747

Please sign in to comment.