Skip to content

Commit 4d3ca29

Browse files
committed
feat: sync docs and examples to upstream base structure
- Sync 56 MDX docs to shadcn-ui/ui v4 base pattern (frontmatter, CodeTabs→Tabs, Steps) - Move 423 examples to examples/stylex/ with React.lazy registry - Add ExamplesIndex.stylex with getComponent() for name-based resolution - Remove children-based ComponentPreview, use childless name prop - Remove changelog sections from component docs - Add StyleX configuration step to all manual installation tabs - Remove Tailwind mentions from docs - Remove barrel __index__.tsx re-exports (unused) - Fix lint and typecheck (0 errors)
1 parent b486ff9 commit 4d3ca29

612 files changed

Lines changed: 21012 additions & 8306 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@ next-env.d.ts
4949
# package builds
5050
**/dist
5151
**/.turbo
52+
**/styled-system
Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,52 @@
1-
import type { ReactNode } from "react";
2-
31
import { ComponentPreviewTabs } from "@/components/component-preview-tabs";
42
import { ComponentSource } from "@/components/component-source";
3+
import { getComponent } from "@/examples/__index__";
54

65
export const ComponentPreview = ({
76
name,
8-
children,
97
className,
108
previewClassName,
119
align = "center",
1210
direction = "ltr",
1311
hideCode = false,
1412
}: {
1513
name?: string;
16-
children?: ReactNode;
1714
className?: string;
1815
previewClassName?: string;
1916
align?: "center" | "start" | "end";
2017
direction?: "ltr" | "rtl";
2118
hideCode?: boolean;
22-
}) => (
23-
<ComponentPreviewTabs
24-
align={align}
25-
className={className}
26-
component={children}
27-
direction={direction}
28-
hideCode={hideCode || !name}
29-
previewClassName={previewClassName}
30-
source={name ? <ComponentSource collapsible={false} name={name} /> : null}
31-
sourcePreview={
32-
name ? (
19+
}) => {
20+
if (!name) {
21+
return null;
22+
}
23+
24+
const Component = getComponent(name);
25+
26+
if (!Component) {
27+
return (
28+
<p className="mt-6 text-sm text-muted-foreground">
29+
Component{" "}
30+
<code className="relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm">
31+
{name}
32+
</code>{" "}
33+
not found in registry.
34+
</p>
35+
);
36+
}
37+
38+
return (
39+
<ComponentPreviewTabs
40+
align={align}
41+
className={className}
42+
component={<Component />}
43+
direction={direction}
44+
hideCode={hideCode}
45+
previewClassName={previewClassName}
46+
source={<ComponentSource collapsible={false} name={name} />}
47+
sourcePreview={
3348
<ComponentSource collapsible={false} maxLines={6} name={name} />
34-
) : null
35-
}
36-
/>
37-
);
49+
}
50+
/>
51+
);
52+
};
Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
11
---
22
title: Accordion
33
description: A vertically stacked set of interactive headings that each reveal a section of content.
4+
component: true
45
links:
56
doc: https://base-ui.com/react/components/accordion
67
api: https://base-ui.com/react/components/accordion#api-reference
78
---
89

9-
import AccordionDemo from "@/examples/accordion-demo";
10-
import AccordionBasic from "@/examples/accordion-basic";
11-
import AccordionMultiple from "@/examples/accordion-multiple";
12-
import AccordionDisabled from "@/examples/accordion-disabled";
13-
import AccordionBorders from "@/examples/accordion-borders";
14-
import AccordionCard from "@/examples/accordion-card";
15-
16-
<ComponentPreview name="accordion-demo" align="start">
17-
<AccordionDemo />
18-
</ComponentPreview>
10+
<ComponentPreview
11+
name="accordion-demo"
12+
align="start"
13+
previewClassName="*:data-[slot=accordion]:max-w-sm h-[300px]"
14+
/>
1915

2016
## Installation
2117

2218
<Tabs defaultValue="cli">
2319

2420
<TabsList>
25-
<TabsTrigger value="cli">CLI</TabsTrigger>
21+
<TabsTrigger value="cli">Command</TabsTrigger>
2622
<TabsTrigger value="manual">Manual</TabsTrigger>
2723
</TabsList>
2824

