Skip to content

Commit dc487a0

Browse files
docs: improving collapsible docs
1 parent 33c7f1b commit dc487a0

File tree

4 files changed

+68
-23
lines changed

4 files changed

+68
-23
lines changed
Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
11
import { component$ } from '@builder.io/qwik';
22
import { CheckIcon } from '../icons/Check';
33
import { Roadmap } from '../icons/Roadmap';
4+
import { IssueIcon } from '../icons/Issues';
45

56
type FeatureListProps = {
67
features: string[];
78
roadmap?: string[];
9+
issues?: string[];
810
};
911

1012
export const FeatureList = component$((props: FeatureListProps) => {
1113
return (
1214
<ul class="mb-12 mt-[-16px] !px-0">
13-
{props.features.map((descriptor) => {
14-
return (
15-
<li
16-
key={descriptor}
17-
class="flex w-full list-none items-center gap-x-2 gap-y-4 border-b-[1px] border-slate-200 py-2 dark:border-slate-800"
18-
>
19-
<CheckIcon class="min-w-[21px]" />
20-
{descriptor}
21-
</li>
22-
);
23-
})}
15+
{props.features && (
16+
<>
17+
{props.features.map((descriptor) => {
18+
return (
19+
<li
20+
key={descriptor}
21+
class="flex w-full list-none items-center gap-x-2 gap-y-4 border-b-[1px] border-slate-200 py-2 dark:border-slate-800"
22+
>
23+
<CheckIcon class="min-w-[21px]" />
24+
{descriptor}
25+
</li>
26+
);
27+
})}
28+
</>
29+
)}
2430
{props.roadmap && (
2531
<>
2632
<h3 class="mb-6 mt-8 scroll-mt-20 text-xl font-semibold">Roadmap</h3>
@@ -39,6 +45,23 @@ export const FeatureList = component$((props: FeatureListProps) => {
3945
})}
4046
</>
4147
)}
48+
{props.issues && (
49+
<>
50+
{props.issues.map((descriptor) => {
51+
return (
52+
<>
53+
<li
54+
key={descriptor}
55+
class="flex w-full list-none items-center gap-x-2 gap-y-4 border-b-[1px] border-slate-200 py-2 dark:border-slate-800"
56+
>
57+
<IssueIcon class="min-w-[21px]" />
58+
{descriptor}
59+
</li>
60+
</>
61+
);
62+
})}
63+
</>
64+
)}
4265
</ul>
4366
);
4467
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { PropsOf } from '@builder.io/qwik';
2+
3+
export function IssueIcon(props: PropsOf<'svg'>, key: string) {
4+
return (
5+
<svg
6+
xmlns="http://www.w3.org/2000/svg"
7+
width="1.35em"
8+
height="1.35em"
9+
viewBox="0 0 256 256"
10+
{...props}
11+
key={key}
12+
>
13+
<g fill="hsl(var(--alert))">
14+
<path d="M224 128a96 96 0 1 1-96-96a96 96 0 0 1 96 96" opacity=".2"></path>
15+
<path d="M176 128a8 8 0 0 1-8 8H88a8 8 0 0 1 0-16h80a8 8 0 0 1 8 8m56 0A104 104 0 1 1 128 24a104.11 104.11 0 0 1 104 104m-16 0a88 88 0 1 0-88 88a88.1 88.1 0 0 0 88-88"></path>
16+
</g>
17+
</svg>
18+
);
19+
}

apps/website/src/routes/docs/headless/collapsible/index.mdx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,27 @@ An interactive component which expands/collapses a panel.
4848

4949
## Why use a headless collapsible?
5050

51-
## Animation
51+
One of the most common questions: _"why not use the native `details` and `summary` HTML elements?"_.
5252

53-
<Showcase name="animation" />
53+
As much as we love the native elements, they come with a couple of problems:
5454

55-
Follows the WAI-ARIA disclosure pattern.
55+
### Native element pain points
5656

5757
<FeatureList
58-
features={[
59-
'Can open by default on SSR (without waking up the component!)',
60-
'Does not execute until interaction (including programmatically)',
61-
'Does not use any visible tasks',
62-
'Automatic animation detection (deprecating the `animated` prop)',
63-
`Provides a bind:isOpen prop so that users can open or close it however they'd like (controlled)`,
64-
'A `defaultOpen` prop to open it by default (uncontrolled)',
65-
'Style based on data states. `initial`, `open`, or `closed`',
58+
issues={[
59+
'Inconsistent accessibility and browser support',
60+
'Inconsistent screen reader support',
61+
'Hierarchy and DOM structure restrictions',
62+
'Lack of full programmatic control',
6663
]}
6764
/>
6865

66+
> To read more about the reasons for implementing an ARIA disclosure widget, check out [Scott O'Hara's article](https://www.scottohara.me/blog/2022/09/12/details-summary.html), as well as the [interactive elements](https://html.spec.whatwg.org/multipage/interactive-elements.html#interactive-elements) section of the HTML spec.
67+
68+
## Animating the content
69+
70+
<Showcase name="animation" />
71+
6972
## Jack's bug watch 🔎:
7073

7174
<strong style={{ color: 'red' }}>BUG:</strong> Refresh the page and click on programmatic toggle.

apps/website/src/routes/docs/headless/collapsible/snippets/building-blocks.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@qwik-ui/he
33

44
export default component$(() => (
55
<Collapsible>
6-
<CollapsibleTrigger>Trigger</CollapsibleTrigger>
6+
<CollapsibleTrigger>Button</CollapsibleTrigger>
77
<CollapsibleContent>Content</CollapsibleContent>
88
</Collapsible>
99
));

0 commit comments

Comments
 (0)