Skip to content

Commit

Permalink
Add default focus style to styled Checkbox (#2099)
Browse files Browse the repository at this point in the history
* Add default focus style to styled Checkbox

For: openstax/unified#2713

* update snaps

* Indent style

* Comment to explain defaultFocusOutline
  • Loading branch information
RoyEJohnson authored Jan 10, 2024
1 parent ef6f665 commit 9a33b54
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/app/components/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ const Checkbox = ({children, className, ...props}: React.PropsWithChildren<Props
{children}
</label>;

// Browser default outline for focus items per
// tslint:disable-next-line:max-line-length
// https://stackoverflow.com/questions/20609485/what-is-the-default-style-of-the-blue-focus-outline-in-chrome/38498539#38498539
const defaultFocusOutline = `
outline: 0.1rem dotted #212121;
outline: 0.5rem auto -webkit-focus-ring-color;
`;

export default styled(Checkbox)`
cursor: pointer;
display: flex;
Expand All @@ -67,6 +75,7 @@ export default styled(Checkbox)`
&:focus-within {
border-radius: 0.4rem;
background-color: ${theme.color.neutral.pageBackground};
${defaultFocusOutline}
${CustomCheckbox} {
border: 1px solid ${theme.color.primary.orange.darkest};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ input:checked + .c10 .c12 {
.c8:focus-within {
border-radius: 0.4rem;
background-color: #f1f1f1;
outline: 0.1rem dotted #212121;
outline: 0.5rem auto -webkit-focus-ring-color;
}
.c8:focus-within .c9 {
Expand Down Expand Up @@ -159,6 +161,8 @@ input:checked + .c10 .c12 {
.c15:focus-within {
border-radius: 0.4rem;
background-color: #f1f1f1;
outline: 0.1rem dotted #212121;
outline: 0.5rem auto -webkit-focus-ring-color;
}
.c15:focus-within .c9 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ input:checked + .c8 .c10 {
.c6:focus-within {
border-radius: 0.4rem;
background-color: #f1f1f1;
outline: 0.1rem dotted #212121;
outline: 0.5rem auto -webkit-focus-ring-color;
}
.c6:focus-within .c7 {
Expand Down Expand Up @@ -159,6 +161,8 @@ input:checked + .c8 .c10 {
.c21:focus-within {
border-radius: 0.4rem;
background-color: #f1f1f1;
outline: 0.1rem dotted #212121;
outline: 0.5rem auto -webkit-focus-ring-color;
}
.c21:focus-within .c7 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ input:checked + .c21 .c22 {
.c19:focus-within {
border-radius: 0.4rem;
background-color: #f1f1f1;
outline: 0.1rem dotted #212121;
outline: 0.5rem auto -webkit-focus-ring-color;
}
.c19:focus-within .c20 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ input:checked + .c21 .c22 {
.c19:focus-within {
border-radius: 0.4rem;
background-color: #f1f1f1;
outline: 0.1rem dotted #212121;
outline: 0.5rem auto -webkit-focus-ring-color;
}
.c19:focus-within .c20 {
Expand Down Expand Up @@ -113,6 +115,8 @@ input:checked + .c21 .c22 {
.c25:focus-within {
border-radius: 0.4rem;
background-color: #f1f1f1;
outline: 0.1rem dotted #212121;
outline: 0.5rem auto -webkit-focus-ring-color;
}
.c25:focus-within .c20 {
Expand Down

0 comments on commit 9a33b54

Please sign in to comment.