Skip to content

Commit f5f889b

Browse files
committed
Use md-react-preview for documentation
1 parent 979712d commit f5f889b

22 files changed

Lines changed: 2198 additions & 186 deletions

docs/components/action-panel.md

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,24 @@ import { ActionPanel } from "@tailor-platform/app-shell";
1515

1616
## Basic Usage
1717

18-
```tsx
18+
```tsx preview height="350"
19+
import { ActionPanel } from "@tailor-platform/app-shell";
20+
import { ReceiptIcon, ExternalLinkIcon } from "lucide-react";
21+
1922
<ActionPanel
2023
title="Actions"
2124
actions={[
2225
{
2326
key: "create-invoice",
2427
label: "Create new sales invoice",
2528
icon: <ReceiptIcon />,
26-
onClick: () => openCreateInvoiceModal(),
29+
onClick: () => console.log("create invoice"),
2730
},
2831
{
2932
key: "view-docs",
3033
label: "View documentation",
3134
icon: <ExternalLinkIcon />,
32-
onClick: () => window.open("/docs", "_blank", "noopener,noreferrer"),
35+
onClick: () => console.log("view docs"),
3336
},
3437
]}
3538
/>
@@ -67,30 +70,29 @@ import { ActionPanel } from "@tailor-platform/app-shell";
6770

6871
Use parent state to control which row is loading:
6972

70-
```tsx
71-
const [loadingKey, setLoadingKey] = useState<string | null>(null);
72-
73-
const handleConfirm = async () => {
74-
setLoadingKey("confirm");
75-
try {
76-
await confirmOrder(orderId);
77-
} finally {
78-
setLoadingKey(null);
79-
}
80-
};
73+
```tsx preview height="350"
74+
import { ActionPanel } from "@tailor-platform/app-shell";
75+
import { CheckIcon, ReceiptIcon } from "lucide-react";
8176

8277
<ActionPanel
8378
title="Actions"
8479
actions={[
80+
{
81+
key: "create-order",
82+
label: "Create new order",
83+
icon: <ReceiptIcon />,
84+
onClick: () => console.log("create new order"),
85+
disabled: true
86+
},
8587
{
8688
key: "confirm",
8789
label: "Confirm order",
8890
icon: <CheckIcon />,
89-
onClick: handleConfirm,
90-
loading: loadingKey === "confirm",
91+
onClick: () => console.log("confirm order"),
92+
loading: true,
9193
},
9294
]}
93-
/>;
95+
/>
9496
```
9597

9698
## Backend-Driven Pattern

docs/components/activity-card.md

Lines changed: 51 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,32 @@ Use `ActivityCardItem` for each item in the standalone API. Use `ActivityCardBas
2222

2323
## Basic Usage
2424

25-
```tsx
26-
const items = [
27-
{
28-
id: "1",
29-
actor: { name: "Hanna", avatarUrl: "/avatars/hanna.jpg" }, // avatarUrl is optional
30-
description: "changed the status from DRAFT to CONFIRMED",
31-
timestamp: new Date("2025-03-21T09:00:00"),
32-
},
33-
{
34-
id: "2",
35-
actor: { name: "Pradeep Kumar" },
36-
description: "created this PO",
37-
timestamp: new Date("2025-03-21T15:16:00"),
38-
},
39-
{
40-
id: "3",
41-
// no actor — system event with no specific subject
42-
description: "Status automatically changed to EXPIRED",
43-
timestamp: new Date("2025-03-20T10:00:00"),
44-
},
45-
];
46-
47-
export function DocumentUpdates() {
48-
return <ActivityCard items={items} title="Updates" />;
49-
}
25+
```tsx preview
26+
import { ActivityCard } from "@tailor-platform/app-shell";
27+
28+
<ActivityCard
29+
title="Updates"
30+
items={[
31+
{
32+
id: "1",
33+
actor: { name: "Hanna", avatarUrl: "/avatars/hanna.jpg" }, // avatarUrl is optional
34+
description: "changed the status from DRAFT to CONFIRMED",
35+
timestamp: new Date("2025-03-21T09:00:00"),
36+
},
37+
{
38+
id: "2",
39+
actor: { name: "Pradeep Kumar" },
40+
description: "created this PO",
41+
timestamp: new Date("2025-03-21T15:16:00"),
42+
},
43+
{
44+
id: "3",
45+
// no actor — system event with no specific subject
46+
description: "Status automatically changed to EXPIRED",
47+
timestamp: new Date("2025-03-20T10:00:00"),
48+
},
49+
]}
50+
/>
5051
```
5152

5253
## Overflow and dialog
@@ -85,10 +86,33 @@ Each activity must include: `id`, `description`, `timestamp` (Date or string). O
8586

8687
Use the compound API when you need fully custom item rendering — custom icons, links, badges, or mixed item kinds. Items still must satisfy `ActivityCardBaseItem` (`id` + `timestamp`). You extend `ActivityCardBaseItem` with any additional fields you need.
8788

88-
### Import
89+
### Example
8990

90-
```tsx
91+
```tsx preview
9192
import { ActivityCard, type ActivityCardBaseItem } from "@tailor-platform/app-shell";
93+
94+
<ActivityCard.Root
95+
items={[
96+
{ id: "1", timestamp: new Date(), kind: "approval", label: "PO approved" },
97+
{ id: "2", timestamp: new Date(), kind: "update", message: "Status changed to CONFIRMED" },
98+
]}
99+
title="Updates"
100+
groupBy="day"
101+
>
102+
<ActivityCard.Items>
103+
{(item) =>
104+
item.kind === "approval" ? (
105+
<ActivityCard.Item>
106+
<p style={{ color: "green" }}>{item.label}</p>
107+
</ActivityCard.Item>
108+
) : (
109+
<ActivityCard.Item>
110+
<p style={{ fontWeight: "bold" }}>{item.message}</p>
111+
</ActivityCard.Item>
112+
)
113+
}
114+
</ActivityCard.Items>
115+
</ActivityCard.Root>
92116
```
93117

