@vygruppen/spor-react 4.0.0 → 4.0.2

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.
@@ -30,7 +30,7 @@ export type FormErrorMessageProps = BoxProps & {
30
30
  * </FormControl>
31
31
  * ```
32
32
  *
33
- * @see https://spor.vy.no/komponenter/skjemaelementer
33
+ * @see https://spor.vy.no/components/form-control
34
34
  */
35
35
  export const FormErrorMessage = ({
36
36
  children,
@@ -147,7 +147,7 @@ type InfoSelectProps<T extends object> = {
147
147
  * </InfoSelect>
148
148
  * ```
149
149
  *
150
- * @see https://spor.vy.no/komponenter/info-select
150
+ * @see https://spor.vy.no/components/info-select
151
151
  */
152
152
  export function InfoSelect<T extends object>({
153
153
  placeholder,
@@ -46,6 +46,7 @@ export const PasswordInput = forwardRef<PasswordInputProps, "input">(
46
46
  onClick={onToggle}
47
47
  borderRadius="sm"
48
48
  marginRight={1}
49
+ isDisabled={props.disabled || props.isDisabled}
49
50
  >
50
51
  {isShowingPassword ? t(texts.hidePassword) : t(texts.showPassword)}
51
52
  </Button>
@@ -24,7 +24,7 @@ export type InfoTagProps = TagProps;
24
24
  * />
25
25
  * ```
26
26
  *
27
- * @see https://spor.vy.no/komponenter/linjetags
27
+ * @see https://spor.vy.no/components/line-tags
28
28
  */
29
29
  export const InfoTag = ({
30
30
  variant,
@@ -23,7 +23,7 @@ export type LineIconProps = BoxProps & {
23
23
  * <LineIcon variant="subway" size="lg" />
24
24
  * ```
25
25
  *
26
- * @see https://spor.vy.no/komponenter/linjetags
26
+ * @see https://spor.vy.no/components/line-tags
27
27
  */
28
28
  export const LineIcon = ({
29
29
  variant,
@@ -58,7 +58,7 @@ export type TravelTagProps = TagProps &
58
58
  * />
59
59
  * ```
60
60
  *
61
- * @see https://spor.vy.no/komponenter/linjetags
61
+ * @see https://spor.vy.no/components/line-tags
62
62
  */
63
63
  export const TravelTag = forwardRef<TravelTagProps, As>(
64
64
  (
@@ -8,6 +8,7 @@ const parts = anatomy("datepicker").parts(
8
8
  "wrapper",
9
9
  "calendarTriggerButton",
10
10
  "arrow",
11
+ "calendarPopover",
11
12
  "calendar",
12
13
  "weekdays",
13
14
  "weekend",
@@ -34,36 +35,10 @@ const config = helpers.defineMultiStyleConfig({
34
35
  paddingY: 0.5,
35
36
  alignItems: "center",
36
37
  _hover: {
37
- boxShadow: getBoxShadowString({
38
- borderColor: mode("darkGrey", "white")(props),
39
- borderWidth: 2,
40
- }),
41
38
  zIndex: zIndices.docked,
42
39
  },
43
- _focusWithin: {
44
- boxShadow: getBoxShadowString({
45
- borderColor: mode("greenHaze", "azure")(props),
46
- borderWidth: 2,
47
- }),
48
- },
49
- _invalid: {
50
- boxShadow: getBoxShadowString({
51
- borderColor: "brightRed",
52
- borderWidth: 2,
53
- }),
54
- },
55
40
  _disabled: {
56
41
  pointerEvents: "none",
57
- boxShadow: getBoxShadowString({
58
- borderColor: mode("osloGrey", "whiteAlpha.400")(props),
59
- borderWidth: 1,
60
- }),
61
- _focus: {
62
- boxShadow: getBoxShadowString({
63
- borderColor: mode("osloGrey", "whiteAlpha.400")(props),
64
- borderWidth: 1,
65
- }),
66
- },
67
42
  },
68
43
  },
69
44
  inputLabel: {
@@ -123,17 +98,19 @@ const config = helpers.defineMultiStyleConfig({
123
98
  }),
124
99
  },
125
100
  },
126
- arrow: {
101
+ arrow: {
127
102
  [$arrowBackground.variable]: mode("white", colors.night)(props),
128
- },
129
- calendar: {
103
+ },
104
+ calendarPopover: {
130
105
  backgroundColor: mode("white", "night")(props),
131
106
  color: mode("darkGrey", "white")(props),
132
107
  boxShadow: getBoxShadowString({
133
108
  borderWidth: 2,
134
109
  borderColor: mode("blackAlpha.200", "whiteAlpha.200")(props),
110
+ baseShadow: "md",
135
111
  }),
136
112
  },
113
+
137
114
  weekdays: {
138
115
  color: mode("darkGrey", "white")(props),
139
116
  },
@@ -216,6 +193,41 @@ const config = helpers.defineMultiStyleConfig({
216
193
  }),
217
194
  variants: {
218
195
  base: (props) => ({
196
+ wrapper: {
197
+ boxShadow: getBoxShadowString({
198
+ borderColor: mode("blackAlpha.400", "whiteAlpha.400")(props),
199
+ }),
200
+ _hover: {
201
+ boxShadow: getBoxShadowString({
202
+ borderColor: mode("darkGrey", "white")(props),
203
+ borderWidth: 2,
204
+ }),
205
+ },
206
+ _focusWithin: {
207
+ boxShadow: getBoxShadowString({
208
+ borderColor: mode("greenHaze", "azure")(props),
209
+ borderWidth: 2,
210
+ }),
211
+ },
212
+ _invalid: {
213
+ boxShadow: getBoxShadowString({
214
+ borderColor: "brightRed",
215
+ borderWidth: 2,
216
+ }),
217
+ },
218
+ _disabled: {
219
+ boxShadow: getBoxShadowString({
220
+ borderColor: mode("osloGrey", "whiteAlpha.400")(props),
221
+ borderWidth: 1,
222
+ }),
223
+ _focus: {
224
+ boxShadow: getBoxShadowString({
225
+ borderColor: mode("osloGrey", "whiteAlpha.400")(props),
226
+ borderWidth: 1,
227
+ }),
228
+ },
229
+ },
230
+ },
219
231
  calendar: {
220
232
  backgroundColor: mode("white", "night")(props),
221
233
  color: mode("darkGrey", "white")(props),
@@ -238,14 +250,55 @@ const config = helpers.defineMultiStyleConfig({
238
250
  },
239
251
  }),
240
252
  floating: (props) => ({
241
- calendar: {
242
- backgroundColor: mode("white", "night")(props),
243
- color: mode("darkGrey", "white")(props),
253
+ wrapper: {
254
+ boxShadow: getBoxShadowString({
255
+ borderColor: mode("blackAlpha.400", "whiteAlpha.400")(props),
256
+ baseShadow: "sm",
257
+ }),
258
+ _hover: {
259
+ boxShadow: getBoxShadowString({
260
+ borderColor: mode("darkGrey", "white")(props),
261
+ borderWidth: 2,
262
+ baseShadow: "sm",
263
+ }),
264
+ },
265
+ _focusWithin: {
244
266
  boxShadow: getBoxShadowString({
245
- borderColor: mode("grey.200", "whiteAlpha.400")(props),
267
+ borderColor: mode("greenHaze", "azure")(props),
268
+ borderWidth: 2,
246
269
  baseShadow: "sm",
247
270
  }),
248
271
  },
272
+ _invalid: {
273
+ boxShadow: getBoxShadowString({
274
+ borderColor: "brightRed",
275
+ borderWidth: 2,
276
+ baseShadow: "sm",
277
+ }),
278
+ },
279
+ _disabled: {
280
+ boxShadow: getBoxShadowString({
281
+ borderColor: mode("osloGrey", "whiteAlpha.400")(props),
282
+ borderWidth: 1,
283
+ baseShadow: "sm",
284
+ }),
285
+ _focus: {
286
+ boxShadow: getBoxShadowString({
287
+ borderColor: mode("osloGrey", "whiteAlpha.400")(props),
288
+ borderWidth: 1,
289
+ baseShadow: "sm",
290
+ }),
291
+ },
292
+ },
293
+ },
294
+ calendar: {
295
+ backgroundColor: mode("white", "night")(props),
296
+ color: mode("darkGrey", "white")(props),
297
+ boxShadow: getBoxShadowString({
298
+ borderColor: mode("grey.200", "whiteAlpha.400")(props),
299
+ baseShadow: "sm",
300
+ }),
301
+ },
249
302
  dateCell: {
250
303
  color: mode("darkGrey", "white")(props),
251
304
  _hover: {
@@ -254,13 +307,43 @@ const config = helpers.defineMultiStyleConfig({
254
307
  },
255
308
  }),
256
309
  ghost: (props) => ({
310
+ wrapper: {
311
+ boxShadow: "none",
312
+ _hover: {
313
+ boxShadow: getBoxShadowString({
314
+ borderColor: mode("darkGrey", "white")(props),
315
+ borderWidth: 2,
316
+ }),
317
+ },
318
+ _focusWithin: {
319
+ boxShadow: getBoxShadowString({
320
+ borderColor: mode("greenHaze", "azure")(props),
321
+ borderWidth: 2,
322
+ }),
323
+ },
324
+ _invalid: {
325
+ boxShadow: getBoxShadowString({
326
+ borderColor: "brightRed",
327
+ borderWidth: 2,
328
+ }),
329
+ },
330
+ _disabled: {
331
+ boxShadow: getBoxShadowString({
332
+ borderColor: mode("osloGrey", "whiteAlpha.400")(props),
333
+ borderWidth: 1,
334
+ }),
335
+ _focus: {
336
+ boxShadow: getBoxShadowString({
337
+ borderColor: mode("osloGrey", "whiteAlpha.400")(props),
338
+ borderWidth: 1,
339
+ }),
340
+ },
341
+ },
342
+ },
257
343
  calendar: {
258
344
  backgroundColor: mode("white", "night")(props),
259
345
  color: mode("darkGrey", "white")(props),
260
- boxShadow: getBoxShadowString({
261
- borderWidth: 2,
262
- borderColor: mode("", "")(props),
263
- }),
346
+ boxShadow: "none",
264
347
  },
265
348
  dateCell: {
266
349
  color: mode("darkGrey", "white")(props),
@@ -268,8 +351,8 @@ const config = helpers.defineMultiStyleConfig({
268
351
  backgroundColor: mode("seaMist", "pine")(props),
269
352
  },
270
353
  _selected: {
271
- backgroundColor: mode("", "primaryGreen")(props),
272
- color: "darkGrey"
354
+ backgroundColor: mode("transparent", "primaryGreen")(props),
355
+ color: "darkGrey",
273
356
  },
274
357
  },
275
358
  }),
@@ -1,15 +1,15 @@
1
1
  import { anatomy } from "@chakra-ui/anatomy";
2
2
  import { createMultiStyleConfigHelpers } from "@chakra-ui/react";
3
- import { mode } from "@chakra-ui/theme-tools";
4
- import { getBoxShadowString } from "../utils/box-shadow-utils";
5
3
  import { focusVisible } from "../utils/focus-utils";
6
4
  import { srOnly } from "../utils/sr-utils";
5
+ import { baseBorder } from "../utils/border-utils";
6
+ import { baseBackground } from "../utils/background-utils";
7
7
 
8
8
  const parts = anatomy("InfoSelect").parts(
9
9
  "container",
10
10
  "label",
11
11
  "button",
12
- "arrowIcon"
12
+ "arrowIcon",
13
13
  );
14
14
 
15
15
  const helpers = createMultiStyleConfigHelpers(parts.keys);
@@ -31,57 +31,44 @@ const config = helpers.defineMultiStyleConfig({
31
31
  justifyContent: "space-between",
32
32
  alignItems: "center",
33
33
  fontSize: "mobile.md",
34
- boxShadow: getBoxShadowString({
35
- borderColor: mode("blackAlpha.400", "whiteAlpha.400")(props),
36
- }),
34
+ ...baseBorder("default", props),
37
35
  _hover: {
38
- boxShadow: getBoxShadowString({
39
- borderColor: mode("darkGrey", "whiteAlpha.600")(props),
40
- borderWidth: 2,
41
- }),
36
+ ...baseBorder("hover", props),
42
37
  },
43
38
  ...focusVisible({
44
39
  focus: {
45
- boxShadow: getBoxShadowString({
46
- borderColor: "greenHaze",
47
- borderWidth: 2,
48
- }),
40
+ ...baseBorder("focus", props),
49
41
  outline: "none",
50
42
  },
51
43
  notFocus: {
52
- boxShadow: getBoxShadowString({
53
- borderColor: mode("blackAlpha.400", "whiteAlpha.400")(props),
54
- }),
44
+ ...baseBorder("default", props),
55
45
  },
56
46
  }),
57
47
  _disabled: {
58
- boxShadow: getBoxShadowString({ borderColor: "platinum" }),
59
- _hover: { boxShadow: getBoxShadowString({ borderColor: "platinum" }) },
60
- _focus: { boxShadow: getBoxShadowString({ borderColor: "platinum" }) },
48
+ color: "whiteAlpha.400",
49
+ ...baseBackground("disabled", props),
50
+ _hover: { ...baseBorder("disabled", props) },
51
+ _focus: { ...baseBorder("disabled", props) },
52
+ },
53
+ _active: {
54
+ ...baseBackground("active", props),
55
+ ...baseBorder("focus", props),
56
+ },
57
+ _expanded: {
58
+ ...baseBackground("active", props),
59
+ ...baseBorder("focus", props),
61
60
  },
62
61
  _invalid: {
63
- boxShadow: getBoxShadowString({
64
- borderColor: "brightRed",
65
- borderWidth: 2,
66
- }),
62
+ ...baseBorder("invalid", props),
67
63
  _hover: {
68
- boxShadow: getBoxShadowString({
69
- borderColor: "darkGrey",
70
- borderWidth: 2,
71
- }),
64
+ ...baseBorder("hover", props),
72
65
  },
73
66
  ...focusVisible({
74
67
  focus: {
75
- boxShadow: getBoxShadowString({
76
- borderColor: "greenHaze",
77
- borderWidth: 2,
78
- }),
68
+ ...baseBorder("focus", props),
79
69
  },
80
70
  notFocus: {
81
- boxShadow: getBoxShadowString({
82
- borderColor: "brightRed",
83
- borderWidth: 2,
84
- }),
71
+ ...baseBorder("invalid", props),
85
72
  },
86
73
  }),
87
74
  },
@@ -45,13 +45,15 @@ const config = helpers.defineMultiStyleConfig({
45
45
  }),
46
46
  },
47
47
  notFocus: {
48
- boxShadow: getBoxShadowString({ borderColor: "darkGrey" }),
48
+ boxShadow: getBoxShadowString({ borderColor: mode("darkGrey", "white")(props) }),
49
49
  },
50
50
  }),
51
51
  _disabled: {
52
- boxShadow: getBoxShadowString({ borderColor: "platinum" }),
53
- _hover: { boxShadow: getBoxShadowString({ borderColor: "platinum" }) },
54
- _focus: { boxShadow: getBoxShadowString({ borderColor: "platinum" }) },
52
+ backgroundColor: mode("blackAlpha.100", "whiteAlpha.100")(props),
53
+ boxShadow: getBoxShadowString({
54
+ borderColor: mode("blackAlpha.200", "whiteAlpha.200")(props)
55
+ }),
56
+ cursor: "not-allowed",
55
57
  },
56
58
  _invalid: {
57
59
  boxShadow: getBoxShadowString({
@@ -60,7 +62,7 @@ const config = helpers.defineMultiStyleConfig({
60
62
  }),
61
63
  _hover: {
62
64
  boxShadow: getBoxShadowString({
63
- borderColor: "darkGrey",
65
+ borderColor: mode("darkGrey", "white")(props),
64
66
  borderWidth: 2,
65
67
  }),
66
68
  },
@@ -100,6 +102,11 @@ const config = helpers.defineMultiStyleConfig({
100
102
  element: {
101
103
  height: "100%",
102
104
  },
105
+ group: {
106
+ ":has(:disabled)": {
107
+ color: mode("blackAlpha.400", "whiteAlpha.400")(props),
108
+ },
109
+ },
103
110
  }),
104
111
  });
105
112
 
@@ -1,21 +1,21 @@
1
1
  import { listAnatomy as parts } from "@chakra-ui/anatomy";
2
- import {
3
- createMultiStyleConfigHelpers,
4
- defineStyle,
5
- } from "@chakra-ui/styled-system";
2
+ import { createMultiStyleConfigHelpers } from "@chakra-ui/styled-system";
6
3
 
7
4
  const { defineMultiStyleConfig, definePartsStyle } =
8
5
  createMultiStyleConfigHelpers(parts.keys);
9
6
 
10
- const baseStyleIcon = defineStyle({
11
- marginEnd: "2",
12
- display: "inline",
13
- verticalAlign: "text-bottom",
14
- fontFamily: "body",
15
- });
16
-
17
7
  const baseStyle = definePartsStyle({
18
- icon: baseStyleIcon,
8
+ container: {
9
+ fontSize: ["mobile.sm", "desktop.sm"],
10
+ },
11
+ item: {
12
+ fontFamily: "body",
13
+ },
14
+ icon: {
15
+ marginEnd: "2",
16
+ display: "inline",
17
+ verticalAlign: "text-bottom",
18
+ },
19
19
  });
20
20
 
21
21
  export default defineMultiStyleConfig({
@@ -1,12 +1,14 @@
1
1
  import { anatomy } from "@chakra-ui/anatomy";
2
2
  import { createMultiStyleConfigHelpers } from "@chakra-ui/react";
3
3
  import { mode } from "@chakra-ui/theme-tools";
4
+ import { colors } from "../foundations";
5
+ import { baseBackground } from "../utils/background-utils";
4
6
 
5
7
  const parts = anatomy("ListBox").parts(
6
8
  "container",
7
9
  "item",
8
10
  "label",
9
- "description"
11
+ "description",
10
12
  );
11
13
 
12
14
  const helpers = createMultiStyleConfigHelpers(parts.keys);
@@ -14,7 +16,11 @@ const helpers = createMultiStyleConfigHelpers(parts.keys);
14
16
  const config = helpers.defineMultiStyleConfig({
15
17
  baseStyle: (props) => ({
16
18
  container: {
17
- background: mode("white", "darkGrey")(props),
19
+ // avoiding extra div by blending a transparent color into darkGrey for dark mode
20
+ backgroundColor: mode(
21
+ "mint",
22
+ `color-mix(in srgb, ${colors.darkGrey}, ${colors.white} 10%)`,
23
+ )(props),
18
24
  boxShadow: "sm",
19
25
  overflowY: "auto",
20
26
  maxHeight: "50vh",
@@ -31,20 +37,20 @@ const config = helpers.defineMultiStyleConfig({
31
37
  color: mode("darkGrey", "white")(props),
32
38
  cursor: "pointer",
33
39
  _hover: {
34
- backgroundColor: mode("seaMist", "darkTeal")(props),
40
+ backgroundColor: mode("seaMist", "pine")(props),
35
41
  outline: "none",
36
42
  },
37
43
  _active: {
38
- backgroundColor: mode("mint", "darkTeal")(props),
44
+ backgroundColor: mode("mint", "pine")(props),
39
45
  outline: "none",
40
46
  },
41
47
  _focus: {
42
48
  outline: "none",
43
- backgroundColor: mode("seaMist", "darkTeal")(props),
49
+ backgroundColor: mode("seaMist", "pine")(props),
44
50
  },
45
51
  _selected: {
46
- backgroundColor: mode("pine", "pine")(props),
47
- color: mode("white", "white")(props),
52
+ ...baseBackground("selected", props),
53
+ color: "white",
48
54
  },
49
55
  },
50
56
  label: {},
@@ -1,6 +1,7 @@
1
- import { selectAnatomy } from "@chakra-ui/anatomy";
2
- import { createMultiStyleConfigHelpers } from "@chakra-ui/react";
3
- import { default as Input } from "./input";
1
+ import {selectAnatomy} from "@chakra-ui/anatomy";
2
+ import {createMultiStyleConfigHelpers} from "@chakra-ui/react";
3
+ import {default as Input} from "./input";
4
+ import {mode} from "@chakra-ui/theme-tools";
4
5
 
5
6
  const parts = selectAnatomy.extend("root");
6
7
 
@@ -43,7 +44,7 @@ const config = helpers.defineMultiStyleConfig({
43
44
  strokeLinecap: "round",
44
45
  fontSize: "1.125rem",
45
46
  _disabled: {
46
- opacity: 0.5,
47
+ color: mode("blackAlpha.400", "whiteAlpha.400")(props),
47
48
  },
48
49
  },
49
50
  }),
@@ -0,0 +1,28 @@
1
+ import { mode, StyleFunctionProps } from "@chakra-ui/theme-tools";
2
+
3
+ type State =
4
+ | "default"
5
+ | "hover"
6
+ | "active"
7
+ | "focus"
8
+ | "selected"
9
+ | "invalid"
10
+ | "disabled";
11
+ export function baseBackground(state: State, props: StyleFunctionProps) {
12
+ switch (state) {
13
+ case "active":
14
+ return {
15
+ backgroundColor: mode("mint", "whiteAlpha.100")(props),
16
+ };
17
+ case "selected":
18
+ return {
19
+ backgroundColor: "pine",
20
+ };
21
+ case "disabled":
22
+ return {
23
+ backgroundColor: mode("silver", "whiteAlpha.100")(props),
24
+ };
25
+ default:
26
+ return {};
27
+ }
28
+ }
@@ -0,0 +1,59 @@
1
+ import { mode, StyleFunctionProps } from "@chakra-ui/theme-tools";
2
+ import { getBoxShadowString } from "./box-shadow-utils";
3
+
4
+ type State =
5
+ | "default"
6
+ | "hover"
7
+ | "active"
8
+ | "focus"
9
+ | "selected"
10
+ | "invalid"
11
+ | "disabled";
12
+
13
+ export function baseBorder(state: State, props: StyleFunctionProps) {
14
+ switch (state) {
15
+ case "hover":
16
+ return {
17
+ boxShadow: getBoxShadowString({
18
+ borderColor: mode("darkGrey", "white")(props),
19
+ borderWidth: 2,
20
+ }),
21
+ };
22
+ case "focus": {
23
+ return {
24
+ boxShadow: getBoxShadowString({
25
+ borderColor: mode("greenHaze", "azure")(props),
26
+ borderWidth: 2,
27
+ }),
28
+ };
29
+ }
30
+ case "disabled": {
31
+ return {
32
+ boxShadow: getBoxShadowString({
33
+ borderColor: mode("platinum", "whiteAlpha.400")(props),
34
+ }),
35
+ };
36
+ }
37
+ case "selected":
38
+ return {
39
+ boxShadow: getBoxShadowString({
40
+ borderColor: mode("greenHaze", "azure")(props),
41
+ }),
42
+ };
43
+ case "invalid": {
44
+ return {
45
+ boxShadow: getBoxShadowString({
46
+ borderColor: "brightRed",
47
+ borderWidth: 2,
48
+ }),
49
+ };
50
+ }
51
+ case "default":
52
+ default:
53
+ return {
54
+ boxShadow: getBoxShadowString({
55
+ borderColor: mode("blackAlpha.400", "whiteAlpha.400")(props),
56
+ }),
57
+ };
58
+ }
59
+ }