Skip to content

Commit

Permalink
fix: better CSS custom property name for focus styles
Browse files Browse the repository at this point in the history
  • Loading branch information
receter committed Oct 2, 2024
1 parent 6449858 commit 9045ec3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/ui/fixtures/simpleForm.fixture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function Fixture() {
<FormField label="What is your name?">
{({ htmlFor }) => <TextInput id={htmlFor} />}
</FormField>
<FormField label="What is your number?" htmlFor="my-custom-id">
<FormField label="What is your number?">
{({ htmlFor }) => <TextInput id={htmlFor} type="tel" />}
</FormField>
<div className={classButtonGroup}>
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/lib/Button/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ a.button {
}

.button:focus-visible {
outline: var(--sys42-button-outline--focus-visible);
outline-offset: var(--sys42-button-outline-offset--focus-visible);
outline: var(--sys42-focus-outline);
outline-offset: var(--sys42-focus-outline-offset);
}

.button:hover {
Expand Down
6 changes: 6 additions & 0 deletions packages/ui/lib/TextInput/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@
var(--sys42-input-text-border-width)
);
}

.textInput:focus,
.textInput:focus-visible {
outline: var(--sys42-focus-outline);
outline-offset: var(--sys42-focus-outline-offset);
}
9 changes: 5 additions & 4 deletions packages/ui/lib/default-custom-properties.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
--sys42-border-radius-md: 0.5rem;
--sys42-border-radius-lg: 1rem;

/* Focus style */
/* This is used for :focus-visible (buttons) and :focus (inputs) */
--sys42-focus-outline: 0.125rem solid #505b92;
--sys42-focus-outline-offset: 0.125rem;

/* Button */
/* There is a bug with border-width in Firefox when values differ between normal and :hover */
--sys42-button-background: #dfe1f9;
Expand All @@ -32,10 +37,6 @@
--sys42-button-box-shadow: none;
--sys42-button-transition: none;

/* :focus-visible */
--sys42-button-outline--focus-visible: 0.125rem solid #505b92;
--sys42-button-outline-offset--focus-visible: 0.125rem;

/* :hover */
--sys42-button-background--hover: #d3d4ec;
--sys42-button-border-color--hover: var(--sys42-button-border-color);
Expand Down

0 comments on commit 9045ec3

Please sign in to comment.