squarex-ui-component-lib 1.0.4 → 1.0.5
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/dist/charts/components/ui/Avatar/Avatar.types.d.ts +1 -1
- package/dist/charts/components/ui/Avatar/Avatar.types.d.ts.map +1 -1
- package/dist/charts/components/ui/Avatar/AvatarBlock.d.ts +13 -0
- package/dist/charts/components/ui/Avatar/AvatarBlock.d.ts.map +1 -0
- package/dist/charts/components/ui/Avatar/AvatarGroup.d.ts +14 -0
- package/dist/charts/components/ui/Avatar/AvatarGroup.d.ts.map +1 -0
- package/dist/charts/components/ui/Avatar/index.d.ts +3 -1
- package/dist/charts/components/ui/Avatar/index.d.ts.map +1 -1
- package/dist/charts/components/ui/Breadcrumb/Breadcrumb.d.ts +1 -1
- package/dist/charts/components/ui/Breadcrumb/Breadcrumb.d.ts.map +1 -1
- package/dist/charts/components/ui/Button/Button.d.ts.map +1 -1
- package/dist/charts/components/ui/ButtonDanger/ButtonDanger.d.ts.map +1 -1
- package/dist/charts/components/ui/Cell/Cell.d.ts.map +1 -1
- package/dist/charts/components/ui/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/charts/components/ui/IconButton/IconButton.d.ts.map +1 -1
- package/dist/charts/components/ui/InputField/InputField.d.ts +5 -0
- package/dist/charts/components/ui/InputField/InputField.d.ts.map +1 -0
- package/dist/charts/components/ui/InputField/InputField.types.d.ts +27 -0
- package/dist/charts/components/ui/InputField/InputField.types.d.ts.map +1 -0
- package/dist/charts/components/ui/InputField/index.d.ts +3 -0
- package/dist/charts/components/ui/InputField/index.d.ts.map +1 -0
- package/dist/charts/components/ui/ListSearch/ListSearch.d.ts +5 -0
- package/dist/charts/components/ui/ListSearch/ListSearch.d.ts.map +1 -0
- package/dist/charts/components/ui/ListSearch/ListSearch.types.d.ts +2 -0
- package/dist/charts/components/ui/ListSearch/ListSearch.types.d.ts.map +1 -0
- package/dist/charts/components/ui/ListSearch/index.d.ts +3 -0
- package/dist/charts/components/ui/ListSearch/index.d.ts.map +1 -0
- package/dist/charts/components/ui/StatusIndicator/StatusIndicator.d.ts.map +1 -1
- package/dist/charts/components/ui/StatusIndicator/StatusIndicator.types.d.ts +1 -1
- package/dist/charts/components/ui/StatusIndicator/StatusIndicator.types.d.ts.map +1 -1
- package/dist/charts/components/ui/TextArea/TextArea.d.ts +0 -9
- package/dist/charts/components/ui/TextArea/TextArea.d.ts.map +1 -1
- package/dist/charts/components/ui/Toast/Toast.d.ts +11 -0
- package/dist/charts/components/ui/Toast/Toast.d.ts.map +1 -0
- package/dist/charts/components/ui/Toast/Toast.types.d.ts +2 -0
- package/dist/charts/components/ui/Toast/Toast.types.d.ts.map +1 -0
- package/dist/charts/components/ui/Toast/index.d.ts +3 -0
- package/dist/charts/components/ui/Toast/index.d.ts.map +1 -0
- package/dist/charts/components/ui/index.d.ts +8 -2
- package/dist/charts/components/ui/index.d.ts.map +1 -1
- package/dist/charts/index.d.ts +3 -0
- package/dist/charts/index.d.ts.map +1 -1
- package/dist/charts/tokens/core/breakpoints.d.ts +23 -0
- package/dist/charts/tokens/core/breakpoints.d.ts.map +1 -0
- package/dist/charts/tokens/core/colors.d.ts +186 -0
- package/dist/charts/tokens/core/colors.d.ts.map +1 -0
- package/dist/charts/tokens/core/index.d.ts +20 -0
- package/dist/charts/tokens/core/index.d.ts.map +1 -0
- package/dist/charts/tokens/core/spacing.d.ts +105 -0
- package/dist/charts/tokens/core/spacing.d.ts.map +1 -0
- package/dist/charts/tokens/core/typography.d.ts +52 -0
- package/dist/charts/tokens/core/typography.d.ts.map +1 -0
- package/dist/charts/tokens/index.d.ts +1646 -0
- package/dist/charts/tokens/index.d.ts.map +1 -0
- package/dist/charts/tokens/js/tokens.d.ts +482 -0
- package/dist/charts/tokens/js/tokens.d.ts.map +1 -0
- package/dist/charts/tokens/semantic/colors.d.ts +320 -0
- package/dist/charts/tokens/semantic/colors.d.ts.map +1 -0
- package/dist/charts/tokens/semantic/effects.d.ts +62 -0
- package/dist/charts/tokens/semantic/effects.d.ts.map +1 -0
- package/dist/charts/tokens/semantic/index.d.ts +18 -0
- package/dist/charts/tokens/semantic/index.d.ts.map +1 -0
- package/dist/charts/tokens/semantic/typography.d.ts +266 -0
- package/dist/charts/tokens/semantic/typography.d.ts.map +1 -0
- package/dist/charts/tokens/tailwind/config.d.ts +151 -0
- package/dist/charts/tokens/tailwind/config.d.ts.map +1 -0
- package/dist/charts/tokens/tailwind/index.d.ts +7 -0
- package/dist/charts/tokens/tailwind/index.d.ts.map +1 -0
- package/dist/charts/tokens/themes/dark.d.ts +308 -0
- package/dist/charts/tokens/themes/dark.d.ts.map +1 -0
- package/dist/charts/tokens/themes/index.d.ts +9 -0
- package/dist/charts/tokens/themes/index.d.ts.map +1 -0
- package/dist/charts/tokens/themes/light.d.ts +308 -0
- package/dist/charts/tokens/themes/light.d.ts.map +1 -0
- package/dist/charts/tokens/utils/cssVariables.d.ts +26 -0
- package/dist/charts/tokens/utils/cssVariables.d.ts.map +1 -0
- package/dist/charts/tokens/utils/hooks.d.ts +773 -0
- package/dist/charts/tokens/utils/hooks.d.ts.map +1 -0
- package/dist/charts/tokens/utils/index.d.ts +7 -0
- package/dist/charts/tokens/utils/index.d.ts.map +1 -0
- package/dist/charts/types/ui.d.ts +42 -1
- package/dist/charts/types/ui.d.ts.map +1 -1
- package/dist/components/ui/Avatar/Avatar.types.d.ts +1 -1
- package/dist/components/ui/Avatar/Avatar.types.d.ts.map +1 -1
- package/dist/components/ui/Avatar/AvatarBlock.d.ts +13 -0
- package/dist/components/ui/Avatar/AvatarBlock.d.ts.map +1 -0
- package/dist/components/ui/Avatar/AvatarGroup.d.ts +14 -0
- package/dist/components/ui/Avatar/AvatarGroup.d.ts.map +1 -0
- package/dist/components/ui/Avatar/index.d.ts +3 -1
- package/dist/components/ui/Avatar/index.d.ts.map +1 -1
- package/dist/components/ui/Breadcrumb/Breadcrumb.d.ts +1 -1
- package/dist/components/ui/Breadcrumb/Breadcrumb.d.ts.map +1 -1
- package/dist/components/ui/Button/Button.d.ts.map +1 -1
- package/dist/components/ui/ButtonDanger/ButtonDanger.d.ts.map +1 -1
- package/dist/components/ui/Cell/Cell.d.ts.map +1 -1
- package/dist/components/ui/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/components/ui/IconButton/IconButton.d.ts.map +1 -1
- package/dist/components/ui/InputField/InputField.d.ts +5 -0
- package/dist/components/ui/InputField/InputField.d.ts.map +1 -0
- package/dist/components/ui/InputField/InputField.types.d.ts +27 -0
- package/dist/components/ui/InputField/InputField.types.d.ts.map +1 -0
- package/dist/components/ui/InputField/index.d.ts +3 -0
- package/dist/components/ui/InputField/index.d.ts.map +1 -0
- package/dist/components/ui/ListSearch/ListSearch.d.ts +5 -0
- package/dist/components/ui/ListSearch/ListSearch.d.ts.map +1 -0
- package/dist/components/ui/ListSearch/ListSearch.types.d.ts +2 -0
- package/dist/components/ui/ListSearch/ListSearch.types.d.ts.map +1 -0
- package/dist/components/ui/ListSearch/index.d.ts +3 -0
- package/dist/components/ui/ListSearch/index.d.ts.map +1 -0
- package/dist/components/ui/StatusIndicator/StatusIndicator.d.ts.map +1 -1
- package/dist/components/ui/StatusIndicator/StatusIndicator.types.d.ts +1 -1
- package/dist/components/ui/StatusIndicator/StatusIndicator.types.d.ts.map +1 -1
- package/dist/components/ui/TextArea/TextArea.d.ts +0 -9
- package/dist/components/ui/TextArea/TextArea.d.ts.map +1 -1
- package/dist/components/ui/Toast/Toast.d.ts +11 -0
- package/dist/components/ui/Toast/Toast.d.ts.map +1 -0
- package/dist/components/ui/Toast/Toast.types.d.ts +2 -0
- package/dist/components/ui/Toast/Toast.types.d.ts.map +1 -0
- package/dist/components/ui/Toast/index.d.ts +3 -0
- package/dist/components/ui/Toast/index.d.ts.map +1 -0
- package/dist/components/ui/index.d.ts +8 -2
- package/dist/components/ui/index.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/tokens/core/breakpoints.d.ts +23 -0
- package/dist/tokens/core/breakpoints.d.ts.map +1 -0
- package/dist/tokens/core/colors.d.ts +186 -0
- package/dist/tokens/core/colors.d.ts.map +1 -0
- package/dist/tokens/core/index.d.ts +20 -0
- package/dist/tokens/core/index.d.ts.map +1 -0
- package/dist/tokens/core/spacing.d.ts +105 -0
- package/dist/tokens/core/spacing.d.ts.map +1 -0
- package/dist/tokens/core/typography.d.ts +52 -0
- package/dist/tokens/core/typography.d.ts.map +1 -0
- package/dist/tokens/index.d.ts +1646 -0
- package/dist/tokens/index.d.ts.map +1 -0
- package/dist/tokens/js/tokens.d.ts +482 -0
- package/dist/tokens/js/tokens.d.ts.map +1 -0
- package/dist/tokens/semantic/colors.d.ts +320 -0
- package/dist/tokens/semantic/colors.d.ts.map +1 -0
- package/dist/tokens/semantic/effects.d.ts +62 -0
- package/dist/tokens/semantic/effects.d.ts.map +1 -0
- package/dist/tokens/semantic/index.d.ts +18 -0
- package/dist/tokens/semantic/index.d.ts.map +1 -0
- package/dist/tokens/semantic/typography.d.ts +266 -0
- package/dist/tokens/semantic/typography.d.ts.map +1 -0
- package/dist/tokens/tailwind/config.d.ts +151 -0
- package/dist/tokens/tailwind/config.d.ts.map +1 -0
- package/dist/tokens/tailwind/index.d.ts +7 -0
- package/dist/tokens/tailwind/index.d.ts.map +1 -0
- package/dist/tokens/themes/dark.d.ts +308 -0
- package/dist/tokens/themes/dark.d.ts.map +1 -0
- package/dist/tokens/themes/index.d.ts +9 -0
- package/dist/tokens/themes/index.d.ts.map +1 -0
- package/dist/tokens/themes/light.d.ts +308 -0
- package/dist/tokens/themes/light.d.ts.map +1 -0
- package/dist/tokens/utils/cssVariables.d.ts +26 -0
- package/dist/tokens/utils/cssVariables.d.ts.map +1 -0
- package/dist/tokens/utils/hooks.d.ts +773 -0
- package/dist/tokens/utils/hooks.d.ts.map +1 -0
- package/dist/tokens/utils/index.d.ts +7 -0
- package/dist/tokens/utils/index.d.ts.map +1 -0
- package/dist/types/ui.d.ts +42 -1
- package/dist/types/ui.d.ts.map +1 -1
- package/dist/ui/components/ui/Avatar/Avatar.types.d.ts +1 -1
- package/dist/ui/components/ui/Avatar/Avatar.types.d.ts.map +1 -1
- package/dist/ui/components/ui/Avatar/AvatarBlock.d.ts +13 -0
- package/dist/ui/components/ui/Avatar/AvatarBlock.d.ts.map +1 -0
- package/dist/ui/components/ui/Avatar/AvatarGroup.d.ts +14 -0
- package/dist/ui/components/ui/Avatar/AvatarGroup.d.ts.map +1 -0
- package/dist/ui/components/ui/Avatar/index.d.ts +3 -1
- package/dist/ui/components/ui/Avatar/index.d.ts.map +1 -1
- package/dist/ui/components/ui/Breadcrumb/Breadcrumb.d.ts +1 -1
- package/dist/ui/components/ui/Breadcrumb/Breadcrumb.d.ts.map +1 -1
- package/dist/ui/components/ui/Button/Button.d.ts.map +1 -1
- package/dist/ui/components/ui/ButtonDanger/ButtonDanger.d.ts.map +1 -1
- package/dist/ui/components/ui/Cell/Cell.d.ts.map +1 -1
- package/dist/ui/components/ui/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/ui/components/ui/IconButton/IconButton.d.ts.map +1 -1
- package/dist/ui/components/ui/InputField/InputField.d.ts +5 -0
- package/dist/ui/components/ui/InputField/InputField.d.ts.map +1 -0
- package/dist/ui/components/ui/InputField/InputField.types.d.ts +27 -0
- package/dist/ui/components/ui/InputField/InputField.types.d.ts.map +1 -0
- package/dist/ui/components/ui/InputField/index.d.ts +3 -0
- package/dist/ui/components/ui/InputField/index.d.ts.map +1 -0
- package/dist/ui/components/ui/ListSearch/ListSearch.d.ts +5 -0
- package/dist/ui/components/ui/ListSearch/ListSearch.d.ts.map +1 -0
- package/dist/ui/components/ui/ListSearch/ListSearch.types.d.ts +2 -0
- package/dist/ui/components/ui/ListSearch/ListSearch.types.d.ts.map +1 -0
- package/dist/ui/components/ui/ListSearch/index.d.ts +3 -0
- package/dist/ui/components/ui/ListSearch/index.d.ts.map +1 -0
- package/dist/ui/components/ui/StatusIndicator/StatusIndicator.d.ts.map +1 -1
- package/dist/ui/components/ui/StatusIndicator/StatusIndicator.types.d.ts +1 -1
- package/dist/ui/components/ui/StatusIndicator/StatusIndicator.types.d.ts.map +1 -1
- package/dist/ui/components/ui/TextArea/TextArea.d.ts +0 -9
- package/dist/ui/components/ui/TextArea/TextArea.d.ts.map +1 -1
- package/dist/ui/components/ui/Toast/Toast.d.ts +11 -0
- package/dist/ui/components/ui/Toast/Toast.d.ts.map +1 -0
- package/dist/ui/components/ui/Toast/Toast.types.d.ts +2 -0
- package/dist/ui/components/ui/Toast/Toast.types.d.ts.map +1 -0
- package/dist/ui/components/ui/Toast/index.d.ts +3 -0
- package/dist/ui/components/ui/Toast/index.d.ts.map +1 -0
- package/dist/ui/components/ui/index.d.ts +8 -2
- package/dist/ui/components/ui/index.d.ts.map +1 -1
- package/dist/ui/index.d.ts +3 -0
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.esm.css +1 -1
- package/dist/ui/index.esm.js +1 -1
- package/dist/ui/index.esm.js.map +1 -1
- package/dist/ui/tokens/core/breakpoints.d.ts +23 -0
- package/dist/ui/tokens/core/breakpoints.d.ts.map +1 -0
- package/dist/ui/tokens/core/colors.d.ts +186 -0
- package/dist/ui/tokens/core/colors.d.ts.map +1 -0
- package/dist/ui/tokens/core/index.d.ts +20 -0
- package/dist/ui/tokens/core/index.d.ts.map +1 -0
- package/dist/ui/tokens/core/spacing.d.ts +105 -0
- package/dist/ui/tokens/core/spacing.d.ts.map +1 -0
- package/dist/ui/tokens/core/typography.d.ts +52 -0
- package/dist/ui/tokens/core/typography.d.ts.map +1 -0
- package/dist/ui/tokens/index.d.ts +1646 -0
- package/dist/ui/tokens/index.d.ts.map +1 -0
- package/dist/ui/tokens/js/tokens.d.ts +482 -0
- package/dist/ui/tokens/js/tokens.d.ts.map +1 -0
- package/dist/ui/tokens/semantic/colors.d.ts +320 -0
- package/dist/ui/tokens/semantic/colors.d.ts.map +1 -0
- package/dist/ui/tokens/semantic/effects.d.ts +62 -0
- package/dist/ui/tokens/semantic/effects.d.ts.map +1 -0
- package/dist/ui/tokens/semantic/index.d.ts +18 -0
- package/dist/ui/tokens/semantic/index.d.ts.map +1 -0
- package/dist/ui/tokens/semantic/typography.d.ts +266 -0
- package/dist/ui/tokens/semantic/typography.d.ts.map +1 -0
- package/dist/ui/tokens/tailwind/config.d.ts +151 -0
- package/dist/ui/tokens/tailwind/config.d.ts.map +1 -0
- package/dist/ui/tokens/tailwind/index.d.ts +7 -0
- package/dist/ui/tokens/tailwind/index.d.ts.map +1 -0
- package/dist/ui/tokens/themes/dark.d.ts +308 -0
- package/dist/ui/tokens/themes/dark.d.ts.map +1 -0
- package/dist/ui/tokens/themes/index.d.ts +9 -0
- package/dist/ui/tokens/themes/index.d.ts.map +1 -0
- package/dist/ui/tokens/themes/light.d.ts +308 -0
- package/dist/ui/tokens/themes/light.d.ts.map +1 -0
- package/dist/ui/tokens/utils/cssVariables.d.ts +26 -0
- package/dist/ui/tokens/utils/cssVariables.d.ts.map +1 -0
- package/dist/ui/tokens/utils/hooks.d.ts +773 -0
- package/dist/ui/tokens/utils/hooks.d.ts.map +1 -0
- package/dist/ui/tokens/utils/index.d.ts +7 -0
- package/dist/ui/tokens/utils/index.d.ts.map +1 -0
- package/dist/ui/types/ui.d.ts +42 -1
- package/dist/ui/types/ui.d.ts.map +1 -1
- package/package.json +20 -7
- package/public/logo/Logo.svg +9 -0
- package/src/tokens/README.md +199 -0
- package/src/tokens/core/breakpoints.ts +25 -0
- package/src/tokens/core/colors.ts +200 -0
- package/src/tokens/core/index.ts +20 -0
- package/src/tokens/core/spacing.ts +114 -0
- package/src/tokens/core/typography.ts +58 -0
- package/src/tokens/css/variables-dark.css +480 -0
- package/src/tokens/css/variables-light.css +480 -0
- package/src/tokens/index.ts +163 -0
- package/src/tokens/js/tokens.ts +486 -0
- package/src/tokens/semantic/colors.ts +383 -0
- package/src/tokens/semantic/effects.ts +69 -0
- package/src/tokens/semantic/index.ts +18 -0
- package/src/tokens/semantic/typography.ts +284 -0
- package/src/tokens/tailwind/config.ts +188 -0
- package/src/tokens/tailwind/index.ts +7 -0
- package/src/tokens/themes/dark.ts +311 -0
- package/src/tokens/themes/index.ts +10 -0
- package/src/tokens/themes/light.ts +17 -0
- package/src/tokens/utils/cssVariables.ts +88 -0
- package/src/tokens/utils/hooks.ts +192 -0
- package/src/tokens/utils/index.ts +7 -0
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dark Theme
|
|
3
|
+
* Dark mode color scheme (inverted from light theme)
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { colors, alphas } from '../core/colors';
|
|
7
|
+
|
|
8
|
+
export const darkTheme = {
|
|
9
|
+
color: {
|
|
10
|
+
background: {
|
|
11
|
+
brand: {
|
|
12
|
+
default: colors.purple[400],
|
|
13
|
+
secondary: colors.purple[600],
|
|
14
|
+
tertiary: colors.purple[800],
|
|
15
|
+
hover: colors.purple[300],
|
|
16
|
+
secondaryHover: colors.purple[500],
|
|
17
|
+
tertiaryHover: colors.purple[700],
|
|
18
|
+
subtleLow: alphas.purple[100],
|
|
19
|
+
subtleMedium: alphas.purple[200],
|
|
20
|
+
},
|
|
21
|
+
action: {
|
|
22
|
+
default: colors.violet[400],
|
|
23
|
+
secondary: colors.violet[600],
|
|
24
|
+
tertiary: colors.violet[800],
|
|
25
|
+
hover: colors.violet[300],
|
|
26
|
+
secondaryHover: colors.violet[500],
|
|
27
|
+
tertiaryHover: colors.violet[700],
|
|
28
|
+
subtleLow: alphas.violet[100],
|
|
29
|
+
subtleMedium: alphas.violet[200],
|
|
30
|
+
},
|
|
31
|
+
success: {
|
|
32
|
+
default: colors.green[600],
|
|
33
|
+
secondary: colors.green[800],
|
|
34
|
+
tertiary: colors.green[950],
|
|
35
|
+
hover: colors.green[500],
|
|
36
|
+
secondaryHover: colors.green[700],
|
|
37
|
+
tertiaryHover: colors.green[800],
|
|
38
|
+
subtleLow: colors.green[900],
|
|
39
|
+
subtleMedium: colors.green[800],
|
|
40
|
+
},
|
|
41
|
+
warning: {
|
|
42
|
+
default: colors.yellow[600],
|
|
43
|
+
secondary: colors.yellow[800],
|
|
44
|
+
tertiary: colors.yellow[950],
|
|
45
|
+
hover: colors.yellow[500],
|
|
46
|
+
secondaryHover: colors.yellow[700],
|
|
47
|
+
tertiaryHover: colors.yellow[900],
|
|
48
|
+
subtleLow: colors.yellow[900],
|
|
49
|
+
subtleMedium: colors.yellow[800],
|
|
50
|
+
},
|
|
51
|
+
danger: {
|
|
52
|
+
default: colors.red[600],
|
|
53
|
+
secondary: colors.red[800],
|
|
54
|
+
tertiary: colors.red[950],
|
|
55
|
+
hover: colors.red[500],
|
|
56
|
+
secondaryHover: colors.red[700],
|
|
57
|
+
tertiaryHover: colors.red[900],
|
|
58
|
+
subtleLow: alphas.red[100],
|
|
59
|
+
subtleMedium: alphas.red[200],
|
|
60
|
+
},
|
|
61
|
+
info: {
|
|
62
|
+
default: colors.blue[600],
|
|
63
|
+
secondary: colors.blue[800],
|
|
64
|
+
tertiary: colors.blue[950],
|
|
65
|
+
hover: colors.blue[500],
|
|
66
|
+
secondaryHover: colors.blue[700],
|
|
67
|
+
tertiaryHover: colors.blue[900],
|
|
68
|
+
subtleLow: colors.blue[900],
|
|
69
|
+
subtleMedium: colors.blue[800],
|
|
70
|
+
},
|
|
71
|
+
neutral: {
|
|
72
|
+
default: colors.slate[600],
|
|
73
|
+
secondary: colors.slate[800],
|
|
74
|
+
tertiary: colors.slate[950],
|
|
75
|
+
hover: colors.slate[500],
|
|
76
|
+
secondaryHover: colors.slate[700],
|
|
77
|
+
tertiaryHover: colors.slate[900],
|
|
78
|
+
subtleLow: alphas.slate[100],
|
|
79
|
+
subtleMedium: alphas.slate[200],
|
|
80
|
+
},
|
|
81
|
+
default: {
|
|
82
|
+
default: colors.slate[950],
|
|
83
|
+
hover: colors.slate[900],
|
|
84
|
+
glass: alphas.black[300],
|
|
85
|
+
onGlass: alphas.black[600],
|
|
86
|
+
onGlassSecondary: alphas.black[700],
|
|
87
|
+
onGlassTertiary: alphas.black[800],
|
|
88
|
+
onGlassHover: alphas.black[800],
|
|
89
|
+
},
|
|
90
|
+
disabled: {
|
|
91
|
+
default: colors.gray[800],
|
|
92
|
+
secondary: colors.gray[900],
|
|
93
|
+
},
|
|
94
|
+
utilities: {
|
|
95
|
+
scrim: 'rgba(0, 0, 0, 0.7)',
|
|
96
|
+
overlay: 'rgba(255, 255, 255, 0.1)',
|
|
97
|
+
blanket: 'rgba(255, 255, 255, 0.15)',
|
|
98
|
+
bgOnGlass: 'rgba(0, 0, 0, 0.45)',
|
|
99
|
+
bgOnGlassOnGlass: 'rgba(0, 0, 0, 0.6)',
|
|
100
|
+
hoverOverlay: 'rgba(255, 255, 255, 0.1)',
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
text: {
|
|
104
|
+
default: {
|
|
105
|
+
default: colors.slate[50],
|
|
106
|
+
secondary: colors.slate[300],
|
|
107
|
+
tertiary: colors.slate[500],
|
|
108
|
+
},
|
|
109
|
+
brand: {
|
|
110
|
+
default: colors.purple[300],
|
|
111
|
+
secondary: colors.purple[400],
|
|
112
|
+
tertiary: colors.purple[600],
|
|
113
|
+
onBrand: colors.purple[950],
|
|
114
|
+
onBrandSecondary: colors.purple[200],
|
|
115
|
+
onBrandTertiary: colors.purple[300],
|
|
116
|
+
},
|
|
117
|
+
action: {
|
|
118
|
+
default: colors.violet[300],
|
|
119
|
+
secondary: colors.violet[400],
|
|
120
|
+
tertiary: colors.violet[600],
|
|
121
|
+
onAction: colors.violet[950],
|
|
122
|
+
onActionSecondary: colors.violet[200],
|
|
123
|
+
onActionTertiary: colors.violet[300],
|
|
124
|
+
},
|
|
125
|
+
success: {
|
|
126
|
+
default: colors.green[300],
|
|
127
|
+
secondary: colors.green[400],
|
|
128
|
+
tertiary: colors.green[500],
|
|
129
|
+
onSuccess: colors.green[950],
|
|
130
|
+
onSuccessSecondary: colors.green[200],
|
|
131
|
+
onSuccessTertiary: colors.green[300],
|
|
132
|
+
},
|
|
133
|
+
warning: {
|
|
134
|
+
default: colors.yellow[300],
|
|
135
|
+
secondary: colors.yellow[400],
|
|
136
|
+
tertiary: colors.yellow[500],
|
|
137
|
+
onWarning: colors.yellow[950],
|
|
138
|
+
onWarningSecondary: colors.yellow[200],
|
|
139
|
+
onWarningTertiary: colors.yellow[300],
|
|
140
|
+
},
|
|
141
|
+
danger: {
|
|
142
|
+
default: colors.red[400],
|
|
143
|
+
secondary: colors.red[500],
|
|
144
|
+
tertiary: colors.red[600],
|
|
145
|
+
onDanger: colors.red[950],
|
|
146
|
+
onDangerSecondary: colors.red[200],
|
|
147
|
+
onDangerTertiary: colors.red[300],
|
|
148
|
+
},
|
|
149
|
+
info: {
|
|
150
|
+
default: colors.blue[400],
|
|
151
|
+
secondary: colors.blue[500],
|
|
152
|
+
tertiary: colors.blue[600],
|
|
153
|
+
onInfo: colors.blue[950],
|
|
154
|
+
onInfoSecondary: colors.blue[200],
|
|
155
|
+
onInfoTertiary: colors.blue[300],
|
|
156
|
+
},
|
|
157
|
+
neutral: {
|
|
158
|
+
default: colors.slate[50],
|
|
159
|
+
secondary: colors.slate[300],
|
|
160
|
+
tertiary: colors.slate[500],
|
|
161
|
+
onNeutral: colors.slate[950],
|
|
162
|
+
onNeutralSecondary: colors.slate[200],
|
|
163
|
+
onNeutralTertiary: colors.slate[300],
|
|
164
|
+
},
|
|
165
|
+
disabled: {
|
|
166
|
+
default: colors.gray[600],
|
|
167
|
+
secondary: colors.gray[700],
|
|
168
|
+
onDisabled: colors.gray[400],
|
|
169
|
+
onDisabledSecondary: colors.gray[500],
|
|
170
|
+
},
|
|
171
|
+
utilities: {
|
|
172
|
+
onOverlay: alphas.white[800],
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
border: {
|
|
176
|
+
default: {
|
|
177
|
+
default: colors.slate[800],
|
|
178
|
+
secondary: colors.slate[700],
|
|
179
|
+
tertiary: colors.slate[500],
|
|
180
|
+
subtleLow: alphas.black[800],
|
|
181
|
+
subtleMedium: alphas.slate[200],
|
|
182
|
+
subtleHigh: alphas.black[400],
|
|
183
|
+
},
|
|
184
|
+
brand: {
|
|
185
|
+
default: colors.purple[700],
|
|
186
|
+
secondary: colors.purple[600],
|
|
187
|
+
tertiary: colors.purple[800],
|
|
188
|
+
onBrand: colors.purple[950],
|
|
189
|
+
onBrandSecondary: colors.purple[200],
|
|
190
|
+
onBrandTertiary: colors.purple[400],
|
|
191
|
+
},
|
|
192
|
+
action: {
|
|
193
|
+
default: colors.violet[600],
|
|
194
|
+
secondary: colors.violet[700],
|
|
195
|
+
tertiary: colors.violet[800],
|
|
196
|
+
onAction: colors.violet[950],
|
|
197
|
+
onActionSecondary: colors.violet[300],
|
|
198
|
+
onActionTertiary: colors.violet[200],
|
|
199
|
+
},
|
|
200
|
+
success: {
|
|
201
|
+
default: colors.green[300],
|
|
202
|
+
secondary: colors.green[400],
|
|
203
|
+
tertiary: colors.green[500],
|
|
204
|
+
},
|
|
205
|
+
warning: {
|
|
206
|
+
default: colors.yellow[300],
|
|
207
|
+
secondary: colors.yellow[400],
|
|
208
|
+
tertiary: colors.yellow[500],
|
|
209
|
+
},
|
|
210
|
+
danger: {
|
|
211
|
+
default: colors.red[500],
|
|
212
|
+
secondary: colors.red[600],
|
|
213
|
+
tertiary: colors.red[800],
|
|
214
|
+
onDanger: colors.red[400],
|
|
215
|
+
},
|
|
216
|
+
info: {
|
|
217
|
+
default: colors.blue[500],
|
|
218
|
+
secondary: colors.blue[600],
|
|
219
|
+
tertiary: colors.blue[800],
|
|
220
|
+
},
|
|
221
|
+
neutral: {
|
|
222
|
+
default: colors.slate[300],
|
|
223
|
+
secondary: colors.slate[500],
|
|
224
|
+
tertiary: colors.slate[700],
|
|
225
|
+
onNeutral: colors.slate[950],
|
|
226
|
+
onNeutralSecondary: colors.slate[200],
|
|
227
|
+
onNeutralTertiary: colors.slate[300],
|
|
228
|
+
},
|
|
229
|
+
disabled: {
|
|
230
|
+
default: colors.gray[700],
|
|
231
|
+
},
|
|
232
|
+
utilities: {
|
|
233
|
+
swatch: 'rgba(255, 255, 255, 0.24)',
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
icon: {
|
|
237
|
+
default: {
|
|
238
|
+
default: colors.slate[100],
|
|
239
|
+
secondary: colors.slate[400],
|
|
240
|
+
tertiary: colors.slate[600],
|
|
241
|
+
},
|
|
242
|
+
brand: {
|
|
243
|
+
default: colors.purple[300],
|
|
244
|
+
secondary: colors.purple[400],
|
|
245
|
+
tertiary: colors.purple[500],
|
|
246
|
+
onBrand: colors.purple[950],
|
|
247
|
+
onBrandSecondary: colors.purple[200],
|
|
248
|
+
onBrandTertiary: colors.purple[300],
|
|
249
|
+
},
|
|
250
|
+
action: {
|
|
251
|
+
default: colors.violet[400],
|
|
252
|
+
secondary: colors.violet[500],
|
|
253
|
+
tertiary: colors.violet[700],
|
|
254
|
+
onAction: colors.violet[950],
|
|
255
|
+
onActionSecondary: colors.violet[200],
|
|
256
|
+
onActionTertiary: colors.violet[300],
|
|
257
|
+
},
|
|
258
|
+
success: {
|
|
259
|
+
default: colors.green[400],
|
|
260
|
+
secondary: colors.green[600],
|
|
261
|
+
tertiary: colors.green[800],
|
|
262
|
+
onSuccess: colors.green[950],
|
|
263
|
+
onSuccessSecondary: colors.green[200],
|
|
264
|
+
onSuccessTertiary: colors.green[300],
|
|
265
|
+
},
|
|
266
|
+
warning: {
|
|
267
|
+
default: colors.yellow[400],
|
|
268
|
+
secondary: colors.yellow[600],
|
|
269
|
+
tertiary: colors.yellow[800],
|
|
270
|
+
onWarning: colors.yellow[950],
|
|
271
|
+
onWarningSecondary: colors.yellow[200],
|
|
272
|
+
onWarningTertiary: colors.yellow[300],
|
|
273
|
+
},
|
|
274
|
+
danger: {
|
|
275
|
+
default: colors.red[400],
|
|
276
|
+
secondary: colors.red[500],
|
|
277
|
+
tertiary: colors.red[600],
|
|
278
|
+
onDanger: colors.red[950],
|
|
279
|
+
onDangerSecondary: colors.red[200],
|
|
280
|
+
onDangerTertiary: colors.red[300],
|
|
281
|
+
},
|
|
282
|
+
info: {
|
|
283
|
+
default: colors.blue[400],
|
|
284
|
+
secondary: colors.blue[600],
|
|
285
|
+
tertiary: colors.blue[800],
|
|
286
|
+
onInfo: colors.blue[950],
|
|
287
|
+
onInfoSecondary: colors.blue[200],
|
|
288
|
+
onInfoTertiary: colors.blue[300],
|
|
289
|
+
},
|
|
290
|
+
neutral: {
|
|
291
|
+
default: colors.slate[100],
|
|
292
|
+
secondary: colors.slate[400],
|
|
293
|
+
tertiary: colors.slate[600],
|
|
294
|
+
onNeutral: colors.slate[950],
|
|
295
|
+
onNeutralSecondary: colors.slate[200],
|
|
296
|
+
onNeutralTertiary: colors.slate[300],
|
|
297
|
+
},
|
|
298
|
+
disabled: {
|
|
299
|
+
default: colors.gray[600],
|
|
300
|
+
secondary: colors.gray[700],
|
|
301
|
+
onDisabled: colors.gray[400],
|
|
302
|
+
onDisabledSecondary: colors.gray[500],
|
|
303
|
+
},
|
|
304
|
+
utilities: {
|
|
305
|
+
onOverlay: alphas.white[800],
|
|
306
|
+
},
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
} as const;
|
|
310
|
+
|
|
311
|
+
export type DarkTheme = typeof darkTheme;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Light Theme
|
|
3
|
+
* Default light mode color scheme
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { background, text, border, icon } from '../semantic/colors';
|
|
7
|
+
|
|
8
|
+
export const lightTheme = {
|
|
9
|
+
color: {
|
|
10
|
+
background,
|
|
11
|
+
text,
|
|
12
|
+
border,
|
|
13
|
+
icon,
|
|
14
|
+
},
|
|
15
|
+
} as const;
|
|
16
|
+
|
|
17
|
+
export type LightTheme = typeof lightTheme;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSS Custom Properties Generator
|
|
3
|
+
* Converts design tokens to CSS variables for runtime theming
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { Theme } from '../index';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Flattens nested object into CSS variable names
|
|
10
|
+
*/
|
|
11
|
+
function flattenObject(
|
|
12
|
+
obj: any,
|
|
13
|
+
prefix = '',
|
|
14
|
+
result: Record<string, string> = {}
|
|
15
|
+
): Record<string, string> {
|
|
16
|
+
for (const key in obj) {
|
|
17
|
+
const value = obj[key];
|
|
18
|
+
const newKey = prefix ? `${prefix}-${kebabCase(key)}` : kebabCase(key);
|
|
19
|
+
|
|
20
|
+
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
21
|
+
flattenObject(value, newKey, result);
|
|
22
|
+
} else {
|
|
23
|
+
result[`--${newKey}`] = String(value);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Converts camelCase to kebab-case
|
|
32
|
+
*/
|
|
33
|
+
function kebabCase(str: string): string {
|
|
34
|
+
return str
|
|
35
|
+
.replace(/([a-z])([A-Z])/g, '$1-$2')
|
|
36
|
+
.replace(/[\s_]+/g, '-')
|
|
37
|
+
.toLowerCase();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Generates CSS custom properties from theme object
|
|
42
|
+
*/
|
|
43
|
+
export function generateCSSVariables(theme: Theme): Record<string, string> {
|
|
44
|
+
return flattenObject(theme);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Applies CSS variables to a DOM element (usually :root or a container)
|
|
49
|
+
*/
|
|
50
|
+
export function applyCSSVariables(
|
|
51
|
+
element: HTMLElement,
|
|
52
|
+
variables: Record<string, string>
|
|
53
|
+
): void {
|
|
54
|
+
for (const [key, value] of Object.entries(variables)) {
|
|
55
|
+
element.style.setProperty(key, value);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Removes CSS variables from a DOM element
|
|
61
|
+
*/
|
|
62
|
+
export function removeCSSVariables(
|
|
63
|
+
element: HTMLElement,
|
|
64
|
+
variables: Record<string, string>
|
|
65
|
+
): void {
|
|
66
|
+
for (const key of Object.keys(variables)) {
|
|
67
|
+
element.style.removeProperty(key);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Gets current value of a CSS variable
|
|
73
|
+
*/
|
|
74
|
+
export function getCSSVariable(name: string, element: HTMLElement = document.documentElement): string {
|
|
75
|
+
return getComputedStyle(element).getPropertyValue(name).trim();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Generates a CSS string with all variables
|
|
80
|
+
*/
|
|
81
|
+
export function generateCSSString(theme: Theme, selector = ':root'): string {
|
|
82
|
+
const variables = generateCSSVariables(theme);
|
|
83
|
+
const cssVars = Object.entries(variables)
|
|
84
|
+
.map(([key, value]) => ` ${key}: ${value};`)
|
|
85
|
+
.join('\n');
|
|
86
|
+
|
|
87
|
+
return `${selector} {\n${cssVars}\n}`;
|
|
88
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Hooks for Design Tokens
|
|
3
|
+
* Provides easy access to tokens and theming in React components
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { useState, useEffect, useCallback, useMemo } from 'react';
|
|
7
|
+
import { tokens, themes, type ThemeMode, type Theme } from '../index';
|
|
8
|
+
import { applyCSSVariables, generateCSSVariables } from './cssVariables';
|
|
9
|
+
|
|
10
|
+
const THEME_STORAGE_KEY = 'squarex-ui-theme';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Hook to access design tokens
|
|
14
|
+
* @returns The tokens object
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const MyComponent = () => {
|
|
18
|
+
* const tokens = useTokens();
|
|
19
|
+
* return <div style={{ color: tokens.color.text.brand.default }}>Hello</div>;
|
|
20
|
+
* };
|
|
21
|
+
*/
|
|
22
|
+
export function useTokens() {
|
|
23
|
+
return tokens;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Hook for theme management
|
|
28
|
+
* @param defaultTheme - The default theme mode ('light' or 'dark')
|
|
29
|
+
* @param persist - Whether to persist theme preference to localStorage
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* const MyApp = () => {
|
|
33
|
+
* const { theme, themeMode, setTheme, toggleTheme } = useTheme('light', true);
|
|
34
|
+
*
|
|
35
|
+
* return (
|
|
36
|
+
* <div>
|
|
37
|
+
* <p>Current theme: {themeMode}</p>
|
|
38
|
+
* <button onClick={toggleTheme}>Toggle Theme</button>
|
|
39
|
+
* </div>
|
|
40
|
+
* );
|
|
41
|
+
* };
|
|
42
|
+
*/
|
|
43
|
+
export function useTheme(defaultTheme: ThemeMode = 'light', persist: boolean = true) {
|
|
44
|
+
// Initialize theme from localStorage or default
|
|
45
|
+
const [themeMode, setThemeMode] = useState<ThemeMode>(() => {
|
|
46
|
+
if (persist && typeof window !== 'undefined') {
|
|
47
|
+
const stored = localStorage.getItem(THEME_STORAGE_KEY) as ThemeMode | null;
|
|
48
|
+
return stored || defaultTheme;
|
|
49
|
+
}
|
|
50
|
+
return defaultTheme;
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Get current theme object
|
|
54
|
+
const theme = useMemo<Theme>(() => themes[themeMode], [themeMode]);
|
|
55
|
+
|
|
56
|
+
// Apply theme to document root
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (typeof window === 'undefined') return;
|
|
59
|
+
|
|
60
|
+
const cssVariables = generateCSSVariables(theme);
|
|
61
|
+
applyCSSVariables(document.documentElement, cssVariables);
|
|
62
|
+
|
|
63
|
+
// Add data attribute for CSS selectors
|
|
64
|
+
document.documentElement.setAttribute('data-theme', themeMode);
|
|
65
|
+
|
|
66
|
+
// Persist to localStorage
|
|
67
|
+
if (persist) {
|
|
68
|
+
localStorage.setItem(THEME_STORAGE_KEY, themeMode);
|
|
69
|
+
}
|
|
70
|
+
}, [theme, themeMode, persist]);
|
|
71
|
+
|
|
72
|
+
// Set theme mode
|
|
73
|
+
const setTheme = useCallback((mode: ThemeMode) => {
|
|
74
|
+
setThemeMode(mode);
|
|
75
|
+
}, []);
|
|
76
|
+
|
|
77
|
+
// Toggle between light and dark
|
|
78
|
+
const toggleTheme = useCallback(() => {
|
|
79
|
+
setThemeMode((current) => (current === 'light' ? 'dark' : 'light'));
|
|
80
|
+
}, []);
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
theme,
|
|
84
|
+
themeMode,
|
|
85
|
+
setTheme,
|
|
86
|
+
toggleTheme,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Hook to detect system color scheme preference
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* const MyApp = () => {
|
|
95
|
+
* const prefersDark = usePrefersDarkMode();
|
|
96
|
+
* const { setTheme } = useTheme();
|
|
97
|
+
*
|
|
98
|
+
* useEffect(() => {
|
|
99
|
+
* setTheme(prefersDark ? 'dark' : 'light');
|
|
100
|
+
* }, [prefersDark, setTheme]);
|
|
101
|
+
* };
|
|
102
|
+
*/
|
|
103
|
+
export function usePrefersDarkMode(): boolean {
|
|
104
|
+
const [prefersDark, setPrefersDark] = useState<boolean>(() => {
|
|
105
|
+
if (typeof window === 'undefined') return false;
|
|
106
|
+
return window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
if (typeof window === 'undefined') return;
|
|
111
|
+
|
|
112
|
+
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
|
113
|
+
const handler = (e: MediaQueryListEvent) => setPrefersDark(e.matches);
|
|
114
|
+
|
|
115
|
+
// Modern browsers
|
|
116
|
+
if (mediaQuery.addEventListener) {
|
|
117
|
+
mediaQuery.addEventListener('change', handler);
|
|
118
|
+
return () => mediaQuery.removeEventListener('change', handler);
|
|
119
|
+
}
|
|
120
|
+
// Legacy browsers
|
|
121
|
+
else if (mediaQuery.addListener) {
|
|
122
|
+
mediaQuery.addListener(handler);
|
|
123
|
+
return () => mediaQuery.removeListener(handler);
|
|
124
|
+
}
|
|
125
|
+
}, []);
|
|
126
|
+
|
|
127
|
+
return prefersDark;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Hook to get responsive breakpoint information
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* const MyComponent = () => {
|
|
135
|
+
* const { isMobile, isTablet, isDesktop } = useBreakpoint();
|
|
136
|
+
*
|
|
137
|
+
* return (
|
|
138
|
+
* <div>
|
|
139
|
+
* {isMobile && <MobileNav />}
|
|
140
|
+
* {isDesktop && <DesktopNav />}
|
|
141
|
+
* </div>
|
|
142
|
+
* );
|
|
143
|
+
* };
|
|
144
|
+
*/
|
|
145
|
+
export function useBreakpoint() {
|
|
146
|
+
const [breakpoint, setBreakpoint] = useState<{
|
|
147
|
+
isMobile: boolean;
|
|
148
|
+
isTablet: boolean;
|
|
149
|
+
isDesktop: boolean;
|
|
150
|
+
isWide: boolean;
|
|
151
|
+
width: number;
|
|
152
|
+
}>(() => {
|
|
153
|
+
if (typeof window === 'undefined') {
|
|
154
|
+
return {
|
|
155
|
+
isMobile: false,
|
|
156
|
+
isTablet: false,
|
|
157
|
+
isDesktop: false,
|
|
158
|
+
isWide: false,
|
|
159
|
+
width: 0,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const width = window.innerWidth;
|
|
164
|
+
return {
|
|
165
|
+
isMobile: width >= tokens.breakpoint.mobile && width < tokens.breakpoint.tablet,
|
|
166
|
+
isTablet: width >= tokens.breakpoint.tablet && width < tokens.breakpoint.desktop,
|
|
167
|
+
isDesktop: width >= tokens.breakpoint.desktop && width < tokens.breakpoint.wide,
|
|
168
|
+
isWide: width >= tokens.breakpoint.wide,
|
|
169
|
+
width,
|
|
170
|
+
};
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
useEffect(() => {
|
|
174
|
+
if (typeof window === 'undefined') return;
|
|
175
|
+
|
|
176
|
+
const handleResize = () => {
|
|
177
|
+
const width = window.innerWidth;
|
|
178
|
+
setBreakpoint({
|
|
179
|
+
isMobile: width >= tokens.breakpoint.mobile && width < tokens.breakpoint.tablet,
|
|
180
|
+
isTablet: width >= tokens.breakpoint.tablet && width < tokens.breakpoint.desktop,
|
|
181
|
+
isDesktop: width >= tokens.breakpoint.desktop && width < tokens.breakpoint.wide,
|
|
182
|
+
isWide: width >= tokens.breakpoint.wide,
|
|
183
|
+
width,
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
window.addEventListener('resize', handleResize);
|
|
188
|
+
return () => window.removeEventListener('resize', handleResize);
|
|
189
|
+
}, []);
|
|
190
|
+
|
|
191
|
+
return breakpoint;
|
|
192
|
+
}
|