@leitware/composables 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/LICENSE +21 -0
- package/README.md +387 -0
- package/dist/presets/brutalist.css +298 -0
- package/dist/presets/default.css +298 -0
- package/dist/presets/signal-pop.css +369 -0
- package/dist/styles.css +2 -0
- package/package.json +216 -0
- package/rules/composables.md +244 -0
- package/src/_internal/accordion.tsx +93 -0
- package/src/_internal/ai-elements/attachments.tsx +385 -0
- package/src/_internal/ai-elements/chain-of-thought.tsx +197 -0
- package/src/_internal/ai-elements/code-block.tsx +516 -0
- package/src/_internal/ai-elements/confirmation.tsx +150 -0
- package/src/_internal/ai-elements/conversation.tsx +148 -0
- package/src/_internal/ai-elements/inline-citation.tsx +248 -0
- package/src/_internal/ai-elements/message.tsx +292 -0
- package/src/_internal/ai-elements/plan.tsx +126 -0
- package/src/_internal/ai-elements/prompt-input.tsx +1285 -0
- package/src/_internal/ai-elements/reasoning.tsx +208 -0
- package/src/_internal/ai-elements/shimmer.tsx +72 -0
- package/src/_internal/ai-elements/sources.tsx +53 -0
- package/src/_internal/ai-elements/suggestion.tsx +48 -0
- package/src/_internal/ai-elements/task.tsx +64 -0
- package/src/_internal/ai-elements/tool.tsx +156 -0
- package/src/_internal/alert-dialog.tsx +159 -0
- package/src/_internal/alert.tsx +88 -0
- package/src/_internal/aspect-ratio.tsx +23 -0
- package/src/_internal/avatar.tsx +58 -0
- package/src/_internal/badge.tsx +60 -0
- package/src/_internal/breadcrumb.tsx +104 -0
- package/src/_internal/bubble.tsx +125 -0
- package/src/_internal/button-group.tsx +78 -0
- package/src/_internal/button.tsx +62 -0
- package/src/_internal/calendar.tsx +179 -0
- package/src/_internal/card.tsx +83 -0
- package/src/_internal/carousel.tsx +215 -0
- package/src/_internal/checkbox.tsx +26 -0
- package/src/_internal/code-block.tsx +53 -0
- package/src/_internal/collapsible.tsx +15 -0
- package/src/_internal/combobox.tsx +264 -0
- package/src/_internal/command.tsx +155 -0
- package/src/_internal/container.tsx +35 -0
- package/src/_internal/dialog.tsx +132 -0
- package/src/_internal/direction.tsx +12 -0
- package/src/_internal/divider.tsx +162 -0
- package/src/_internal/dropdown-menu.tsx +247 -0
- package/src/_internal/dropzone.tsx +481 -0
- package/src/_internal/empty.tsx +94 -0
- package/src/_internal/field.tsx +221 -0
- package/src/_internal/grid-overlay.tsx +48 -0
- package/src/_internal/grid.tsx +109 -0
- package/src/_internal/hover-card.tsx +47 -0
- package/src/_internal/icon.tsx +45 -0
- package/src/_internal/input-group.tsx +146 -0
- package/src/_internal/input.tsx +24 -0
- package/src/_internal/item.tsx +187 -0
- package/src/_internal/kbd.tsx +28 -0
- package/src/_internal/label.tsx +18 -0
- package/src/_internal/layout-bento.tsx +386 -0
- package/src/_internal/layout.tsx +174 -0
- package/src/_internal/marker.tsx +66 -0
- package/src/_internal/message.tsx +85 -0
- package/src/_internal/native-select.tsx +50 -0
- package/src/_internal/pagination.tsx +108 -0
- package/src/_internal/popover.tsx +83 -0
- package/src/_internal/progress.tsx +59 -0
- package/src/_internal/radio-group.tsx +36 -0
- package/src/_internal/resizable.tsx +44 -0
- package/src/_internal/scroll-area.tsx +48 -0
- package/src/_internal/select.tsx +187 -0
- package/src/_internal/separator.tsx +19 -0
- package/src/_internal/sheet.tsx +122 -0
- package/src/_internal/sidebar.tsx +687 -0
- package/src/_internal/skeleton.tsx +13 -0
- package/src/_internal/slider.tsx +60 -0
- package/src/_internal/sonner.tsx +51 -0
- package/src/_internal/spacer.tsx +42 -0
- package/src/_internal/spinner.tsx +16 -0
- package/src/_internal/stack.tsx +78 -0
- package/src/_internal/switch.tsx +31 -0
- package/src/_internal/table.tsx +84 -0
- package/src/_internal/tabs.tsx +74 -0
- package/src/_internal/textarea.tsx +19 -0
- package/src/_internal/toggle-group.tsx +99 -0
- package/src/_internal/toggle.tsx +42 -0
- package/src/_internal/tooltip.tsx +55 -0
- package/src/_internal/typography.tsx +129 -0
- package/src/hooks/use-mobile.ts +19 -0
- package/src/hooks/use-numeric-input.ts +119 -0
- package/src/index.ts +443 -0
- package/src/lib/numeric-input.ts +88 -0
- package/src/lib/utils.ts +39 -0
- package/src/opinionated/accordion.tsx +92 -0
- package/src/opinionated/ai/attachments.tsx +27 -0
- package/src/opinionated/ai/chain-of-thought.tsx +16 -0
- package/src/opinionated/ai/code-block.tsx +22 -0
- package/src/opinionated/ai/confirmation.tsx +16 -0
- package/src/opinionated/ai/conversation.tsx +13 -0
- package/src/opinionated/ai/index.ts +15 -0
- package/src/opinionated/ai/inline-citation.tsx +30 -0
- package/src/opinionated/ai/message.tsx +26 -0
- package/src/opinionated/ai/plan.tsx +18 -0
- package/src/opinionated/ai/prompt-input.tsx +29 -0
- package/src/opinionated/ai/reasoning.tsx +9 -0
- package/src/opinionated/ai/shimmer.tsx +4 -0
- package/src/opinionated/ai/sources.tsx +10 -0
- package/src/opinionated/ai/suggestion.tsx +6 -0
- package/src/opinionated/ai/task.tsx +12 -0
- package/src/opinionated/ai/tool.tsx +14 -0
- package/src/opinionated/alert-dialog.tsx +143 -0
- package/src/opinionated/alert.tsx +99 -0
- package/src/opinionated/aspect-ratio.tsx +12 -0
- package/src/opinionated/avatar.tsx +59 -0
- package/src/opinionated/badge.tsx +33 -0
- package/src/opinionated/breadcrumb.tsx +99 -0
- package/src/opinionated/bubble.tsx +9 -0
- package/src/opinionated/button.tsx +59 -0
- package/src/opinionated/calendar.tsx +20 -0
- package/src/opinionated/card.tsx +83 -0
- package/src/opinionated/carousel.tsx +99 -0
- package/src/opinionated/checkbox.tsx +11 -0
- package/src/opinionated/code-block.tsx +12 -0
- package/src/opinionated/collapsible.tsx +123 -0
- package/src/opinionated/combobox.tsx +123 -0
- package/src/opinionated/container.tsx +12 -0
- package/src/opinionated/dialog.tsx +124 -0
- package/src/opinionated/direction.tsx +6 -0
- package/src/opinionated/divider.tsx +13 -0
- package/src/opinionated/dropdown-menu.tsx +131 -0
- package/src/opinionated/dropzone.tsx +39 -0
- package/src/opinionated/empty.tsx +191 -0
- package/src/opinionated/field.tsx +26 -0
- package/src/opinionated/form-calendar-popover.tsx +138 -0
- package/src/opinionated/form-checkbox.tsx +107 -0
- package/src/opinionated/form-combobox.tsx +181 -0
- package/src/opinionated/form-date-of-birth.tsx +193 -0
- package/src/opinionated/form-dropzone.tsx +126 -0
- package/src/opinionated/form-input-group.tsx +184 -0
- package/src/opinionated/form-input.tsx +118 -0
- package/src/opinionated/form-multi-combobox.tsx +213 -0
- package/src/opinionated/form-multi-dropzone.tsx +141 -0
- package/src/opinionated/form-radiogroup.tsx +116 -0
- package/src/opinionated/form-select.tsx +176 -0
- package/src/opinionated/form-slider.tsx +100 -0
- package/src/opinionated/form-switch.tsx +117 -0
- package/src/opinionated/form-textarea.tsx +79 -0
- package/src/opinionated/grid-overlay.tsx +11 -0
- package/src/opinionated/grid.tsx +14 -0
- package/src/opinionated/hover-card.tsx +59 -0
- package/src/opinionated/icon.tsx +14 -0
- package/src/opinionated/input-group.tsx +20 -0
- package/src/opinionated/input.tsx +11 -0
- package/src/opinionated/item.tsx +182 -0
- package/src/opinionated/kbd.tsx +16 -0
- package/src/opinionated/label.tsx +11 -0
- package/src/opinionated/layout-bento.tsx +29 -0
- package/src/opinionated/layout.tsx +26 -0
- package/src/opinionated/list.tsx +94 -0
- package/src/opinionated/marker.tsx +7 -0
- package/src/opinionated/message.tsx +8 -0
- package/src/opinionated/native-select.tsx +51 -0
- package/src/opinionated/pagination.tsx +204 -0
- package/src/opinionated/popover.tsx +68 -0
- package/src/opinionated/progress.tsx +48 -0
- package/src/opinionated/radio-group.tsx +13 -0
- package/src/opinionated/resizable.tsx +2 -0
- package/src/opinionated/scroll-area.tsx +82 -0
- package/src/opinionated/select.tsx +101 -0
- package/src/opinionated/separator.tsx +11 -0
- package/src/opinionated/sheet.tsx +120 -0
- package/src/opinionated/sidebar.tsx +68 -0
- package/src/opinionated/skeleton.tsx +246 -0
- package/src/opinionated/slider.tsx +11 -0
- package/src/opinionated/sonner.tsx +15 -0
- package/src/opinionated/spacer.tsx +11 -0
- package/src/opinionated/stack.tsx +18 -0
- package/src/opinionated/switch.tsx +11 -0
- package/src/opinionated/table.tsx +11 -0
- package/src/opinionated/tabs.tsx +68 -0
- package/src/opinionated/textarea.tsx +11 -0
- package/src/opinionated/theme-injector.tsx +31 -0
- package/src/opinionated/toggle-group.tsx +63 -0
- package/src/opinionated/toggle.tsx +75 -0
- package/src/opinionated/token-config-panel/color-editor.tsx +85 -0
- package/src/opinionated/token-config-panel/helpers.ts +31 -0
- package/src/opinionated/token-config-panel/index.tsx +398 -0
- package/src/opinionated/token-config-panel/json-import-export.tsx +89 -0
- package/src/opinionated/token-config-panel/preset-manager.ts +31 -0
- package/src/opinionated/token-config-panel/presets-data.ts +23 -0
- package/src/opinionated/token-config-panel/spacing-editor.tsx +325 -0
- package/src/opinionated/token-config-panel/types.ts +39 -0
- package/src/opinionated/token-config-panel/typography-editor.tsx +145 -0
- package/src/opinionated/tooltip.tsx +62 -0
- package/src/opinionated/typography.tsx +7 -0
- package/src/scripts/lint-no-arbitrary.ts +155 -0
- package/src/styles/composable.css +68 -0
- package/src/styles/presets/brutalist.css +298 -0
- package/src/styles/presets/default.css +298 -0
- package/src/styles/presets/signal-pop.css +369 -0
- package/src/styles/presets-data/brutalist.ts +325 -0
- package/src/styles/presets-data/default.ts +315 -0
- package/src/styles/presets-data/index.ts +45 -0
- package/src/styles/presets-data/signal-pop.ts +393 -0
- package/src/styles/tokens/base.css +71 -0
- package/src/styles/tokens/components.css +150 -0
- package/src/styles/tokens/palette.css +795 -0
- package/src/styles/tokens/registry.ts +324 -0
- package/src/styles/tokens/semantic.css +266 -0
- package/src/styles/tokens/tailwind-theme.css +247 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Preset } from './types'
|
|
2
|
+
|
|
3
|
+
export { presets } from './presets-data'
|
|
4
|
+
|
|
5
|
+
/* ------------------------------------------------------------------ */
|
|
6
|
+
/* Preset helpers */
|
|
7
|
+
/* ------------------------------------------------------------------ */
|
|
8
|
+
|
|
9
|
+
const PRESET_STYLE_ID = 'composables-preset-overrides'
|
|
10
|
+
|
|
11
|
+
function buildPresetStyleSheet(preset: Preset): string {
|
|
12
|
+
const lightLines = Object.entries(preset.overrides)
|
|
13
|
+
.map(([k, v]) => ` ${k}: ${v};`)
|
|
14
|
+
.join('\n')
|
|
15
|
+
const darkLines = Object.entries(preset.darkOverrides)
|
|
16
|
+
.map(([k, v]) => ` ${k}: ${v};`)
|
|
17
|
+
.join('\n')
|
|
18
|
+
return `:root {\n${lightLines}\n}\n.dark {\n${darkLines}\n}`
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function injectPresetStyle(preset: Preset) {
|
|
22
|
+
removePresetStyle()
|
|
23
|
+
const style = document.createElement('style')
|
|
24
|
+
style.id = PRESET_STYLE_ID
|
|
25
|
+
style.textContent = buildPresetStyleSheet(preset)
|
|
26
|
+
document.head.appendChild(style)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function removePresetStyle() {
|
|
30
|
+
document.getElementById(PRESET_STYLE_ID)?.remove()
|
|
31
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Preset } from './types'
|
|
2
|
+
|
|
3
|
+
import { presetDefinitions } from '../../styles/presets-data'
|
|
4
|
+
|
|
5
|
+
/* ------------------------------------------------------------------ */
|
|
6
|
+
/* Exported presets map */
|
|
7
|
+
/* ------------------------------------------------------------------ */
|
|
8
|
+
|
|
9
|
+
export const presets: Record<string, Preset | null> = {
|
|
10
|
+
...Object.fromEntries(
|
|
11
|
+
presetDefinitions.map((preset) => [
|
|
12
|
+
preset.name,
|
|
13
|
+
preset.name === 'default'
|
|
14
|
+
? null
|
|
15
|
+
: {
|
|
16
|
+
label: preset.label,
|
|
17
|
+
description: preset.description,
|
|
18
|
+
overrides: preset.light,
|
|
19
|
+
darkOverrides: preset.dark,
|
|
20
|
+
},
|
|
21
|
+
]),
|
|
22
|
+
),
|
|
23
|
+
}
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { Input } from '../../_internal/input'
|
|
4
|
+
import { HStack } from '../../_internal/stack'
|
|
5
|
+
import { Typography } from '../../_internal/typography'
|
|
6
|
+
import { FormInput } from '../form-input'
|
|
7
|
+
import { FormSlider } from '../form-slider'
|
|
8
|
+
|
|
9
|
+
import type { DimensionToken, StringToken } from './types'
|
|
10
|
+
import { getResolvedDimension, parseNumericValue } from './helpers'
|
|
11
|
+
|
|
12
|
+
/* ------------------------------------------------------------------ */
|
|
13
|
+
/* Dimension token definitions */
|
|
14
|
+
/* ------------------------------------------------------------------ */
|
|
15
|
+
|
|
16
|
+
export const spacingTokens: DimensionToken[] = [
|
|
17
|
+
{
|
|
18
|
+
cssVar: '--spacing',
|
|
19
|
+
label: 'Base unit',
|
|
20
|
+
defaultValue: 0.25,
|
|
21
|
+
min: 0.0625,
|
|
22
|
+
max: 0.75,
|
|
23
|
+
step: 0.0625,
|
|
24
|
+
unit: 'rem',
|
|
25
|
+
},
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
export const borderWidthTokens: DimensionToken[] = [
|
|
29
|
+
{
|
|
30
|
+
cssVar: '--border-width-base',
|
|
31
|
+
label: 'Base border width',
|
|
32
|
+
defaultValue: 0.0625,
|
|
33
|
+
min: 0,
|
|
34
|
+
max: 0.25,
|
|
35
|
+
step: 0.0625,
|
|
36
|
+
unit: 'rem',
|
|
37
|
+
},
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
export const radiusTokens: DimensionToken[] = [
|
|
41
|
+
{
|
|
42
|
+
cssVar: '--radius',
|
|
43
|
+
label: 'Base radius',
|
|
44
|
+
defaultValue: 0.5,
|
|
45
|
+
min: 0,
|
|
46
|
+
max: 1.5,
|
|
47
|
+
step: 0.0625,
|
|
48
|
+
unit: 'rem',
|
|
49
|
+
},
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
export const typographySizeTokens: DimensionToken[] = [
|
|
53
|
+
{
|
|
54
|
+
cssVar: '--font-size-base',
|
|
55
|
+
label: 'Base font size',
|
|
56
|
+
defaultValue: 1,
|
|
57
|
+
min: 0.625,
|
|
58
|
+
max: 1.5,
|
|
59
|
+
step: 0.025,
|
|
60
|
+
unit: 'rem',
|
|
61
|
+
},
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
export const lineHeightTokens: DimensionToken[] = [
|
|
65
|
+
{
|
|
66
|
+
cssVar: '--leading-base',
|
|
67
|
+
label: 'Base line height',
|
|
68
|
+
defaultValue: 1.33,
|
|
69
|
+
min: 1,
|
|
70
|
+
max: 2,
|
|
71
|
+
step: 0.01,
|
|
72
|
+
unit: '',
|
|
73
|
+
},
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
export const letterSpacingTokens: DimensionToken[] = [
|
|
77
|
+
{
|
|
78
|
+
cssVar: '--letter-spacing-base',
|
|
79
|
+
label: 'Base letter spacing',
|
|
80
|
+
defaultValue: 0.025,
|
|
81
|
+
min: 0,
|
|
82
|
+
max: 0.1,
|
|
83
|
+
step: 0.005,
|
|
84
|
+
unit: 'em',
|
|
85
|
+
},
|
|
86
|
+
]
|
|
87
|
+
|
|
88
|
+
export const opacityTokens: DimensionToken[] = [
|
|
89
|
+
{
|
|
90
|
+
cssVar: '--opacity-disabled',
|
|
91
|
+
label: 'Disabled opacity',
|
|
92
|
+
defaultValue: 0.5,
|
|
93
|
+
min: 0,
|
|
94
|
+
max: 1,
|
|
95
|
+
step: 0.05,
|
|
96
|
+
unit: '',
|
|
97
|
+
},
|
|
98
|
+
]
|
|
99
|
+
|
|
100
|
+
export const shadowDimensionTokens: DimensionToken[] = [
|
|
101
|
+
{
|
|
102
|
+
cssVar: '--shadow-offset-y',
|
|
103
|
+
label: 'Offset Y',
|
|
104
|
+
defaultValue: 1,
|
|
105
|
+
min: 0,
|
|
106
|
+
max: 8,
|
|
107
|
+
step: 0.5,
|
|
108
|
+
unit: 'px',
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
cssVar: '--shadow-blur',
|
|
112
|
+
label: 'Blur',
|
|
113
|
+
defaultValue: 2,
|
|
114
|
+
min: 0,
|
|
115
|
+
max: 10,
|
|
116
|
+
step: 0.5,
|
|
117
|
+
unit: 'px',
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
cssVar: '--shadow-spread',
|
|
121
|
+
label: 'Spread',
|
|
122
|
+
defaultValue: 1,
|
|
123
|
+
min: 0,
|
|
124
|
+
max: 6,
|
|
125
|
+
step: 0.5,
|
|
126
|
+
unit: 'px',
|
|
127
|
+
},
|
|
128
|
+
]
|
|
129
|
+
|
|
130
|
+
export const dropdownOffsetTokens: DimensionToken[] = [
|
|
131
|
+
{
|
|
132
|
+
cssVar: '--dropdown-offset',
|
|
133
|
+
label: 'Dropdown offset',
|
|
134
|
+
defaultValue: 4,
|
|
135
|
+
min: 0,
|
|
136
|
+
max: 16,
|
|
137
|
+
step: 1,
|
|
138
|
+
unit: '',
|
|
139
|
+
},
|
|
140
|
+
]
|
|
141
|
+
|
|
142
|
+
export const overlayOffsetTokens: DimensionToken[] = [
|
|
143
|
+
{
|
|
144
|
+
cssVar: '--overlay-offset',
|
|
145
|
+
label: 'Overlay offset',
|
|
146
|
+
defaultValue: 4,
|
|
147
|
+
min: 0,
|
|
148
|
+
max: 16,
|
|
149
|
+
step: 1,
|
|
150
|
+
unit: '',
|
|
151
|
+
},
|
|
152
|
+
]
|
|
153
|
+
|
|
154
|
+
export const containerTokens: DimensionToken[] = [
|
|
155
|
+
{
|
|
156
|
+
cssVar: '--container-sm',
|
|
157
|
+
label: 'sm',
|
|
158
|
+
defaultValue: 624,
|
|
159
|
+
min: 336,
|
|
160
|
+
max: 1104,
|
|
161
|
+
step: 96,
|
|
162
|
+
unit: 'px',
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
cssVar: '--container-md',
|
|
166
|
+
label: 'md',
|
|
167
|
+
defaultValue: 816,
|
|
168
|
+
min: 432,
|
|
169
|
+
max: 1296,
|
|
170
|
+
step: 96,
|
|
171
|
+
unit: 'px',
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
cssVar: '--container-lg',
|
|
175
|
+
label: 'lg',
|
|
176
|
+
defaultValue: 1104,
|
|
177
|
+
min: 624,
|
|
178
|
+
max: 1584,
|
|
179
|
+
step: 96,
|
|
180
|
+
unit: 'px',
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
cssVar: '--container-xl',
|
|
184
|
+
label: 'xl',
|
|
185
|
+
defaultValue: 1392,
|
|
186
|
+
min: 816,
|
|
187
|
+
max: 1968,
|
|
188
|
+
step: 96,
|
|
189
|
+
unit: 'px',
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
cssVar: '--container-2xl',
|
|
193
|
+
label: '2xl',
|
|
194
|
+
defaultValue: 1488,
|
|
195
|
+
min: 1008,
|
|
196
|
+
max: 2064,
|
|
197
|
+
step: 96,
|
|
198
|
+
unit: 'px',
|
|
199
|
+
},
|
|
200
|
+
]
|
|
201
|
+
|
|
202
|
+
export const shadowColorToken: StringToken = {
|
|
203
|
+
cssVar: '--shadow-base-color',
|
|
204
|
+
label: 'Base color',
|
|
205
|
+
defaultValue: 'rgba(0, 0, 0, 0.1)',
|
|
206
|
+
placeholder: 'rgba(…) or color value',
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export const allDimensionTokens = [
|
|
210
|
+
...spacingTokens,
|
|
211
|
+
...borderWidthTokens,
|
|
212
|
+
...radiusTokens,
|
|
213
|
+
...typographySizeTokens,
|
|
214
|
+
...lineHeightTokens,
|
|
215
|
+
...letterSpacingTokens,
|
|
216
|
+
...opacityTokens,
|
|
217
|
+
...shadowDimensionTokens,
|
|
218
|
+
...containerTokens,
|
|
219
|
+
...dropdownOffsetTokens,
|
|
220
|
+
...overlayOffsetTokens,
|
|
221
|
+
]
|
|
222
|
+
|
|
223
|
+
export const allStringTokens = [shadowColorToken]
|
|
224
|
+
|
|
225
|
+
/* ------------------------------------------------------------------ */
|
|
226
|
+
/* DimensionSliderRow */
|
|
227
|
+
/* ------------------------------------------------------------------ */
|
|
228
|
+
|
|
229
|
+
export function DimensionSliderRow({
|
|
230
|
+
token,
|
|
231
|
+
onApply,
|
|
232
|
+
}: {
|
|
233
|
+
token: DimensionToken
|
|
234
|
+
onApply: (cssVar: string, value: string) => void
|
|
235
|
+
}) {
|
|
236
|
+
const [value, setValue] = React.useState(() => {
|
|
237
|
+
const resolved = getResolvedDimension(token.cssVar)
|
|
238
|
+
return resolved ? parseNumericValue(resolved) : token.defaultValue
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
function handleChange(newVal: number | readonly number[]) {
|
|
242
|
+
const num = Array.isArray(newVal) ? newVal[0] : newVal
|
|
243
|
+
setValue(num)
|
|
244
|
+
onApply(token.cssVar, `${num}${token.unit}`)
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function handleInputChange(e: React.ChangeEvent<HTMLInputElement>) {
|
|
248
|
+
const num = Number.parseFloat(e.target.value)
|
|
249
|
+
if (!Number.isNaN(num)) {
|
|
250
|
+
const clamped = Math.min(token.max, Math.max(token.min, num))
|
|
251
|
+
setValue(clamped)
|
|
252
|
+
onApply(token.cssVar, `${clamped}${token.unit}`)
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return (
|
|
257
|
+
<HStack gap={3} align="end" className="py-1">
|
|
258
|
+
<div className="flex-1">
|
|
259
|
+
<FormSlider
|
|
260
|
+
label={token.label}
|
|
261
|
+
orientation="vertical"
|
|
262
|
+
value={[value]}
|
|
263
|
+
onValueChange={handleChange}
|
|
264
|
+
min={token.min}
|
|
265
|
+
max={token.max}
|
|
266
|
+
step={token.step}
|
|
267
|
+
showValue
|
|
268
|
+
valueFormatter={(v) => {
|
|
269
|
+
const n = Array.isArray(v) ? v[0] : v
|
|
270
|
+
return `${n}${token.unit}`
|
|
271
|
+
}}
|
|
272
|
+
/>
|
|
273
|
+
</div>
|
|
274
|
+
<FormInput
|
|
275
|
+
className="w-20 shrink-0"
|
|
276
|
+
type="number"
|
|
277
|
+
value={value}
|
|
278
|
+
onChange={handleInputChange}
|
|
279
|
+
step={token.step}
|
|
280
|
+
min={token.min}
|
|
281
|
+
max={token.max}
|
|
282
|
+
/>
|
|
283
|
+
</HStack>
|
|
284
|
+
)
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/* ------------------------------------------------------------------ */
|
|
288
|
+
/* StringTokenRow */
|
|
289
|
+
/* ------------------------------------------------------------------ */
|
|
290
|
+
|
|
291
|
+
export function StringTokenRow({
|
|
292
|
+
token,
|
|
293
|
+
onApply,
|
|
294
|
+
}: {
|
|
295
|
+
token: StringToken
|
|
296
|
+
onApply: (cssVar: string, value: string) => void
|
|
297
|
+
}) {
|
|
298
|
+
const [value, setValue] = React.useState(() => {
|
|
299
|
+
const resolved = getResolvedDimension(token.cssVar)
|
|
300
|
+
return resolved || token.defaultValue
|
|
301
|
+
})
|
|
302
|
+
|
|
303
|
+
function handleCommit() {
|
|
304
|
+
const trimmed = value.trim()
|
|
305
|
+
if (trimmed) onApply(token.cssVar, trimmed)
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return (
|
|
309
|
+
<div className="py-1">
|
|
310
|
+
<Typography variant="caption-100" className="text-muted-foreground mb-1 block">
|
|
311
|
+
{token.label}
|
|
312
|
+
</Typography>
|
|
313
|
+
<Input
|
|
314
|
+
className="h-7 font-mono text-xs"
|
|
315
|
+
value={value}
|
|
316
|
+
placeholder={token.placeholder}
|
|
317
|
+
onChange={(e) => setValue(e.target.value)}
|
|
318
|
+
onBlur={handleCommit}
|
|
319
|
+
onKeyDown={(e) => {
|
|
320
|
+
if (e.key === 'Enter') handleCommit()
|
|
321
|
+
}}
|
|
322
|
+
/>
|
|
323
|
+
</div>
|
|
324
|
+
)
|
|
325
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* ------------------------------------------------------------------ */
|
|
2
|
+
/* Shared types for token-config-panel */
|
|
3
|
+
/* ------------------------------------------------------------------ */
|
|
4
|
+
|
|
5
|
+
export interface FlatToken {
|
|
6
|
+
cssVar: string
|
|
7
|
+
reference: string
|
|
8
|
+
category: string
|
|
9
|
+
label: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface DimensionToken {
|
|
13
|
+
cssVar: string
|
|
14
|
+
label: string
|
|
15
|
+
defaultValue: number
|
|
16
|
+
min: number
|
|
17
|
+
max: number
|
|
18
|
+
step: number
|
|
19
|
+
unit: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface StringToken {
|
|
23
|
+
cssVar: string
|
|
24
|
+
label: string
|
|
25
|
+
defaultValue: string
|
|
26
|
+
placeholder?: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface Preset {
|
|
30
|
+
label: string
|
|
31
|
+
description: string
|
|
32
|
+
overrides: Record<string, string>
|
|
33
|
+
darkOverrides: Record<string, string>
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface FontGroup {
|
|
37
|
+
label: string
|
|
38
|
+
fonts: string[]
|
|
39
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { Typography } from '../../_internal/typography'
|
|
4
|
+
|
|
5
|
+
import type { FontGroup } from './types'
|
|
6
|
+
import { getResolvedDimension } from './helpers'
|
|
7
|
+
|
|
8
|
+
/* ------------------------------------------------------------------ */
|
|
9
|
+
/* Google Fonts — grouped by style */
|
|
10
|
+
/* ------------------------------------------------------------------ */
|
|
11
|
+
|
|
12
|
+
const FONT_GROUPS: FontGroup[] = [
|
|
13
|
+
{
|
|
14
|
+
label: 'Sans-Serif',
|
|
15
|
+
fonts: [
|
|
16
|
+
'Inter',
|
|
17
|
+
'Roboto',
|
|
18
|
+
'Open Sans',
|
|
19
|
+
'Lato',
|
|
20
|
+
'Montserrat',
|
|
21
|
+
'Poppins',
|
|
22
|
+
'DM Sans',
|
|
23
|
+
'Nunito',
|
|
24
|
+
'Raleway',
|
|
25
|
+
'Source Sans 3',
|
|
26
|
+
'IBM Plex Sans',
|
|
27
|
+
'Work Sans',
|
|
28
|
+
'Outfit',
|
|
29
|
+
'Plus Jakarta Sans',
|
|
30
|
+
'Manrope',
|
|
31
|
+
'Figtree',
|
|
32
|
+
'Albert Sans',
|
|
33
|
+
'Red Hat Display',
|
|
34
|
+
'Lexend',
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
label: 'Serif',
|
|
39
|
+
fonts: [
|
|
40
|
+
'Playfair Display',
|
|
41
|
+
'Merriweather',
|
|
42
|
+
'Lora',
|
|
43
|
+
'Source Serif 4',
|
|
44
|
+
'Cormorant Garamond',
|
|
45
|
+
'Libre Baskerville',
|
|
46
|
+
'Bitter',
|
|
47
|
+
'Crimson Text',
|
|
48
|
+
'EB Garamond',
|
|
49
|
+
'DM Serif Display',
|
|
50
|
+
'Fraunces',
|
|
51
|
+
'Instrument Serif',
|
|
52
|
+
'Newsreader',
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
label: 'Display & Decorative',
|
|
57
|
+
fonts: ['Space Grotesk', 'Sora', 'Epilogue', 'Urbanist', 'Archivo', 'Be Vietnam Pro'],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
label: 'Monospace',
|
|
61
|
+
fonts: [
|
|
62
|
+
'JetBrains Mono',
|
|
63
|
+
'Fira Code',
|
|
64
|
+
'Source Code Pro',
|
|
65
|
+
'IBM Plex Mono',
|
|
66
|
+
'Space Mono',
|
|
67
|
+
'Roboto Mono',
|
|
68
|
+
'Inconsolata',
|
|
69
|
+
'Red Hat Mono',
|
|
70
|
+
'DM Mono',
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
label: 'Handwriting & Script',
|
|
75
|
+
fonts: ['Caveat', 'Dancing Script', 'Pacifico', 'Satisfy', 'Kalam', 'Patrick Hand'],
|
|
76
|
+
},
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
export const ALL_FONT_NAMES = FONT_GROUPS.flatMap((g) => g.fonts)
|
|
80
|
+
|
|
81
|
+
const loadedFonts = new Set<string>()
|
|
82
|
+
|
|
83
|
+
export function loadGoogleFont(name: string) {
|
|
84
|
+
if (name === 'Inter' || loadedFonts.has(name)) return
|
|
85
|
+
loadedFonts.add(name)
|
|
86
|
+
const link = document.createElement('link')
|
|
87
|
+
link.rel = 'stylesheet'
|
|
88
|
+
link.href = `https://fonts.googleapis.com/css2?family=${encodeURIComponent(name)}:wght@300;400;500;600;700&display=swap`
|
|
89
|
+
document.head.appendChild(link)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export const fontCssVars = ['--font-sans', '--font-heading', '--font-brand'] as const
|
|
93
|
+
|
|
94
|
+
/* ------------------------------------------------------------------ */
|
|
95
|
+
/* FontSelectRow */
|
|
96
|
+
/* ------------------------------------------------------------------ */
|
|
97
|
+
|
|
98
|
+
export function FontSelectRow({
|
|
99
|
+
label,
|
|
100
|
+
cssVar,
|
|
101
|
+
onApply,
|
|
102
|
+
}: {
|
|
103
|
+
label: string
|
|
104
|
+
cssVar: string
|
|
105
|
+
onApply: (cssVar: string, value: string) => void
|
|
106
|
+
}) {
|
|
107
|
+
const [value, setValue] = React.useState(() => {
|
|
108
|
+
const resolved = getResolvedDimension(cssVar).trim()
|
|
109
|
+
for (const font of ALL_FONT_NAMES) {
|
|
110
|
+
if (resolved.startsWith(`"${font}"`) || resolved.startsWith(font)) return font
|
|
111
|
+
}
|
|
112
|
+
return 'Inter'
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
function handleChange(e: React.ChangeEvent<HTMLSelectElement>) {
|
|
116
|
+
const font = e.target.value
|
|
117
|
+
setValue(font)
|
|
118
|
+
loadGoogleFont(font)
|
|
119
|
+
const fontValue = font === 'Inter' ? '"Inter Variable", sans-serif' : `"${font}", sans-serif`
|
|
120
|
+
onApply(cssVar, fontValue)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<div className="py-1">
|
|
125
|
+
<Typography variant="caption-100" className="text-muted-foreground mb-1 block">
|
|
126
|
+
{label}
|
|
127
|
+
</Typography>
|
|
128
|
+
<select
|
|
129
|
+
value={value}
|
|
130
|
+
onChange={handleChange}
|
|
131
|
+
className="w-full h-7 rounded-md border border-stroke bg-transparent px-2 text-xs text-foreground outline-none focus:ring-[length:var(--border-width)] focus:ring-focus"
|
|
132
|
+
>
|
|
133
|
+
{FONT_GROUPS.map((group) => (
|
|
134
|
+
<optgroup key={group.label} label={group.label}>
|
|
135
|
+
{group.fonts.map((font) => (
|
|
136
|
+
<option key={font} value={font}>
|
|
137
|
+
{font}
|
|
138
|
+
</option>
|
|
139
|
+
))}
|
|
140
|
+
</optgroup>
|
|
141
|
+
))}
|
|
142
|
+
</select>
|
|
143
|
+
</div>
|
|
144
|
+
)
|
|
145
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Tooltip as TooltipPrimitiveBase } from '@base-ui/react/tooltip'
|
|
2
|
+
import type * as React from 'react'
|
|
3
|
+
|
|
4
|
+
import { TooltipContent, Tooltip as TooltipPrimitive, TooltipTrigger } from '../_internal/tooltip'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Props for the opinionated Tooltip component.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* <Tooltip content="Copy to clipboard">
|
|
12
|
+
* <Button size="icon"><CopyIcon /></Button>
|
|
13
|
+
* </Tooltip>
|
|
14
|
+
*
|
|
15
|
+
* <Tooltip content="Requires admin access" side="right">
|
|
16
|
+
* <span>Restricted action</span>
|
|
17
|
+
* </Tooltip>
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export interface TooltipProps extends Omit<TooltipPrimitiveBase.Root.Props, 'children'> {
|
|
21
|
+
/** Content shown in the tooltip popup. */
|
|
22
|
+
content: React.ReactNode
|
|
23
|
+
className?: string
|
|
24
|
+
/** Which side of the trigger the tooltip appears on. @default 'top' */
|
|
25
|
+
side?: 'top' | 'bottom' | 'left' | 'right'
|
|
26
|
+
sideOffset?: number
|
|
27
|
+
align?: 'start' | 'center' | 'end'
|
|
28
|
+
alignOffset?: number
|
|
29
|
+
/** The element that triggers the tooltip on hover/focus. */
|
|
30
|
+
children: React.ReactNode
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function Tooltip({
|
|
34
|
+
content,
|
|
35
|
+
className,
|
|
36
|
+
side = 'top',
|
|
37
|
+
sideOffset = 4,
|
|
38
|
+
align = 'center',
|
|
39
|
+
alignOffset = 0,
|
|
40
|
+
children,
|
|
41
|
+
...tooltipProps
|
|
42
|
+
}: TooltipProps) {
|
|
43
|
+
return (
|
|
44
|
+
<TooltipPrimitive {...tooltipProps}>
|
|
45
|
+
<TooltipTrigger>{children}</TooltipTrigger>
|
|
46
|
+
<TooltipContent
|
|
47
|
+
className={className}
|
|
48
|
+
side={side}
|
|
49
|
+
sideOffset={sideOffset}
|
|
50
|
+
align={align}
|
|
51
|
+
alignOffset={alignOffset}
|
|
52
|
+
>
|
|
53
|
+
{content}
|
|
54
|
+
</TooltipContent>
|
|
55
|
+
</TooltipPrimitive>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Re-export all tooltip sub-components for convenience
|
|
60
|
+
export { TooltipContent, TooltipTrigger }
|
|
61
|
+
|
|
62
|
+
export { Tooltip }
|