Skip to content

Commit

Permalink
docs(collapsible): added a11y section in collapsible doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Powerplex committed Jun 7, 2024
1 parent b196c08 commit caec9de
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/components/collapsible/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"wai-aria",
"aria",
"a11y",
"collapsible"
"collapsible",
"disclosure"
],
"main": "./dist/index.js",
"module": "./dist/index.mjs",
Expand Down
16 changes: 16 additions & 0 deletions packages/components/collapsible/src/Collapsible.doc.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Meta, Canvas } from '@storybook/addon-docs'
import { ArgTypes } from '@storybook/blocks'
import { Kbd } from '@spark-ui/kbd'

import { Collapsible } from '.'

Expand Down Expand Up @@ -38,3 +39,18 @@ A `Collapsible` is closed by default. Interacting with its trigger will open the
### Animation

TODO

## Accessibility

Adheres to the [Disclosure (Show/Hide) Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/).

### Keyboard Interactions

- <Kbd>Enter</Kbd> - activates the disclosure control and toggles the visibility of the disclosure content.
- <Kbd>Space</Kbd> - activates the disclosure control and toggles the visibility of the disclosure content.

### WAI-ARIA Roles, States, and Properties

- The element that shows and hides the content has role [button](https://w3c.github.io/aria/#button).
- When the content is visible, the element with role button has [aria-expanded](https://w3c.github.io/aria/#aria-expanded) set to `true`. When the content area is hidden, it is set to `false`.
- Optionally, the element with role button has a value specified for [aria-controls](https://w3c.github.io/aria/#aria-controls) that refers to the element that contains all the content that is shown or hidden.
4 changes: 1 addition & 3 deletions packages/components/collapsible/src/Collapsible.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ const meta: Meta<typeof Collapsible> = {
export default meta

const CartItem = ({ children }: PropsWithChildren) => {
return (
<div className="rounded-md bg-neutral-container p-lg text-on-neutral-container">{children}</div>
)
return <div className="rounded-md bg-main-container p-lg text-on-main-container">{children}</div>
}

export const Default: StoryFn = () => {
Expand Down

0 comments on commit caec9de

Please sign in to comment.