@@ -63,16 +59,16 @@ pnpm add @base-ui/react @stylexjs/stylex
6359

6460
## Usage
6561

66-
```tsx
62+
```tsx showLineNumbers
6763
import {
6864
Accordion,
6965
AccordionContent,
7066
AccordionItem,
7167
AccordionTrigger,
72-
} from "@/components/ui/accordion/accordion";
68+
} from "@/components/ui/accordion";
7369
```
7470

75-
```tsx
71+
```tsx showLineNumbers
7672
<Accordion defaultValue={["item-1"]}>
7773
<AccordionItem value="item-1">
7874
<AccordionTrigger>Is it accessible?</AccordionTrigger>
@@ -87,7 +83,7 @@ import {
8783

8884
Use the following composition to build an `Accordion`:
8985

90-
```txt
86+
```text
9187
Accordion
9288
├── AccordionItem
9389
│ ├── AccordionTrigger
@@ -97,59 +93,62 @@ Accordion
9793
└── AccordionContent
9894
```
9995

100-
## Examples
101-
102-
### Basic
96+
## Basic
10397

10498
A basic accordion that shows one item at a time. The first item is open by default.
10599

106-
<ComponentPreview name="accordion-basic" align="start">
107-
<AccordionBasic />
108-
</ComponentPreview>
100+
<ComponentPreview
101+
name="accordion-basic"
102+
align="start"
103+
previewClassName="*:data-[slot=accordion]:max-w-sm h-[300px]"
104+
/>
109105

110-
### Multiple
106+
## Multiple
111107

112108
Use the `multiple` prop to allow multiple items to be open at the same time.
113109

114-
<ComponentPreview name="accordion-multiple" align="start">
115-
<AccordionMultiple />
116-
</ComponentPreview>
110+
<ComponentPreview
111+
name="accordion-multiple"
112+
align="start"
113+
previewClassName="*:data-[slot=accordion]:max-w-sm h-[450px]"
114+
/>
117115

118-
### Disabled
116+
## Disabled
119117

120118
Use the `disabled` prop on `AccordionItem` to disable individual items.
121119

122-
<ComponentPreview name="accordion-disabled" align="start">
123-
<AccordionDisabled />
124-
</ComponentPreview>
120+
<ComponentPreview
121+
name="accordion-disabled"
122+
align="start"
123+
previewClassName="*:data-[slot=accordion]:max-w-sm h-[300px]"
124+
/>
125125

126-
### Borders
126+
## Borders
127127

128-
Wrap the `Accordion` in a bordered, rounded container to group the items.
128+
Add `border` to the `Accordion` and `border-b last:border-b-0` to the `AccordionItem` to add borders to the items.
129129

130-
<ComponentPreview name="accordion-borders" align="start">
131-
<AccordionBorders />
132-
</ComponentPreview>
130+
<ComponentPreview
131+
name="accordion-borders"
132+
align="start"
133+
previewClassName="*:data-[slot=accordion]:max-w-sm h-[300px]"
134+
/>
133135

134-
### Card
136+
## Card
135137

136138
Wrap the `Accordion` in a `Card` component.
137139

138-
<ComponentPreview name="accordion-card" align="start">
139-
<AccordionCard />
140-
</ComponentPreview>
141-
142-
import AccordionRtl from "@/examples/accordion-rtl";
140+
<ComponentPreview
141+
name="accordion-card"
142+
align="start"
143+
previewClassName="*:data-[slot=accordion]:max-w-sm h-[435px]"
144+
/>
143145

144146
## RTL
145147

146-
To enable right-to-left support, see the [RTL guide](/docs/rtl).
148+
To enable RTL support in shadcn/ui, see the [RTL configuration guide](/docs/rtl).
147149

148-
<ComponentPreview name="accordion-rtl" direction="rtl">
149-
<AccordionRtl />
150-
</ComponentPreview>
150+
<ComponentPreview name="accordion-rtl" align="start" direction="rtl" />
151151

152152
## API Reference
153153

154-
See the [Base UI](https://base-ui.com/react/components/accordion#api-reference)
155-
documentation for the full API.
154+
See the [Base UI](https://base-ui.com/react/components/accordion#api-reference) documentation for more information.

0 commit comments

Comments
 (0)