Skip to content

Commit

Permalink
feat: introduce 3 focus-visible tokens for Skip Link
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbert committed Sep 18, 2024
1 parent d42b8e6 commit 07db8f0
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 12 deletions.
15 changes: 15 additions & 0 deletions .changeset/olive-numbers-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
"@utrecht/skip-link-css": minor
---

Add new tokens for Skip Link, to replace deprecated tokens:

- `utrecht.skip-link.focus-visible.color`
- `utrecht.skip-link.focus-visible.background-color`
- `utrecht.skip-link.focus-visible.text-decoration`

The following Skip Link tokens are now deprecated:

- `utrecht.skip-link.focus.color`
- `utrecht.skip-link.focus.background-color`
- `utrecht.skip-link.focus.text-decoration`
10 changes: 9 additions & 1 deletion components/skip-link/src/_mixin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,18 @@
text-decoration: var(--utrecht-skip-link-text-decoration);
}

/* stylelint-disable-next-line block-no-empty */
@mixin utrecht-skip-link--focus {
}

@mixin utrecht-skip-link--focus-visible {
@include utrecht-focus-ring;

text-decoration: var(--utrecht-skip-link-focus-text-decoration);
/* `var(--utrecht-skip-link-focus-text-decoration)` is deprecated, but for now we keep it for backwards compatibility */
text-decoration: var(
--utrecht-skip-link-focus-visible-text-decoration,
var(--utrecht-skip-link-focus-text-decoration)
);
}

@mixin utrecht-skip-link--hidden {
Expand Down
12 changes: 9 additions & 3 deletions components/skip-link/src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,14 @@
@include utrecht-skip-link--visible;
}

.utrecht-skip-link--focus,
.utrecht-skip-link:focus,
/*
* @deprecated `utrecht-skip-link--focus` is deprecated, use `utrecht-skip-link--focus-visible` instead.
*/
.utrecht-skip-link--focus {
@include utrecht-skip-link--focus-visible;
}

.utrecht-skip-link--focus-visible,
.utrecht-skip-link:focus-visible {
@include utrecht-skip-link--focus;
@include utrecht-skip-link--focus-visible;
}
38 changes: 38 additions & 0 deletions components/skip-link/src/tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,44 @@
"type": "other"
},
"focus": {
"background-color": {
"$extensions": {
"nl.nldesignsystem.css.property": {
"syntax": "<color>",
"inherits": true
},
"nl.nldesignsystem.figma.supports-token": true,
"nl.nldesignsystem.deprecated": true,
"nl.nldesignsystem.redirect": "utrecht.skip-link.focus-visible.background-color"
},
"type": "color"
},
"color": {
"$extensions": {
"nl.nldesignsystem.css.property": {
"syntax": "<color>",
"inherits": true
},
"nl.nldesignsystem.figma.supports-token": true,
"nl.nldesignsystem.deprecated": true,
"nl.nldesignsystem.redirect": "utrecht.skip-link.focus-visible.color"
},
"type": "color"
},
"text-decoration": {
"$extensions": {
"nl.nldesignsystem.css.property": {
"syntax": ["inherit", "none", "underline"],
"inherits": true
},
"nl.nldesignsystem.figma.supports-token": true,
"nl.nldesignsystem.deprecated": true,
"nl.nldesignsystem.redirect": "utrecht.skip-link.focus-visible.text-decoration"
},
"type": "textDecoration"
}
},
"focus-visible": {
"background-color": {
"$extensions": {
"nl.nldesignsystem.css.property": {
Expand Down
18 changes: 12 additions & 6 deletions packages/storybook-css/src/SkipLink.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ interface SkipLinkStoryProps extends SkipLinkProps {
visibleOnFocus?: boolean;
}

const SkipLinkStory = ({ focus, visibility, visibleOnFocus, ...restProps }: SkipLinkStoryProps) => (
const SkipLinkStory = ({ focusVisible, visibility, visibleOnFocus, ...restProps }: SkipLinkStoryProps) => (
<SkipLink
className={clsx({
'utrecht-skip-link--focus': focus,
'utrecht-skip-link--focus-visible': focusVisible,
'utrecht-skip-link--visible-on-focus': visibleOnFocus,
'utrecht-skip-link--hidden': visibility === 'hidden',
'utrecht-skip-link--visible': visibility === 'visible',
Expand Down Expand Up @@ -49,6 +49,12 @@ const meta = {
required: true,
},
},
focusVisible: {
description: 'Simulate :focus-visible',
type: {
name: 'boolean',
},
},
visibility: {
description: 'Visibilty',
type: 'select',
Expand All @@ -62,7 +68,7 @@ const meta = {
args: {
children: '',
href: '',
focus: false,
focusVisible: false,
visibility: '',
visibleOnFocus: false,
},
Expand Down Expand Up @@ -94,7 +100,7 @@ type Story = StoryObj<typeof meta>;
export const Default: Story = {
args: {
href: '#main',
focus: true,
focusVisible: true,
children: 'Skip to main content',
visibility: 'visible',
},
Expand All @@ -110,7 +116,7 @@ export const Default: Story = {
export const VisibleOnFocus: Story = {
args: {
href: '#main',
focus: true,
focusVisible: true,
children: 'Skip to main content',
visibleOnFocus: true,
},
Expand All @@ -129,7 +135,7 @@ export const VisibleOnFocus: Story = {
export const RightToLeft: Story = {
args: {
href: '#main',
focus: true,
focusVisible: true,
children: 'تخطي إلى المحتوى الرئيسي',
visibility: 'visible',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
"text-decoration": { "value": "{utrecht.link.text-decoration}" },
"focus": {
"color": { "value": "{utrecht.topnav.link.focus.color}" },
"background-color": { "value": "{utrecht.topnav.link.focus.background-color}" },
"text-decoration": { "value": "{utrecht.link.focus.text-decoration}" }
"background-color": { "value": "{utrecht.topnav.link.focus.background-color}" }
},
"focus-visible": {
"text-decoration": { "value": "{utrecht.link.focus-visible.text-decoration}" }
}
}
}
Expand Down

0 comments on commit 07db8f0

Please sign in to comment.