@vygruppen/spor-react 1.3.3 → 2.0.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 (197) hide show
  1. package/.turbo/turbo-build.log +12 -10
  2. package/CHANGELOG.md +40 -0
  3. package/README.md +1 -1
  4. package/dist/index.d.ts +6718 -27
  5. package/dist/index.js +14139 -140
  6. package/dist/index.mjs +13818 -27
  7. package/package.json +19 -31
  8. package/src/accordion/Accordion.test.tsx +20 -0
  9. package/src/accordion/Accordion.tsx +62 -0
  10. package/src/accordion/AccordionContext.tsx +27 -0
  11. package/src/accordion/Expandable.tsx +157 -0
  12. package/src/accordion/index.tsx +2 -0
  13. package/src/alert/AlertIcon.tsx +75 -0
  14. package/src/alert/BaseAlert.test.tsx +37 -0
  15. package/src/alert/BaseAlert.tsx +21 -0
  16. package/src/alert/ClosableAlert.test.tsx +37 -0
  17. package/src/alert/ClosableAlert.tsx +75 -0
  18. package/src/alert/ExpandableAlert.test.tsx +84 -0
  19. package/src/alert/ExpandableAlert.tsx +84 -0
  20. package/src/alert/StaticAlert.tsx +25 -0
  21. package/src/alert/index.tsx +3 -0
  22. package/src/button/Button.test.tsx +23 -0
  23. package/src/button/Button.tsx +162 -0
  24. package/src/button/ButtonGroup.tsx +43 -0
  25. package/src/button/CloseButton.tsx +63 -0
  26. package/src/button/FloatingActionButton.tsx +113 -0
  27. package/src/button/IconButton.tsx +63 -0
  28. package/src/button/index.tsx +5 -0
  29. package/src/card/Card.tsx +59 -0
  30. package/src/card/index.tsx +1 -0
  31. package/src/datepicker/Calendar.tsx +32 -0
  32. package/src/datepicker/CalendarCell.tsx +74 -0
  33. package/src/datepicker/CalendarGrid.tsx +76 -0
  34. package/src/datepicker/CalendarHeader.tsx +153 -0
  35. package/src/datepicker/CalendarNavigationButton.tsx +26 -0
  36. package/src/datepicker/CalendarTriggerButton.tsx +36 -0
  37. package/src/datepicker/DateField.tsx +51 -0
  38. package/src/datepicker/DatePicker.tsx +153 -0
  39. package/src/datepicker/DateRangePicker.tsx +165 -0
  40. package/src/datepicker/DateTimeSegment.tsx +56 -0
  41. package/src/datepicker/RangeCalendar.tsx +35 -0
  42. package/src/datepicker/StyledField.tsx +31 -0
  43. package/src/datepicker/TimeField.tsx +46 -0
  44. package/src/datepicker/TimePicker.test.tsx +74 -0
  45. package/src/datepicker/TimePicker.tsx +196 -0
  46. package/src/datepicker/index.tsx +4 -0
  47. package/src/datepicker/utils.ts +33 -0
  48. package/src/i18n/index.tsx +38 -0
  49. package/src/image/index.tsx +2 -0
  50. package/src/index.tsx +25 -26
  51. package/src/input/CardSelect.tsx +165 -0
  52. package/src/input/Checkbox.tsx +24 -0
  53. package/src/input/CheckboxGroup.tsx +43 -0
  54. package/src/input/ChoiceChip.tsx +102 -0
  55. package/src/input/Dialog.tsx +29 -0
  56. package/src/input/FormControl.tsx +11 -0
  57. package/src/input/FormErrorMessage.tsx +91 -0
  58. package/src/input/FormLabel.tsx +11 -0
  59. package/src/input/InfoSelect.tsx +209 -0
  60. package/src/input/Input.tsx +59 -0
  61. package/src/input/InputElement.tsx +45 -0
  62. package/src/input/ListBox.tsx +123 -0
  63. package/src/input/NativeSelect.tsx +38 -0
  64. package/src/input/PasswordInput.tsx +70 -0
  65. package/src/input/Popover.tsx +70 -0
  66. package/src/input/Radio.tsx +34 -0
  67. package/src/input/RadioGroup.tsx +47 -0
  68. package/src/input/SearchInput.tsx +89 -0
  69. package/src/input/Switch.tsx +40 -0
  70. package/src/input/Textarea.tsx +98 -0
  71. package/src/input/index.tsx +20 -0
  72. package/src/layout/Divider.tsx +26 -0
  73. package/src/layout/Stack.tsx +42 -0
  74. package/src/layout/index.tsx +28 -0
  75. package/src/linjetag/InfoTag.tsx +54 -0
  76. package/src/linjetag/LineIcon.tsx +44 -0
  77. package/src/linjetag/TravelTag.tsx +121 -0
  78. package/src/linjetag/icons.tsx +80 -0
  79. package/src/linjetag/index.tsx +3 -0
  80. package/src/linjetag/types.d.ts +24 -0
  81. package/src/link/TextLink.tsx +45 -0
  82. package/src/link/index.tsx +1 -0
  83. package/src/loader/ClientOnly.tsx +29 -0
  84. package/src/loader/ColorInlineLoader.tsx +27 -0
  85. package/src/loader/ColorSpinner.tsx +44 -0
  86. package/src/loader/ContentLoader.tsx +27 -0
  87. package/src/loader/DarkFullScreenLoader.tsx +23 -0
  88. package/src/loader/DarkInlineLoader.tsx +25 -0
  89. package/src/loader/DarkSpinner.tsx +43 -0
  90. package/src/loader/LightFullScreenLoader.tsx +23 -0
  91. package/src/loader/LightInlineLoader.tsx +25 -0
  92. package/src/loader/LightSpinner.tsx +41 -0
  93. package/src/loader/Lottie.tsx +10 -0
  94. package/src/loader/ProgressBar.tsx +128 -0
  95. package/src/loader/ProgressLoader.tsx +140 -0
  96. package/src/loader/Skeleton.tsx +16 -0
  97. package/src/loader/SkeletonCircle.tsx +13 -0
  98. package/src/loader/SkeletonText.tsx +10 -0
  99. package/src/loader/index.tsx +14 -0
  100. package/src/loader/useHydrated.tsx +34 -0
  101. package/src/loader/useRotatingLabel.tsx +22 -0
  102. package/src/logo/VyLogo.tsx +101 -0
  103. package/src/logo/index.tsx +1 -0
  104. package/src/media-controller/JumpButton.tsx +69 -0
  105. package/src/media-controller/PlayPauseButton.tsx +67 -0
  106. package/src/media-controller/SkipButton.tsx +66 -0
  107. package/src/media-controller/icons.tsx +80 -0
  108. package/src/media-controller/index.test.tsx +59 -0
  109. package/src/media-controller/index.tsx +3 -0
  110. package/src/modal/Drawer.tsx +122 -0
  111. package/src/modal/Modal.tsx +15 -0
  112. package/src/modal/ModalHeader.tsx +31 -0
  113. package/src/modal/SimpleDrawer.tsx +44 -0
  114. package/src/modal/index.tsx +4 -0
  115. package/src/popover/PopoverWizardBody.tsx +91 -0
  116. package/src/popover/SimplePopover.tsx +75 -0
  117. package/src/popover/WizardPopover.tsx +61 -0
  118. package/src/popover/index.tsx +23 -0
  119. package/src/provider/SporProvider.tsx +67 -0
  120. package/src/provider/index.tsx +1 -0
  121. package/src/stepper/Stepper.tsx +115 -0
  122. package/src/stepper/StepperContext.tsx +55 -0
  123. package/src/stepper/StepperStep.tsx +48 -0
  124. package/src/stepper/index.tsx +2 -0
  125. package/src/tab/Tabs.tsx +20 -0
  126. package/src/tab/index.tsx +9 -0
  127. package/src/table/Table.tsx +58 -0
  128. package/src/table/index.tsx +19 -0
  129. package/src/theme/components/accordion.ts +143 -0
  130. package/src/theme/components/alert.ts +59 -0
  131. package/src/theme/components/badge.ts +109 -0
  132. package/src/theme/components/button.ts +217 -0
  133. package/src/theme/components/card-select.ts +158 -0
  134. package/src/theme/components/card.ts +174 -0
  135. package/src/theme/components/checkbox.ts +90 -0
  136. package/src/theme/components/choice-chip.ts +79 -0
  137. package/src/theme/components/close-button.ts +56 -0
  138. package/src/theme/components/code.ts +17 -0
  139. package/src/theme/components/datepicker.ts +194 -0
  140. package/src/theme/components/drawer.ts +92 -0
  141. package/src/theme/components/fab.ts +111 -0
  142. package/src/theme/components/form-label.ts +17 -0
  143. package/src/theme/components/form.ts +27 -0
  144. package/src/theme/components/index.ts +34 -0
  145. package/src/theme/components/info-select.ts +91 -0
  146. package/src/theme/components/info-tag.ts +49 -0
  147. package/src/theme/components/input.ts +97 -0
  148. package/src/theme/components/line-icon.ts +121 -0
  149. package/src/theme/components/link.ts +155 -0
  150. package/src/theme/components/listbox.ts +52 -0
  151. package/src/theme/components/media-controller-button.ts +134 -0
  152. package/src/theme/components/modal.ts +93 -0
  153. package/src/theme/components/popover.ts +63 -0
  154. package/src/theme/components/radio.ts +64 -0
  155. package/src/theme/components/select.ts +52 -0
  156. package/src/theme/components/skeleton.ts +40 -0
  157. package/src/theme/components/stepper.ts +230 -0
  158. package/src/theme/components/switch.ts +227 -0
  159. package/src/theme/components/table.ts +163 -0
  160. package/src/theme/components/tabs.ts +282 -0
  161. package/src/theme/components/textarea.ts +14 -0
  162. package/src/theme/components/toast.ts +28 -0
  163. package/src/theme/components/travel-tag.ts +267 -0
  164. package/src/theme/font-faces.ts +66 -0
  165. package/src/theme/foundations/borders.ts +11 -0
  166. package/src/theme/foundations/breakpoints.ts +9 -0
  167. package/src/theme/foundations/colors.ts +10 -0
  168. package/src/theme/foundations/config.ts +5 -0
  169. package/src/theme/foundations/fontSizes.ts +29 -0
  170. package/src/theme/foundations/fontWeights.ts +5 -0
  171. package/src/theme/foundations/fonts.ts +7 -0
  172. package/src/theme/foundations/index.ts +14 -0
  173. package/src/theme/foundations/lineHeights.ts +5 -0
  174. package/src/theme/foundations/radii.ts +12 -0
  175. package/src/theme/foundations/shadows.ts +8 -0
  176. package/src/theme/foundations/sizes.ts +34 -0
  177. package/src/theme/foundations/spacing.ts +30 -0
  178. package/src/theme/foundations/textStyles.ts +60 -0
  179. package/src/theme/foundations/zIndices.ts +17 -0
  180. package/src/theme/index.ts +14 -0
  181. package/src/theme/utils/box-shadow-utils.ts +44 -0
  182. package/src/theme/utils/focus-utils.ts +16 -0
  183. package/src/toast/ActionToast.test.tsx +22 -0
  184. package/src/toast/ActionToast.tsx +28 -0
  185. package/src/toast/BaseToast.test.tsx +27 -0
  186. package/src/toast/BaseToast.tsx +75 -0
  187. package/src/toast/ClosableToast.test.tsx +17 -0
  188. package/src/toast/ClosableToast.tsx +40 -0
  189. package/src/toast/index.tsx +1 -0
  190. package/src/toast/useToast.tsx +99 -0
  191. package/src/typography/Badge.tsx +68 -0
  192. package/src/typography/Code.tsx +32 -0
  193. package/src/typography/Heading.tsx +32 -0
  194. package/src/typography/Text.tsx +26 -0
  195. package/src/typography/index.tsx +4 -0
  196. package/src/util/externals.tsx +23 -0
  197. package/src/util/index.tsx +1 -0
