@titan-design/react-ui 0.9.3 → 0.11.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.
Files changed (120) hide show
  1. package/dist/bodymap.js +78 -24
  2. package/dist/bodymap.js.map +1 -1
  3. package/dist/bodymap.mjs +78 -24
  4. package/dist/bodymap.mjs.map +1 -1
  5. package/dist/index.d.mts +429 -11
  6. package/dist/index.d.ts +429 -11
  7. package/dist/index.js +2386 -885
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +2306 -836
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/{pages-DyEx-lBf.d.ts → pages-B1hqnGIC.d.ts} +149 -15
  12. package/dist/{pages-D7hOD4Vj.d.mts → pages-CvsFqNtx.d.mts} +149 -15
  13. package/dist/pages.d.mts +1 -1
  14. package/dist/pages.d.ts +1 -1
  15. package/dist/pages.js +1900 -1609
  16. package/dist/pages.js.map +1 -1
  17. package/dist/pages.mjs +1901 -1610
  18. package/dist/pages.mjs.map +1 -1
  19. package/dist/theme/index.d.mts +129 -34
  20. package/dist/theme/index.d.ts +129 -34
  21. package/dist/theme/index.js +95 -19
  22. package/dist/theme/index.js.map +1 -1
  23. package/dist/theme/index.mjs +92 -20
  24. package/dist/theme/index.mjs.map +1 -1
  25. package/dist/theme/tokens-css.js +88 -24
  26. package/dist/theme/tokens-css.js.map +1 -1
  27. package/dist/theme/tokens-css.mjs +88 -24
  28. package/dist/theme/tokens-css.mjs.map +1 -1
  29. package/package.json +8 -3
  30. package/src/components/custom/Fatigue/DualGhostSpark.stories.tsx +258 -0
  31. package/src/components/custom/Fatigue/DualGhostSpark.test.tsx +138 -0
  32. package/src/components/custom/Fatigue/DualGhostSpark.tsx +208 -0
  33. package/src/components/custom/Fatigue/FatigueLights.stories.tsx +74 -0
  34. package/src/components/custom/Fatigue/FatigueLights.test.tsx +33 -0
  35. package/src/components/custom/Fatigue/FatigueLights.tsx +83 -0
  36. package/src/components/custom/Fatigue/GhostBand.test.tsx +235 -0
  37. package/src/components/custom/Fatigue/GhostBand.tsx +246 -0
  38. package/src/components/custom/Fatigue/GhostBloom.tsx +132 -0
  39. package/src/components/custom/Fatigue/GhostSpark.stories.tsx +175 -0
  40. package/src/components/custom/Fatigue/GhostSpark.test.tsx +45 -0
  41. package/src/components/custom/Fatigue/GhostSpark.tsx +126 -0
  42. package/src/components/custom/Fatigue/LiveFatigueCard.stories.tsx +126 -0
  43. package/src/components/custom/Fatigue/LiveFatigueCard.test.tsx +28 -0
  44. package/src/components/custom/Fatigue/LiveFatigueCard.tsx +86 -0
  45. package/src/components/custom/Fatigue/LiveFatiguePanel.stories.tsx +95 -0
  46. package/src/components/custom/Fatigue/LiveFatiguePanel.tsx +151 -0
  47. package/src/components/custom/Fatigue/README.md +93 -0
  48. package/src/components/custom/Fatigue/RomProgressionChart.stories.tsx +94 -0
  49. package/src/components/custom/Fatigue/RomProgressionChart.test.tsx +31 -0
  50. package/src/components/custom/Fatigue/RomProgressionChart.tsx +132 -0
  51. package/src/components/custom/Fatigue/SilverRedPalette.stories.tsx +226 -0
  52. package/src/components/custom/Fatigue/VelocityHero.stories.tsx +70 -0
  53. package/src/components/custom/Fatigue/VelocityHero.test.tsx +26 -0
  54. package/src/components/custom/Fatigue/VelocityHero.tsx +46 -0
  55. package/src/components/custom/Fatigue/VerdictHero.stories.tsx +59 -0
  56. package/src/components/custom/Fatigue/VerdictHero.test.tsx +49 -0
  57. package/src/components/custom/Fatigue/VerdictHero.tsx +79 -0
  58. package/src/components/custom/Fatigue/fatigue-mock.test.ts +59 -0
  59. package/src/components/custom/Fatigue/fatigue-mock.ts +268 -0
  60. package/src/components/custom/Fatigue/fatigue-model.ts +129 -0
  61. package/src/components/custom/Fatigue/fatigue-tokens.test.ts +70 -0
  62. package/src/components/custom/Fatigue/fatigue-tokens.ts +180 -0
  63. package/src/components/custom/Fatigue/index.ts +41 -0
  64. package/src/components/custom/Fatigue/tempo-pacing.test.ts +176 -0
  65. package/src/components/custom/Fatigue/tempo-pacing.ts +112 -0
  66. package/src/components/custom/Workout/BaseBadge.tsx +5 -5
  67. package/src/components/custom/Workout/DualVelocityStrip.test.tsx +685 -0
  68. package/src/components/custom/Workout/ExerciseCard.test.tsx +4 -4
  69. package/src/components/custom/Workout/ExerciseCard.tsx +3 -1
  70. package/src/components/custom/Workout/ExerciseDetailPage.tsx +7 -1
  71. package/src/components/custom/Workout/README.md +62 -16
  72. package/src/components/custom/Workout/RowInventory.stories.tsx +5 -2
  73. package/src/components/custom/Workout/S3FullRail.stories.tsx +13 -1
  74. package/src/components/custom/Workout/SegmentedBar.stories.tsx +3 -3
  75. package/src/components/custom/Workout/SessionHeader.tsx +2 -2
  76. package/src/components/custom/Workout/SessionRail.stories.tsx +4 -1
  77. package/src/components/custom/Workout/SessionRail.test.tsx +43 -0
  78. package/src/components/custom/Workout/SessionRail.tsx +55 -18
  79. package/src/components/custom/Workout/SetRow.test.tsx +6 -6
  80. package/src/components/custom/Workout/SetRow.tsx +9 -2
  81. package/src/components/custom/Workout/SupersetWrapper.stories.tsx +16 -25
  82. package/src/components/custom/Workout/SupersetWrapper.tsx +1 -1
  83. package/src/components/custom/Workout/TempoDisplay.tsx +3 -7
  84. package/src/components/custom/Workout/VelocityStrip.compact.stories.tsx +191 -0
  85. package/src/components/custom/Workout/VelocityStrip.dual.stories.tsx +186 -0
  86. package/src/components/custom/Workout/VelocityStrip.expanded.stories.tsx +296 -0
  87. package/src/components/custom/Workout/VelocityStrip.hero.stories.tsx +259 -0
  88. package/src/components/custom/Workout/VelocityStrip.stories.tsx +217 -250
  89. package/src/components/custom/Workout/VelocityStrip.test.tsx +196 -79
  90. package/src/components/custom/Workout/VelocityStrip.tsx +953 -609
  91. package/src/components/custom/Workout/VolumeLandmarkBar.stories.tsx +4 -1
  92. package/src/components/custom/Workout/WorkoutPill.tsx +2 -2
  93. package/src/components/custom/Workout/index.ts +3 -0
  94. package/src/components/custom/Workout/velocity-story-kit.tsx +438 -0
  95. package/src/components/custom/charts/SetBarChart.test.tsx +275 -0
  96. package/src/components/custom/charts/SetBarChart.tsx +651 -0
  97. package/src/components/custom/charts/live-rep-growth.ts +91 -0
  98. package/src/components/custom/index.ts +1 -0
  99. package/src/components/ui/surface/Surface.stories.tsx +195 -1
  100. package/src/components/ui/surface/Surface.test.tsx +148 -9
  101. package/src/components/ui/surface/Surface.tsx +37 -9
  102. package/src/components/ui/surface/SurfaceContext.ts +48 -8
  103. package/src/components/ui/surface/index.ts +1 -0
  104. package/src/components/ui/surface/surface.contract.test.ts +283 -0
  105. package/src/test/raw-color-patterns.test.ts +71 -0
  106. package/src/theme/ColorPalettes.stories.tsx +871 -0
  107. package/src/theme/ColorPrimitives.stories.tsx +300 -0
  108. package/src/theme/bar-paper.ts +59 -0
  109. package/src/theme/color-stories.coverage.test.ts +130 -0
  110. package/src/theme/color-story-kit.tsx +170 -0
  111. package/src/theme/config.ts +12 -0
  112. package/src/theme/elevation.ts +90 -67
  113. package/src/theme/global.css +35 -9
  114. package/src/theme/tokens/primitives.ts +40 -0
  115. package/src/theme/tokens/semantic.ts +63 -14
  116. package/tailwind.config.js +8 -0
  117. package/src/components/custom/Workout/VelocityStrip.modalities.stories.tsx +0 -254
  118. package/src/components/custom/Workout/VelocityStrip.responsive.stories.tsx +0 -145
  119. package/src/theme/ColorSystem.stories.tsx +0 -323
  120. package/src/theme/Colors.stories.tsx +0 -323
