@cdx-ui/components 0.3.4 → 0.3.6
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 +1 -1
- package/coverage.svg +1 -1
- package/docs/components/bar-chart/content.md +703 -0
- package/docs/components/content.md +9 -1
- package/docs/components/line-chart/content.md +567 -0
- package/docs/components/pie-chart/content.md +493 -0
- package/docs/components/progress-segmented/content.md +1 -1
- package/docs/components/select/content.md +144 -2
- package/docs/components/stepper/content.md +599 -0
- package/docs/components/system-alert/content.md +533 -0
- package/docs/foundations/expressions/icons/content.md +1 -1
- package/docs/foundations/styles/tokens/all-tokens/content.md +2 -1
- package/docs/llms.txt +10 -0
- package/docs/patterns/content.md +1 -0
- package/docs/patterns/dashboard/content.md +423 -19
- package/docs/patterns/insights/content.md +590 -0
- package/docs/resources/release-notes/0.3.4/content.md +27 -0
- package/docs/resources/release-notes/0.3.5/content.md +7 -0
- package/docs/resources/release-notes/content.md +2 -0
- package/lib/commonjs/components/BarChart/geometry.js +1130 -0
- package/lib/commonjs/components/BarChart/geometry.js.map +1 -0
- package/lib/commonjs/components/BarChart/index.js +942 -0
- package/lib/commonjs/components/BarChart/index.js.map +1 -0
- package/lib/commonjs/components/BarChart/styles.js +26 -0
- package/lib/commonjs/components/BarChart/styles.js.map +1 -0
- package/lib/commonjs/components/Button/index.js +2 -2
- package/lib/commonjs/components/Button/index.js.map +1 -1
- package/lib/commonjs/components/Chip/styles.js +3 -1
- package/lib/commonjs/components/Chip/styles.js.map +1 -1
- package/lib/commonjs/components/LineChart/geometry.js +698 -0
- package/lib/commonjs/components/LineChart/geometry.js.map +1 -0
- package/lib/commonjs/components/LineChart/index.js +747 -0
- package/lib/commonjs/components/LineChart/index.js.map +1 -0
- package/lib/commonjs/components/LineChart/styles.js +25 -0
- package/lib/commonjs/components/LineChart/styles.js.map +1 -0
- package/lib/commonjs/components/PieChart/geometry.js +216 -0
- package/lib/commonjs/components/PieChart/geometry.js.map +1 -0
- package/lib/commonjs/components/PieChart/index.js +476 -0
- package/lib/commonjs/components/PieChart/index.js.map +1 -0
- package/lib/commonjs/components/PieChart/styles.js +88 -0
- package/lib/commonjs/components/PieChart/styles.js.map +1 -0
- package/lib/commonjs/components/ProgressCircle/ProgressCircleRing.js +9 -31
- package/lib/commonjs/components/ProgressCircle/ProgressCircleRing.js.map +1 -1
- package/lib/commonjs/components/ProgressCircle/ProgressRing.js +52 -0
- package/lib/commonjs/components/ProgressCircle/ProgressRing.js.map +1 -0
- package/lib/commonjs/components/ScrollShadow/useScrollShadow.js +8 -7
- package/lib/commonjs/components/ScrollShadow/useScrollShadow.js.map +1 -1
- package/lib/commonjs/components/Stepper/index.js +369 -0
- package/lib/commonjs/components/Stepper/index.js.map +1 -0
- package/lib/commonjs/components/Stepper/styles.js +211 -0
- package/lib/commonjs/components/Stepper/styles.js.map +1 -0
- package/lib/commonjs/components/Stepper/useStepperLabelFit.js +22 -0
- package/lib/commonjs/components/Stepper/useStepperLabelFit.js.map +1 -0
- package/lib/commonjs/components/Stepper/useStepperLabelFit.web.js +52 -0
- package/lib/commonjs/components/Stepper/useStepperLabelFit.web.js.map +1 -0
- package/lib/commonjs/components/Stepper/useStepperRingColors.js +31 -0
- package/lib/commonjs/components/Stepper/useStepperRingColors.js.map +1 -0
- package/lib/commonjs/components/SystemAlert/animation.js +218 -0
- package/lib/commonjs/components/SystemAlert/animation.js.map +1 -0
- package/lib/commonjs/components/SystemAlert/index.js +525 -0
- package/lib/commonjs/components/SystemAlert/index.js.map +1 -0
- package/lib/commonjs/components/SystemAlert/styles.js +178 -0
- package/lib/commonjs/components/SystemAlert/styles.js.map +1 -0
- package/lib/commonjs/components/SystemAlert/useSystemAlertStatusBarStyle.js +53 -0
- package/lib/commonjs/components/SystemAlert/useSystemAlertStatusBarStyle.js.map +1 -0
- package/lib/commonjs/components/Tabs/index.js +4 -0
- package/lib/commonjs/components/Tabs/index.js.map +1 -1
- package/lib/commonjs/components/Tabs/styles.js +1 -1
- package/lib/commonjs/components/Tabs/styles.js.map +1 -1
- package/lib/commonjs/components/chart/ChartInspector.js +610 -0
- package/lib/commonjs/components/chart/ChartInspector.js.map +1 -0
- package/lib/commonjs/components/chart/format.js +93 -0
- package/lib/commonjs/components/chart/format.js.map +1 -0
- package/lib/commonjs/components/chart/index.js +2 -0
- package/lib/commonjs/components/chart/index.js.map +1 -0
- package/lib/commonjs/components/chart/motion.js +97 -0
- package/lib/commonjs/components/chart/motion.js.map +1 -0
- package/lib/commonjs/components/chart/palette.js +178 -0
- package/lib/commonjs/components/chart/palette.js.map +1 -0
- package/lib/commonjs/components/chart/size.js +34 -0
- package/lib/commonjs/components/chart/size.js.map +1 -0
- package/lib/commonjs/components/chart/ticks.js +59 -0
- package/lib/commonjs/components/chart/ticks.js.map +1 -0
- package/lib/commonjs/components/chart/types.js +6 -0
- package/lib/commonjs/components/chart/types.js.map +1 -0
- package/lib/commonjs/components/chart/useChartHostWidth.js +27 -0
- package/lib/commonjs/components/chart/useChartHostWidth.js.map +1 -0
- package/lib/commonjs/components/index.js +60 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/figma/SystemAlert.Button.figma.js +28 -0
- package/lib/commonjs/figma/SystemAlert.Button.figma.js.map +1 -0
- package/lib/commonjs/figma/SystemAlert.Close.figma.js +22 -0
- package/lib/commonjs/figma/SystemAlert.Close.figma.js.map +1 -0
- package/lib/commonjs/figma/SystemAlert.Description.figma.js +20 -0
- package/lib/commonjs/figma/SystemAlert.Description.figma.js.map +1 -0
- package/lib/commonjs/figma/SystemAlert.IconButton.figma.js +31 -0
- package/lib/commonjs/figma/SystemAlert.IconButton.figma.js.map +1 -0
- package/lib/commonjs/figma/SystemAlert.figma.js +48 -0
- package/lib/commonjs/figma/SystemAlert.figma.js.map +1 -0
- package/lib/module/components/BarChart/geometry.js +1110 -0
- package/lib/module/components/BarChart/geometry.js.map +1 -0
- package/lib/module/components/BarChart/index.js +936 -0
- package/lib/module/components/BarChart/index.js.map +1 -0
- package/lib/module/components/BarChart/styles.js +22 -0
- package/lib/module/components/BarChart/styles.js.map +1 -0
- package/lib/module/components/Button/index.js +2 -2
- package/lib/module/components/Button/index.js.map +1 -1
- package/lib/module/components/Chip/styles.js +3 -1
- package/lib/module/components/Chip/styles.js.map +1 -1
- package/lib/module/components/LineChart/geometry.js +685 -0
- package/lib/module/components/LineChart/geometry.js.map +1 -0
- package/lib/module/components/LineChart/index.js +741 -0
- package/lib/module/components/LineChart/index.js.map +1 -0
- package/lib/module/components/LineChart/styles.js +21 -0
- package/lib/module/components/LineChart/styles.js.map +1 -0
- package/lib/module/components/PieChart/geometry.js +209 -0
- package/lib/module/components/PieChart/geometry.js.map +1 -0
- package/lib/module/components/PieChart/index.js +471 -0
- package/lib/module/components/PieChart/index.js.map +1 -0
- package/lib/module/components/PieChart/styles.js +84 -0
- package/lib/module/components/PieChart/styles.js.map +1 -0
- package/lib/module/components/ProgressCircle/ProgressCircleRing.js +10 -32
- package/lib/module/components/ProgressCircle/ProgressCircleRing.js.map +1 -1
- package/lib/module/components/ProgressCircle/ProgressRing.js +48 -0
- package/lib/module/components/ProgressCircle/ProgressRing.js.map +1 -0
- package/lib/module/components/ScrollShadow/useScrollShadow.js +8 -7
- package/lib/module/components/ScrollShadow/useScrollShadow.js.map +1 -1
- package/lib/module/components/Stepper/index.js +360 -0
- package/lib/module/components/Stepper/index.js.map +1 -0
- package/lib/module/components/Stepper/styles.js +206 -0
- package/lib/module/components/Stepper/styles.js.map +1 -0
- package/lib/module/components/Stepper/useStepperLabelFit.js +18 -0
- package/lib/module/components/Stepper/useStepperLabelFit.js.map +1 -0
- package/lib/module/components/Stepper/useStepperLabelFit.web.js +48 -0
- package/lib/module/components/Stepper/useStepperLabelFit.web.js.map +1 -0
- package/lib/module/components/Stepper/useStepperRingColors.js +28 -0
- package/lib/module/components/Stepper/useStepperRingColors.js.map +1 -0
- package/lib/module/components/SystemAlert/animation.js +213 -0
- package/lib/module/components/SystemAlert/animation.js.map +1 -0
- package/lib/module/components/SystemAlert/index.js +515 -0
- package/lib/module/components/SystemAlert/index.js.map +1 -0
- package/lib/module/components/SystemAlert/styles.js +174 -0
- package/lib/module/components/SystemAlert/styles.js.map +1 -0
- package/lib/module/components/SystemAlert/useSystemAlertStatusBarStyle.js +49 -0
- package/lib/module/components/SystemAlert/useSystemAlertStatusBarStyle.js.map +1 -0
- package/lib/module/components/Tabs/index.js +4 -0
- package/lib/module/components/Tabs/index.js.map +1 -1
- package/lib/module/components/Tabs/styles.js +1 -1
- package/lib/module/components/Tabs/styles.js.map +1 -1
- package/lib/module/components/chart/ChartInspector.js +600 -0
- package/lib/module/components/chart/ChartInspector.js.map +1 -0
- package/lib/module/components/chart/format.js +84 -0
- package/lib/module/components/chart/format.js.map +1 -0
- package/lib/module/components/chart/index.js +2 -0
- package/lib/module/components/chart/index.js.map +1 -0
- package/lib/module/components/chart/motion.js +89 -0
- package/lib/module/components/chart/motion.js.map +1 -0
- package/lib/module/components/chart/palette.js +168 -0
- package/lib/module/components/chart/palette.js.map +1 -0
- package/lib/module/components/chart/size.js +29 -0
- package/lib/module/components/chart/size.js.map +1 -0
- package/lib/module/components/chart/ticks.js +55 -0
- package/lib/module/components/chart/ticks.js.map +1 -0
- package/lib/module/components/chart/types.js +4 -0
- package/lib/module/components/chart/types.js.map +1 -0
- package/lib/module/components/chart/useChartHostWidth.js +23 -0
- package/lib/module/components/chart/useChartHostWidth.js.map +1 -0
- package/lib/module/components/index.js +5 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/figma/SystemAlert.Button.figma.js +22 -0
- package/lib/module/figma/SystemAlert.Button.figma.js.map +1 -0
- package/lib/module/figma/SystemAlert.Close.figma.js +18 -0
- package/lib/module/figma/SystemAlert.Close.figma.js.map +1 -0
- package/lib/module/figma/SystemAlert.Description.figma.js +14 -0
- package/lib/module/figma/SystemAlert.Description.figma.js.map +1 -0
- package/lib/module/figma/SystemAlert.IconButton.figma.js +25 -0
- package/lib/module/figma/SystemAlert.IconButton.figma.js.map +1 -0
- package/lib/module/figma/SystemAlert.figma.js +42 -0
- package/lib/module/figma/SystemAlert.figma.js.map +1 -0
- package/lib/typescript/components/BarChart/geometry.d.ts +236 -0
- package/lib/typescript/components/BarChart/geometry.d.ts.map +1 -0
- package/lib/typescript/components/BarChart/index.d.ts +193 -0
- package/lib/typescript/components/BarChart/index.d.ts.map +1 -0
- package/lib/typescript/components/BarChart/styles.d.ts +32 -0
- package/lib/typescript/components/BarChart/styles.d.ts.map +1 -0
- package/lib/typescript/components/Chip/styles.d.ts.map +1 -1
- package/lib/typescript/components/LineChart/geometry.d.ts +248 -0
- package/lib/typescript/components/LineChart/geometry.d.ts.map +1 -0
- package/lib/typescript/components/LineChart/index.d.ts +105 -0
- package/lib/typescript/components/LineChart/index.d.ts.map +1 -0
- package/lib/typescript/components/LineChart/styles.d.ts +12 -0
- package/lib/typescript/components/LineChart/styles.d.ts.map +1 -0
- package/lib/typescript/components/PieChart/geometry.d.ts +43 -0
- package/lib/typescript/components/PieChart/geometry.d.ts.map +1 -0
- package/lib/typescript/components/PieChart/index.d.ts +147 -0
- package/lib/typescript/components/PieChart/index.d.ts.map +1 -0
- package/lib/typescript/components/PieChart/styles.d.ts +27 -0
- package/lib/typescript/components/PieChart/styles.d.ts.map +1 -0
- package/lib/typescript/components/ProgressCircle/ProgressCircleRing.d.ts.map +1 -1
- package/lib/typescript/components/ProgressCircle/ProgressRing.d.ts +17 -0
- package/lib/typescript/components/ProgressCircle/ProgressRing.d.ts.map +1 -0
- package/lib/typescript/components/ScrollShadow/useScrollShadow.d.ts.map +1 -1
- package/lib/typescript/components/Stepper/index.d.ts +68 -0
- package/lib/typescript/components/Stepper/index.d.ts.map +1 -0
- package/lib/typescript/components/Stepper/styles.d.ts +46 -0
- package/lib/typescript/components/Stepper/styles.d.ts.map +1 -0
- package/lib/typescript/components/Stepper/useStepperLabelFit.d.ts +15 -0
- package/lib/typescript/components/Stepper/useStepperLabelFit.d.ts.map +1 -0
- package/lib/typescript/components/Stepper/useStepperLabelFit.web.d.ts +10 -0
- package/lib/typescript/components/Stepper/useStepperLabelFit.web.d.ts.map +1 -0
- package/lib/typescript/components/Stepper/useStepperRingColors.d.ts +6 -0
- package/lib/typescript/components/Stepper/useStepperRingColors.d.ts.map +1 -0
- package/lib/typescript/components/SystemAlert/animation.d.ts +56 -0
- package/lib/typescript/components/SystemAlert/animation.d.ts.map +1 -0
- package/lib/typescript/components/SystemAlert/index.d.ts +110 -0
- package/lib/typescript/components/SystemAlert/index.d.ts.map +1 -0
- package/lib/typescript/components/SystemAlert/styles.d.ts +38 -0
- package/lib/typescript/components/SystemAlert/styles.d.ts.map +1 -0
- package/lib/typescript/components/SystemAlert/useSystemAlertStatusBarStyle.d.ts +14 -0
- package/lib/typescript/components/SystemAlert/useSystemAlertStatusBarStyle.d.ts.map +1 -0
- package/lib/typescript/components/Tabs/index.d.ts.map +1 -1
- package/lib/typescript/components/chart/ChartInspector.d.ts +101 -0
- package/lib/typescript/components/chart/ChartInspector.d.ts.map +1 -0
- package/lib/typescript/components/chart/format.d.ts +16 -0
- package/lib/typescript/components/chart/format.d.ts.map +1 -0
- package/lib/typescript/components/chart/index.d.ts +3 -0
- package/lib/typescript/components/chart/index.d.ts.map +1 -0
- package/lib/typescript/components/chart/motion.d.ts +27 -0
- package/lib/typescript/components/chart/motion.d.ts.map +1 -0
- package/lib/typescript/components/chart/palette.d.ts +44 -0
- package/lib/typescript/components/chart/palette.d.ts.map +1 -0
- package/lib/typescript/components/chart/size.d.ts +25 -0
- package/lib/typescript/components/chart/size.d.ts.map +1 -0
- package/lib/typescript/components/chart/ticks.d.ts +3 -0
- package/lib/typescript/components/chart/ticks.d.ts.map +1 -0
- package/lib/typescript/components/chart/types.d.ts +163 -0
- package/lib/typescript/components/chart/types.d.ts.map +1 -0
- package/lib/typescript/components/chart/useChartHostWidth.d.ts +9 -0
- package/lib/typescript/components/chart/useChartHostWidth.d.ts.map +1 -0
- package/lib/typescript/components/index.d.ts +5 -0
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/figma/SystemAlert.Button.figma.d.ts +11 -0
- package/lib/typescript/figma/SystemAlert.Button.figma.d.ts.map +1 -0
- package/lib/typescript/figma/SystemAlert.Close.figma.d.ts +11 -0
- package/lib/typescript/figma/SystemAlert.Close.figma.d.ts.map +1 -0
- package/lib/typescript/figma/SystemAlert.Description.figma.d.ts +8 -0
- package/lib/typescript/figma/SystemAlert.Description.figma.d.ts.map +1 -0
- package/lib/typescript/figma/SystemAlert.IconButton.figma.d.ts +11 -0
- package/lib/typescript/figma/SystemAlert.IconButton.figma.d.ts.map +1 -0
- package/lib/typescript/figma/SystemAlert.figma.d.ts +8 -0
- package/lib/typescript/figma/SystemAlert.figma.d.ts.map +1 -0
- package/package.json +5 -5
- package/src/components/BarChart/geometry.ts +1469 -0
- package/src/components/BarChart/index.tsx +1424 -0
- package/src/components/BarChart/styles.ts +31 -0
- package/src/components/Button/index.tsx +1 -1
- package/src/components/Chip/styles.ts +3 -1
- package/src/components/LineChart/geometry.ts +957 -0
- package/src/components/LineChart/index.tsx +1109 -0
- package/src/components/LineChart/styles.ts +26 -0
- package/src/components/PieChart/geometry.ts +295 -0
- package/src/components/PieChart/index.tsx +715 -0
- package/src/components/PieChart/styles.ts +101 -0
- package/src/components/ProgressCircle/ProgressCircleRing.tsx +10 -39
- package/src/components/ProgressCircle/ProgressRing.tsx +60 -0
- package/src/components/ScrollShadow/useScrollShadow.ts +12 -11
- package/src/components/Stepper/index.tsx +452 -0
- package/src/components/Stepper/styles.ts +234 -0
- package/src/components/Stepper/useStepperLabelFit.ts +21 -0
- package/src/components/Stepper/useStepperLabelFit.web.ts +53 -0
- package/src/components/Stepper/useStepperRingColors.ts +29 -0
- package/src/components/SystemAlert/animation.ts +252 -0
- package/src/components/SystemAlert/index.tsx +684 -0
- package/src/components/SystemAlert/styles.ts +212 -0
- package/src/components/SystemAlert/useSystemAlertStatusBarStyle.ts +57 -0
- package/src/components/Tabs/index.tsx +4 -0
- package/src/components/Tabs/styles.ts +1 -1
- package/src/components/chart/ChartInspector.tsx +726 -0
- package/src/components/chart/format.ts +95 -0
- package/src/components/chart/index.ts +24 -0
- package/src/components/chart/motion.ts +98 -0
- package/src/components/chart/palette.tsx +247 -0
- package/src/components/chart/size.ts +21 -0
- package/src/components/chart/ticks.ts +53 -0
- package/src/components/chart/types.ts +183 -0
- package/src/components/chart/useChartHostWidth.ts +26 -0
- package/src/components/index.ts +5 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import { cva, type VariantProps } from '@cdx-ui/utils';
|
|
3
|
+
|
|
4
|
+
export type SystemAlertColor = 'danger' | 'warning' | 'success' | 'info' | 'brand';
|
|
5
|
+
|
|
6
|
+
// Button and IconButton have no on-strong ghost colour (and no `brand`), so the
|
|
7
|
+
// controls are restyled here, following Toast's neutral stand-in.
|
|
8
|
+
const ON_STRONG_INTERACTION: Record<SystemAlertColor, string | undefined> = {
|
|
9
|
+
danger: Platform.select({
|
|
10
|
+
default: 'data-[active=true]:bg-surface-danger-strong-active',
|
|
11
|
+
web: [
|
|
12
|
+
'data-[hover=true]:bg-surface-danger-strong-hover',
|
|
13
|
+
'data-[active=true]:data-[hover=true]:bg-surface-danger-strong-active',
|
|
14
|
+
'web:data-[focus-visible=true]:ring-offset-surface-danger-strong',
|
|
15
|
+
].join(' '),
|
|
16
|
+
}),
|
|
17
|
+
warning: Platform.select({
|
|
18
|
+
default: 'data-[active=true]:bg-surface-warning-strong-active',
|
|
19
|
+
web: [
|
|
20
|
+
'data-[hover=true]:bg-surface-warning-strong-hover',
|
|
21
|
+
'data-[active=true]:data-[hover=true]:bg-surface-warning-strong-active',
|
|
22
|
+
'web:data-[focus-visible=true]:ring-offset-surface-warning-strong',
|
|
23
|
+
].join(' '),
|
|
24
|
+
}),
|
|
25
|
+
success: Platform.select({
|
|
26
|
+
default: 'data-[active=true]:bg-surface-success-strong-active',
|
|
27
|
+
web: [
|
|
28
|
+
'data-[hover=true]:bg-surface-success-strong-hover',
|
|
29
|
+
'data-[active=true]:data-[hover=true]:bg-surface-success-strong-active',
|
|
30
|
+
'web:data-[focus-visible=true]:ring-offset-surface-success-strong',
|
|
31
|
+
].join(' '),
|
|
32
|
+
}),
|
|
33
|
+
info: Platform.select({
|
|
34
|
+
default: 'data-[active=true]:bg-surface-info-strong-active',
|
|
35
|
+
web: [
|
|
36
|
+
'data-[hover=true]:bg-surface-info-strong-hover',
|
|
37
|
+
'data-[active=true]:data-[hover=true]:bg-surface-info-strong-active',
|
|
38
|
+
'web:data-[focus-visible=true]:ring-offset-surface-info-strong',
|
|
39
|
+
].join(' '),
|
|
40
|
+
}),
|
|
41
|
+
brand: Platform.select({
|
|
42
|
+
default: 'data-[active=true]:bg-surface-brand-strong-active',
|
|
43
|
+
web: [
|
|
44
|
+
'data-[hover=true]:bg-surface-brand-strong-hover',
|
|
45
|
+
'data-[active=true]:data-[hover=true]:bg-surface-brand-strong-active',
|
|
46
|
+
'web:data-[focus-visible=true]:ring-offset-surface-brand-strong',
|
|
47
|
+
].join(' '),
|
|
48
|
+
}),
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const ON_STRONG_CONTENT: Record<SystemAlertColor, string> = {
|
|
52
|
+
danger: 'text-content-danger-on-strong',
|
|
53
|
+
warning: 'text-content-warning-on-strong',
|
|
54
|
+
success: 'text-content-success-on-strong',
|
|
55
|
+
info: 'text-content-info-on-strong',
|
|
56
|
+
brand: 'text-content-brand-on-strong',
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// ── Root ─────────────────────────────────────────────────────────────────────
|
|
60
|
+
|
|
61
|
+
export const systemAlertRootVariants = cva(['w-full'], {
|
|
62
|
+
variants: {
|
|
63
|
+
color: {
|
|
64
|
+
danger: 'bg-surface-danger-strong',
|
|
65
|
+
warning: 'bg-surface-warning-strong',
|
|
66
|
+
success: 'bg-surface-success-strong',
|
|
67
|
+
info: 'bg-surface-info-strong',
|
|
68
|
+
brand: 'bg-surface-brand-strong',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
defaultVariants: {
|
|
72
|
+
color: 'info',
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// ── Presence (internal clip wrapper and the surface inside it, `isOpen` only) ─
|
|
77
|
+
|
|
78
|
+
// Web: inline px heights transition on the wrapper and on the clip inside it, with the same
|
|
79
|
+
// timing. The wrapper's `minHeight` is the reserved inset, so the page moves only once the
|
|
80
|
+
// surface leaves the strip. The clip has no minimum and `justify-end` pins the surface's bottom
|
|
81
|
+
// edge to it, so the surface slides through the strip and `translateY = b − H` falls out of
|
|
82
|
+
// layout. A translate transition is composited and starts a frame before a height one in
|
|
83
|
+
// Chromium, which opens a gap. The timings mirror `SYSTEM_ALERT_ENTER_MS` /
|
|
84
|
+
// `SYSTEM_ALERT_EXIT_MS` in `./animation`. Native overrides the overflow inline; see
|
|
85
|
+
// `NATIVE_WRAPPER_STYLE` in `./index`.
|
|
86
|
+
const WEB_HEIGHT_TRANSITION = [
|
|
87
|
+
'web:transition-[height] web:duration-300 web:ease-[cubic-bezier(0.32,0.72,0,1)]',
|
|
88
|
+
'web:data-[state=closed]:duration-[220ms] web:data-[state=closed]:ease-[cubic-bezier(0.4,0,1,1)]',
|
|
89
|
+
'web:motion-reduce:transition-none web:motion-reduce:duration-0',
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
export const systemAlertPresenceVariants = cva([
|
|
93
|
+
'w-full overflow-hidden',
|
|
94
|
+
...WEB_HEIGHT_TRANSITION,
|
|
95
|
+
]);
|
|
96
|
+
|
|
97
|
+
export const systemAlertPresenceClipVariants = cva([
|
|
98
|
+
'w-full overflow-hidden justify-end',
|
|
99
|
+
...WEB_HEIGHT_TRANSITION,
|
|
100
|
+
]);
|
|
101
|
+
|
|
102
|
+
// The surface stays in flow so a settled wrapper sizes to it (`height: auto`); `shrink-0`
|
|
103
|
+
// keeps its natural height while the wrapper's animated height is smaller.
|
|
104
|
+
export const systemAlertPresenceSurfaceVariants = cva(['shrink-0']);
|
|
105
|
+
|
|
106
|
+
// ── Body (internal row below the safe-area padding) ──────────────────────────
|
|
107
|
+
|
|
108
|
+
export const systemAlertBodyVariants = cva(['flex-row items-start min-h-11 ps-3 pe-3']);
|
|
109
|
+
|
|
110
|
+
// ── Icon ─────────────────────────────────────────────────────────────────────
|
|
111
|
+
|
|
112
|
+
// `mt-3` centres the 20px glyph on the first 20px text line of the 44px row.
|
|
113
|
+
export const systemAlertIconVariants = cva(['size-5 shrink-0 mt-3 me-3'], {
|
|
114
|
+
variants: {
|
|
115
|
+
color: ON_STRONG_CONTENT,
|
|
116
|
+
},
|
|
117
|
+
defaultVariants: {
|
|
118
|
+
color: 'info',
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// ── Description ──────────────────────────────────────────────────────────────
|
|
123
|
+
|
|
124
|
+
export const systemAlertDescriptionVariants = cva(['flex-1 min-w-0 py-3 body-md font-medium'], {
|
|
125
|
+
variants: {
|
|
126
|
+
color: ON_STRONG_CONTENT,
|
|
127
|
+
},
|
|
128
|
+
defaultVariants: {
|
|
129
|
+
color: 'info',
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// ── Actions ──────────────────────────────────────────────────────────────────
|
|
134
|
+
|
|
135
|
+
// The `-me-1.5` end offset optically aligns the last ghost control with the row
|
|
136
|
+
// padding. When the root renders a close button, the close button carries it.
|
|
137
|
+
export const systemAlertActionsVariants = cva(['shrink-0 flex-row items-center gap-0.5 py-1.5'], {
|
|
138
|
+
variants: {
|
|
139
|
+
hasClose: {
|
|
140
|
+
true: '',
|
|
141
|
+
false: '-me-1.5',
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
defaultVariants: {
|
|
145
|
+
hasClose: false,
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// ── Action (ghost small Button) ──────────────────────────────────────────────
|
|
150
|
+
|
|
151
|
+
export const systemAlertActionVariants = cva([], {
|
|
152
|
+
variants: {
|
|
153
|
+
color: ON_STRONG_INTERACTION,
|
|
154
|
+
},
|
|
155
|
+
defaultVariants: {
|
|
156
|
+
color: 'info',
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
export const systemAlertActionLabelVariants = cva([], {
|
|
161
|
+
variants: {
|
|
162
|
+
color: ON_STRONG_CONTENT,
|
|
163
|
+
},
|
|
164
|
+
defaultVariants: {
|
|
165
|
+
color: 'info',
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// ── IconAction (ghost small IconButton) ──────────────────────────────────────
|
|
170
|
+
|
|
171
|
+
export const systemAlertIconActionVariants = cva([], {
|
|
172
|
+
variants: {
|
|
173
|
+
color: ON_STRONG_INTERACTION,
|
|
174
|
+
},
|
|
175
|
+
defaultVariants: {
|
|
176
|
+
color: 'info',
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
export const systemAlertIconActionIconVariants = cva([], {
|
|
181
|
+
variants: {
|
|
182
|
+
color: ON_STRONG_CONTENT,
|
|
183
|
+
},
|
|
184
|
+
defaultVariants: {
|
|
185
|
+
color: 'info',
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
// ── Close (ghost small IconButton rendered by the root) ──────────────────────
|
|
190
|
+
|
|
191
|
+
// `my-1.5` matches the actions row's vertical padding; `ms-0.5` matches its gap.
|
|
192
|
+
export const systemAlertCloseVariants = cva(['my-1.5 ms-0.5 -me-1.5'], {
|
|
193
|
+
variants: {
|
|
194
|
+
color: ON_STRONG_INTERACTION,
|
|
195
|
+
},
|
|
196
|
+
defaultVariants: {
|
|
197
|
+
color: 'info',
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
export const systemAlertCloseIconVariants = cva([], {
|
|
202
|
+
variants: {
|
|
203
|
+
color: ON_STRONG_CONTENT,
|
|
204
|
+
},
|
|
205
|
+
defaultVariants: {
|
|
206
|
+
color: 'info',
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
// ── Types ────────────────────────────────────────────────────────────────────
|
|
211
|
+
|
|
212
|
+
export type SystemAlertVariantProps = VariantProps<typeof systemAlertRootVariants>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useCSSVariable } from 'uniwind';
|
|
2
|
+
import type { SystemAlertColor } from './styles';
|
|
3
|
+
|
|
4
|
+
export type SystemAlertStatusBarStyle = 'light' | 'dark';
|
|
5
|
+
|
|
6
|
+
// Light-theme glyphs, used when the token cannot be read (no Uniwind runtime, e.g. Jest).
|
|
7
|
+
const FALLBACKS: Record<SystemAlertColor, SystemAlertStatusBarStyle> = {
|
|
8
|
+
danger: 'light',
|
|
9
|
+
warning: 'dark',
|
|
10
|
+
success: 'light',
|
|
11
|
+
info: 'light',
|
|
12
|
+
brand: 'light',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// Above this relative luminance, black contrasts more than white (the two ratios meet at ~0.179).
|
|
16
|
+
const LIGHT_LUMINANCE = 0.179;
|
|
17
|
+
|
|
18
|
+
function relativeLuminance(value: string): number | undefined {
|
|
19
|
+
const hex = /^#([0-9a-f]{3}|[0-9a-f]{6})(?:[0-9a-f]{2})?$/i.exec(value.trim());
|
|
20
|
+
let channels: number[] | undefined;
|
|
21
|
+
if (hex) {
|
|
22
|
+
const digits =
|
|
23
|
+
hex[1].length === 3
|
|
24
|
+
? hex[1]
|
|
25
|
+
.split('')
|
|
26
|
+
.map((digit) => digit + digit)
|
|
27
|
+
.join('')
|
|
28
|
+
: hex[1];
|
|
29
|
+
channels = [0, 2, 4].map((start) => Number.parseInt(digits.slice(start, start + 2), 16));
|
|
30
|
+
} else {
|
|
31
|
+
const rgb = /^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i.exec(value.trim());
|
|
32
|
+
if (rgb) channels = rgb.slice(1, 4).map(Number);
|
|
33
|
+
}
|
|
34
|
+
if (!channels || channels.some((channel) => !Number.isFinite(channel))) return undefined;
|
|
35
|
+
const [r, g, b] = channels.map((channel) => {
|
|
36
|
+
const c = channel / 255;
|
|
37
|
+
return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
|
|
38
|
+
});
|
|
39
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The status-bar glyph style that matches a SystemAlert's text on its strong surface, for a
|
|
44
|
+
* banner that paints behind the status bar. Read from the active theme's
|
|
45
|
+
* `content-{color}-on-strong` token, so it follows FI themes and light and dark mode.
|
|
46
|
+
*
|
|
47
|
+
* SystemAlert never sets the status bar. Pass the result to whatever owns it in your app,
|
|
48
|
+
* such as `expo-status-bar`'s `style`, React Native `StatusBar`'s `barStyle`
|
|
49
|
+
* (`'light-content'` / `'dark-content'`), or your navigator's status-bar option, and apply it
|
|
50
|
+
* only while the banner is open and its screen is focused.
|
|
51
|
+
*/
|
|
52
|
+
export function useSystemAlertStatusBarStyle(color: SystemAlertColor): SystemAlertStatusBarStyle {
|
|
53
|
+
const textColor = useCSSVariable(`--color-content-${color}-on-strong`);
|
|
54
|
+
const luminance = typeof textColor === 'string' ? relativeLuminance(textColor) : undefined;
|
|
55
|
+
if (luminance === undefined) return FALLBACKS[color];
|
|
56
|
+
return luminance > LIGHT_LUMINANCE ? 'light' : 'dark';
|
|
57
|
+
}
|
|
@@ -71,6 +71,9 @@ interface TabLayout {
|
|
|
71
71
|
height: number;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
/** Ignore subpixel web layout drift when deciding whether an overflow control is needed. */
|
|
75
|
+
const SCROLL_EDGE_TOLERANCE = 1;
|
|
76
|
+
|
|
74
77
|
/** Minimum horizontal scroll offset so `layout` is fully inside the viewport. */
|
|
75
78
|
function scrollXToRevealTab(
|
|
76
79
|
layout: TabLayout,
|
|
@@ -481,6 +484,7 @@ const TabsList = forwardRef<ComponentRef<typeof View>, TabsListProps>(
|
|
|
481
484
|
orientation="horizontal"
|
|
482
485
|
surface={isSolidHorizontalScroll ? 'secondary' : 'background'}
|
|
483
486
|
size={isSolidHorizontalScroll ? 'default' : 'small'}
|
|
487
|
+
offset={SCROLL_EDGE_TOLERANCE}
|
|
484
488
|
edgeClassName={isSolidHorizontalScroll ? undefined : 'opacity-85'}
|
|
485
489
|
onCapabilityChange={setScrollCapability}
|
|
486
490
|
>
|
|
@@ -307,7 +307,7 @@ export const tabsPanelVariants = cva(['data-[state=inactive]:hidden'], {
|
|
|
307
307
|
defaultVariants: { orientation: 'horizontal' },
|
|
308
308
|
});
|
|
309
309
|
|
|
310
|
-
export const tabsTabLabelVariants = cva('body-md', {
|
|
310
|
+
export const tabsTabLabelVariants = cva('body-md text-center', {
|
|
311
311
|
variants: {
|
|
312
312
|
state: {
|
|
313
313
|
// Selection state is a CVA input (not a `data-[]` selector) so inactive/active
|