ai-design-system 0.1.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/README.md +307 -0
- package/components/ai-elements/actions.tsx +65 -0
- package/components/ai-elements/artifact.tsx +147 -0
- package/components/ai-elements/branch.tsx +212 -0
- package/components/ai-elements/canvas.tsx +24 -0
- package/components/ai-elements/chain-of-thought.tsx +228 -0
- package/components/ai-elements/code-block.tsx +179 -0
- package/components/ai-elements/confirmation.tsx +169 -0
- package/components/ai-elements/connection.tsx +28 -0
- package/components/ai-elements/context.tsx +408 -0
- package/components/ai-elements/controls.tsx +18 -0
- package/components/ai-elements/conversation.tsx +97 -0
- package/components/ai-elements/edge.tsx +140 -0
- package/components/ai-elements/image.tsx +24 -0
- package/components/ai-elements/inline-citation.tsx +287 -0
- package/components/ai-elements/loader.tsx +96 -0
- package/components/ai-elements/message.tsx +80 -0
- package/components/ai-elements/node.tsx +71 -0
- package/components/ai-elements/open-in-chat.tsx +363 -0
- package/components/ai-elements/panel.tsx +15 -0
- package/components/ai-elements/plan.tsx +142 -0
- package/components/ai-elements/prompt-input.tsx +1352 -0
- package/components/ai-elements/queue.tsx +274 -0
- package/components/ai-elements/reasoning.tsx +178 -0
- package/components/ai-elements/response.tsx +22 -0
- package/components/ai-elements/shimmer.tsx +64 -0
- package/components/ai-elements/sources.tsx +77 -0
- package/components/ai-elements/suggestion.tsx +56 -0
- package/components/ai-elements/task.tsx +87 -0
- package/components/ai-elements/tool.tsx +179 -0
- package/components/ai-elements/toolbar.tsx +16 -0
- package/components/ai-elements/web-preview.tsx +263 -0
- package/components/blocks/AIConversation/AIConversation.stories.tsx +164 -0
- package/components/blocks/AIConversation/AIConversation.tsx +186 -0
- package/components/blocks/AIConversation/index.ts +8 -0
- package/components/blocks/AppSidebar/AppSidebar.stories.tsx +63 -0
- package/components/blocks/AppSidebar/AppSidebar.tsx +87 -0
- package/components/blocks/AppSidebar/index.ts +2 -0
- package/components/blocks/DocumentEditorWithComments/DocumentEditorWithComments.stories.tsx +341 -0
- package/components/blocks/DocumentEditorWithComments/DocumentEditorWithComments.tsx +255 -0
- package/components/blocks/DocumentEditorWithComments/index.ts +9 -0
- package/components/blocks/FileChangeQueue/FileChangeQueue.stories.tsx +207 -0
- package/components/blocks/FileChangeQueue/FileChangeQueue.tsx +143 -0
- package/components/blocks/FileChangeQueue/index.ts +7 -0
- package/components/blocks/LayoutProvider/LayoutProvider.tsx +34 -0
- package/components/blocks/LayoutProvider/index.ts +1 -0
- package/components/blocks/index.ts +2 -0
- package/components/composites/AgentIndicator/AgentIndicator.stories.tsx +154 -0
- package/components/composites/AgentIndicator/AgentIndicator.tsx +102 -0
- package/components/composites/AgentIndicator/index.ts +8 -0
- package/components/composites/AppHeader/AppHeader.stories.tsx +46 -0
- package/components/composites/AppHeader/AppHeader.tsx +24 -0
- package/components/composites/AppHeader/index.ts +2 -0
- package/components/composites/CommentBox/CommentBox.stories.tsx +192 -0
- package/components/composites/CommentBox/CommentBox.tsx +364 -0
- package/components/composites/CommentBox/index.ts +8 -0
- package/components/composites/Confirmation/Confirmation.stories.tsx +151 -0
- package/components/composites/Confirmation/Confirmation.tsx +93 -0
- package/components/composites/Confirmation/index.ts +7 -0
- package/components/composites/DataTable/DataTable.stories.tsx +35 -0
- package/components/composites/DataTable/DataTable.tsx +95 -0
- package/components/composites/DataTable/index.ts +2 -0
- package/components/composites/DocumentEditor/DocumentEditor.css +106 -0
- package/components/composites/DocumentEditor/DocumentEditor.stories.tsx +927 -0
- package/components/composites/DocumentEditor/DocumentEditor.tsx +279 -0
- package/components/composites/DocumentEditor/index.ts +8 -0
- package/components/composites/FileQueue/FileQueue.stories.tsx +175 -0
- package/components/composites/FileQueue/FileQueue.tsx +161 -0
- package/components/composites/FileQueue/FileStatusBadge.tsx +74 -0
- package/components/composites/FileQueue/index.ts +24 -0
- package/components/composites/InteractiveChart/InteractiveChart.stories.tsx +49 -0
- package/components/composites/InteractiveChart/InteractiveChart.tsx +69 -0
- package/components/composites/InteractiveChart/index.ts +2 -0
- package/components/composites/ModeToggle/ModeToggle.stories.tsx +212 -0
- package/components/composites/ModeToggle/ModeToggle.tsx +100 -0
- package/components/composites/ModeToggle/index.ts +7 -0
- package/components/composites/NavUser/NavUser.stories.tsx +50 -0
- package/components/composites/NavUser/NavUser.tsx +60 -0
- package/components/composites/NavUser/index.ts +2 -0
- package/components/composites/NavigationList/NavigationList.stories.tsx +46 -0
- package/components/composites/NavigationList/NavigationList.tsx +46 -0
- package/components/composites/NavigationList/index.ts +2 -0
- package/components/composites/OrchestratorMessage/OrchestratorMessage.stories.tsx +188 -0
- package/components/composites/OrchestratorMessage/OrchestratorMessage.tsx +72 -0
- package/components/composites/OrchestratorMessage/index.ts +8 -0
- package/components/composites/PageContainer/PageContainer.stories.tsx +41 -0
- package/components/composites/PageContainer/PageContainer.tsx +24 -0
- package/components/composites/PageContainer/index.ts +2 -0
- package/components/composites/PromptInput/PromptInput.stories.tsx +200 -0
- package/components/composites/PromptInput/PromptInput.tsx +129 -0
- package/components/composites/PromptInput/index.ts +8 -0
- package/components/composites/SpecialistMessage/SpecialistMessage.stories.tsx +286 -0
- package/components/composites/SpecialistMessage/SpecialistMessage.tsx +107 -0
- package/components/composites/SpecialistMessage/index.ts +8 -0
- package/components/composites/StatsCard/StatsCard.stories.tsx +76 -0
- package/components/composites/StatsCard/StatsCard.tsx +81 -0
- package/components/composites/StatsCard/index.ts +2 -0
- package/components/composites/TablePagination/TablePagination.stories.tsx +38 -0
- package/components/composites/TablePagination/TablePagination.tsx +119 -0
- package/components/composites/TablePagination/index.ts +2 -0
- package/components/composites/TableToolbar/TableToolbar.stories.tsx +60 -0
- package/components/composites/TableToolbar/TableToolbar.tsx +66 -0
- package/components/composites/TableToolbar/index.ts +2 -0
- package/components/composites/ThemeSelector/ThemeSelector.stories.tsx +48 -0
- package/components/composites/ThemeSelector/ThemeSelector.tsx +79 -0
- package/components/composites/ThemeSelector/index.ts +2 -0
- package/components/composites/ToolCallDisplay/ToolCallDisplay.stories.tsx +49 -0
- package/components/composites/ToolCallDisplay/ToolCallDisplay.tsx +108 -0
- package/components/composites/ToolCallDisplay/index.ts +8 -0
- package/components/composites/UserMessage/UserMessage.stories.tsx +59 -0
- package/components/composites/UserMessage/UserMessage.tsx +52 -0
- package/components/composites/UserMessage/index.ts +8 -0
- package/components/composites/index.ts +90 -0
- package/components/features/AIDocEditor/AIDocEditor.behaviors.stories.tsx +451 -0
- package/components/features/AIDocEditor/AIDocEditor.mocks.ts +96 -0
- package/components/features/AIDocEditor/AIDocEditor.stories.tsx +140 -0
- package/components/features/AIDocEditor/AIDocEditor.tsx +130 -0
- package/components/features/AIDocEditor/index.ts +8 -0
- package/components/features/AIDocEditor/useAIDocEditor.d.ts +97 -0
- package/components/features/AIDocEditor/useAIDocEditor.mock.ts +83 -0
- package/components/features/PageLayout/PageLayout.behaviors.stories.tsx +119 -0
- package/components/features/PageLayout/PageLayout.mocks.ts +27 -0
- package/components/features/PageLayout/PageLayout.stories.tsx +142 -0
- package/components/features/PageLayout/PageLayout.tsx +94 -0
- package/components/features/PageLayout/index.ts +4 -0
- package/components/features/PageLayout/usePageLayout.d.ts +24 -0
- package/components/features/PageLayout/usePageLayout.mock.ts +19 -0
- package/components/features/RefinementPanel/README.md +189 -0
- package/components/features/RefinementPanel/RefinementPanel.behaviors.stories.tsx +475 -0
- package/components/features/RefinementPanel/RefinementPanel.mocks.ts +131 -0
- package/components/features/RefinementPanel/RefinementPanel.stories.tsx +141 -0
- package/components/features/RefinementPanel/RefinementPanel.tsx +160 -0
- package/components/features/RefinementPanel/index.ts +25 -0
- package/components/features/RefinementPanel/useRefinementPanel.d.ts +74 -0
- package/components/features/RefinementPanel/useRefinementPanel.mock.ts +121 -0
- package/components/features/SpecNavigator/SpecNavigator.behaviors.stories.tsx +379 -0
- package/components/features/SpecNavigator/SpecNavigator.mocks.ts +131 -0
- package/components/features/SpecNavigator/SpecNavigator.stories.tsx +122 -0
- package/components/features/SpecNavigator/SpecNavigator.tsx +43 -0
- package/components/features/SpecNavigator/index.ts +2 -0
- package/components/features/SpecNavigator/useSpecNavigator.d.ts +122 -0
- package/components/features/SpecNavigator/useSpecNavigator.mock.ts +93 -0
- package/components/features/index.ts +18 -0
- package/components/index.ts +14 -0
- package/components/primitives/Accordion/Accordion.stories.tsx +87 -0
- package/components/primitives/Accordion/Accordion.tsx +66 -0
- package/components/primitives/Accordion/index.ts +13 -0
- package/components/primitives/Alert/Alert.stories.tsx +422 -0
- package/components/primitives/Alert/Alert.tsx +61 -0
- package/components/primitives/Alert/index.ts +8 -0
- package/components/primitives/AlertDialog/AlertDialog.stories.tsx +367 -0
- package/components/primitives/AlertDialog/AlertDialog.tsx +182 -0
- package/components/primitives/AlertDialog/index.ts +25 -0
- package/components/primitives/Avatar/Avatar.stories.tsx +321 -0
- package/components/primitives/Avatar/Avatar.tsx +63 -0
- package/components/primitives/Avatar/index.ts +8 -0
- package/components/primitives/Badge/Badge.stories.tsx +74 -0
- package/components/primitives/Badge/Badge.tsx +49 -0
- package/components/primitives/Badge/index.ts +2 -0
- package/components/primitives/Button/Button.stories.tsx +445 -0
- package/components/primitives/Button/Button.tsx +89 -0
- package/components/primitives/Button/index.ts +7 -0
- package/components/primitives/Card/Card.stories.tsx +831 -0
- package/components/primitives/Card/Card.tsx +242 -0
- package/components/primitives/Card/index.ts +30 -0
- package/components/primitives/Carousel/Carousel.stories.tsx +32 -0
- package/components/primitives/Carousel/Carousel.tsx +63 -0
- package/components/primitives/Carousel/index.ts +13 -0
- package/components/primitives/Chart/Chart.stories.tsx +346 -0
- package/components/primitives/Chart/Chart.tsx +117 -0
- package/components/primitives/Chart/index.ts +20 -0
- package/components/primitives/Checkbox/Checkbox.stories.tsx +87 -0
- package/components/primitives/Checkbox/Checkbox.tsx +38 -0
- package/components/primitives/Checkbox/index.ts +2 -0
- package/components/primitives/Collapsible/Collapsible.stories.tsx +38 -0
- package/components/primitives/Collapsible/Collapsible.tsx +39 -0
- package/components/primitives/Collapsible/index.ts +8 -0
- package/components/primitives/Command/Command.stories.tsx +150 -0
- package/components/primitives/Command/Command.tsx +147 -0
- package/components/primitives/Command/index.ts +20 -0
- package/components/primitives/Dialog/Dialog.stories.tsx +390 -0
- package/components/primitives/Dialog/Dialog.tsx +140 -0
- package/components/primitives/Dialog/index.ts +22 -0
- package/components/primitives/Drawer/Drawer.stories.tsx +327 -0
- package/components/primitives/Drawer/Drawer.tsx +208 -0
- package/components/primitives/Drawer/index.ts +27 -0
- package/components/primitives/DropdownMenu/DropdownMenu.stories.tsx +150 -0
- package/components/primitives/DropdownMenu/DropdownMenu.tsx +73 -0
- package/components/primitives/DropdownMenu/index.ts +1 -0
- package/components/primitives/HoverCard/HoverCard.stories.tsx +26 -0
- package/components/primitives/HoverCard/HoverCard.tsx +39 -0
- package/components/primitives/HoverCard/index.ts +8 -0
- package/components/primitives/Icon/Icon.stories.tsx +281 -0
- package/components/primitives/Icon/Icon.tsx +87 -0
- package/components/primitives/Icon/index.ts +8 -0
- package/components/primitives/Input/Input.stories.tsx +370 -0
- package/components/primitives/Input/Input.tsx +88 -0
- package/components/primitives/Input/index.ts +7 -0
- package/components/primitives/InputGroup/InputGroup.stories.tsx +40 -0
- package/components/primitives/InputGroup/InputGroup.tsx +72 -0
- package/components/primitives/InputGroup/index.ts +14 -0
- package/components/primitives/Label/Label.stories.tsx +227 -0
- package/components/primitives/Label/Label.tsx +53 -0
- package/components/primitives/Label/index.ts +7 -0
- package/components/primitives/Popover/Popover.stories.tsx +42 -0
- package/components/primitives/Popover/Popover.tsx +107 -0
- package/components/primitives/Popover/index.ts +2 -0
- package/components/primitives/Progress/Progress.stories.tsx +340 -0
- package/components/primitives/Progress/Progress.tsx +31 -0
- package/components/primitives/Progress/index.ts +1 -0
- package/components/primitives/ScrollArea/ScrollArea.stories.tsx +26 -0
- package/components/primitives/ScrollArea/ScrollArea.tsx +28 -0
- package/components/primitives/ScrollArea/index.ts +6 -0
- package/components/primitives/Select/Select.stories.tsx +288 -0
- package/components/primitives/Select/Select.tsx +162 -0
- package/components/primitives/Select/index.ts +22 -0
- package/components/primitives/Separator/Separator.stories.tsx +264 -0
- package/components/primitives/Separator/Separator.tsx +48 -0
- package/components/primitives/Separator/index.ts +7 -0
- package/components/primitives/Sidebar/Sidebar.stories.tsx +358 -0
- package/components/primitives/Sidebar/Sidebar.tsx +317 -0
- package/components/primitives/Sidebar/index.ts +41 -0
- package/components/primitives/Table/Table.stories.tsx +389 -0
- package/components/primitives/Table/Table.tsx +191 -0
- package/components/primitives/Table/index.ts +26 -0
- package/components/primitives/Tabs/Tabs.stories.tsx +129 -0
- package/components/primitives/Tabs/Tabs.tsx +70 -0
- package/components/primitives/Tabs/index.ts +13 -0
- package/components/primitives/Textarea/Textarea.stories.tsx +358 -0
- package/components/primitives/Textarea/Textarea.tsx +91 -0
- package/components/primitives/Textarea/index.ts +7 -0
- package/components/primitives/ToggleGroup/ToggleGroup.stories.tsx +87 -0
- package/components/primitives/ToggleGroup/ToggleGroup.tsx +52 -0
- package/components/primitives/ToggleGroup/index.ts +6 -0
- package/components/primitives/Tooltip/Tooltip.stories.tsx +336 -0
- package/components/primitives/Tooltip/Tooltip.tsx +78 -0
- package/components/primitives/Tooltip/index.ts +10 -0
- package/components/primitives/index.ts +34 -0
- package/components/ui/accordion.tsx +66 -0
- package/components/ui/alert-dialog.tsx +157 -0
- package/components/ui/alert.tsx +66 -0
- package/components/ui/avatar.tsx +53 -0
- package/components/ui/badge.tsx +46 -0
- package/components/ui/button.tsx +60 -0
- package/components/ui/card.tsx +117 -0
- package/components/ui/carousel.tsx +241 -0
- package/components/ui/chart.tsx +334 -0
- package/components/ui/checkbox.tsx +32 -0
- package/components/ui/collapsible.tsx +33 -0
- package/components/ui/command.tsx +184 -0
- package/components/ui/dialog.tsx +143 -0
- package/components/ui/drawer.tsx +118 -0
- package/components/ui/dropdown-menu.tsx +257 -0
- package/components/ui/hover-card.tsx +44 -0
- package/components/ui/input-group.tsx +170 -0
- package/components/ui/input.tsx +48 -0
- package/components/ui/label.tsx +26 -0
- package/components/ui/popover.tsx +33 -0
- package/components/ui/progress.tsx +31 -0
- package/components/ui/scroll-area.tsx +58 -0
- package/components/ui/select.tsx +187 -0
- package/components/ui/separator.tsx +31 -0
- package/components/ui/sidebar.tsx +577 -0
- package/components/ui/table.tsx +120 -0
- package/components/ui/tabs.tsx +66 -0
- package/components/ui/textarea.tsx +46 -0
- package/components/ui/toggle-group.tsx +83 -0
- package/components/ui/toggle.tsx +47 -0
- package/components/ui/tooltip.tsx +61 -0
- package/dist/index.cjs +7389 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +75 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js +7160 -0
- package/dist/index.js.map +1 -0
- package/hooks/useAIDocReviewer.d.ts +0 -0
- package/lib/utils.ts +6 -0
- package/package.json +140 -0
- package/tokens/color/base.json +14 -0
- package/tokens/color/dark.json +40 -0
- package/tokens/color/green.json +21 -0
- package/tokens/color/light.json +52 -0
- package/tokens/color/neutral.json +20 -0
- package/tokens/color/violet.json +21 -0
- package/tokens/spacing.json +22 -0
- package/utils/ai-editor/format-date.ts +41 -0
- package/utils/ai-editor/index.ts +22 -0
- package/utils/ai-editor/type-guards.ts +72 -0
- package/utils/ai-editor/validation.ts +130 -0
- package/utils/editor-annotations.ts +122 -0
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { Progress } from "./Progress";
|
|
3
|
+
import { useState, useEffect } from "react";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Progress component displays the completion progress of a task.
|
|
7
|
+
*
|
|
8
|
+
* ## Features
|
|
9
|
+
* - Determinate progress (0-100%)
|
|
10
|
+
* - Smooth animated transitions
|
|
11
|
+
* - Customizable height and color
|
|
12
|
+
* - ARIA attributes for accessibility
|
|
13
|
+
* - WCAG 2.1 Level AA compliant
|
|
14
|
+
*
|
|
15
|
+
* ## Usage
|
|
16
|
+
* ```tsx
|
|
17
|
+
* <Progress value={50} />
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* ## Accessibility
|
|
21
|
+
* - Uses role="progressbar"
|
|
22
|
+
* - aria-valuenow for current value
|
|
23
|
+
* - aria-valuemin and aria-valuemax for range
|
|
24
|
+
* - Screen reader announcements
|
|
25
|
+
*/
|
|
26
|
+
const meta: Meta<typeof Progress> = {
|
|
27
|
+
title: "Primitives/Progress",
|
|
28
|
+
component: Progress,
|
|
29
|
+
parameters: {
|
|
30
|
+
layout: "centered",
|
|
31
|
+
docs: {
|
|
32
|
+
description: {
|
|
33
|
+
component:
|
|
34
|
+
"Displays an indicator showing the completion progress of a task.",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
tags: ["autodocs"],
|
|
39
|
+
argTypes: {
|
|
40
|
+
value: {
|
|
41
|
+
control: { type: "range", min: 0, max: 100, step: 1 },
|
|
42
|
+
description: "The progress value (0-100)",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default meta;
|
|
48
|
+
type Story = StoryObj<typeof Progress>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Default progress at 50%
|
|
52
|
+
*/
|
|
53
|
+
export const Default: Story = {
|
|
54
|
+
args: {
|
|
55
|
+
value: 50,
|
|
56
|
+
className: "w-[300px]",
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Different progress values
|
|
62
|
+
*/
|
|
63
|
+
export const Values: Story = {
|
|
64
|
+
render: () => (
|
|
65
|
+
<div className="space-y-4 w-[300px]">
|
|
66
|
+
<div className="space-y-2">
|
|
67
|
+
<div className="text-sm text-muted-foreground">0% Complete</div>
|
|
68
|
+
<Progress value={0} />
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
<div className="space-y-2">
|
|
72
|
+
<div className="text-sm text-muted-foreground">25% Complete</div>
|
|
73
|
+
<Progress value={25} />
|
|
74
|
+
</div>
|
|
75
|
+
|
|
76
|
+
<div className="space-y-2">
|
|
77
|
+
<div className="text-sm text-muted-foreground">50% Complete</div>
|
|
78
|
+
<Progress value={50} />
|
|
79
|
+
</div>
|
|
80
|
+
|
|
81
|
+
<div className="space-y-2">
|
|
82
|
+
<div className="text-sm text-muted-foreground">75% Complete</div>
|
|
83
|
+
<Progress value={75} />
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
<div className="space-y-2">
|
|
87
|
+
<div className="text-sm text-muted-foreground">100% Complete</div>
|
|
88
|
+
<Progress value={100} />
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
),
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Animated progress (simulating upload/download)
|
|
96
|
+
*/
|
|
97
|
+
export const Animated: Story = {
|
|
98
|
+
render: () => {
|
|
99
|
+
const [progress, setProgress] = useState(0);
|
|
100
|
+
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
const timer = setInterval(() => {
|
|
103
|
+
setProgress((prev) => {
|
|
104
|
+
if (prev >= 100) {
|
|
105
|
+
return 0;
|
|
106
|
+
}
|
|
107
|
+
return prev + 10;
|
|
108
|
+
});
|
|
109
|
+
}, 500);
|
|
110
|
+
|
|
111
|
+
return () => clearInterval(timer);
|
|
112
|
+
}, []);
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<div className="space-y-2 w-[300px]">
|
|
116
|
+
<div className="text-sm text-muted-foreground">{progress}% Complete</div>
|
|
117
|
+
<Progress value={progress} />
|
|
118
|
+
</div>
|
|
119
|
+
);
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Different sizes
|
|
125
|
+
*/
|
|
126
|
+
export const Sizes: Story = {
|
|
127
|
+
render: () => (
|
|
128
|
+
<div className="space-y-4 w-[300px]">
|
|
129
|
+
<div className="space-y-2">
|
|
130
|
+
<div className="text-sm text-muted-foreground">Extra Small (h-1)</div>
|
|
131
|
+
<Progress value={60} className="h-1" />
|
|
132
|
+
</div>
|
|
133
|
+
|
|
134
|
+
<div className="space-y-2">
|
|
135
|
+
<div className="text-sm text-muted-foreground">Small (h-2, default)</div>
|
|
136
|
+
<Progress value={60} className="h-2" />
|
|
137
|
+
</div>
|
|
138
|
+
|
|
139
|
+
<div className="space-y-2">
|
|
140
|
+
<div className="text-sm text-muted-foreground">Medium (h-3)</div>
|
|
141
|
+
<Progress value={60} className="h-3" />
|
|
142
|
+
</div>
|
|
143
|
+
|
|
144
|
+
<div className="space-y-2">
|
|
145
|
+
<div className="text-sm text-muted-foreground">Large (h-4)</div>
|
|
146
|
+
<Progress value={60} className="h-4" />
|
|
147
|
+
</div>
|
|
148
|
+
|
|
149
|
+
<div className="space-y-2">
|
|
150
|
+
<div className="text-sm text-muted-foreground">Extra Large (h-6)</div>
|
|
151
|
+
<Progress value={60} className="h-6" />
|
|
152
|
+
</div>
|
|
153
|
+
</div>
|
|
154
|
+
),
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Custom colors
|
|
159
|
+
*/
|
|
160
|
+
export const CustomColors: Story = {
|
|
161
|
+
render: () => (
|
|
162
|
+
<div className="space-y-4 w-[300px]">
|
|
163
|
+
<div className="space-y-2">
|
|
164
|
+
<div className="text-sm text-muted-foreground">Success (Green)</div>
|
|
165
|
+
<Progress
|
|
166
|
+
value={75}
|
|
167
|
+
className="[&>div]:bg-green-500"
|
|
168
|
+
/>
|
|
169
|
+
</div>
|
|
170
|
+
|
|
171
|
+
<div className="space-y-2">
|
|
172
|
+
<div className="text-sm text-muted-foreground">Warning (Yellow)</div>
|
|
173
|
+
<Progress
|
|
174
|
+
value={50}
|
|
175
|
+
className="[&>div]:bg-yellow-500"
|
|
176
|
+
/>
|
|
177
|
+
</div>
|
|
178
|
+
|
|
179
|
+
<div className="space-y-2">
|
|
180
|
+
<div className="text-sm text-muted-foreground">Error (Red)</div>
|
|
181
|
+
<Progress
|
|
182
|
+
value={25}
|
|
183
|
+
className="[&>div]:bg-red-500"
|
|
184
|
+
/>
|
|
185
|
+
</div>
|
|
186
|
+
|
|
187
|
+
<div className="space-y-2">
|
|
188
|
+
<div className="text-sm text-muted-foreground">Info (Blue)</div>
|
|
189
|
+
<Progress
|
|
190
|
+
value={80}
|
|
191
|
+
className="[&>div]:bg-blue-500"
|
|
192
|
+
/>
|
|
193
|
+
</div>
|
|
194
|
+
</div>
|
|
195
|
+
),
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Upload progress simulation
|
|
200
|
+
*/
|
|
201
|
+
export const UploadSimulation: Story = {
|
|
202
|
+
render: () => {
|
|
203
|
+
const [progress, setProgress] = useState(0);
|
|
204
|
+
const [isUploading, setIsUploading] = useState(false);
|
|
205
|
+
|
|
206
|
+
const startUpload = () => {
|
|
207
|
+
setProgress(0);
|
|
208
|
+
setIsUploading(true);
|
|
209
|
+
|
|
210
|
+
const timer = setInterval(() => {
|
|
211
|
+
setProgress((prev) => {
|
|
212
|
+
if (prev >= 100) {
|
|
213
|
+
clearInterval(timer);
|
|
214
|
+
setIsUploading(false);
|
|
215
|
+
return 100;
|
|
216
|
+
}
|
|
217
|
+
// Simulate varying upload speeds
|
|
218
|
+
const increment = Math.random() * 15 + 5;
|
|
219
|
+
return Math.min(prev + increment, 100);
|
|
220
|
+
});
|
|
221
|
+
}, 300);
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
return (
|
|
225
|
+
<div className="space-y-4 w-[400px]">
|
|
226
|
+
<div className="space-y-2">
|
|
227
|
+
<div className="flex justify-between text-sm">
|
|
228
|
+
<span className="text-muted-foreground">Uploading file.pdf</span>
|
|
229
|
+
<span className="font-medium">{Math.round(progress)}%</span>
|
|
230
|
+
</div>
|
|
231
|
+
<Progress value={progress} />
|
|
232
|
+
{progress === 100 && !isUploading && (
|
|
233
|
+
<div className="text-sm text-green-600 dark:text-green-400">
|
|
234
|
+
Upload complete!
|
|
235
|
+
</div>
|
|
236
|
+
)}
|
|
237
|
+
</div>
|
|
238
|
+
|
|
239
|
+
<button
|
|
240
|
+
onClick={startUpload}
|
|
241
|
+
disabled={isUploading}
|
|
242
|
+
className="px-4 py-2 bg-primary text-primary-foreground rounded-md disabled:opacity-50"
|
|
243
|
+
>
|
|
244
|
+
{isUploading ? "Uploading..." : "Start Upload"}
|
|
245
|
+
</button>
|
|
246
|
+
</div>
|
|
247
|
+
);
|
|
248
|
+
},
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Multi-step progress
|
|
253
|
+
*/
|
|
254
|
+
export const MultiStep: Story = {
|
|
255
|
+
render: () => {
|
|
256
|
+
const [currentStep, setCurrentStep] = useState(1);
|
|
257
|
+
const totalSteps = 4;
|
|
258
|
+
const progress = (currentStep / totalSteps) * 100;
|
|
259
|
+
|
|
260
|
+
return (
|
|
261
|
+
<div className="space-y-4 w-[400px]">
|
|
262
|
+
<div className="space-y-2">
|
|
263
|
+
<div className="flex justify-between text-sm">
|
|
264
|
+
<span className="text-muted-foreground">
|
|
265
|
+
Step {currentStep} of {totalSteps}
|
|
266
|
+
</span>
|
|
267
|
+
<span className="font-medium">{Math.round(progress)}%</span>
|
|
268
|
+
</div>
|
|
269
|
+
<Progress value={progress} />
|
|
270
|
+
</div>
|
|
271
|
+
|
|
272
|
+
<div className="flex gap-2">
|
|
273
|
+
<button
|
|
274
|
+
onClick={() => setCurrentStep((prev) => Math.max(prev - 1, 1))}
|
|
275
|
+
disabled={currentStep === 1}
|
|
276
|
+
className="px-4 py-2 bg-secondary text-secondary-foreground rounded-md disabled:opacity-50"
|
|
277
|
+
>
|
|
278
|
+
Previous
|
|
279
|
+
</button>
|
|
280
|
+
<button
|
|
281
|
+
onClick={() => setCurrentStep((prev) => Math.min(prev + 1, totalSteps))}
|
|
282
|
+
disabled={currentStep === totalSteps}
|
|
283
|
+
className="px-4 py-2 bg-primary text-primary-foreground rounded-md disabled:opacity-50"
|
|
284
|
+
>
|
|
285
|
+
Next
|
|
286
|
+
</button>
|
|
287
|
+
</div>
|
|
288
|
+
</div>
|
|
289
|
+
);
|
|
290
|
+
},
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Indeterminate state (loading)
|
|
295
|
+
*/
|
|
296
|
+
export const IndeterminateLoading: Story = {
|
|
297
|
+
render: () => (
|
|
298
|
+
<div className="space-y-4 w-[300px]">
|
|
299
|
+
<div className="space-y-2">
|
|
300
|
+
<div className="text-sm text-muted-foreground">Loading...</div>
|
|
301
|
+
<div className="h-2 w-full overflow-hidden rounded-full bg-primary/20">
|
|
302
|
+
<div className="h-full w-1/3 animate-[shimmer_2s_ease-in-out_infinite] bg-primary" />
|
|
303
|
+
</div>
|
|
304
|
+
</div>
|
|
305
|
+
<style>{`
|
|
306
|
+
@keyframes shimmer {
|
|
307
|
+
0% { transform: translateX(-100%); }
|
|
308
|
+
100% { transform: translateX(400%); }
|
|
309
|
+
}
|
|
310
|
+
`}</style>
|
|
311
|
+
</div>
|
|
312
|
+
),
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Dark mode support
|
|
317
|
+
*/
|
|
318
|
+
export const DarkMode: Story = {
|
|
319
|
+
parameters: {
|
|
320
|
+
backgrounds: { default: "dark" },
|
|
321
|
+
},
|
|
322
|
+
render: () => (
|
|
323
|
+
<div className="dark space-y-4 w-[300px]">
|
|
324
|
+
<div className="space-y-2">
|
|
325
|
+
<div className="text-sm text-muted-foreground">Default</div>
|
|
326
|
+
<Progress value={60} />
|
|
327
|
+
</div>
|
|
328
|
+
|
|
329
|
+
<div className="space-y-2">
|
|
330
|
+
<div className="text-sm text-muted-foreground">Success</div>
|
|
331
|
+
<Progress value={80} className="[&>div]:bg-green-500" />
|
|
332
|
+
</div>
|
|
333
|
+
|
|
334
|
+
<div className="space-y-2">
|
|
335
|
+
<div className="text-sm text-muted-foreground">Warning</div>
|
|
336
|
+
<Progress value={50} className="[&>div]:bg-yellow-500" />
|
|
337
|
+
</div>
|
|
338
|
+
</div>
|
|
339
|
+
),
|
|
340
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Progress as ShadcnProgress } from "@/components/ui/progress";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Progress Primitive
|
|
8
|
+
*
|
|
9
|
+
* Displays an indicator showing the completion progress of a task.
|
|
10
|
+
*
|
|
11
|
+
* Features:
|
|
12
|
+
* - Determinate progress (0-100%)
|
|
13
|
+
* - Smooth transitions
|
|
14
|
+
* - Customizable height and color
|
|
15
|
+
* - Accessible with proper ARIA attributes
|
|
16
|
+
* - WCAG 2.1 Level AA compliant
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
export type ProgressProps = React.ComponentProps<typeof ShadcnProgress>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Progress - Displays task completion progress
|
|
23
|
+
*/
|
|
24
|
+
export const Progress = React.memo<ProgressProps>(
|
|
25
|
+
React.forwardRef<React.ElementRef<typeof ShadcnProgress>, ProgressProps>(
|
|
26
|
+
(props, ref) => {
|
|
27
|
+
return <ShadcnProgress ref={ref} {...props} />;
|
|
28
|
+
}
|
|
29
|
+
)
|
|
30
|
+
);
|
|
31
|
+
Progress.displayName = "Progress";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Progress, type ProgressProps } from "./Progress";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { ScrollArea } from "./ScrollArea";
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof ScrollArea> = {
|
|
5
|
+
title: "Primitives/ScrollArea",
|
|
6
|
+
component: ScrollArea,
|
|
7
|
+
parameters: { layout: "centered" },
|
|
8
|
+
tags: ["autodocs"],
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof ScrollArea>;
|
|
13
|
+
|
|
14
|
+
export const Default: Story = {
|
|
15
|
+
render: () => (
|
|
16
|
+
<ScrollArea className="h-[200px] w-[350px] rounded-md border p-4">
|
|
17
|
+
<div className="space-y-4">
|
|
18
|
+
{Array.from({ length: 20 }).map((_, i) => (
|
|
19
|
+
<p key={i} className="text-sm">
|
|
20
|
+
Item {i + 1} - This is scrollable content
|
|
21
|
+
</p>
|
|
22
|
+
))}
|
|
23
|
+
</div>
|
|
24
|
+
</ScrollArea>
|
|
25
|
+
),
|
|
26
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import {
|
|
5
|
+
ScrollArea as ShadcnScrollArea,
|
|
6
|
+
ScrollBar as ShadcnScrollBar,
|
|
7
|
+
} from "@/components/ui/scroll-area";
|
|
8
|
+
|
|
9
|
+
export type ScrollAreaProps = React.ComponentProps<typeof ShadcnScrollArea>;
|
|
10
|
+
export type ScrollBarProps = React.ComponentProps<typeof ShadcnScrollBar>;
|
|
11
|
+
|
|
12
|
+
export const ScrollArea = React.memo<ScrollAreaProps>(
|
|
13
|
+
React.forwardRef<React.ElementRef<typeof ShadcnScrollArea>, ScrollAreaProps>(
|
|
14
|
+
(props, ref) => {
|
|
15
|
+
return <ShadcnScrollArea ref={ref} {...props} />;
|
|
16
|
+
}
|
|
17
|
+
)
|
|
18
|
+
);
|
|
19
|
+
ScrollArea.displayName = "ScrollArea";
|
|
20
|
+
|
|
21
|
+
export const ScrollBar = React.memo<ScrollBarProps>(
|
|
22
|
+
React.forwardRef<React.ElementRef<typeof ShadcnScrollBar>, ScrollBarProps>(
|
|
23
|
+
(props, ref) => {
|
|
24
|
+
return <ShadcnScrollBar ref={ref} {...props} />;
|
|
25
|
+
}
|
|
26
|
+
)
|
|
27
|
+
);
|
|
28
|
+
ScrollBar.displayName = "ScrollBar";
|