Skip to content

Commit c3e4c2c

Browse files
Merge pull request #376 from thejackshelton/accordion-improvements
docs(accordion): docs improvements, typos, etc
2 parents 823acf6 + c6d54c7 commit c3e4c2c

File tree

3 files changed

+42
-19
lines changed

3 files changed

+42
-19
lines changed

apps/website/src/routes/docs/headless/(components)/accordion/examples.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,11 @@ export const MultiAccordion = component$(() => {
104104
<AccordionContent class="accordion-animation-1 overflow-hidden">
105105
<p class="bg-violet-200 dark:bg-gray-900 p-4 ">
106106
100%. The trigger has a <strong>[data-state]</strong> selector that can be
107-
styled when opened or closed.
107+
styled when equal to the <strong>open</strong> or <strong>closed</strong>{' '}
108+
values.
109+
<br />
110+
<br />
111+
For example, [data-state="open"]
108112
</p>
109113
</AccordionContent>
110114
</AccordionItem>

apps/website/src/routes/docs/headless/(components)/accordion/index.mdx

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import {
77
AccordionItem,
88
AccordionContent,
99
AccordionTrigger,
10-
Checkbox,
10+
AccordionHeader,
1111
} from '@qwik-ui/headless';
12+
1213
import {
1314
HeroAccordion,
1415
MultiAccordion,
@@ -89,7 +90,7 @@ import { AlphaBanner } from '../../../_components/alpha-banner/alpha-banner';
8990
```
9091
</HeroAccordion>
9192

92-
Qwik UI's Accordion implementation follows the [WAI-Aria](https://www.w3.org/WAI/ARIA/apg/patterns/accordion/) design pattern, along with some additional API's that enhance the flexibiltiy, types, and performance.
93+
Qwik UI's Accordion implementation follows the [WAI-Aria](https://www.w3.org/WAI/ARIA/apg/patterns/accordion/) design pattern, along with some additional API's that enhance the flexibility, types, and performance.
9394

9495
##### ✨ Features
9596

@@ -112,10 +113,18 @@ Qwik UI's Accordion implementation follows the [WAI-Aria](https://www.w3.org/WAI
112113
## Building blocks
113114

114115
<CodeExample>
115-
```tsx
116-
import { component$ } from '@builder.io/qwik';
117-
118-
export default component$(() => (
116+
```tsx
117+
import { component$ } from '@builder.io/qwik';
118+
import {
119+
AccordionRoot,
120+
AccordionItem,
121+
AccordionHeader,
122+
AccordionTrigger,
123+
AccordionContent
124+
} from '@qwik-ui/headless';
125+
126+
export default component$(() => {
127+
return (
119128
<AccordionRoot>
120129
<AccordionItem>
121130
<AccordionHeader>
@@ -124,8 +133,9 @@ Qwik UI's Accordion implementation follows the [WAI-Aria](https://www.w3.org/WAI
124133
<AccordionContent>Content</AccordionContent>
125134
</AccordionItem>
126135
</AccordionRoot>
127-
));
128-
```
136+
)
137+
});
138+
```
129139

130140
</CodeExample>
131141

@@ -138,23 +148,23 @@ Qwik UI's Accordion implementation follows the [WAI-Aria](https://www.w3.org/WAI
138148
propDescriptors={[
139149
{
140150
name: 'AccordionRoot',
141-
description: 'The Root container for the accordion.',
151+
description: 'The root container for the accordion.',
142152
},
143153
{
144154
name: 'AccordionItem',
145-
description: `An item inside of the root. It contains the item's heading, trigger, and the content`,
155+
description: `An item inside of the root. It contains the item's heading, trigger, and content.`,
146156
},
147157
{
148158
name: 'AccordionHeader',
149159
description: `An HTML Heading Element. The default is set to h3, can be changed with the as prop.`,
150160
},
151161
{
152162
name: 'AccordionTrigger',
153-
description: `Opens or closes the matching content, and should be put inside the AccordionHeader.`,
163+
description: `Toggles the corresponding content when clicked or activated. It should be placed within the AccordionHeader component.`,
154164
},
155165
{
156166
name: 'AccordionContent',
157-
description: `The content associated with that item when clicking on its respective trigger.`,
167+
description: `Contains the content associated with an item when clicking on its respective trigger.`,
158168
},
159169
]}
160170
/>
@@ -169,16 +179,17 @@ Qwik UI's Accordion implementation follows the [WAI-Aria](https://www.w3.org/WAI
169179
<AccordionItem>
170180
<AccordionHeader>
171181
<AccordionTrigger class="accordion-trigger">
172-
<span>Can I styled based on the trigger state?</span>
182+
<span>Can I style content based on the trigger state?</span>
173183
<span>
174184
<p class="plus-styles">+</p>
175185
</span>
176186
</AccordionTrigger>
177187
</AccordionHeader>
178188
<AccordionContent class="accordion-content">
179189
<p>
180-
100%. The trigger has a [data-state] selector that can be styled when
181-
opened or closed.
190+
100%. The trigger has a [data-state] selector that can be styled when equal to the open or closed values.
191+
192+
For example, [data-state="open"]
182193
</p>
183194
</AccordionContent>
184195
</AccordionItem>
@@ -686,14 +697,14 @@ propDescriptors={[
686697
{
687698
name: 'onSelectedIndexChange$',
688699
type: 'function',
689-
info: '(index: number) => void',
700+
info: 'PropFunction<(index: number) => void>',
690701
description:
691702
'An event hook that gets notified whenever the selected index changes.',
692703
},
693704
{
694705
name: 'onFocusIndexChange$',
695706
type: 'function',
696-
info: '(index: number) => void',
707+
info: 'PropFunction<(index: number) => void>',
697708
description:
698709
'An event hook that gets notified whenever the focus index changes.',
699710
},
@@ -753,6 +764,13 @@ propDescriptors={[
753764
description:
754765
'A custom click handler that executes when the key is pressed down.',
755766
},
767+
{
768+
name: 'onFocus$',
769+
type: 'function',
770+
info: 'PropFunction<() => void>',
771+
description:
772+
'A custom click handler that executes when element is focused.',
773+
},
756774
]}
757775
/>
758776
```

packages/kit-headless/src/components/accordion/accordion-trigger.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,10 @@ export const AccordionTrigger = component$(
108108
<button
109109
ref={ref}
110110
id={triggerId}
111-
data-trigger-id={triggerId}
112111
disabled={disabled}
113112
aria-disabled={disabled}
113+
data-trigger-id={triggerId}
114+
data-state={isTriggerExpandedSig.value ? 'open' : 'closed'}
114115
onClick$={[
115116
$(() => {
116117
selectedTriggerIdSig.value = triggerId;

0 commit comments

Comments
 (0)