94118
### Parts
@@ -119,39 +143,6 @@ import { ActivityCard, type ActivityCardBaseItem } from "@tailor-platform/app-sh
119143
| `children` | `React.ReactNode` | - | Content for the item row (text, badges, links, etc.). |
120144
| `className` | `string` | - | Additional CSS classes. |
121145

122-
### Example
123-
124-
```tsx
125-
import { ActivityCard, type ActivityCardBaseItem } from "@tailor-platform/app-shell";
126-
127-
interface MyItem extends ActivityCardBaseItem {
128-
kind: "approval" | "update";
129-
label?: string;
130-
message?: string;
131-
}
132-
133-
const items: MyItem[] = [
134-
{ id: "1", timestamp: new Date(), kind: "approval", label: "PO approved" },
135-
{ id: "2", timestamp: new Date(), kind: "update", message: "Status changed to CONFIRMED" },
136-
];
137-
138-
<ActivityCard.Root items={items} title="Updates" groupBy="day">
139-
<ActivityCard.Items<MyItem>>
140-
{(item) =>
141-
item.kind === "approval" ? (
142-
<ActivityCard.Item indicator={<ApprovedIcon />}>
143-
<p>{item.label}</p>
144-
</ActivityCard.Item>
145-
) : (
146-
<ActivityCard.Item>
147-
<p>{item.message}</p>
148-
</ActivityCard.Item>
149-
)
150-
}
151-
</ActivityCard.Items>
152-
</ActivityCard.Root>;
153-
```
154-
155146
---
156147

157148
## See also

docs/components/autocomplete.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ import { Autocomplete } from "@tailor-platform/app-shell";
1515

1616
## Basic Usage
1717