@@ -0,0 +1,267 @@
1
+ import { createMultiStyleConfigHelpers } from "@chakra-ui/react";
2
+ import type { StyleFunctionProps } from "@chakra-ui/theme-tools";
3
+ import { anatomy } from "@chakra-ui/theme-tools";
4
+ import { getBoxShadowString } from "../utils/box-shadow-utils";
5
+ import { focusVisible } from "../utils/focus-utils";
6
+
7
+ const parts = anatomy("travel-tag").parts(
8
+ "container",
9
+ "iconContainer",
10
+ "icon",
11
+ "textContainer",
12
+ "title",
13
+ "description",
14
+ "deviationIcon"
15
+ );
16
+
17
+ const helpers = createMultiStyleConfigHelpers(parts.keys);
18
+
19
+ const config = helpers.defineMultiStyleConfig({
20
+ baseStyle: (props) => ({
21
+ container: {
22
+ position: "relative",
23
+ display: "flex",
24
+ alignItems: "center",
25
+ padding: 0.5,
26
+ width: "fit-content",
27
+ ...getDeviationContainerStyle(props),
28
+ transitionDuration: "fast",
29
+ transitionProperty: "common",
30
+ _disabled: {
31
+ backgroundColor: "silver",
32
+ },
33
+ "button&, a&": {
34
+ _hover: {
35
+ boxShadow: getBoxShadowString({
36
+ borderColor: props.theme.colors.blackAlpha[100],
37
+ baseShadow: "sm",
38
+ }),
39
+ },
40
+ ...focusVisible({
41
+ focus: {
42
+ outline: "none",
43
+ borderColor: "transparent",
44
+ boxShadow: getBoxShadowString({
45
+ borderWidth: 2,
46
+ borderColor: "darkGrey",
47
+ }),
48
+ },
49
+ notFocus: {
50
+ boxShadow: "none",
51
+ borderColor: getDeviationBorderColor(props),
52
+ },
53
+ }),
54
+ _active: {
55
+ opacity: 0.5,
56
+ boxShadow: "none",
57
+ },
58
+ },
59
+ },
60
+ iconContainer: {
61
+ padding: 0.5,
62
+ "[aria-disabled=true] &": {
63
+ backgroundColor: "osloGrey",
64
+ color: "white",
65
+ },
66
+ },
67
+ textContainer: {
68
+ color: "darkGrey",
69
+ paddingRight: 0.5,
70
+ whiteSpace: "nowrap",
71
+ "[aria-disabled=true] &": {
72
+ color: "dimGrey",
73
+ },
74
+ },
75
+ title: {
76
+ fontWeight: "bold",
77
+ },
78
+ description: {
79
+ fontWeight: "normal",
80
+ },
81
+ deviationIcon: {
82
+ ...getDeviationIconStyle(props),
83
+ },
84
+ }),
85
+ variants: {
86
+ "local-train": {
87
+ container: {
88
+ backgroundColor: "linjetag.lokaltogLight",
89
+ },
90
+ },
91
+ "region-train": {
92
+ container: {
93
+ backgroundColor: "linjetag.regiontogLight",
94
+ },
95
+ },
96
+ "region-express-train": {
97
+ container: {
98
+ backgroundColor: "linjetag.regionEkspressLight",
99
+ },
100
+ },
101
+ "long-distance-train": {
102
+ container: {
103
+ backgroundColor: "linjetag.fjerntogLight",
104
+ },
105
+ },
106
+ "airport-express-train": {
107
+ container: {
108
+ backgroundColor: "linjetag.flytogLight",
109
+ },
110
+ },
111
+ "vy-bus": {
112
+ container: {
113
+ backgroundColor: "linjetag.vyBussLight",
114
+ },
115
+ },
116
+ "local-bus": {
117
+ container: {
118
+ backgroundColor: "linjetag.lokalbussLight",
119
+ },
120
+ },
121
+ ferry: {
122
+ container: {
123
+ backgroundColor: "linjetag.fergeLight",
124
+ },
125
+ },
126
+ subway: {
127
+ container: {
128
+ backgroundColor: "linjetag.tbaneLight",
129
+ },
130
+ },
131
+ tram: {
132
+ container: {
133
+ backgroundColor: "linjetag.trikkLight",
134
+ },
135
+ },
136
+ "alt-transport": {
137
+ container: {
138
+ backgroundColor: "linjetag.altTransportLight",
139
+ },
140
+ },
141
+ walk: {
142
+ container: {
143
+ backgroundColor: "white",
144
+ _disabled: {
145
+ backgroundColor: "white",
146
+ },
147
+ },
148
+ iconContainer: {
149
+ border: "none",
150
+ position: "relative",
151
+ left: -1,
152
+ "[aria-disabled=true] &": {
153
+ backgroundColor: "transparent",
154
+ color: "osloGrey",
155
+ },
156
+ },
157
+ textContainer: {
158
+ position: "absolute",
159
+ left: 2,
160
+ bottom: -0.5,
161
+ "[aria-disabled=true] &": {
162
+ color: "osloGrey",
163
+ },
164
+ },
165
+ title: {
166
+ fontSize: "mobile.xs",
167
+ fontWeight: "normal",
168
+ },
169
+ description: {
170
+ display: "none",
171
+ },
172
+ },
173
+ },
174
+ sizes: {
175
+ sm: {
176
+ container: {
177
+ borderRadius: "sm",
178
+ },
179
+ iconContainer: {
180
+ borderRadius: "xs",
181
+ },
182
+ textContainer: {
183
+ marginLeft: 1,
184
+ fontSize: "mobile.sm",
185
+ },
186
+ },
187
+ md: {
188
+ container: {
189
+ borderRadius: "sm",
190
+ },
191
+ iconContainer: {
192
+ borderRadius: "0.5625rem", // 9px
193
+ },
194
+ textContainer: {
195
+ marginLeft: 1.5,
196
+ fontSize: "mobile.sm",
197
+ },
198
+ },
199
+ lg: {
200
+ container: {
201
+ borderRadius: "sm",
202
+ },
203
+ iconContainer: {
204
+ borderRadius: "0.5625rem", // 9px
205
+ },
206
+ textContainer: {
207
+ marginLeft: 2,
208
+ fontSize: "mobile.md",
209
+ },
210
+ },
211
+ },
212
+ defaultProps: {
213
+ size: "md",
214
+ },
215
+ });
216
+
217
+ export default config;
218
+
219
+ const getDeviationContainerStyle = (props: StyleFunctionProps) => {
220
+ switch (props.deviationLevel) {
221
+ case "critical":
222
+ return {
223
+ border: "1px solid",
224
+ borderColor: getDeviationBorderColor(props),
225
+ };
226
+ case "major":
227
+ return {
228
+ border: "1px solid",
229
+ borderColor: getDeviationBorderColor(props),
230
+ };
231
+ default:
232
+ return {};
233
+ }
234
+ };
235
+
236
+ const getDeviationBorderColor = (props: StyleFunctionProps) => {
237
+ switch (props.deviationLevel) {
238
+ case "critical":
239
+ return "brightRed";
240
+ case "major":
241
+ return "golden";
242
+ default:
243
+ return "transparent";
244
+ }
245
+ };
246
+
247
+ const getDeviationIconStyle = (props: StyleFunctionProps) => {
248
+ return {
249
+ position: "absolute",
250
+ top: "0",
251
+ right: "0",
252
+ transform: "translate(50%, -50%)",
253
+ zIndex: "banner",
254
+ stroke: "white",
255
+ color:
256
+ deviationIconColor[
257
+ props.deviationLevel as keyof typeof deviationIconColor
258
+ ] || "inherit",
259
+ };
260
+ };
261
+
262
+ const deviationIconColor = {
263
+ critical: "brightRed",
264
+ major: "golden",
265
+ minor: "golden",
266
+ info: "ocean",
267
+ } as const;
@@ -0,0 +1,66 @@
1
+ import tokens from "@vygruppen/spor-design-tokens";
2
+
3
+ /** A string of CSS that should be injected in the global CSS space */
4
+ export const fontFaces = `
5
+ @font-face {
6
+ font-family: ${tokens.asset.font["vy-sans"]["light"].name};
7
+ src: url("https://www.vy.no/styles/font/VySans-Light.woff2") format("woff2"),
8
+ url("https://www.vy.no/styles/font/VySans-Light.woff") format("woff");
9
+ font-style: normal;
10
+ font-weight: 300;
11
+ font-display: swap
12
+ }
13
+ @font-face {
14
+ font-family: ${tokens.asset.font["vy-sans"]["light-italic"].name};
15
+ src: url("https://www.vy.no/styles/font/VySans-LightItalic.woff2")
16
+ format("woff2"),
17
+ url("https://www.vy.no/styles/font/VySans-LightItalic.woff") format("woff");
18
+ font-style: italic;
19
+ font-weight: 300;
20
+ font-display: swap
21
+ }
22
+ @font-face {
23
+ font-family: ${tokens.asset.font["vy-sans"]["medium"].name};
24
+ src: url("https://www.vy.no/styles/font/VySans-Regular.woff2") format("woff2"),
25
+ url("https://www.vy.no/styles/font/VySans-Regular.woff") format("woff");
26
+ font-style: normal;
27
+ font-weight: 400;
28
+ font-display: swap
29
+ }
30
+ @font-face {
31
+ font-family: ${tokens.asset.font["vy-sans"]["medium-italic"].name}
32
+ src: url("https://www.vy.no/styles/font/VySans-RegularItalic.woff2")
33
+ format("woff2"),
34
+ url("https://www.vy.no/styles/font/VySans-RegularItalic.woff")
35
+ format("woff");
36
+ font-style: italic;
37
+ font-weight: 400;
38
+ font-display: swap
39
+ }
40
+ @font-face {
41
+ font-family: ${tokens.asset.font["vy-sans"]["bold"].name};
42
+ src: url("https://www.vy.no/styles/font/VySans-Bold.woff2") format("woff2"),
43
+ url("https://www.vy.no/styles/font/VySans-Bold.woff") format("woff");
44
+ font-style: normal;
45
+ font-weight: 700;
46
+ font-display: swap
47
+ }
48
+ @font-face {
49
+ font-family: ${tokens.asset.font["vy-sans"]["bold-italic"].name};
50
+ src: url("https://www.vy.no/styles/font/VySans-BoldItalic.woff2")
51
+ format("woff2"),
52
+ url("https://www.vy.no/styles/font/VySans-BoldItalic.woff") format("woff");
53
+ font-style: italic;
54
+ font-weight: 700;
55
+ font-display: swap
56
+ }
57
+ @font-face {
58
+ font-family: ${tokens.asset.font["vy-display"].name};
59
+ src: url("https://www.vy.no/styles/font/VyDisplay-Medium.woff2")
60
+ format("woff2"),
61
+ url("https://www.vy.no/styles/font/VyDisplay-Medium.woff") format("woff");
62
+ font-style: normal;
63
+ font-weight: 400;
64
+ font-display: swap
65
+ }
66
+ `;
@@ -0,0 +1,11 @@
1
+ import tokens from "@vygruppen/spor-design-tokens";
2
+
3
+ export const borders = {
4
+ none: "0",
5
+ sm: `${tokens.size.stroke.sm} solid`,
6
+ "sm-dashed": `${tokens.size.stroke.sm} dashed`,
7
+ md: `${tokens.size.stroke.md} solid`,
8
+ "md-dashed": `${tokens.size.stroke.md} dashed`,
9
+ lg: `${tokens.size.stroke.lg} solid`,
10
+ "lg-dashed": `${tokens.size.stroke.lg} dashed`,
11
+ };
@@ -0,0 +1,9 @@
1
+ import tokens from "@vygruppen/spor-design-tokens";
2
+
3
+ export const breakpoints = {
4
+ sm: tokens.size.breakpoint.sm,
5
+ md: tokens.size.breakpoint.md,
6
+ lg: tokens.size.breakpoint.lg,
7
+ xl: tokens.size.breakpoint.lg,
8
+ "2xl": tokens.size.breakpoint.lg,
9
+ };
@@ -0,0 +1,10 @@
1
+ import tokens from "@vygruppen/spor-design-tokens";
2
+
3
+ export type ColorsType = typeof tokens.color.alias &
4
+ typeof tokens.color.palette & { linjetag: typeof tokens.color.linjetag };
5
+
6
+ export const colors: ColorsType = {
7
+ ...tokens.color.alias,
8
+ ...tokens.color.palette,
9
+ linjetag: tokens.color.linjetag,
10
+ };
@@ -0,0 +1,5 @@
1
+ export const config = {
2
+ cssVarPrefix: "spor",
3
+ initialColorMode: "light",
4
+ useSystemColorMode: false,
5
+ };
@@ -0,0 +1,29 @@
1
+ import tokens from "@vygruppen/spor-design-tokens";
2
+
3
+ export const fontSizes = {
4
+ "2xs": tokens.size.font.xs.mobile,
5
+ xs: tokens.size.font.sm.mobile,
6
+ sm: tokens.size.font.md.mobile,
7
+ md: tokens.size.font.lg.mobile,
8
+ lg: tokens.size.font.xl.mobile,
9
+ xl: tokens.size.font.xxl.mobile,
10
+ "2xl": tokens.size.font.xl.desktop,
11
+ "3xl": tokens.size.font.xxl.desktop,
12
+
13
+ mobile: {
14
+ xs: tokens.size.font.xs.mobile,
15
+ sm: tokens.size.font.sm.mobile,
16
+ md: tokens.size.font.md.mobile,
17
+ lg: tokens.size.font.lg.mobile,
18
+ xl: tokens.size.font.xl.mobile,
19
+ xxl: tokens.size.font.xxl.mobile,
20
+ },
21
+ desktop: {
22
+ xs: tokens.size.font.xs.desktop,
23
+ sm: tokens.size.font.sm.desktop,
24
+ md: tokens.size.font.md.desktop,
25
+ lg: tokens.size.font.lg.desktop,
26
+ xl: tokens.size.font.xl.desktop,
27
+ xxl: tokens.size.font.xxl.desktop,
28
+ },
29
+ };
@@ -0,0 +1,5 @@
1
+ export const fontWeights = {
2
+ light: 300,
3
+ medium: 400,
4
+ bold: 700,
5
+ };
@@ -0,0 +1,7 @@
1
+ import tokens from "@vygruppen/spor-design-tokens";
2
+
3
+ export const fonts = {
4
+ body: tokens.font.family.body,
5
+ heading: tokens.font.family.heading,
6
+ mono: tokens.font.family.monospace,
7
+ };
@@ -0,0 +1,14 @@
1
+ export * from "./borders";
2
+ export * from "./breakpoints";
3
+ export * from "./colors";
4
+ export * from "./config";
5
+ export * from "./fonts";
6
+ export * from "./fontSizes";
7
+ export * from "./fontWeights";
8
+ export * from "./lineHeights";
9
+ export * from "./radii";
10
+ export * from "./shadows";
11
+ export * from "./sizes";
12
+ export * from "./spacing";
13
+ export * from "./textStyles";
14
+ export * from "./zIndices";
@@ -0,0 +1,5 @@
1
+ import tokens from "@vygruppen/spor-design-tokens";
2
+
3
+ export const lineHeights = {
4
+ normal: tokens.font.style.lg["line-height"],
5
+ };
@@ -0,0 +1,12 @@
1
+ import tokens from "@vygruppen/spor-design-tokens";
2
+
3
+ export const radii = {
4
+ none: tokens.size["border-radius"].none,
5
+ xs: tokens.size["border-radius"].xs,
6
+ sm: tokens.size["border-radius"].sm,
7
+ md: tokens.size["border-radius"].md,
8
+ lg: tokens.size["border-radius"].lg,
9
+ xl: tokens.size["border-radius"].xl,
10
+ "2xl": tokens.size["border-radius"]["2xl"],
11
+ round: "50%",
12
+ };
@@ -0,0 +1,8 @@
1
+ import tokens from "@vygruppen/spor-design-tokens";
2
+
3
+ export const shadows = {
4
+ none: "none",
5
+ sm: tokens.depth.shadow.sm.value,
6
+ md: tokens.depth.shadow.md.value,
7
+ lg: tokens.depth.shadow.lg.value,
8
+ };
@@ -0,0 +1,34 @@
1
+ import { spacing } from "./spacing";
2
+
3
+ const largeSizes = {
4
+ max: "max-content",
5
+ min: "min-content",
6
+ full: "100%",
7
+ "3xs": "14rem",
8
+ "2xs": "16rem",
9
+ xs: "20rem",
10
+ sm: "24rem",
11
+ md: "28rem",
12
+ lg: "32rem",
13
+ xl: "36rem",
14
+ "2xl": "42rem",
15
+ "3xl": "48rem",
16
+ "4xl": "56rem",
17
+ "5xl": "64rem",
18
+ "6xl": "72rem",
19
+ "7xl": "80rem",
20
+ "8xl": "90rem",
21
+ };
22
+
23
+ const container = {
24
+ sm: "640px",
25
+ md: "768px",
26
+ lg: "1024px",
27
+ xl: "1280px",
28
+ };
29
+
30
+ export const sizes = {
31
+ ...spacing,
32
+ ...largeSizes,
33
+ container,
34
+ };
@@ -0,0 +1,30 @@
1
+ import tokens from "@vygruppen/spor-design-tokens";
2
+
3
+ type Token = { value: { number: number } };
4
+ type Spacing = {
5
+ 0: Token;
6
+ 0.5: Token;
7
+ 1: Token;
8
+ 1.5: Token;
9
+ 2: Token;
10
+ 3: Token;
11
+ 4: Token;
12
+ 5: Token;
13
+ 6: Token;
14
+ 7: Token;
15
+ 8: Token;
16
+ 9: Token;
17
+ 10: Token;
18
+ 11: Token;
19
+ 12: Token;
20
+ };
21
+
22
+ export const spacing = Object.entries(tokens.size.spacing).reduce(
23
+ (tokens, [key, token]) => ({
24
+ ...tokens,
25
+ [Number(key)]: token,
26
+ }),
27
+ {} as Record<keyof Spacing, string>
28
+ );
29
+
30
+ export const space = spacing;
@@ -0,0 +1,60 @@
1
+ import tokens from "@vygruppen/spor-design-tokens";
2
+
3
+ export const textStyles = {
4
+ "2xl": {
5
+ fontSize: [
6
+ tokens.font.style.xxl["font-size"].mobile,
7
+ tokens.font.style.xxl["font-size"].desktop,
8
+ ],
9
+ fontFamily: tokens.font.style.xxl["font-family"],
10
+ lineHeight: tokens.font.style.xxl["line-height"],
11
+ },
12
+ "xl-display": {
13
+ fontSize: [
14
+ tokens.font.style["xl-display"]["font-size"].mobile,
15
+ tokens.font.style["xl-display"]["font-size"].desktop,
16
+ ],
17
+ fontFamily: tokens.font.style["xl-display"]["font-family"],
18
+ lineHeight: tokens.font.style["xl-display"]["line-height"],
19
+ },
20
+ "xl-sans": {
21
+ fontSize: [
22
+ tokens.font.style["xl-sans"]["font-size"].mobile,
23
+ tokens.font.style["xl-sans"]["font-size"].desktop,
24
+ ],
25
+ fontFamily: tokens.font.style["xl-sans"]["font-family"],
26
+ lineHeight: tokens.font.style["xl-sans"]["line-height"],
27
+ },
28
+ lg: {
29
+ fontSize: [
30
+ tokens.font.style.lg["font-size"].mobile,
31
+ tokens.font.style.lg["font-size"].desktop,
32
+ ],
33
+ fontFamily: tokens.font.style.lg["font-family"],
34
+ lineHeight: tokens.font.style.lg["line-height"],
35
+ },
36
+ md: {
37
+ fontSize: [
38
+ tokens.font.style.md["font-size"].mobile,
39
+ tokens.font.style.md["font-size"].desktop,
40
+ ],
41
+ fontFamily: tokens.font.style.md["font-family"],
42
+ lineHeight: tokens.font.style.md["line-height"],
43
+ },
44
+ sm: {
45
+ fontSize: [
46
+ tokens.font.style.sm["font-size"].mobile,
47
+ tokens.font.style.sm["font-size"].desktop,
48
+ ],
49
+ fontFamily: tokens.font.style.sm["font-family"],
50
+ lineHeight: tokens.font.style.sm["line-height"],
51
+ },
52
+ xs: {
53
+ fontSize: [
54
+ tokens.font.style.xs["font-size"].mobile,
55
+ tokens.font.style.xs["font-size"].desktop,
56
+ ],
57
+ fontFamily: tokens.font.style.xs["font-family"],
58
+ lineHeight: tokens.font.style.xs["line-height"],
59
+ },
60
+ };
@@ -0,0 +1,17 @@
1
+ import tokens from "@vygruppen/spor-design-tokens";
2
+
3
+ export const zIndices = {
4
+ hide: tokens.depth["z-index"].hide,
5
+ auto: "auto",
6
+ base: tokens.depth["z-index"].base,
7
+ docked: tokens.depth["z-index"].docked,
8
+ dropdown: tokens.depth["z-index"].dropdown,
9
+ sticky: tokens.depth["z-index"].sticky,
10
+ banner: tokens.depth["z-index"].banner,
11
+ overlay: tokens.depth["z-index"].overlay,
12
+ modal: tokens.depth["z-index"].modal,
13
+ popover: tokens.depth["z-index"].popover,
14
+ skipLink: tokens.depth["z-index"].skipLink,
15
+ toast: tokens.depth["z-index"].toast,
16
+ tooltip: tokens.depth["z-index"].tooltip,
17
+ };
@@ -0,0 +1,14 @@
1
+ import { theme as defaultTheme } from "@chakra-ui/theme";
2
+ import * as components from "./components";
3
+ import * as foundations from "./foundations";
4
+
5
+ export const theme = {
6
+ ...defaultTheme,
7
+ ...foundations,
8
+ components: {
9
+ ...defaultTheme.components,
10
+ ...components,
11
+ },
12
+ };
13
+
14
+ export { fontFaces } from "./font-faces";
@@ -0,0 +1,44 @@
1
+ import { colors, ColorsType } from "../foundations/colors";
2
+ import { shadows } from "../foundations/shadows";
3
+
4
+ type GetBoxShadowStringArgs = {
5
+ baseShadow?: keyof typeof shadows;
6
+ borderColor?: keyof typeof colors | string;
7
+ borderWidth?: number;
8
+ isInset?: boolean;
9
+ };
10
+ /**
11
+ * A utility for creating box shadow strings
12
+ */
13
+ export const getBoxShadowString = (
14
+ args: GetBoxShadowStringArgs | GetBoxShadowStringArgs[]
15
+ ): string => {
16
+ if (Array.isArray(args)) {
17
+ return args.map((arg) => getBoxShadowString(arg)).join(", ");
18
+ }
19
+
20
+ const { baseShadow, borderColor, borderWidth = 1, isInset = true } = args;
21
+ const allShadows: string[] = [];
22
+
23
+ if (borderColor) {
24
+ let color = borderColor;
25
+ if (borderColor in colors) {
26
+ color = colors[borderColor as keyof typeof colors] as string;
27
+ } else {
28
+ const [subgroup, value] = borderColor.split(".");
29
+ const subgroupValue = (colors[subgroup as keyof ColorsType] as any)?.[
30
+ value
31
+ ];
32
+ if (subgroupValue) {
33
+ color = subgroupValue;
34
+ }
35
+ }
36
+ allShadows.push(
37
+ `${isInset ? "inset " : ""}0 0 0 ${borderWidth}px ${color}`
38
+ );
39
+ }
40
+ if (baseShadow) {
41
+ allShadows.push(shadows[baseShadow]);
42
+ }
43
+ return allShadows.join(", ");
44
+ };
@@ -0,0 +1,16 @@
1
+ import { SystemStyleObject } from "@chakra-ui/theme-tools";
2
+
3
+ type FocusArgs = {
4
+ /** The styles applied for when the element is not focused */
5
+ notFocus: SystemStyleObject;
6
+ /** The styles applied for when the element is focused */
7
+ focus: SystemStyleObject;
8
+ };
9
+ /**
10
+ * A helper function for applying focus styles in such a way that they work with Safari – which doesn't support :focus-visible.
11
+ */
12
+ export const focusVisible = ({ notFocus, focus }: FocusArgs) => ({
13
+ _focus: focus,
14
+ _focusVisible: focus,
15
+ "&[data-focus]:not([data-focus-visible])": notFocus,
16
+ });