shapes-ui 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/ISSUE_TEMPLATE/bug_report.yml +47 -0
- package/.github/ISSUE_TEMPLATE/config.yml +1 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +31 -0
- package/.github/pull_request_template.md +14 -0
- package/.github/workflows/pr-preview.yml +68 -0
- package/.github/workflows/release.yml +8 -0
- package/.idea/compiler.xml +6 -0
- package/.idea/copilot.data.migration.ask2agent.xml +6 -0
- package/.idea/vcs.xml +6 -0
- package/CHANGELOG.md +31 -0
- package/CODE_OF_CONDUCT.md +41 -0
- package/CONTRIBUTING.md +52 -0
- package/README.md +5 -0
- package/SECURITY.md +0 -0
- package/content/components/field.mdx +2 -2
- package/content/components/fieldset.mdx +1 -1
- package/content/components/menubar.mdx +4 -2
- package/content/components/meter.mdx +13 -1
- package/content/components/navigation-menu.mdx +6 -0
- package/content/components/number-field.mdx +24 -0
- package/content/components/popover.mdx +20 -0
- package/content/components/preview-card.mdx +11 -0
- package/content/components/progress.mdx +2 -0
- package/content/components/radio.mdx +20 -0
- package/content/components/select.mdx +30 -0
- package/content/components/slider.mdx +48 -0
- package/content/components/switch.mdx +26 -0
- package/content/components/tabs.mdx +32 -0
- package/content/components/toast.mdx +60 -0
- package/content/components/toggle.mdx +34 -2
- package/content/components/toolbar.mdx +26 -0
- package/content/components/tooltip.mdx +25 -0
- package/content-collections.ts +1 -1
- package/examples/__index.tsx +231 -0
- package/examples/checkbox-demo.tsx +1 -1
- package/examples/checkbox-form.tsx +3 -3
- package/examples/field-custom-control.tsx +33 -9
- package/examples/form-demo.tsx +5 -10
- package/examples/menu-advanced.tsx +1 -3
- package/examples/menu-align.tsx +19 -16
- package/examples/menu-checkbox.tsx +2 -3
- package/examples/menu-demo.tsx +1 -3
- package/examples/menu-group.tsx +1 -3
- package/examples/menu-radio.tsx +1 -3
- package/examples/menu-submenu.tsx +2 -3
- package/examples/menubar-advanced.tsx +91 -0
- package/examples/meter-demo.tsx +8 -21
- package/examples/meter-flip.tsx +13 -0
- package/examples/meter-no-label.tsx +12 -0
- package/examples/meter-no-value.tsx +12 -0
- package/examples/navigation-menu-demo.tsx +113 -1
- package/examples/number-field-buttons-end.tsx +20 -0
- package/examples/number-field-demo.tsx +17 -1
- package/examples/number-field-scrub.tsx +38 -0
- package/examples/popover-demo.tsx +18 -1
- package/examples/popover-form.tsx +46 -0
- package/examples/popover-positions.tsx +54 -0
- package/examples/preview-card-demo.tsx +26 -1
- package/examples/preview-card-links.tsx +38 -0
- package/examples/progress-demo.tsx +33 -1
- package/examples/radio-card.tsx +28 -0
- package/examples/radio-demo.tsx +19 -1
- package/examples/radio-description.tsx +26 -0
- package/examples/radio-orientation.tsx +21 -0
- package/examples/select-alignment.tsx +51 -0
- package/examples/select-demo.tsx +36 -1
- package/examples/select-disabled.tsx +38 -0
- package/examples/select-groups.tsx +54 -0
- package/examples/select-invalid.tsx +41 -0
- package/examples/select-scrollable.tsx +112 -0
- package/examples/slider-controlled.tsx +28 -0
- package/examples/slider-demo.tsx +3 -1
- package/examples/slider-disabled.tsx +7 -0
- package/examples/slider-edge.tsx +13 -0
- package/examples/slider-multiple.tsx +7 -0
- package/examples/slider-range.tsx +5 -0
- package/examples/slider-vertical.tsx +10 -0
- package/examples/switch-demo.tsx +19 -1
- package/examples/switch-disabled.tsx +20 -0
- package/examples/switch-sizes.tsx +24 -0
- package/examples/switch-with-label.tsx +16 -0
- package/examples/tabs-demo.tsx +14 -1
- package/examples/tabs-disabled.tsx +21 -0
- package/examples/tabs-line.tsx +18 -0
- package/examples/tabs-vertical.tsx +13 -0
- package/examples/toast-action.tsx +39 -0
- package/examples/toast-anchored.tsx +36 -0
- package/examples/toast-demo.tsx +27 -1
- package/examples/toast-positions.tsx +54 -0
- package/examples/toast-promise.tsx +51 -0
- package/examples/toast-stacked.tsx +30 -0
- package/examples/toast-timeout.tsx +43 -0
- package/examples/toast-update.tsx +38 -0
- package/examples/toast-variants.tsx +54 -0
- package/examples/toggle-controlled.tsx +20 -0
- package/examples/toggle-demo.tsx +7 -51
- package/examples/toggle-group-demo.tsx +19 -0
- package/examples/toggle-group-multiple.tsx +19 -0
- package/examples/toggle-icon-fill.tsx +12 -0
- package/examples/toolbar-demo.tsx +45 -21
- package/examples/toolbar-input-link.tsx +35 -0
- package/examples/toolbar-menu.tsx +53 -0
- package/examples/tooltip-demo.tsx +48 -0
- package/examples/tooltip-positions.tsx +60 -0
- package/package.json +8 -8
- package/public/r/drawer.json +1 -1
- package/public/r/field.json +1 -1
- package/public/r/menubar.json +1 -1
- package/public/r/meter.json +1 -1
- package/public/r/navigation-menu.json +1 -1
- package/public/r/number-field.json +4 -2
- package/public/r/popover.json +1 -1
- package/public/r/preview-card.json +1 -1
- package/public/r/progress.json +1 -1
- package/public/r/radio.json +1 -1
- package/public/r/select.json +1 -1
- package/public/r/slider.json +1 -1
- package/public/r/switch.json +1 -1
- package/public/r/tabs.json +1 -1
- package/public/r/toast.json +2 -1
- package/public/r/toggle.json +1 -1
- package/public/r/toolbar.json +1 -1
- package/public/r/tooltip.json +15 -0
- package/src/components/docs/layout/header.tsx +4 -14
- package/src/components/docs/layout/mobile-menu.tsx +27 -78
- package/src/components/docs/layout/nav-list.tsx +27 -21
- package/src/components/docs/layout/split-layout.tsx +6 -3
- package/src/components/ui/badge.tsx +1 -1
- package/src/components/ui/checkbox.tsx +1 -1
- package/src/components/ui/drawer.tsx +1 -1
- package/src/components/ui/field.tsx +9 -28
- package/src/components/ui/form.tsx +1 -1
- package/src/components/ui/menubar.tsx +52 -18
- package/src/components/ui/meter.tsx +12 -24
- package/src/components/ui/navigation-menu.tsx +121 -38
- package/src/components/ui/number-field.tsx +42 -46
- package/src/components/ui/popover.tsx +7 -2
- package/src/components/ui/preview-card.tsx +4 -2
- package/src/components/ui/progress.tsx +7 -18
- package/src/components/ui/radio.tsx +32 -19
- package/src/components/ui/select.tsx +6 -6
- package/src/components/ui/slider.tsx +8 -5
- package/src/components/ui/switch.tsx +13 -17
- package/src/components/ui/tabs.tsx +23 -10
- package/src/components/ui/toast.tsx +190 -29
- package/src/components/ui/toggle.tsx +1 -1
- package/src/components/ui/toolbar.tsx +17 -4
- package/src/components/ui/tooltip.tsx +54 -0
- package/src/routes/__root.tsx +3 -5
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Tabs, TabsPanel, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
|
2
|
+
|
|
3
|
+
export default function TabsDisabled() {
|
|
4
|
+
return (
|
|
5
|
+
<Tabs defaultValue="public" className={"mx-auto w-full max-w-md"}>
|
|
6
|
+
<TabsList>
|
|
7
|
+
<TabsTrigger value="public">Public</TabsTrigger>
|
|
8
|
+
<TabsTrigger value="team">Team</TabsTrigger>
|
|
9
|
+
<TabsTrigger value="enterprise" disabled>
|
|
10
|
+
Enterprise
|
|
11
|
+
</TabsTrigger>
|
|
12
|
+
</TabsList>
|
|
13
|
+
<TabsPanel value="public" className="rounded-lg border p-4 text-sm text-muted-foreground">
|
|
14
|
+
Public documentation is available on all plans.
|
|
15
|
+
</TabsPanel>
|
|
16
|
+
<TabsPanel value="team" className="rounded-lg border p-4 text-sm text-muted-foreground">
|
|
17
|
+
Team features are available on the Pro plan.
|
|
18
|
+
</TabsPanel>
|
|
19
|
+
</Tabs>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Tabs, TabsPanel, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
|
2
|
+
|
|
3
|
+
export default function TabsLine() {
|
|
4
|
+
return (
|
|
5
|
+
<Tabs defaultValue="overview" className={"mx-auto w-full max-w-md"}>
|
|
6
|
+
<TabsList variant="line">
|
|
7
|
+
<TabsTrigger value="overview">Overview</TabsTrigger>
|
|
8
|
+
<TabsTrigger value="analytics">Analytics</TabsTrigger>
|
|
9
|
+
</TabsList>
|
|
10
|
+
<TabsPanel value="overview" className="pt-2 text-sm text-muted-foreground">
|
|
11
|
+
Review key account trends and recent activity.
|
|
12
|
+
</TabsPanel>
|
|
13
|
+
<TabsPanel value="analytics" className="pt-2 text-sm text-muted-foreground">
|
|
14
|
+
Compare traffic, retention, and conversion metrics.
|
|
15
|
+
</TabsPanel>
|
|
16
|
+
</Tabs>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
|
2
|
+
|
|
3
|
+
export default function TabsVertical() {
|
|
4
|
+
return (
|
|
5
|
+
<Tabs defaultValue="profile" orientation="vertical">
|
|
6
|
+
<TabsList className="min-w-36">
|
|
7
|
+
<TabsTrigger value="profile">Profile</TabsTrigger>
|
|
8
|
+
<TabsTrigger value="billing">Billing</TabsTrigger>
|
|
9
|
+
<TabsTrigger value="security">Security</TabsTrigger>
|
|
10
|
+
</TabsList>
|
|
11
|
+
</Tabs>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Button } from "@/components/ui/button";
|
|
2
|
+
import { Toast, useToast } from "@/components/ui/toast";
|
|
3
|
+
|
|
4
|
+
export default function ToastAction() {
|
|
5
|
+
return (
|
|
6
|
+
<Toast>
|
|
7
|
+
<ToastActionTrigger />
|
|
8
|
+
</Toast>
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function ToastActionTrigger() {
|
|
13
|
+
const toast = useToast();
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Button
|
|
17
|
+
variant="outline"
|
|
18
|
+
onClick={() => {
|
|
19
|
+
const toastId = toast.add({
|
|
20
|
+
title: "Project archived",
|
|
21
|
+
description: "The project was moved to archive.",
|
|
22
|
+
type: "success",
|
|
23
|
+
actionProps: {
|
|
24
|
+
children: "Undo",
|
|
25
|
+
onClick: () => {
|
|
26
|
+
toast.close(toastId);
|
|
27
|
+
toast.add({
|
|
28
|
+
title: "Archive reverted",
|
|
29
|
+
description: "The project is active again.",
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
}}
|
|
35
|
+
>
|
|
36
|
+
Archive project
|
|
37
|
+
</Button>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { Button } from "@/components/ui/button";
|
|
4
|
+
import { Toast, useToast } from "@/components/ui/toast";
|
|
5
|
+
|
|
6
|
+
export default function ToastAnchored() {
|
|
7
|
+
return (
|
|
8
|
+
<Toast>
|
|
9
|
+
<ToastAnchoredAction />
|
|
10
|
+
</Toast>
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function ToastAnchoredAction() {
|
|
15
|
+
const toast = useToast();
|
|
16
|
+
const anchorRef = React.useRef<HTMLButtonElement | null>(null);
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<Button
|
|
20
|
+
ref={anchorRef}
|
|
21
|
+
variant="outline"
|
|
22
|
+
onClick={() => {
|
|
23
|
+
toast.add({
|
|
24
|
+
description: "Copied",
|
|
25
|
+
timeout: 1500,
|
|
26
|
+
positionerProps: {
|
|
27
|
+
anchor: anchorRef.current,
|
|
28
|
+
sideOffset: 8,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}}
|
|
32
|
+
>
|
|
33
|
+
Copy
|
|
34
|
+
</Button>
|
|
35
|
+
);
|
|
36
|
+
}
|
package/examples/toast-demo.tsx
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
import { Button } from "@/components/ui/button";
|
|
2
|
+
import { Toast, useToast } from "@/components/ui/toast";
|
|
3
|
+
|
|
1
4
|
export default function ToastDemo() {
|
|
2
|
-
return
|
|
5
|
+
return (
|
|
6
|
+
<Toast>
|
|
7
|
+
<ToastDemoAction />
|
|
8
|
+
</Toast>
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function ToastDemoAction() {
|
|
13
|
+
const toast = useToast();
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Button
|
|
17
|
+
variant="outline"
|
|
18
|
+
onClick={() =>
|
|
19
|
+
toast.add({
|
|
20
|
+
title: "Changes saved",
|
|
21
|
+
description: "Your profile has been updated successfully.",
|
|
22
|
+
type: "success",
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
>
|
|
26
|
+
Show toast
|
|
27
|
+
</Button>
|
|
28
|
+
);
|
|
3
29
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { Button } from "@/components/ui/button";
|
|
4
|
+
import { Toast, useToast, type ToastPosition } from "@/components/ui/toast";
|
|
5
|
+
|
|
6
|
+
const positions: ToastPosition[] = [
|
|
7
|
+
"top-left",
|
|
8
|
+
"top-center",
|
|
9
|
+
"top-right",
|
|
10
|
+
"bottom-left",
|
|
11
|
+
"bottom-center",
|
|
12
|
+
"bottom-right",
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
export default function ToastPositions() {
|
|
16
|
+
const [position, setPosition] = React.useState<ToastPosition>("bottom-right");
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<Toast position={position}>
|
|
20
|
+
<ToastPositionActions position={position} onPositionChange={setPosition} />
|
|
21
|
+
</Toast>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function ToastPositionActions({
|
|
26
|
+
position,
|
|
27
|
+
onPositionChange,
|
|
28
|
+
}: {
|
|
29
|
+
position: ToastPosition;
|
|
30
|
+
onPositionChange: React.Dispatch<React.SetStateAction<ToastPosition>>;
|
|
31
|
+
}) {
|
|
32
|
+
const toast = useToast();
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<div className="flex flex-wrap gap-2">
|
|
36
|
+
{positions.map((value) => (
|
|
37
|
+
<Button
|
|
38
|
+
key={value}
|
|
39
|
+
variant={position === value ? "default" : "outline"}
|
|
40
|
+
onClick={() => {
|
|
41
|
+
onPositionChange(value);
|
|
42
|
+
toast.add({
|
|
43
|
+
title: "Position updated",
|
|
44
|
+
description: `Now showing at ${value}.`,
|
|
45
|
+
type: "success",
|
|
46
|
+
});
|
|
47
|
+
}}
|
|
48
|
+
>
|
|
49
|
+
{value}
|
|
50
|
+
</Button>
|
|
51
|
+
))}
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Button } from "@/components/ui/button";
|
|
2
|
+
import { Toast, useToast } from "@/components/ui/toast";
|
|
3
|
+
|
|
4
|
+
export default function ToastPromise() {
|
|
5
|
+
return (
|
|
6
|
+
<Toast>
|
|
7
|
+
<ToastPromiseAction />
|
|
8
|
+
</Toast>
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function ToastPromiseAction() {
|
|
13
|
+
const toast = useToast();
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Button
|
|
17
|
+
variant="outline"
|
|
18
|
+
onClick={() => {
|
|
19
|
+
const request = new Promise<string>((resolve, reject) => {
|
|
20
|
+
setTimeout(() => {
|
|
21
|
+
if (Math.random() > 0.4) {
|
|
22
|
+
resolve("Report export complete");
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
reject(new Error("Could not generate report"));
|
|
26
|
+
}, 1500);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
void toast.promise(request, {
|
|
30
|
+
loading: {
|
|
31
|
+
title: "Exporting",
|
|
32
|
+
description: "Preparing your report...",
|
|
33
|
+
timeout: 0,
|
|
34
|
+
},
|
|
35
|
+
success: (message) => ({
|
|
36
|
+
title: "Done",
|
|
37
|
+
description: message,
|
|
38
|
+
type: "success",
|
|
39
|
+
}),
|
|
40
|
+
error: (error: Error) => ({
|
|
41
|
+
title: "Export failed",
|
|
42
|
+
description: error.message,
|
|
43
|
+
type: "error",
|
|
44
|
+
}),
|
|
45
|
+
});
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
Run async action
|
|
49
|
+
</Button>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Button } from "@/components/ui/button";
|
|
2
|
+
import { Toast, useToast } from "@/components/ui/toast";
|
|
3
|
+
|
|
4
|
+
export default function ToastStacked() {
|
|
5
|
+
return (
|
|
6
|
+
<Toast>
|
|
7
|
+
<ToastStackedAction />
|
|
8
|
+
</Toast>
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function ToastStackedAction() {
|
|
13
|
+
const toast = useToast();
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Button
|
|
17
|
+
variant="outline"
|
|
18
|
+
onClick={() => {
|
|
19
|
+
for (let index = 0; index < 4; index += 1) {
|
|
20
|
+
toast.add({
|
|
21
|
+
title: `Toast ${index + 1}`,
|
|
22
|
+
description: "This demonstrates stacked toast behavior.",
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}}
|
|
26
|
+
>
|
|
27
|
+
Show stacked toasts
|
|
28
|
+
</Button>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Button } from "@/components/ui/button";
|
|
2
|
+
import { Toast, useToast } from "@/components/ui/toast";
|
|
3
|
+
|
|
4
|
+
export default function ToastTimeout() {
|
|
5
|
+
return (
|
|
6
|
+
<Toast>
|
|
7
|
+
<ToastTimeoutActions />
|
|
8
|
+
</Toast>
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function ToastTimeoutActions() {
|
|
13
|
+
const toast = useToast();
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<div className="flex flex-wrap gap-2">
|
|
17
|
+
<Button
|
|
18
|
+
variant="outline"
|
|
19
|
+
onClick={() =>
|
|
20
|
+
toast.add({
|
|
21
|
+
title: "Quick notice",
|
|
22
|
+
description: "This toast closes in 1 second.",
|
|
23
|
+
timeout: 1000,
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
>
|
|
27
|
+
1s timeout
|
|
28
|
+
</Button>
|
|
29
|
+
<Button
|
|
30
|
+
variant="outline"
|
|
31
|
+
onClick={() =>
|
|
32
|
+
toast.add({
|
|
33
|
+
title: "Long notice",
|
|
34
|
+
description: "This toast stays for 8 seconds.",
|
|
35
|
+
timeout: 8000,
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
>
|
|
39
|
+
8s timeout
|
|
40
|
+
</Button>
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Button } from "@/components/ui/button";
|
|
2
|
+
import { Toast, useToast } from "@/components/ui/toast";
|
|
3
|
+
|
|
4
|
+
export default function ToastUpdate() {
|
|
5
|
+
return (
|
|
6
|
+
<Toast>
|
|
7
|
+
<ToastUpdateAction />
|
|
8
|
+
</Toast>
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function ToastUpdateAction() {
|
|
13
|
+
const toast = useToast();
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Button
|
|
17
|
+
variant="outline"
|
|
18
|
+
onClick={() => {
|
|
19
|
+
const toastId = toast.add({
|
|
20
|
+
title: "Uploading",
|
|
21
|
+
description: "Starting upload...",
|
|
22
|
+
timeout: 0,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
setTimeout(() => {
|
|
26
|
+
toast.update(toastId, {
|
|
27
|
+
title: "Upload complete",
|
|
28
|
+
description: "Your files are ready.",
|
|
29
|
+
type: "success",
|
|
30
|
+
timeout: 3000,
|
|
31
|
+
});
|
|
32
|
+
}, 1200);
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
Show updatable toast
|
|
36
|
+
</Button>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Button } from "@/components/ui/button";
|
|
2
|
+
import { Toast, useToast } from "@/components/ui/toast";
|
|
3
|
+
|
|
4
|
+
export default function ToastVariants() {
|
|
5
|
+
return (
|
|
6
|
+
<Toast>
|
|
7
|
+
<ToastVariantsActions />
|
|
8
|
+
</Toast>
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function ToastVariantsActions() {
|
|
13
|
+
const toast = useToast();
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<div className="flex flex-wrap gap-2">
|
|
17
|
+
<Button
|
|
18
|
+
variant="outline"
|
|
19
|
+
onClick={() =>
|
|
20
|
+
toast.add({
|
|
21
|
+
title: "Heads up",
|
|
22
|
+
description: "New account activity was detected.",
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
>
|
|
26
|
+
Default
|
|
27
|
+
</Button>
|
|
28
|
+
<Button
|
|
29
|
+
variant="outline"
|
|
30
|
+
onClick={() =>
|
|
31
|
+
toast.add({
|
|
32
|
+
title: "Saved",
|
|
33
|
+
description: "Your preferences were updated.",
|
|
34
|
+
type: "success",
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
>
|
|
38
|
+
Success
|
|
39
|
+
</Button>
|
|
40
|
+
<Button
|
|
41
|
+
variant="outline"
|
|
42
|
+
onClick={() =>
|
|
43
|
+
toast.add({
|
|
44
|
+
title: "Action failed",
|
|
45
|
+
description: "Please try again in a few moments.",
|
|
46
|
+
type: "error",
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
>
|
|
50
|
+
Error
|
|
51
|
+
</Button>
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Bold } from "lucide-react";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
|
|
6
|
+
import { Toggle } from "@/components/ui/toggle";
|
|
7
|
+
|
|
8
|
+
export default function ToggleControlled() {
|
|
9
|
+
const [pressed, setPressed] = useState(false);
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<div className="flex flex-col gap-2">
|
|
13
|
+
<Toggle aria-label="Toggle bold formatting" pressed={pressed} onPressedChange={setPressed}>
|
|
14
|
+
<Bold />
|
|
15
|
+
Bold
|
|
16
|
+
</Toggle>
|
|
17
|
+
<p className="text-xs text-muted-foreground">Pressed: {pressed ? "true" : "false"}</p>
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
}
|
package/examples/toggle-demo.tsx
CHANGED
|
@@ -1,55 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StarIcon } from "lucide-react";
|
|
2
2
|
|
|
3
|
-
import { Toggle
|
|
3
|
+
import { Toggle } from "@/components/ui/toggle";
|
|
4
4
|
|
|
5
|
-
export
|
|
5
|
+
export default function ToggleDemo() {
|
|
6
6
|
return (
|
|
7
|
-
<
|
|
8
|
-
<
|
|
9
|
-
|
|
10
|
-
<Toggle>
|
|
11
|
-
<Bold />
|
|
12
|
-
Bold
|
|
13
|
-
</Toggle>
|
|
14
|
-
</div>
|
|
15
|
-
|
|
16
|
-
<div className="flex flex-col gap-2">
|
|
17
|
-
<p className="text-sm font-medium">Toggle Group</p>
|
|
18
|
-
<ToggleGroup>
|
|
19
|
-
<Toggle>
|
|
20
|
-
<Bold />
|
|
21
|
-
</Toggle>
|
|
22
|
-
<Toggle>
|
|
23
|
-
<Italic />
|
|
24
|
-
</Toggle>
|
|
25
|
-
<Toggle>
|
|
26
|
-
<Underline />
|
|
27
|
-
</Toggle>
|
|
28
|
-
</ToggleGroup>
|
|
29
|
-
</div>
|
|
30
|
-
|
|
31
|
-
<div className="flex flex-col gap-2">
|
|
32
|
-
<p className="text-sm font-medium">Toggle Sizes</p>
|
|
33
|
-
<div className="flex gap-2">
|
|
34
|
-
<Toggle size="sm">
|
|
35
|
-
<Bold className="size-3" />
|
|
36
|
-
</Toggle>
|
|
37
|
-
<Toggle>
|
|
38
|
-
<Bold />
|
|
39
|
-
</Toggle>
|
|
40
|
-
<Toggle size="lg">
|
|
41
|
-
<Bold />
|
|
42
|
-
</Toggle>
|
|
43
|
-
</div>
|
|
44
|
-
</div>
|
|
45
|
-
|
|
46
|
-
<div className="flex flex-col gap-2">
|
|
47
|
-
<p className="text-sm font-medium">Toggle Variants</p>
|
|
48
|
-
<div className="flex gap-2">
|
|
49
|
-
<Toggle variant="default">Default</Toggle>
|
|
50
|
-
<Toggle variant="outline">Outline</Toggle>
|
|
51
|
-
</div>
|
|
52
|
-
</div>
|
|
53
|
-
</div>
|
|
7
|
+
<Toggle aria-label="Toggle favourite">
|
|
8
|
+
<StarIcon data-slot="fill" />
|
|
9
|
+
</Toggle>
|
|
54
10
|
);
|
|
55
|
-
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AlignCenter, AlignLeft, AlignRight } from "lucide-react";
|
|
2
|
+
|
|
3
|
+
import { Toggle, ToggleGroup } from "@/components/ui/toggle";
|
|
4
|
+
|
|
5
|
+
export default function ToggleGroupDemo() {
|
|
6
|
+
return (
|
|
7
|
+
<ToggleGroup defaultValue={["left"]}>
|
|
8
|
+
<Toggle value="left" aria-label="Align left" size="sm">
|
|
9
|
+
<AlignLeft />
|
|
10
|
+
</Toggle>
|
|
11
|
+
<Toggle value="center" aria-label="Align center" size="sm">
|
|
12
|
+
<AlignCenter />
|
|
13
|
+
</Toggle>
|
|
14
|
+
<Toggle value="right" aria-label="Align right" size="sm">
|
|
15
|
+
<AlignRight />
|
|
16
|
+
</Toggle>
|
|
17
|
+
</ToggleGroup>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Bold, Italic, Underline } from "lucide-react";
|
|
2
|
+
|
|
3
|
+
import { Toggle, ToggleGroup } from "@/components/ui/toggle";
|
|
4
|
+
|
|
5
|
+
export default function ToggleGroupMultiple() {
|
|
6
|
+
return (
|
|
7
|
+
<ToggleGroup multiple defaultValue={["bold"]}>
|
|
8
|
+
<Toggle value="bold" aria-label="Bold">
|
|
9
|
+
<Bold />
|
|
10
|
+
</Toggle>
|
|
11
|
+
<Toggle value="italic" aria-label="Italic">
|
|
12
|
+
<Italic />
|
|
13
|
+
</Toggle>
|
|
14
|
+
<Toggle value="underline" aria-label="Underline">
|
|
15
|
+
<Underline />
|
|
16
|
+
</Toggle>
|
|
17
|
+
</ToggleGroup>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StarIcon } from "lucide-react";
|
|
2
|
+
|
|
3
|
+
import { Toggle } from "@/components/ui/toggle";
|
|
4
|
+
|
|
5
|
+
export default function ToggleIconFill() {
|
|
6
|
+
return (
|
|
7
|
+
<Toggle aria-label="Toggle favourite">
|
|
8
|
+
<StarIcon data-slot="fill" />
|
|
9
|
+
Favourite
|
|
10
|
+
</Toggle>
|
|
11
|
+
);
|
|
12
|
+
}
|
|
@@ -1,32 +1,56 @@
|
|
|
1
1
|
import { Bold, Italic, Underline, List, Quote } from "lucide-react";
|
|
2
2
|
|
|
3
|
+
import { Toggle } from "@/components/ui/toggle";
|
|
3
4
|
import { Toolbar, ToolbarButton, ToolbarGroup, ToolbarSeparator } from "@/components/ui/toolbar";
|
|
4
5
|
|
|
5
|
-
export
|
|
6
|
+
export default function ToolbarDemo() {
|
|
6
7
|
return (
|
|
7
|
-
<Toolbar>
|
|
8
|
+
<Toolbar className="w-full max-w-md justify-start rounded-lg">
|
|
8
9
|
<ToolbarGroup>
|
|
9
|
-
<ToolbarButton
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
<ToolbarButton
|
|
11
|
+
render={
|
|
12
|
+
<Toggle aria-label="Bold" size={"sm"}>
|
|
13
|
+
<Bold />
|
|
14
|
+
</Toggle>
|
|
15
|
+
}
|
|
16
|
+
/>
|
|
17
|
+
<ToolbarButton
|
|
18
|
+
aria-label="Italic"
|
|
19
|
+
render={
|
|
20
|
+
<Toggle aria-label="Italic" size={"sm"}>
|
|
21
|
+
<Italic />
|
|
22
|
+
</Toggle>
|
|
23
|
+
}
|
|
24
|
+
/>
|
|
21
25
|
|
|
26
|
+
<ToolbarButton
|
|
27
|
+
render={
|
|
28
|
+
<Toggle aria-label="Underline" size={"sm"}>
|
|
29
|
+
<Underline />
|
|
30
|
+
</Toggle>
|
|
31
|
+
}
|
|
32
|
+
/>
|
|
33
|
+
</ToolbarGroup>
|
|
34
|
+
<ToolbarSeparator orientation="vertical" />
|
|
22
35
|
<ToolbarGroup>
|
|
23
|
-
<ToolbarButton
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
36
|
+
<ToolbarButton
|
|
37
|
+
aria-label="List"
|
|
38
|
+
render={
|
|
39
|
+
<Toggle aria-label="List" size={"sm"}>
|
|
40
|
+
<List className="size-4" />
|
|
41
|
+
</Toggle>
|
|
42
|
+
}
|
|
43
|
+
/>
|
|
44
|
+
|
|
45
|
+
<ToolbarButton
|
|
46
|
+
aria-label="Quote"
|
|
47
|
+
render={
|
|
48
|
+
<Toggle aria-label="Quote" size={"sm"}>
|
|
49
|
+
<Quote className="size-4" />
|
|
50
|
+
</Toggle>
|
|
51
|
+
}
|
|
52
|
+
/>
|
|
29
53
|
</ToolbarGroup>
|
|
30
54
|
</Toolbar>
|
|
31
55
|
);
|
|
32
|
-
}
|
|
56
|
+
}
|