@@ -1,323 +0,0 @@
1
- import type { ReactNode } from 'react'
2
- import type { Meta, StoryObj } from '@storybook/react-vite'
3
- import { View, Text } from 'react-native'
4
- import {
5
- primitiveColors,
6
- primitiveRamps,
7
- categoricalPalette,
8
- getCategoricalColor,
9
- CATEGORICAL_CVD_SAFE_MAX,
10
- divergingScale,
11
- sequentialEffort,
12
- bestTextColor,
13
- } from './tokens/primitives'
14
-
15
- const meta: Meta = {
16
- title: 'Foundations/Color/System',
17
- tags: ['autodocs'],
18
- }
19
- export default meta
20
-
21
- // ---- color math (self-contained; drives the accessibility panel) ----
22
- const hexToRgb = (hex: string): [number, number, number] => {
23
- const h = hex.replace('#', '')
24
- return [0, 2, 4].map((i) => parseInt(h.slice(i, i + 2), 16) / 255) as [number, number, number]
25
- }
26
- const toHex = (v: number) => Math.round(Math.min(1, Math.max(0, v)) * 255).toString(16).padStart(2, '0')
27
- const lin = (c: number) => (c >= 0.04045 ? ((c + 0.055) / 1.055) ** 2.4 : c / 12.92)
28
- const gamma = (c: number) => (c >= 0.0031308 ? 1.055 * Math.max(0, c) ** (1 / 2.4) - 0.055 : 12.92 * c)
29
- const relLum = (hex: string) => {
30
- const [r, g, b] = hexToRgb(hex).map(lin)
31
- return 0.2126 * r + 0.7152 * g + 0.0722 * b
32
- }
33
- const contrast = (a: string, b: string) => {
34
- const [l1, l2] = [relLum(a), relLum(b)].sort((x, y) => y - x)
35
- return (l1 + 0.05) / (l2 + 0.05)
36
- }
37
- const bestText = (hex: string) => (contrast(hex, '#000000') >= contrast(hex, '#FFFFFF') ? '#000000' : '#FFFFFF')
38
- // Machado-2009 dichromacy simulation (severity 1.0)
39
- const CVD = {
40
- deuteranopia: [0.367322, 0.860646, -0.227968, 0.280085, 0.672501, 0.047413, -0.01182, 0.04294, 0.968881],
41
- protanopia: [0.152286, 1.052583, -0.204868, 0.114503, 0.786281, 0.099216, -0.003882, -0.048116, 1.051998],
42
- } as const
43
- const simulate = (M: readonly number[], hex: string) => {
44
- const [r, g, b] = hexToRgb(hex).map(lin)
45
- const out = [
46
- M[0] * r + M[1] * g + M[2] * b,
47
- M[3] * r + M[4] * g + M[5] * b,
48
- M[6] * r + M[7] * g + M[8] * b,
49
- ].map(gamma)
50
- return '#' + out.map(toHex).join('')
51
- }
52
-
53
- const STEPS = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950] as const
54
-
55
- function SectionTitle({ children }: { children: string }) {
56
- return <Text className="text-lg font-bold text-text-primary mb-3 mt-2">{children}</Text>
57
- }
58
-
59
- function Ramp({ name, ramp }: { name: string; ramp: Record<number, string> }) {
60
- return (
61
- <View style={{ flexDirection: 'row', alignItems: 'center', gap: 12, marginBottom: 6 }}>
62
- <Text className="text-text-secondary text-xs" style={{ width: 150 }}>
63
- {name}
64
- </Text>
65
- <View style={{ flexDirection: 'row', flex: 1, borderRadius: 6, overflow: 'hidden', borderWidth: 1, borderColor: '#2C2C2C' }}>
66
- {STEPS.map((s) => (
67
- <View key={s} style={{ flex: 1, height: 30, backgroundColor: ramp[s] }} />
68
- ))}
69
- </View>
70
- </View>
71
- )
72
- }
73
-
74
- function Chip({ hex, label, sub }: { hex: string; label?: string; sub?: string }) {
75
- return (
76
- <View style={{ alignItems: 'center' }}>
77
- <View
78
- style={{
79
- width: 58,
80
- height: 44,
81
- borderRadius: 8,
82
- backgroundColor: hex,
83
- borderWidth: 1,
84
- borderColor: '#2C2C2C',
85
- alignItems: 'center',
86
- justifyContent: 'center',
87
- }}
88
- >
89
- {label ? <Text style={{ color: bestText(hex), fontSize: 11, fontWeight: '700' }}>{label}</Text> : null}
90
- </View>
91
- {sub ? <Text className="text-text-secondary" style={{ fontSize: 8, marginTop: 2 }}>{sub}</Text> : null}
92
- </View>
93
- )
94
- }
95
-
96
- const RAMP_NAMES: Array<[keyof typeof primitiveRamps, string]> = [
97
- ['red', 'Red'],
98
- ['orange', 'Orange'],
99
- ['amber', 'Amber'],
100
- ['green', 'Green'],
101
- ['cyan', 'Cyan'],
102
- ['blue', 'Blue'],
103
- ['magenta', 'Magenta'],
104
- ]
105
-
106
- const SEM = {
107
- success: primitiveRamps.green[300],
108
- warning: primitiveRamps.amber[300],
109
- error: primitiveRamps.red[600],
110
- info: primitiveRamps.blue[500],
111
- deload: primitiveRamps.magenta[600],
112
- brand: primitiveRamps.orange[400],
113
- brandDark: primitiveRamps.orange[600],
114
- brandSecondary: primitiveRamps.cyan[600],
115
- spinner: primitiveRamps.cyan[600],
116
- neutral: primitiveColors.neutral[500],
117
- } as const
118
-
119
- // BodyMap training-status diverging scale (from the divergingScale token).
120
- const D3_STATUS = divergingScale
121
-
122
- export const Overview: StoryObj = {
123
- render: () => (
124
- <View style={{ padding: 24, gap: 6 }}>
125
- <Text className="text-2xl font-bold text-text-primary mb-1">Color System</Text>
126
- <Text className="text-text-secondary mb-4">
127
- Seven OKLCH tonal ramps and an ordered, colorblind-safe categorical palette. Ramps are the single
128
- source of truth; the categorical references ramp steps.
129
- </Text>
130
-
131
- <SectionTitle>Tonal ramps</SectionTitle>
132
- {RAMP_NAMES.map(([key, name]) => (
133
- <Ramp key={key} name={name} ramp={primitiveRamps[key]} />
134
- ))}
135
-
136
- <SectionTitle>Semantic tokens</SectionTitle>
137
- <View style={{ flexDirection: 'row', flexWrap: 'wrap', gap: 18 }}>
138
- {Object.entries(SEM).map(([label, hex]) => (
139
- <View key={label} style={{ alignItems: 'center' }}>
140
- <Chip hex={hex} />
141
- <Text className="text-text-secondary" style={{ fontSize: 9, marginTop: 3 }}>
142
- {label}
143
- </Text>
144
- </View>
145
- ))}
146
- </View>
147
-
148
- <SectionTitle>Categorical — ordered, nested, CVD-safe to 6</SectionTitle>
149
- {(['default', 'dark'] as const).map((variant) => (
150
- <View key={variant} style={{ marginBottom: 10 }}>
151
- <Text className="text-text-secondary text-xs mb-1" style={{ textTransform: 'capitalize' }}>
152
- {variant}
153
- </Text>
154
- <View style={{ flexDirection: 'row', gap: 6 }}>
155
- {categoricalPalette[variant].map((hex, i) => (
156
- <Chip key={i} hex={hex} label={`${i + 1}`} sub={i < CATEGORICAL_CVD_SAFE_MAX ? undefined : 'ext'} />
157
- ))}
158
- </View>
159
- </View>
160
- ))}
161
-
162
- <SectionTitle>Data-viz scales</SectionTitle>
163
- <Text className="text-text-secondary text-xs mb-2">
164
- Diverging (BodyMap training-status) — light-centered so it reads in lightness and stays
165
- colorblind-stable; direction is the blue↔red axis. Labels use per-cell best-contrast text.
166
- </Text>
167
- <View style={{ flexDirection: 'row', gap: 6, marginBottom: 12 }}>
168
- {['under', 'maint', 'optimal', 'approach', 'over'].map((l, i) => (
169
- <View key={l} style={{ flex: 1, height: 40, borderRadius: 6, backgroundColor: divergingScale[i], alignItems: 'center', justifyContent: 'center' }}>
170
- <Text style={{ color: bestTextColor(divergingScale[i]), fontSize: 10, fontWeight: '700' }}>{l}</Text>
171
- </View>
172
- ))}
173
- </View>
174
- <Text className="text-text-secondary text-xs mb-2">
175
- Sequential effort (low → high) — an ordinal green→yellow→orange→red scale that IntensityBar uses
176
- in full and VelocityStrip/RPE sub-samples.
177
- </Text>
178
- <View style={{ flexDirection: 'row', gap: 4, marginBottom: 4 }}>
179
- {sequentialEffort.map((hex, i) => (
180
- <View key={i} style={{ flex: 1, height: 34, borderRadius: 5, backgroundColor: hex, alignItems: 'center', justifyContent: 'center' }}>
181
- <Text style={{ color: bestTextColor(hex), fontSize: 10, fontWeight: '700' }}>{i + 1}</Text>
182
- </View>
183
- ))}
184
- </View>
185
-
186
- <SectionTitle>Component examples — correct color roles</SectionTitle>
187
- <View style={{ flexDirection: 'row', gap: 20, flexWrap: 'wrap', alignItems: 'flex-start' }}>
188
- {/* BodyMap muscle heatmap — training-status diverging (D3) */}
189
- <Demo label="BodyMap · training status">
190
- <View style={{ flexDirection: 'row', flexWrap: 'wrap', width: 132, gap: 4 }}>
191
- {[
192
- ['Chest', 4], ['Quads', 2], ['Back', 3],
193
- ['Delts', 0], ['Biceps', 4], ['Calves', 1],
194
- ].map(([m, idx]) => (
195
- <View key={m as string} style={{ width: 40, backgroundColor: D3_STATUS[idx as number], borderRadius: 5, paddingVertical: 6 }}>
196
- <Text style={{ color: bestTextColor(D3_STATUS[idx as number]), fontSize: 8, fontWeight: '700', textAlign: 'center' }}>{m as string}</Text>
197
- </View>
198
- ))}
199
- </View>
200
- </Demo>
201
- {/* StatusDot — semantic */}
202
- <Demo label="StatusDot · semantic">
203
- <View style={{ gap: 6 }}>
204
- {[['ok', SEM.success], ['warn', SEM.warning], ['err', SEM.error], ['neutral', SEM.neutral]].map(([l, c]) => (
205
- <View key={l as string} style={{ flexDirection: 'row', alignItems: 'center', gap: 6 }}>
206
- <View style={{ width: 12, height: 12, borderRadius: 6, backgroundColor: c as string }} />
207
- <Text className="text-text-secondary" style={{ fontSize: 11 }}>{l as string}</Text>
208
- </View>
209
- ))}
210
- </View>
211
- </Demo>
212
- {/* WorkoutPill — status */}
213
- <Demo label="WorkoutPill">
214
- <View style={{ flexDirection: 'row', gap: 6, flexWrap: 'wrap', maxWidth: 220 }}>
215
- {[['Done', SEM.success], ['Now', SEM.brand], ['Next', SEM.neutral], ['Deload', SEM.deload]].map(([t, c]) => (
216
- <View key={t as string} style={{ borderRadius: 99, borderWidth: 1, borderColor: c as string, paddingHorizontal: 10, paddingVertical: 3 }}>
217
- <Text style={{ color: c as string, fontSize: 11, fontWeight: '700' }}>{t as string}</Text>
218
- </View>
219
- ))}
220
- </View>
221
- </Demo>
222
- {/* StrengthTrend legend — series → semantic */}
223
- <Demo label="StrengthTrend · series">
224
- <View style={{ flexDirection: 'row', gap: 12, flexWrap: 'wrap' }}>
225
- {[['1RM', SEM.brand], ['vel', SEM.success], ['miss', SEM.error], ['RPE', SEM.warning]].map(([l, c]) => (
226
- <View key={l as string} style={{ flexDirection: 'row', alignItems: 'center', gap: 4 }}>
227
- <View style={{ width: 14, height: 3, backgroundColor: c as string, borderRadius: 2 }} />
228
- <Text className="text-text-secondary" style={{ fontSize: 10 }}>{l as string}</Text>
229
- </View>
230
- ))}
231
- </View>
232
- </Demo>
233
- {/* Treemap — ordered categorical */}
234
- <Demo label="Treemap · categorical">
235
- <View style={{ flexDirection: 'row', flexWrap: 'wrap', width: 140, gap: 2 }}>
236
- {[46, 30, 30, 24, 24, 24, 20].map((h, i) => (
237
- <View key={i} style={{ height: h, flexGrow: 1, flexBasis: h > 40 ? 60 : 40, backgroundColor: getCategoricalColor(i), borderRadius: 3 }} />
238
- ))}
239
- </View>
240
- </Demo>
241
- {/* Spinner */}
242
- <Demo label="Spinner">
243
- <View style={{ width: 24, height: 24, borderRadius: 12, borderWidth: 3, borderColor: '#2C2C2C', borderTopColor: SEM.spinner }} />
244
- </Demo>
245
- {/* IntensityBar — full effort scale */}
246
- <Demo label="IntensityBar · effort">
247
- <View style={{ flexDirection: 'row', gap: 2, width: 132 }}>
248
- {sequentialEffort.map((hex, i) => (
249
- <View key={i} style={{ flex: 1, height: 20, backgroundColor: hex, borderRadius: 2 }} />
250
- ))}
251
- </View>
252
- </Demo>
253
- {/* VelocityStrip / RPE — effort sub-sample */}
254
- <Demo label="VelocityStrip · RPE">
255
- <View style={{ flexDirection: 'row', gap: 3 }}>
256
- {[sequentialEffort[0], sequentialEffort[2], sequentialEffort[3], sequentialEffort[5]].map((hex, i) => (
257
- <View key={i} style={{ width: 30, height: 26, borderRadius: 4, backgroundColor: hex, alignItems: 'center', justifyContent: 'center' }}>
258
- <Text style={{ color: bestTextColor(hex), fontSize: 9, fontWeight: '700' }}>{['S', 'M', 'F', 'X'][i]}</Text>
259
- </View>
260
- ))}
261
- </View>
262
- </Demo>
263
- </View>
264
- </View>
265
- ),
266
- }
267
-
268
- function Demo({ label, children }: { label: string; children: ReactNode }) {
269
- return (
270
- <View style={{ padding: 10, backgroundColor: '#1A1A1A', borderRadius: 8 }}>
271
- <Text className="text-text-secondary" style={{ fontSize: 9, marginBottom: 6 }}>{label}</Text>
272
- {children}
273
- </View>
274
- )
275
- }
276
-
277
- export const Accessibility: StoryObj = {
278
- render: () => (
279
- <View style={{ padding: 24 }}>
280
- <Text className="text-2xl font-bold text-text-primary mb-1">Categorical Accessibility</Text>
281
- <Text className="text-text-secondary mb-5">
282
- In-place text contrast and colorblind simulation for the categorical series. Converging strips across
283
- two swatches signal a collision for that viewer; all pairs hold ΔE ≥ 8 through the first {CATEGORICAL_CVD_SAFE_MAX}.
284
- </Text>
285
-
286
- {(['default', 'dark'] as const).map((variant) => {
287
- const colors = categoricalPalette[variant]
288
- const textColor = variant === 'dark' ? '#FFFFFF' : '#000000'
289
- return (
290
- <View key={variant} style={{ marginBottom: 22 }}>
291
- <Text className="text-lg font-bold text-text-primary mb-2" style={{ textTransform: 'capitalize' }}>
292
- {variant}
293
- </Text>
294
- {/* swatches with in-place text + contrast ratio */}
295
- <View style={{ flexDirection: 'row', gap: 6, marginBottom: 6 }}>
296
- {colors.map((hex, i) => (
297
- <View key={i} style={{ alignItems: 'center' }}>
298
- <View style={{ width: 56, height: 40, borderRadius: 6, backgroundColor: hex, alignItems: 'center', justifyContent: 'center' }}>
299
- <Text style={{ color: textColor, fontSize: 11, fontWeight: '700' }}>Aa</Text>
300
- </View>
301
- <Text className="text-text-secondary" style={{ fontSize: 8, marginTop: 2 }}>
302
- {contrast(hex, textColor).toFixed(1)}:1
303
- </Text>
304
- </View>
305
- ))}
306
- </View>
307
- {/* CVD simulation strips */}
308
- {(['deuteranopia', 'protanopia'] as const).map((mode) => (
309
- <View key={mode} style={{ flexDirection: 'row', alignItems: 'center', marginTop: 3 }}>
310
- <Text className="text-text-secondary" style={{ fontSize: 9, width: 96 }}>{mode}</Text>
311
- <View style={{ flexDirection: 'row', gap: 6 }}>
312
- {colors.map((hex, i) => (
313
- <View key={i} style={{ width: 56, height: 14, borderRadius: 3, backgroundColor: simulate(CVD[mode], hex) }} />
314
- ))}
315
- </View>
316
- </View>
317
- ))}
318
- </View>
319
- )
320
- })}
321
- </View>
322
- ),
323
- }
@@ -1,323 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react-vite'
2
- import { View, Text } from 'react-native'
3
- import { primitiveColors, discreteRainbow, primitiveRamps, categoricalPalette } from './tokens/primitives'
4
- import { semanticColorsLight, semanticColorsDark } from './tokens/semantic'
5
-
6
- const meta: Meta = {
7
- title: 'Foundations/Color/Palette',
8
- tags: ['autodocs'],
9
- }
10
-
11
- export default meta
12
-
13
- interface ColorSwatchProps {
14
- name: string
15
- value: string
16
- textColor?: string
17
- }
18
-
19
- function ColorSwatch({ name, value, textColor = '#FFFFFF' }: ColorSwatchProps) {
20
- const displayValue = value.startsWith('rgba') ? value : value.toUpperCase()
21
-
22
- return (
23
- <View style={{ flexDirection: 'row', alignItems: 'center', gap: 12 }}>
24
- <View
25
- style={{
26
- width: 48,
27
- height: 48,
28
- borderRadius: 8,
29
- backgroundColor: value,
30
- borderWidth: 1,
31
- borderColor: '#374151',
32
- }}
33
- />
34
- <View>
35
- <Text className="font-semibold text-text-primary text-sm">
36
- {name}
37
- </Text>
38
- <Text className="text-text-secondary text-xs">
39
- {displayValue}
40
- </Text>
41
- </View>
42
- </View>
43
- )
44
- }
45
-
46
- function ColorScale({ name, colors }: { name: string; colors: Record<string | number, string> }) {
47
- return (
48
- <View style={{ marginBottom: 32 }}>
49
- <Text className="text-lg font-bold text-text-primary mb-3">
50
- {name}
51
- </Text>
52
- <View style={{ flexDirection: 'row', flexWrap: 'wrap', gap: 8 }}>
53
- {Object.entries(colors).map(([shade, color]) => (
54
- <View key={shade} style={{ alignItems: 'center' }}>
55
- <View
56
- style={{
57
- width: 64,
58
- height: 64,
59
- borderRadius: 8,
60
- backgroundColor: color,
61
- borderWidth: 1,
62
- borderColor: '#374151',
63
- }}
64
- />
65
- <Text className="text-text-secondary text-xs mt-1">
66
- {shade}
67
- </Text>
68
- </View>
69
- ))}
70
- </View>
71
- </View>
72
- )
73
- }
74
-
75
- export const PrimitiveColors: StoryObj = {
76
- render: () => (
77
- <View style={{ padding: 24 }}>
78
- <Text className="text-2xl font-bold text-text-primary mb-6">
79
- Primitive Colors
80
- </Text>
81
- <Text className="text-text-secondary mb-6">
82
- Raw color values. Chromatic hues live as OKLCH tonal ramps (see the Tonal Ramps story);
83
- these are the achromatic and support scales. Use semantic tokens when building components.
84
- </Text>
85
-
86
- <ColorScale name="Blue" colors={primitiveColors.blue} />
87
- <ColorScale name="Red" colors={primitiveColors.red} />
88
- <ColorScale name="Red Vivid" colors={primitiveColors.redVivid} />
89
- <ColorScale name="Neutral" colors={primitiveColors.neutral} />
90
- <ColorScale name="Charcoal (Dark Backgrounds)" colors={primitiveColors.charcoal} />
91
- </View>
92
- ),
93
- }
94
-
95
- export const BrandColors: StoryObj = {
96
- render: () => (
97
- <View style={{ padding: 24 }}>
98
- <Text className="text-2xl font-bold text-text-primary mb-6">
99
- Brand Colors
100
- </Text>
101
-
102
- <View style={{ gap: 16 }}>
103
- <ColorSwatch name="brand-primary" value={semanticColorsLight['brand-primary']} />
104
- <ColorSwatch name="brand-primary-light" value={semanticColorsLight['brand-primary-light']} />
105
- <ColorSwatch name="brand-primary-dark" value={semanticColorsLight['brand-primary-dark']} />
106
- <ColorSwatch name="brand-secondary" value={semanticColorsLight['brand-secondary']} />
107
- <ColorSwatch name="brand-secondary-light" value={semanticColorsLight['brand-secondary-light']} />
108
- <ColorSwatch name="brand-secondary-dark" value={semanticColorsLight['brand-secondary-dark']} />
109
- </View>
110
- </View>
111
- ),
112
- }
113
-
114
- export const StatusColors: StoryObj = {
115
- render: () => (
116
- <View style={{ padding: 24 }}>
117
- <Text className="text-2xl font-bold text-text-primary mb-6">
118
- Status Colors
119
- </Text>
120
-
121
- <View style={{ gap: 16 }}>
122
- <ColorSwatch name="status-success" value={semanticColorsLight['status-success']} />
123
- <ColorSwatch name="status-error" value={semanticColorsLight['status-error']} />
124
- <ColorSwatch name="status-warning" value={semanticColorsLight['status-warning']} />
125
- <ColorSwatch name="status-info" value={semanticColorsLight['status-info']} />
126
- </View>
127
- </View>
128
- ),
129
- }
130
-
131
- export const TextColors: StoryObj = {
132
- render: () => (
133
- <View style={{ padding: 24 }}>
134
- <Text className="text-2xl font-bold text-text-primary mb-6">
135
- Text Colors (Dark Mode)
136
- </Text>
137
-
138
- <View style={{ gap: 16 }}>
139
- <ColorSwatch name="text-primary" value={semanticColorsDark['text-primary']} />
140
- <ColorSwatch name="text-secondary" value={semanticColorsDark['text-secondary']} />
141
- <ColorSwatch name="text-tertiary" value={semanticColorsDark['text-tertiary']} />
142
- <ColorSwatch name="text-disabled" value={semanticColorsDark['text-disabled']} />
143
- <ColorSwatch name="text-link" value={semanticColorsDark['text-link']} />
144
- </View>
145
- </View>
146
- ),
147
- }
148
-
149
- export const SurfaceColors: StoryObj = {
150
- render: () => (
151
- <View style={{ padding: 24 }}>
152
- <Text className="text-2xl font-bold text-text-primary mb-6">
153
- Surface Colors (Dark Mode)
154
- </Text>
155
-
156
- <View style={{ gap: 16 }}>
157
- <ColorSwatch name="surface-base" value={semanticColorsDark['surface-base']} />
158
- <ColorSwatch name="surface-elevated" value={semanticColorsDark['surface-elevated']} />
159
- <ColorSwatch name="surface-raised" value={semanticColorsDark['surface-raised']} />
160
- <ColorSwatch name="surface-input" value={semanticColorsDark['surface-input']} />
161
- <ColorSwatch name="background-base" value={semanticColorsDark['background-base']} />
162
- <ColorSwatch name="background-default" value={semanticColorsDark['background-default']} />
163
- </View>
164
- </View>
165
- ),
166
- }
167
-
168
- export const ResultColors: StoryObj = {
169
- render: () => (
170
- <View style={{ padding: 24 }}>
171
- <Text className="text-2xl font-bold text-text-primary mb-6">
172
- Result/Outcome Colors
173
- </Text>
174
- <Text className="text-text-secondary mb-6">
175
- Colors for indicating positive, negative, or neutral outcomes.
176
- </Text>
177
-
178
- <View style={{ gap: 16 }}>
179
- <ColorSwatch name="result-improve" value={semanticColorsLight['result-improve']} />
180
- <ColorSwatch name="result-improve-light" value={semanticColorsLight['result-improve-light']} />
181
- <ColorSwatch name="result-degrade" value={semanticColorsLight['result-degrade']} />
182
- <ColorSwatch name="result-degrade-light" value={semanticColorsLight['result-degrade-light']} />
183
- <ColorSwatch name="result-inconclusive" value={semanticColorsLight['result-inconclusive']} />
184
- <ColorSwatch name="result-inconclusive-light" value={semanticColorsLight['result-inconclusive-light']} />
185
- <ColorSwatch name="result-neutral" value={semanticColorsLight['result-neutral']} />
186
- </View>
187
- </View>
188
- ),
189
- }
190
-
191
- export const DataVisualizationColors: StoryObj = {
192
- render: () => (
193
- <View style={{ padding: 24 }}>
194
- <Text className="text-2xl font-bold text-text-primary mb-6">
195
- Data Visualization Colors
196
- </Text>
197
- <Text className="text-text-secondary mb-6">
198
- Colors optimized for charts and data visualization. Based on Paul Tol&apos;s color schemes.
199
- </Text>
200
-
201
- <View style={{ gap: 16 }}>
202
- <ColorSwatch name="data-1" value={semanticColorsLight['data-1']} />
203
- <ColorSwatch name="data-2" value={semanticColorsLight['data-2']} />
204
- <ColorSwatch name="data-3" value={semanticColorsLight['data-3']} textColor="#000000" />
205
- <ColorSwatch name="data-4" value={semanticColorsLight['data-4']} />
206
- <ColorSwatch name="data-5" value={semanticColorsLight['data-5']} />
207
- <ColorSwatch name="data-6" value={semanticColorsLight['data-6']} />
208
- <ColorSwatch name="data-7" value={semanticColorsLight['data-7']} textColor="#000000" />
209
- <ColorSwatch name="data-8" value={semanticColorsLight['data-8']} textColor="#000000" />
210
- <ColorSwatch name="data-9" value={semanticColorsLight['data-9']} textColor="#000000" />
211
- <ColorSwatch name="data-10" value={semanticColorsLight['data-10']} />
212
- </View>
213
-
214
- <Text className="text-lg font-bold text-text-primary mt-8 mb-3">
215
- Full Discrete Rainbow Palette
216
- </Text>
217
- <View style={{ flexDirection: 'row', flexWrap: 'wrap', gap: 4 }}>
218
- {discreteRainbow.map((color, index) => (
219
- <View
220
- key={index}
221
- style={{
222
- width: 32,
223
- height: 32,
224
- borderRadius: 4,
225
- backgroundColor: color,
226
- borderWidth: 1,
227
- borderColor: '#374151',
228
- }}
229
- />
230
- ))}
231
- </View>
232
- </View>
233
- ),
234
- }
235
-
236
- function CategoricalRow({ name, colors }: { name: string; colors: readonly string[] }) {
237
- return (
238
- <View style={{ marginBottom: 24 }}>
239
- <Text className="text-lg font-bold text-text-primary mb-3">
240
- {name} <Text className="text-text-secondary text-sm">({colors.length})</Text>
241
- </Text>
242
- <View style={{ flexDirection: 'row', flexWrap: 'wrap', gap: 8 }}>
243
- {colors.map((color, index) => (
244
- <View key={index} style={{ alignItems: 'center' }}>
245
- <View
246
- style={{
247
- width: 56,
248
- height: 56,
249
- borderRadius: 8,
250
- backgroundColor: color,
251
- borderWidth: 1,
252
- borderColor: '#374151',
253
- }}
254
- />
255
- <Text className="text-text-secondary text-xs mt-1">{color.toUpperCase()}</Text>
256
- </View>
257
- ))}
258
- </View>
259
- </View>
260
- )
261
- }
262
-
263
- export const TonalRamps: StoryObj = {
264
- render: () => (
265
- <View style={{ padding: 24 }}>
266
- <Text className="text-2xl font-bold text-text-primary mb-6">
267
- Tonal Ramps (Foundations)
268
- </Text>
269
- <Text className="text-text-secondary mb-6">
270
- Seven OKLCH-generated hue ramps, 11 perceptual steps each (50 → 950). Built with hue-torsion and a
271
- chroma arc; amber absorbs the former yellow (lemon → warm body) and cyan absorbs the former steel.
272
- </Text>
273
-
274
- <ColorScale name="Red" colors={primitiveRamps.red} />
275
- <ColorScale name="Orange" colors={primitiveRamps.orange} />
276
- <ColorScale name="Amber" colors={primitiveRamps.amber} />
277
- <ColorScale name="Green" colors={primitiveRamps.green} />
278
- <ColorScale name="Cyan" colors={primitiveRamps.cyan} />
279
- <ColorScale name="Blue" colors={primitiveRamps.blue} />
280
- <ColorScale name="Magenta" colors={primitiveRamps.magenta} />
281
- </View>
282
- ),
283
- }
284
-
285
- export const CategoricalPalette: StoryObj = {
286
- render: () => (
287
- <View style={{ padding: 24 }}>
288
- <Text className="text-2xl font-bold text-text-primary mb-6">
289
- Categorical Palette
290
- </Text>
291
- <Text className="text-text-secondary mb-6">
292
- Ordered, colorblind-safe qualitative series (worst-case deut/protanopia floor 8 through the first
293
- six colors; the 7th is extended — pair it with a legend). Series index is stable. Use{' '}
294
- <Text className="font-semibold">default</Text> on neutral/light surfaces (also legible under black
295
- text) and <Text className="font-semibold">dark</Text> where white text sits on the swatch.
296
- </Text>
297
-
298
- <CategoricalRow name="Default" colors={categoricalPalette.default} />
299
- <CategoricalRow name="Dark (white text)" colors={categoricalPalette.dark} />
300
- </View>
301
- ),
302
- }
303
-
304
- export const BorderColors: StoryObj = {
305
- render: () => (
306
- <View style={{ padding: 24 }}>
307
- <Text className="text-2xl font-bold text-text-primary mb-6">
308
- Border Colors (Dark Mode)
309
- </Text>
310
-
311
- <View style={{ gap: 16 }}>
312
- <ColorSwatch name="border-default" value={semanticColorsDark['border-default']} />
313
- <ColorSwatch name="border-subtle" value={semanticColorsDark['border-subtle']} />
314
- <ColorSwatch name="border-strong" value={semanticColorsDark['border-strong']} />
315
- <ColorSwatch name="border-focus" value={semanticColorsDark['border-focus']} />
316
- <ColorSwatch name="border-input" value={semanticColorsDark['border-input']} />
317
- <ColorSwatch name="border-input-hover" value={semanticColorsDark['border-input-hover']} />
318
- <ColorSwatch name="border-input-focus" value={semanticColorsDark['border-input-focus']} />
319
- <ColorSwatch name="border-input-error" value={semanticColorsDark['border-input-error']} />
320
- </View>
321
- </View>
322
- ),
323
- }