torch-glare 2.1.1 → 2.1.2
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/apps/lib/components/BadgeField.tsx +2 -2
- package/apps/lib/components/DataViews/ARCHITECTURE.md +439 -0
- package/apps/lib/components/DataViews/DataViewsConfigPanel.tsx +416 -0
- package/apps/lib/components/DataViews/DataViewsHeader.tsx +126 -0
- package/apps/lib/components/DataViews/DataViewsLayout.tsx +300 -0
- package/apps/lib/components/DataViews/FilterPanel.tsx +324 -0
- package/apps/lib/components/DataViews/InboxView.tsx +514 -0
- package/apps/lib/components/DataViews/KanbanView.tsx +242 -0
- package/apps/lib/components/DataViews/PanelControls.tsx +80 -0
- package/apps/lib/components/DataViews/SettingsPanel.tsx +285 -0
- package/apps/lib/components/DataViews/TableView.tsx +232 -0
- package/apps/lib/components/DataViews/TreeView.tsx +363 -0
- package/apps/lib/components/DataViews/badgeAdapter.ts +45 -0
- package/apps/lib/components/DataViews/fieldRenderers.tsx +334 -0
- package/apps/lib/components/DataViews/filters/DateRangePopover.tsx +113 -0
- package/apps/lib/components/DataViews/filters/PresetChips.tsx +45 -0
- package/apps/lib/components/DataViews/filters/RangeSliderWithInputs.tsx +154 -0
- package/apps/lib/components/DataViews/index.ts +30 -0
- package/apps/lib/components/DataViews/tree/TreeDrawer.tsx +54 -0
- package/apps/lib/components/DataViews/tree/TreeSidebar.tsx +77 -0
- package/apps/lib/components/DataViews/types.ts +177 -0
- package/apps/lib/components/TreeFolder/TreeFolder.tsx +387 -0
- package/apps/lib/components/TreeFolder/TreeFolderBreadcrumb.tsx +80 -0
- package/apps/lib/components/TreeFolder/TreeFolderRow.tsx +235 -0
- package/apps/lib/components/TreeFolder/TreeFolderStyles.tsx +60 -0
- package/apps/lib/components/TreeFolder/icons.tsx +63 -0
- package/apps/lib/components/TreeFolder/index.ts +17 -0
- package/apps/lib/components/TreeFolder/treeFolderUtils.ts +114 -0
- package/apps/lib/components/TreeFolder/types.ts +68 -0
- package/apps/lib/components/TreeFolder/useTreeFolderDnD.ts +261 -0
- package/apps/lib/hooks/useDataViewsState.ts +169 -0
- package/apps/lib/hooks/useIsMobile.ts +21 -0
- package/apps/lib/utils/dataViews/columnUtils.ts +130 -0
- package/apps/lib/utils/dataViews/fieldUtils.ts +198 -0
- package/apps/lib/utils/dataViews/nestedDataUtils.tsx +364 -0
- package/apps/lib/utils/dataViews/pathUtils.ts +132 -0
- package/apps/lib/utils/dataViews/rangeUtils.ts +225 -0
- package/apps/lib/utils/dataViews/treeUtils.ts +403 -0
- package/dist/bin/index.js +3 -3
- package/dist/bin/index.js.map +1 -1
- package/dist/src/commands/add.d.ts.map +1 -1
- package/dist/src/commands/add.js +29 -6
- package/dist/src/commands/add.js.map +1 -1
- package/dist/src/commands/utils.d.ts.map +1 -1
- package/dist/src/commands/utils.js +22 -2
- package/dist/src/commands/utils.js.map +1 -1
- package/dist/src/shared/copyComponentsRecursively.d.ts.map +1 -1
- package/dist/src/shared/copyComponentsRecursively.js +8 -1
- package/dist/src/shared/copyComponentsRecursively.js.map +1 -1
- package/dist/src/shared/getDependenciesAndInstallNestedComponents.d.ts +18 -4
- package/dist/src/shared/getDependenciesAndInstallNestedComponents.d.ts.map +1 -1
- package/dist/src/shared/getDependenciesAndInstallNestedComponents.js +110 -40
- package/dist/src/shared/getDependenciesAndInstallNestedComponents.js.map +1 -1
- package/docs/components/form-stepper.md +244 -0
- package/docs/components/stepper.md +215 -0
- package/docs/components/timeline.md +248 -0
- package/package.json +6 -6
- package/apps/lib/components/Charts-dev.tsx +0 -365
- package/apps/lib/components/Command-dev.tsx +0 -151
- package/apps/lib/components/IosDatePicker-dev.tsx +0 -341
- /package/docs/components/{labeled-checkbox.md → labeled-check-box.md} +0 -0
- /package/docs/components/{tree-dropdown.md → tree-drop-down.md} +0 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Stepper
|
|
3
|
+
description: Generic horizontal/vertical stepper with pending, active, completed, and error states. Composed of Stepper, Step, StepIndicator, StepConnector, StepLabel, and StepDescription.
|
|
4
|
+
component: true
|
|
5
|
+
group: Forms
|
|
6
|
+
keywords: [stepper, steps, wizard, progress, multi-step, vertical, horizontal]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Stepper
|
|
10
|
+
|
|
11
|
+
A generic step-progress component for wizards, onboarding flows, and multi-section forms. Each step has four states — `pending`, `active`, `completed`, `error` — derived automatically from `activeStep` or set explicitly per `Step`.
|
|
12
|
+
|
|
13
|
+
The component is composed of `Stepper`, `Step`, `StepIndicator`, `StepConnector`, `StepLabel`, and `StepDescription`. Compare to [`FormStepper`](./form-stepper.md), which is a pill-shaped variant with no connector line.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx torch-glare@latest add Stepper
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Imports
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import {
|
|
25
|
+
Stepper,
|
|
26
|
+
Step,
|
|
27
|
+
StepIndicator,
|
|
28
|
+
StepConnector,
|
|
29
|
+
StepLabel,
|
|
30
|
+
StepDescription,
|
|
31
|
+
} from '@/components/Stepper'
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Basic Usage
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { useState } from 'react'
|
|
38
|
+
import {
|
|
39
|
+
Stepper,
|
|
40
|
+
Step,
|
|
41
|
+
StepIndicator,
|
|
42
|
+
StepConnector,
|
|
43
|
+
StepLabel,
|
|
44
|
+
} from '@/components/Stepper'
|
|
45
|
+
|
|
46
|
+
export function BasicStepper() {
|
|
47
|
+
const [activeStep, setActiveStep] = useState(1)
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<Stepper activeStep={activeStep}>
|
|
51
|
+
<Step index={0}>
|
|
52
|
+
<StepIndicator />
|
|
53
|
+
<StepLabel>Account</StepLabel>
|
|
54
|
+
</Step>
|
|
55
|
+
<StepConnector />
|
|
56
|
+
<Step index={1}>
|
|
57
|
+
<StepIndicator />
|
|
58
|
+
<StepLabel>Profile</StepLabel>
|
|
59
|
+
</Step>
|
|
60
|
+
<StepConnector />
|
|
61
|
+
<Step index={2}>
|
|
62
|
+
<StepIndicator />
|
|
63
|
+
<StepLabel>Confirm</StepLabel>
|
|
64
|
+
</Step>
|
|
65
|
+
</Stepper>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
State derivation: `index < activeStep` → `completed`, `index === activeStep` → `active`, otherwise `pending`. Pass `isCompleted`, `isActive`, or `isError` on a `Step` to override.
|
|
71
|
+
|
|
72
|
+
## Examples
|
|
73
|
+
|
|
74
|
+
### Vertical orientation with descriptions
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
<Stepper orientation="vertical" activeStep={1}>
|
|
78
|
+
<Step index={0}>
|
|
79
|
+
<StepIndicator />
|
|
80
|
+
<div>
|
|
81
|
+
<StepLabel>Create account</StepLabel>
|
|
82
|
+
<StepDescription>Email and password.</StepDescription>
|
|
83
|
+
</div>
|
|
84
|
+
</Step>
|
|
85
|
+
<StepConnector />
|
|
86
|
+
<Step index={1}>
|
|
87
|
+
<StepIndicator />
|
|
88
|
+
<div>
|
|
89
|
+
<StepLabel>Verify email</StepLabel>
|
|
90
|
+
<StepDescription>Check your inbox for a code.</StepDescription>
|
|
91
|
+
</div>
|
|
92
|
+
</Step>
|
|
93
|
+
<StepConnector />
|
|
94
|
+
<Step index={2}>
|
|
95
|
+
<StepIndicator />
|
|
96
|
+
<div>
|
|
97
|
+
<StepLabel>Done</StepLabel>
|
|
98
|
+
<StepDescription>You're all set.</StepDescription>
|
|
99
|
+
</div>
|
|
100
|
+
</Step>
|
|
101
|
+
</Stepper>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Error state
|
|
105
|
+
|
|
106
|
+
```tsx
|
|
107
|
+
<Stepper activeStep={2}>
|
|
108
|
+
<Step index={0}>
|
|
109
|
+
<StepIndicator />
|
|
110
|
+
<StepLabel>Account</StepLabel>
|
|
111
|
+
</Step>
|
|
112
|
+
<StepConnector />
|
|
113
|
+
<Step index={1} isError>
|
|
114
|
+
<StepIndicator />
|
|
115
|
+
<StepLabel>Payment</StepLabel>
|
|
116
|
+
</Step>
|
|
117
|
+
<StepConnector />
|
|
118
|
+
<Step index={2}>
|
|
119
|
+
<StepIndicator />
|
|
120
|
+
<StepLabel>Confirm</StepLabel>
|
|
121
|
+
</Step>
|
|
122
|
+
</Stepper>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
`StepIndicator` auto-renders a check icon for `completed`, a close icon for `error`, and the step number otherwise. Override via `icon`, `completedIcon`, or `errorIcon`.
|
|
126
|
+
|
|
127
|
+
### Custom indicators
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
<Step index={0} isCompleted>
|
|
131
|
+
<StepIndicator
|
|
132
|
+
completedIcon={<i className="ri-shield-check-line" />}
|
|
133
|
+
errorIcon={<i className="ri-shield-cross-line" />}
|
|
134
|
+
/>
|
|
135
|
+
<StepLabel>Verified</StepLabel>
|
|
136
|
+
</Step>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Sizes
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
<Stepper size="S" activeStep={1}> {/* 22px indicators */} </Stepper>
|
|
143
|
+
<Stepper size="M" activeStep={1}> {/* 28px — default */} </Stepper>
|
|
144
|
+
<Stepper size="L" activeStep={1}> {/* 34px */} </Stepper>
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## API Reference
|
|
148
|
+
|
|
149
|
+
### Stepper
|
|
150
|
+
|
|
151
|
+
| Prop | Type | Default | Description |
|
|
152
|
+
| ------------- | --------------------------------- | -------------- | ---------------------------------------------------- |
|
|
153
|
+
| `activeStep` | `number` | `0` | Zero-based index of the active step. |
|
|
154
|
+
| `orientation` | `'horizontal' \| 'vertical'` | `'horizontal'` | Layout direction. |
|
|
155
|
+
| `size` | `'S' \| 'M' \| 'L'` | `'M'` | Indicator size for all children. |
|
|
156
|
+
| `theme` | `'dark' \| 'light' \| 'default'` | — | Theme override applied via `data-theme`. |
|
|
157
|
+
|
|
158
|
+
### Step
|
|
159
|
+
|
|
160
|
+
| Prop | Type | Default | Description |
|
|
161
|
+
| ------------- | --------- | ------- | ------------------------------------------------------------ |
|
|
162
|
+
| `index` | `number` | `0` | Zero-based step index. Compared with `Stepper.activeStep`. |
|
|
163
|
+
| `isActive` | `boolean` | — | Force the active state. |
|
|
164
|
+
| `isCompleted` | `boolean` | — | Force the completed state. |
|
|
165
|
+
| `isError` | `boolean` | — | Force the error state. Overrides active and completed. |
|
|
166
|
+
|
|
167
|
+
### StepIndicator
|
|
168
|
+
|
|
169
|
+
| Prop | Type | Default | Description |
|
|
170
|
+
| --------------- | ----------- | ------- | ------------------------------------------------- |
|
|
171
|
+
| `icon` | `ReactNode` | — | Replaces the step number for the pending state. |
|
|
172
|
+
| `completedIcon` | `ReactNode` | — | Replaces the default check icon when completed. |
|
|
173
|
+
| `errorIcon` | `ReactNode` | — | Replaces the default close icon on error. |
|
|
174
|
+
|
|
175
|
+
### StepConnector
|
|
176
|
+
|
|
177
|
+
The line between steps. No props beyond standard HTML attributes — orientation comes from the parent `Stepper`.
|
|
178
|
+
|
|
179
|
+
### StepLabel / StepDescription
|
|
180
|
+
|
|
181
|
+
Forward `HTMLAttributes<HTMLDivElement>`. Their colors follow the parent `Step` state automatically.
|
|
182
|
+
|
|
183
|
+
## Styling
|
|
184
|
+
|
|
185
|
+
- Default state: `bg-background-presentation-action-disabled`, gray border, disabled foreground.
|
|
186
|
+
- Active: blue informational background + focus ring.
|
|
187
|
+
- Completed: green success background and ring; check icon.
|
|
188
|
+
- Error: red negative background and ring; close icon.
|
|
189
|
+
- Connectors: `2px` line, gray when pending, focus-blue when the preceding step is completed.
|
|
190
|
+
|
|
191
|
+
## TypeScript Types
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
import type { VariantProps } from 'class-variance-authority'
|
|
195
|
+
import type { stepperStyles, stepIndicatorStyles } from '@/components/Stepper'
|
|
196
|
+
|
|
197
|
+
type StepperVariants = VariantProps<typeof stepperStyles>
|
|
198
|
+
// { orientation?: 'horizontal' | 'vertical' }
|
|
199
|
+
|
|
200
|
+
type IndicatorVariants = VariantProps<typeof stepIndicatorStyles>
|
|
201
|
+
// { state?: 'pending' | 'active' | 'completed' | 'error'; size?: 'S' | 'M' | 'L' }
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Accessibility
|
|
205
|
+
|
|
206
|
+
- Wrap the stepper in a `<nav aria-label="Progress">` when it represents real navigation.
|
|
207
|
+
- Use `aria-current="step"` on the active step's container when steps are interactive.
|
|
208
|
+
- Don't rely on color alone for error — pair with `StepDescription` or an off-screen message.
|
|
209
|
+
|
|
210
|
+
## Best Practices
|
|
211
|
+
|
|
212
|
+
1. Use `Stepper` when you need a connector line + numbered/iconified steps. Use `FormStepper` when you want pill-shaped buttons without a line.
|
|
213
|
+
2. Keep `Step` count to 3–5 horizontal, 3–7 vertical. Beyond that, switch to a checklist or summary.
|
|
214
|
+
3. Drive state from `activeStep` in the parent — only fall back to `isActive`/`isCompleted` for non-linear flows.
|
|
215
|
+
4. Provide a `StepDescription` only on vertical steppers — descriptions wrap horizontal layouts awkwardly.
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Timeline
|
|
3
|
+
description: Vertical or horizontal timeline for activity logs, audit trails, and history. Composed of indicator, separator, content, heading, and description parts with five semantic variants.
|
|
4
|
+
component: true
|
|
5
|
+
group: Data Display
|
|
6
|
+
keywords: [timeline, activity, history, audit, log, events, vertical, horizontal]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Timeline
|
|
10
|
+
|
|
11
|
+
A composable timeline for activity logs, change history, audit trails, and event sequences. Each item has an indicator, a connecting separator, and a content block. The indicator supports five variants — `default`, `active`, `completed`, `error`, `warning` — each with built-in icons and color tokens.
|
|
12
|
+
|
|
13
|
+
The component is composed of `Timeline`, `TimelineItem`, `TimelineIndicator`, `TimelineSeparator`, `TimelineConnector`, `TimelineContent`, `TimelineHeading`, and `TimelineDescription`. Unlike [`Stepper`](./stepper.md), Timeline doesn't track an `activeStep` — each item's variant is set explicitly.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx torch-glare@latest add Timeline
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Imports
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import {
|
|
25
|
+
Timeline,
|
|
26
|
+
TimelineItem,
|
|
27
|
+
TimelineIndicator,
|
|
28
|
+
TimelineSeparator,
|
|
29
|
+
TimelineConnector,
|
|
30
|
+
TimelineContent,
|
|
31
|
+
TimelineHeading,
|
|
32
|
+
TimelineDescription,
|
|
33
|
+
} from '@/components/Timeline'
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Basic Usage
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
import {
|
|
40
|
+
Timeline,
|
|
41
|
+
TimelineItem,
|
|
42
|
+
TimelineIndicator,
|
|
43
|
+
TimelineSeparator,
|
|
44
|
+
TimelineConnector,
|
|
45
|
+
TimelineContent,
|
|
46
|
+
TimelineHeading,
|
|
47
|
+
TimelineDescription,
|
|
48
|
+
} from '@/components/Timeline'
|
|
49
|
+
|
|
50
|
+
export function BasicTimeline() {
|
|
51
|
+
return (
|
|
52
|
+
<Timeline>
|
|
53
|
+
<TimelineItem>
|
|
54
|
+
<TimelineConnector>
|
|
55
|
+
<TimelineIndicator variant="completed" />
|
|
56
|
+
<TimelineSeparator />
|
|
57
|
+
</TimelineConnector>
|
|
58
|
+
<TimelineContent>
|
|
59
|
+
<TimelineHeading>Account created</TimelineHeading>
|
|
60
|
+
<TimelineDescription>March 5, 2026 · 9:14 AM</TimelineDescription>
|
|
61
|
+
</TimelineContent>
|
|
62
|
+
</TimelineItem>
|
|
63
|
+
|
|
64
|
+
<TimelineItem>
|
|
65
|
+
<TimelineConnector>
|
|
66
|
+
<TimelineIndicator variant="active" />
|
|
67
|
+
<TimelineSeparator active />
|
|
68
|
+
</TimelineConnector>
|
|
69
|
+
<TimelineContent>
|
|
70
|
+
<TimelineHeading>Email verified</TimelineHeading>
|
|
71
|
+
<TimelineDescription>March 5, 2026 · 9:32 AM</TimelineDescription>
|
|
72
|
+
</TimelineContent>
|
|
73
|
+
</TimelineItem>
|
|
74
|
+
|
|
75
|
+
<TimelineItem>
|
|
76
|
+
<TimelineConnector>
|
|
77
|
+
<TimelineIndicator variant="default" />
|
|
78
|
+
</TimelineConnector>
|
|
79
|
+
<TimelineContent>
|
|
80
|
+
<TimelineHeading>Profile setup</TimelineHeading>
|
|
81
|
+
<TimelineDescription>Pending</TimelineDescription>
|
|
82
|
+
</TimelineContent>
|
|
83
|
+
</TimelineItem>
|
|
84
|
+
</Timeline>
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The last `TimelineItem` should typically omit `TimelineSeparator` so the line ends at the final indicator. `TimelineContent` auto-removes its bottom padding on the last item via `group-last/item:pb-0`.
|
|
90
|
+
|
|
91
|
+
## Examples
|
|
92
|
+
|
|
93
|
+
### Indicator variants
|
|
94
|
+
|
|
95
|
+
`completed` renders a check icon, `error` renders a close icon, `warning` renders an alert icon. `default` and `active` render a `6×6` filled dot. Pass `icon` or `children` to override.
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
<TimelineIndicator variant="default" />
|
|
99
|
+
<TimelineIndicator variant="active" />
|
|
100
|
+
<TimelineIndicator variant="completed" />
|
|
101
|
+
<TimelineIndicator variant="error" />
|
|
102
|
+
<TimelineIndicator variant="warning" />
|
|
103
|
+
<TimelineIndicator variant="active" icon={<i className="ri-flashlight-line" />} />
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Sizes
|
|
107
|
+
|
|
108
|
+
Indicators support `S` (`22px`), `M` (`28px`, default), and `L` (`34px`).
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
<TimelineIndicator size="S" variant="completed" />
|
|
112
|
+
<TimelineIndicator size="M" variant="completed" />
|
|
113
|
+
<TimelineIndicator size="L" variant="completed" />
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Horizontal orientation
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
<Timeline orientation="horizontal">
|
|
120
|
+
<TimelineItem>
|
|
121
|
+
<TimelineConnector orientation="horizontal">
|
|
122
|
+
<TimelineIndicator variant="completed" />
|
|
123
|
+
<TimelineSeparator orientation="horizontal" active />
|
|
124
|
+
</TimelineConnector>
|
|
125
|
+
<TimelineContent>
|
|
126
|
+
<TimelineHeading>Submitted</TimelineHeading>
|
|
127
|
+
<TimelineDescription>2:14 PM</TimelineDescription>
|
|
128
|
+
</TimelineContent>
|
|
129
|
+
</TimelineItem>
|
|
130
|
+
|
|
131
|
+
<TimelineItem>
|
|
132
|
+
<TimelineConnector orientation="horizontal">
|
|
133
|
+
<TimelineIndicator variant="active" />
|
|
134
|
+
</TimelineConnector>
|
|
135
|
+
<TimelineContent>
|
|
136
|
+
<TimelineHeading>Reviewing</TimelineHeading>
|
|
137
|
+
<TimelineDescription>Now</TimelineDescription>
|
|
138
|
+
</TimelineContent>
|
|
139
|
+
</TimelineItem>
|
|
140
|
+
</Timeline>
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Pass `orientation="horizontal"` on `Timeline`, `TimelineItem`, `TimelineConnector`, and `TimelineSeparator` — the orientation isn't propagated through context.
|
|
144
|
+
|
|
145
|
+
### Activity log
|
|
146
|
+
|
|
147
|
+
```tsx
|
|
148
|
+
const events = [
|
|
149
|
+
{ id: 1, variant: 'completed', heading: 'Order placed', when: 'Mar 5 · 9:14 AM' },
|
|
150
|
+
{ id: 2, variant: 'completed', heading: 'Payment received', when: 'Mar 5 · 9:15 AM' },
|
|
151
|
+
{ id: 3, variant: 'active', heading: 'Preparing order', when: 'Mar 5 · 10:02 AM' },
|
|
152
|
+
{ id: 4, variant: 'default', heading: 'Shipped', when: 'Pending' },
|
|
153
|
+
{ id: 5, variant: 'default', heading: 'Delivered', when: 'Pending' },
|
|
154
|
+
] as const
|
|
155
|
+
|
|
156
|
+
export function OrderTimeline() {
|
|
157
|
+
return (
|
|
158
|
+
<Timeline>
|
|
159
|
+
{events.map((e, i) => (
|
|
160
|
+
<TimelineItem key={e.id}>
|
|
161
|
+
<TimelineConnector>
|
|
162
|
+
<TimelineIndicator variant={e.variant} />
|
|
163
|
+
{i < events.length - 1 && (
|
|
164
|
+
<TimelineSeparator active={e.variant === 'completed' || e.variant === 'active'} />
|
|
165
|
+
)}
|
|
166
|
+
</TimelineConnector>
|
|
167
|
+
<TimelineContent>
|
|
168
|
+
<TimelineHeading>{e.heading}</TimelineHeading>
|
|
169
|
+
<TimelineDescription>{e.when}</TimelineDescription>
|
|
170
|
+
</TimelineContent>
|
|
171
|
+
</TimelineItem>
|
|
172
|
+
))}
|
|
173
|
+
</Timeline>
|
|
174
|
+
)
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## API Reference
|
|
179
|
+
|
|
180
|
+
### Timeline
|
|
181
|
+
|
|
182
|
+
| Prop | Type | Default | Description |
|
|
183
|
+
| ------------- | ------------------------------- | ------------ | ---------------------------------------- |
|
|
184
|
+
| `orientation` | `'vertical' \| 'horizontal'` | `'vertical'` | Layout direction. |
|
|
185
|
+
| `theme` | `'dark' \| 'light' \| 'default'` | — | Theme override applied via `data-theme`. |
|
|
186
|
+
|
|
187
|
+
### TimelineItem
|
|
188
|
+
|
|
189
|
+
| Prop | Type | Default | Description |
|
|
190
|
+
| ------------- | ---------------------------- | ------------ | ---------------------------------------------- |
|
|
191
|
+
| `orientation` | `'vertical' \| 'horizontal'` | `'vertical'` | Should match the parent `Timeline`. |
|
|
192
|
+
|
|
193
|
+
### TimelineIndicator
|
|
194
|
+
|
|
195
|
+
| Prop | Type | Default | Description |
|
|
196
|
+
| --------- | --------------------------------------------------------------- | ----------- | ---------------------------------------------------------------------- |
|
|
197
|
+
| `variant` | `'default' \| 'active' \| 'completed' \| 'error' \| 'warning'` | `'default'` | Visual state. Drives both color tokens and the auto-rendered icon. |
|
|
198
|
+
| `size` | `'S' \| 'M' \| 'L'` | `'M'` | Indicator diameter (`22 / 28 / 34px`). |
|
|
199
|
+
| `icon` | `ReactNode` | — | Custom icon — overrides the variant's default. |
|
|
200
|
+
| `children`| `ReactNode` | — | Custom content — used when `icon` is not set. |
|
|
201
|
+
|
|
202
|
+
### TimelineSeparator
|
|
203
|
+
|
|
204
|
+
| Prop | Type | Default | Description |
|
|
205
|
+
| ------------- | ---------------------------- | ------------ | ---------------------------------------------------------- |
|
|
206
|
+
| `orientation` | `'vertical' \| 'horizontal'` | `'vertical'` | Line direction. |
|
|
207
|
+
| `active` | `boolean` | `false` | Render the line in focus blue (use after completed steps). |
|
|
208
|
+
|
|
209
|
+
### TimelineConnector
|
|
210
|
+
|
|
211
|
+
Wraps the indicator and separator. Pass `orientation` to switch between column (vertical) and row (horizontal) layout.
|
|
212
|
+
|
|
213
|
+
### TimelineContent / TimelineHeading / TimelineDescription
|
|
214
|
+
|
|
215
|
+
Forward `HTMLAttributes<HTMLDivElement>`. `TimelineContent` removes its bottom padding on the last item; `TimelineHeading` uses `typography-body-medium-medium`; `TimelineDescription` uses `typography-body-small-regular` with secondary text color.
|
|
216
|
+
|
|
217
|
+
## Styling
|
|
218
|
+
|
|
219
|
+
- Indicators use the standard state token set: `state-information-primary`, `state-success-primary`, `state-negative-primary`, `state-warning-primary`.
|
|
220
|
+
- Separator: `1px` neutral line by default, focus-blue when `active`.
|
|
221
|
+
- Vertical content: `pb-6 pt-[2px]` — gives breathing room between items.
|
|
222
|
+
- Horizontal content: aligned under the indicator with `gap-3`.
|
|
223
|
+
|
|
224
|
+
## TypeScript Types
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
import type { VariantProps } from 'class-variance-authority'
|
|
228
|
+
import type { timelineStyles, indicatorStyles, separatorStyles } from '@/components/Timeline'
|
|
229
|
+
|
|
230
|
+
type TimelineVariants = VariantProps<typeof timelineStyles>
|
|
231
|
+
type IndicatorVariants = VariantProps<typeof indicatorStyles>
|
|
232
|
+
// { variant?: 'default' | 'active' | 'completed' | 'error' | 'warning'; size?: 'S' | 'M' | 'L' }
|
|
233
|
+
type SeparatorVariants = VariantProps<typeof separatorStyles>
|
|
234
|
+
// { orientation?: 'vertical' | 'horizontal'; active?: boolean }
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Accessibility
|
|
238
|
+
|
|
239
|
+
- Use `<ol>` semantics when the order matters (audit logs, order tracking) — wrap `Timeline` in `<ol>` and each `TimelineItem` in `<li>`.
|
|
240
|
+
- Variants like `error` and `warning` should be paired with text in `TimelineDescription` — color is never the sole signal.
|
|
241
|
+
- Decorative icons inside indicators don't need labels; the heading carries the meaning.
|
|
242
|
+
|
|
243
|
+
## Best Practices
|
|
244
|
+
|
|
245
|
+
1. Reach for Timeline when items are events at points in time. Reach for Stepper when items are tasks the user has to complete.
|
|
246
|
+
2. Always omit `TimelineSeparator` on the last item so the line doesn't dangle.
|
|
247
|
+
3. Use `active` on the separator after a `completed` indicator to color the connecting segment blue — it visually links progress.
|
|
248
|
+
4. Cap visible items at 5–7 in vertical mode; collapse the rest behind a "show earlier" affordance for long histories.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "torch-glare",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
"publishConfig": {
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc -b",
|
|
20
|
+
"deploy": "npx tsc --build --force && npm publish --access public"
|
|
21
|
+
},
|
|
18
22
|
"dependencies": {
|
|
19
23
|
"commander": "^13.1.0",
|
|
20
24
|
"inquirer": "^9.2.15"
|
|
@@ -23,9 +27,5 @@
|
|
|
23
27
|
"@types/inquirer": "^9.0.7",
|
|
24
28
|
"@types/node": "^22.14.0",
|
|
25
29
|
"typescript": "^5.0.0"
|
|
26
|
-
},
|
|
27
|
-
"scripts": {
|
|
28
|
-
"build": "tsc -b",
|
|
29
|
-
"deploy": "npx tsc --build --force && npm publish --access public"
|
|
30
30
|
}
|
|
31
|
-
}
|
|
31
|
+
}
|