Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style(v2): update aria-label for accessibility of checkbox #708

Merged
merged 1 commit into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 35 additions & 4 deletions packages/ui/src/components/checkbox/checkbox.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
onClick: {
action: 'onClick',
},
'aria-label': {
control: 'text',
description:
'attribute defines a string value that labels an interactive element',
},
},
} satisfies Meta<Checkbox>
</script>
Expand All @@ -34,13 +39,39 @@
</Template>

<!-- 👇 Each story then reuses that template -->
<Story name="Unchecked" args="{{ checked: false, label: 'Accept Terms' }}" />
<Story
name="Unchecked"
args="{{
checked: false,
label: 'Accept Terms',
'aria-label': 'for accept terms',
}}"
/>

<Story name="Checked" args="{{ checked: true, label: 'Accept Terms' }}" />
<Story
name="Checked"
args="{{
checked: true,
label: 'Accept Terms',
'aria-label': 'for accept terms',
}}"
/>

<Story name="Unchecked Without Label" args="{{ checked: false }}" />
<Story
name="Unchecked Without Label"
args="{{
checked: false,
'aria-label': 'for example of unchecked checkbox without label',
}}"
/>

<Story name="Checked Without Label" args="{{ checked: true }}" />
<Story
name="Checked Without Label"
args="{{
checked: true,
'aria-label': 'for example of checkbox without label',
}}"
/>

<Story
name="Disabled Checkbox"
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/checkbox/checkbox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
export { className as class }
</script>

<div let:label class="flex items-center space-x-2 p-1">
<div class="flex items-center space-x-2 p-1">
<CheckboxPrimitive.Root
class="{cn(
'border-on-surface-placeholder ring-offset-background focus-visible:ring-ring data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-neutral-white peer box-content h-4 w-4 shrink-0 rounded-sm border-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-50',
Expand Down
Loading