18-
```tsx
18+
```tsx preview align="start"
19+
import { Autocomplete } from "@tailor-platform/app-shell";
20+
1921
<Autocomplete
2022
items={["Apple", "Banana", "Cherry"]}
2123
placeholder="Type a fruit..."
@@ -60,13 +62,16 @@ interface ItemGroup<T> {
6062

6163
## Grouped Suggestions
6264

63-
```tsx
64-
const cities = [
65-
{ label: "Japan", items: ["Tokyo", "Osaka", "Kyoto"] },
66-
{ label: "France", items: ["Paris", "Lyon", "Marseille"] },
67-
];
65+
```tsx preview align="start" height="350"
66+
import { Autocomplete } from "@tailor-platform/app-shell";
6867

69-
<Autocomplete items={cities} placeholder="Search cities..." />;
68+
<Autocomplete
69+
placeholder="Search cities..."
70+
items={[
71+
{ label: "Japan", items: ["Tokyo", "Osaka", "Kyoto"] },
72+
{ label: "France", items: ["Paris", "Lyon", "Marseille"] },
73+
]}
74+
/>
7075
```
7176

7277
## Object Items with mapItem

docs/components/avatar.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ import { Avatar } from "@tailor-platform/app-shell";
1515

1616
## Basic usage
1717

18-
```tsx
18+
```tsx preview
19+
import { Avatar } from "@tailor-platform/app-shell";
20+
1921
<Avatar.Root>
2022
<Avatar.Image src="/user.png" alt="Jane Doe" />
2123
<Avatar.Fallback>JD</Avatar.Fallback>
@@ -42,7 +44,9 @@ import { Avatar } from "@tailor-platform/app-shell";
4244

4345
## Sizes
4446

45-
```tsx
47+
```tsx preview wrap="row"
48+
import { Avatar } from "@tailor-platform/app-shell";
49+
4650
<Avatar.Root size="sm">
4751
<Avatar.Fallback>AB</Avatar.Fallback>
4852
</Avatar.Root>

docs/components/badge.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ import { Badge } from "@tailor-platform/app-shell";
1515

1616
## Basic Usage
1717

18-
```tsx
18+
```tsx preview wrap="row"
19+
import { Badge } from "@tailor-platform/app-shell";
20+
1921
<Badge>Default</Badge>
2022
<Badge variant="success">Success</Badge>
2123
<Badge variant="warning">Warning</Badge>
@@ -28,7 +30,9 @@ import { Badge } from "@tailor-platform/app-shell";
2830

2931
Filled background variants for high emphasis:
3032

31-
```tsx
33+
```tsx preview wrap="row"
34+
import { Badge } from "@tailor-platform/app-shell";
35+
3236
<Badge variant="default">Default</Badge>
3337
<Badge variant="success">Approved</Badge>
3438
<Badge variant="warning">Pending</Badge>
@@ -40,7 +44,9 @@ Filled background variants for high emphasis:
4044

4145
Outlined badges with colored status dots for subtle emphasis:
4246

43-
```tsx
47+
```tsx preview wrap="row"
48+
import { Badge } from "@tailor-platform/app-shell";
49+
4450
<Badge variant="outline-success">Active</Badge>
4551
<Badge variant="outline-warning">In Progress</Badge>
4652
<Badge variant="outline-error">Failed</Badge>
@@ -113,7 +119,8 @@ const priorities = [
113119

114120
### With Icons
115121

116-
```tsx
122+
```tsx preview wrap="row"
123+
import { Badge } from "@tailor-platform/app-shell";
117124
import { CheckCircle, AlertCircle, XCircle } from "lucide-react";
118125

119126
<div className="astw:flex astw:gap-2">
@@ -155,7 +162,9 @@ function ProductBadge({ product }: { product: Product }) {
155162

156163
### Custom Styling
157164

158-
```tsx
165+
```tsx preview
166+
import { Badge } from "@tailor-platform/app-shell";
167+
159168
<Badge variant="success" className="astw:text-xs astw:px-3 astw:py-1 astw:uppercase">
160169
Premium
161170
</Badge>

docs/components/button.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ import { Button } from "@tailor-platform/app-shell";
1515

1616
## Basic Usage
1717

18-
```tsx
18+
```tsx preview wrap="row"
19+
import { Button } from "@tailor-platform/app-shell";
20+
1921
<Button>Click me</Button>
2022
<Button variant="outline">Outline</Button>
2123
<Button variant="destructive">Delete</Button>
@@ -35,7 +37,9 @@ All standard HTML `<button>` props are also accepted.
3537

3638
## Variants
3739

38-
```tsx
40+
```tsx preview wrap="row"
41+
import { Button } from "@tailor-platform/app-shell";
42+
3943
<Button variant="default">Primary Action</Button>
4044
<Button variant="destructive">Delete</Button>
4145
<Button variant="outline">Secondary Action</Button>
@@ -46,7 +50,10 @@ All standard HTML `<button>` props are also accepted.
4650

4751
## Sizes
4852

49-
```tsx
53+
```tsx preview wrap="row"
54+
import { Button } from "@tailor-platform/app-shell";
55+
import { PlusIcon } from "lucide-react";
56+
5057
<Button size="xs">Extra Small</Button>
5158
<Button size="sm">Small</Button>
5259
<Button size="default">Default</Button>
@@ -73,7 +80,9 @@ This is the Base UI render pattern — the button's class names and event handle
7380

7481
### Form Actions
7582

76-
```tsx
83+
```tsx preview
84+
import { Button } from "@tailor-platform/app-shell";
85+
7786
<div className="astw:flex astw:gap-2 astw:justify-end">
7887
<Button variant="outline">Cancel</Button>
7988
<Button>Save Changes</Button>
@@ -90,7 +99,8 @@ This is the Base UI render pattern — the button's class names and event handle
9099

91100
### Icon Button
92101

93-
```tsx
102+
```tsx preview
103+
import { Button } from "@tailor-platform/app-shell";
94104
import { PlusIcon } from "lucide-react";
95105

96106
<Button size="icon" variant="outline">
@@ -108,7 +118,7 @@ import { type ButtonProps } from "@tailor-platform/app-shell";
108118

109119
Use `buttonVariants` to apply button styles to non-button elements:
110120

111-
```tsx
121+
```tsx preview
112122
import { buttonVariants } from "@tailor-platform/app-shell";
113123

114124
<a href="/orders" className={buttonVariants({ variant: "outline", size: "sm" })}>

0 commit comments

Comments
 (0)