@vygruppen/spor-react 12.14.0 → 12.14.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vygruppen/spor-react",
3
3
  "type": "module",
4
- "version": "12.14.0",
4
+ "version": "12.14.2",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.ts",
@@ -68,8 +68,8 @@
68
68
  "vitest": "^0.26.3",
69
69
  "vitest-axe": "^0.1.0",
70
70
  "vitest-canvas-mock": "^0.2.2",
71
- "@vygruppen/eslint-config": "1.2.3",
72
- "@vygruppen/tsconfig": "0.1.1"
71
+ "@vygruppen/tsconfig": "0.1.1",
72
+ "@vygruppen/eslint-config": "1.2.3"
73
73
  },
74
74
  "peerDependencies": {
75
75
  "react": ">=18.0.0 <19.0.0",
@@ -6,7 +6,6 @@ import {
6
6
  HStack,
7
7
  RecipeVariantProps,
8
8
  Span,
9
- Stack,
10
9
  Text,
11
10
  useSlotRecipe,
12
11
  } from "@chakra-ui/react";
@@ -127,16 +126,10 @@ export const ServiceAlert = forwardRef<HTMLDivElement, ServiceAlertProps>(
127
126
  </HStack>
128
127
  </Accordion.ItemTrigger>
129
128
 
130
- <Accordion.ItemContent asChild>
131
- <Stack flexDirection="row" width="100%">
132
- <Accordion.ItemBody
133
- as={Stack}
134
- width={contentWidth}
135
- css={styles.itemBody}
136
- >
137
- {children}
138
- </Accordion.ItemBody>
139
- </Stack>
129
+ <Accordion.ItemContent css={styles.itemContent}>
130
+ <Accordion.ItemBody maxWidth={contentWidth} css={styles.itemBody}>
131
+ {children}
132
+ </Accordion.ItemBody>
140
133
  </Accordion.ItemContent>
141
134
  </Accordion.Item>
142
135
  </Accordion.Root>
@@ -0,0 +1,27 @@
1
+ import { Button, ButtonProps } from "./Button";
2
+ import { IconButton, IconButtonProps } from "./IconButton";
3
+
4
+ /**
5
+ * For internal use
6
+ */
7
+
8
+ type Props = IconButtonProps &
9
+ Omit<ButtonProps, "leftIcon" | "rightIcon"> & {
10
+ label: string;
11
+ };
12
+
13
+ export const ResponsiveButton = ({ label, icon, ...props }: Props) => {
14
+ return (
15
+ <>
16
+ <Button display={["none", "flex"]} leftIcon={icon} {...props}>
17
+ {label}
18
+ </Button>
19
+ <IconButton
20
+ display={["flex", "none"]}
21
+ aria-label={label}
22
+ icon={icon}
23
+ {...props}
24
+ />
25
+ </>
26
+ );
27
+ };
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { Box, Flex } from "@chakra-ui/react";
2
+ import { Flex } from "@chakra-ui/react";
3
3
  import { getLocalTimeZone } from "@internationalized/date";
4
4
  import {
5
5
  ArrowLeftOutline24Icon,
@@ -7,6 +7,8 @@ import {
7
7
  } from "@vygruppen/spor-icon-react";
8
8
  import { CalendarState, RangeCalendarState } from "react-stately";
9
9
 
10
+ import { Text } from "@/typography";
11
+
10
12
  import { createTexts, useTranslation } from "../i18n";
11
13
  import { CalendarNavigationButton } from "./CalendarNavigationButton";
12
14
  import { useCurrentLocale } from "./utils";
@@ -103,16 +105,16 @@ export const CalendarNavigator = ({
103
105
  icon={<ArrowLeftOutline24Icon />}
104
106
  aria-label={`${t(texts.previous)} ${t(texts[unit])}`}
105
107
  />
106
- <Box
108
+ <Text
107
109
  role="heading"
108
- fontSize="sm"
110
+ variant="md"
109
111
  fontWeight="bold"
110
112
  flex="1"
111
113
  textAlign="center"
112
114
  color={"core.text"}
113
115
  >
114
116
  {capitalize(title)}
115
- </Box>
117
+ </Text>
116
118
  <CalendarNavigationButton
117
119
  onPress={onNext}
118
120
  isDisabled={isNextDisabled}
@@ -63,11 +63,7 @@ export const DateField = forwardRef<HTMLDivElement, DateFieldProps>(
63
63
  position="absolute"
64
64
  paddingTop="2px"
65
65
  >
66
- <Label
67
- padding="0"
68
- fontSize={["mobile.xs", "desktop.xs"]}
69
- {...props.labelProps}
70
- >
66
+ <Label padding="0" {...props.labelProps}>
71
67
  {props.label} <Field.RequiredIndicator />
72
68
  </Label>
73
69
  </Box>
@@ -4,8 +4,6 @@ import {
4
4
  Box,
5
5
  createContext,
6
6
  Drawer as ChakraDrawer,
7
- Grid,
8
- GridItem,
9
7
  Portal,
10
8
  useDialogContext,
11
9
  } from "@chakra-ui/react";
@@ -16,7 +14,9 @@ import {
16
14
  import { forwardRef } from "react";
17
15
  import { useSwipeable } from "react-swipeable";
18
16
 
19
- import { Button, CloseButton } from "../button";
17
+ import { ResponsiveButton } from "@/button/ResponsiveButton";
18
+
19
+ import { CloseButton } from "../button";
20
20
  import { createTexts, useTranslation } from "../i18n";
21
21
  import {
22
22
  DrawerContentProps,
@@ -116,9 +116,11 @@ export const DrawerCloseTrigger = forwardRef<
116
116
  return (
117
117
  <ChakraDrawer.CloseTrigger ref={ref} {...props} asChild>
118
118
  {size === "full" ? (
119
- <Button variant="ghost" leftIcon={<CloseFill24Icon />}>
120
- {t(texts.close)}
121
- </Button>
119
+ <ResponsiveButton
120
+ variant="ghost"
121
+ icon={<CloseFill24Icon />}
122
+ label={t(texts.close)}
123
+ />
122
124
  ) : (
123
125
  <CloseButton size="md" />
124
126
  )}
@@ -132,10 +134,12 @@ export const DrawerBackTrigger = forwardRef<
132
134
  >((props, ref) => {
133
135
  const { t } = useTranslation();
134
136
  return (
135
- <ChakraDrawer.CloseTrigger asChild {...props} ref={ref} top="0">
136
- <Button variant="ghost" leftIcon={<ArrowLeftFill24Icon />}>
137
- {t(texts.back)}
138
- </Button>
137
+ <ChakraDrawer.CloseTrigger asChild {...props} ref={ref}>
138
+ <ResponsiveButton
139
+ variant="ghost"
140
+ icon={<ArrowLeftFill24Icon />}
141
+ label={t(texts.back)}
142
+ />
139
143
  </ChakraDrawer.CloseTrigger>
140
144
  );
141
145
  });
@@ -147,20 +151,10 @@ export const DrawerFullScreenHeader = forwardRef<
147
151
  >((props, ref) => {
148
152
  const { backTrigger = true, closeTrigger = true, children } = props;
149
153
  return (
150
- <ChakraDrawer.Header {...props} ref={ref} asChild>
151
- <Grid templateColumns="1fr auto 1fr" height="auto" paddingX="8">
152
- <GridItem width="full" alignSelf="center">
153
- {backTrigger && <DrawerBackTrigger />}
154
- </GridItem>
155
- <GridItem width="full" alignSelf="end" asChild>
156
- {children && <DrawerTitle>{children}</DrawerTitle>}
157
- </GridItem>
158
- {closeTrigger && (
159
- <GridItem width="full" alignSelf="end">
160
- <DrawerCloseTrigger justifySelf="end" top="0" />
161
- </GridItem>
162
- )}
163
- </Grid>
154
+ <ChakraDrawer.Header {...props} ref={ref}>
155
+ <Box>{backTrigger && <DrawerBackTrigger />}</Box>
156
+ {<DrawerTitle>{children}</DrawerTitle>}
157
+ <Box> {closeTrigger && <DrawerCloseTrigger />}</Box>
164
158
  </ChakraDrawer.Header>
165
159
  );
166
160
  });
@@ -104,7 +104,7 @@ export const Field = React.forwardRef<HTMLDivElement, FieldProps>(
104
104
  )}
105
105
  </ChakraField.Root>
106
106
  {helperText && (
107
- <Text fontSize="sm" color="text.tertiary">
107
+ <Text variant="sm" color="text.tertiary">
108
108
  {helperText}
109
109
  </Text>
110
110
  )}
@@ -127,7 +127,11 @@ export function ItemDescription({ children }: { children: React.ReactNode }) {
127
127
  const recipe = useSlotRecipe({ key: "listbox" });
128
128
  const styles = recipe({});
129
129
  return (
130
- <Box {...descriptionProps} css={styles} fontSize={"xs"}>
130
+ <Box
131
+ {...descriptionProps}
132
+ css={styles}
133
+ fontSize={["mobile.xs", "desktop.xs"]}
134
+ >
131
135
  {children}
132
136
  </Box>
133
137
  );
@@ -233,7 +237,7 @@ function ListBoxSection({ section, state }: ListBoxSectionProps) {
233
237
  >
234
238
  {section.rendered && (
235
239
  <Box
236
- fontSize="mobile.xs"
240
+ fontSize={["mobile.sm", "desktop.sm"]}
237
241
  color={titleColor}
238
242
  paddingTop={1}
239
243
  marginTop={isFirstSection ? 0 : 2}
@@ -78,7 +78,7 @@ export const Switch = forwardRef<HTMLInputElement, SwitchProps>(
78
78
  <ChakraSwitch.Control css={styles.control}>
79
79
  <ChakraSwitch.Thumb />
80
80
  </ChakraSwitch.Control>
81
- <ChakraSwitch.Label>{label}</ChakraSwitch.Label>
81
+ {label && <ChakraSwitch.Label>{label}</ChakraSwitch.Label>}
82
82
  </ChakraSwitch.Root>
83
83
  </Field>
84
84
  );
@@ -44,7 +44,6 @@ export const StepperStep = ({
44
44
  {disabled ? (
45
45
  <Text
46
46
  variant="xs"
47
- fontSize="1rem"
48
47
  color={disabledTextColor}
49
48
  cursor="default"
50
49
  paddingX={2}
@@ -22,13 +22,13 @@ export const accordionSlotRecipe = defineSlotRecipe({
22
22
  textAlign: "left",
23
23
  width: "full",
24
24
  alignItems: "center",
25
- fontSize: ["mobile.sm", null, "desktop.sm"],
25
+ fontSize: ["mobile.sm", "desktop.sm"],
26
26
  fontFamily: "body",
27
27
  fontWeight: "bold",
28
28
  outlineOffset: "-2px",
29
- paddingX: [2, null, 3],
30
- paddingY: [1, null, 1.5],
31
- minHeight: [6, null, 7],
29
+ paddingX: [2, 3],
30
+ paddingY: [1, 1.5],
31
+ minHeight: [6, 7],
32
32
  cursor: "pointer",
33
33
  _disabled: {
34
34
  pointerEvents: "none",
@@ -37,7 +37,7 @@ export const accordionSlotRecipe = defineSlotRecipe({
37
37
  },
38
38
  itemContent: {
39
39
  borderBottomRadius: "sm",
40
- fontSize: ["mobile.sm", null, "desktop.sm"],
40
+ fontSize: ["mobile.sm", "desktop.sm"],
41
41
  color: "text",
42
42
  height: "auto",
43
43
  overflow: "hidden",
@@ -52,7 +52,7 @@ export const accordionSlotRecipe = defineSlotRecipe({
52
52
  },
53
53
  itemBody: {
54
54
  paddingY: 2,
55
- paddingX: [2, null, 3],
55
+ paddingX: [2, 3],
56
56
  },
57
57
  itemIndicator: {
58
58
  transition: "rotate 0.2s",
@@ -22,7 +22,8 @@ export const alertServiceSlotRecipe = defineSlotRecipe({
22
22
  display: "flex",
23
23
  flexDirection: "column",
24
24
  justifyContent: "center",
25
- padding: [2, null, null, 2],
25
+ padding: ["2", "3"],
26
+ paddingBottom: "1",
26
27
  borderBottomRadius: "md",
27
28
  borderTopRadius: "none",
28
29
  width: "full",
@@ -39,27 +40,41 @@ export const alertServiceSlotRecipe = defineSlotRecipe({
39
40
  },
40
41
  },
41
42
  itemTriggerTitle: {
42
- fontSize: ["xs", null, null, "sm"],
43
+ fontSize: ["mobile.sm", "desktop.sm"],
43
44
  },
44
45
  notificationText: {
45
46
  fontWeight: "400",
46
- fontSize: ["2xs", null, null, "xs"],
47
+ fontSize: ["mobile.xs", "desktop.xs"],
47
48
  textWrap: "nowrap",
49
+ color: "alert.service.text.secondary",
48
50
  },
51
+
52
+ itemContent: {
53
+ paddingX: ["2", "3"],
54
+ paddingBottom: ["2", "3"],
55
+ paddingTop: ["1", "2"],
56
+ },
57
+
49
58
  itemBody: {
50
59
  marginX: "auto",
51
60
  padding: "0 !important",
52
- paddingBottom: ["0.5", null, null, "1"],
53
- color: "text.inverted",
61
+ color: "alert.service.text.secondary",
62
+ gap: 0,
63
+ flexDirection: "column",
64
+ display: "flex",
54
65
  "& > p": {
55
- gap: 2,
56
66
  width: "full",
57
67
  borderBottom: "1px dashed",
58
68
  borderColor: "outline.inverted",
59
- paddingBottom: "3",
60
- paddingTop: "2",
69
+
70
+ paddingY: ["1", "1.5"],
71
+
72
+ _first: {
73
+ paddingTop: 0,
74
+ },
61
75
  _last: {
62
76
  borderBottom: "none",
77
+ paddingBottom: 0,
63
78
  },
64
79
  },
65
80
  },
@@ -10,7 +10,6 @@ export const choiceChipSlotRecipe = defineSlotRecipe({
10
10
  display: "inline-flex",
11
11
  alignItems: "center",
12
12
  boxAlign: "center",
13
- fontSize: "xs",
14
13
  cursor: "pointer",
15
14
  transitionProperty: "all",
16
15
  borderRadius: "xl",
@@ -69,7 +68,6 @@ export const choiceChipSlotRecipe = defineSlotRecipe({
69
68
  display: "flex",
70
69
  alignItems: "center",
71
70
  gap: "1",
72
- fontSize: "xs",
73
71
  },
74
72
  },
75
73
 
@@ -83,6 +81,10 @@ export const choiceChipSlotRecipe = defineSlotRecipe({
83
81
  height: 5,
84
82
  paddingX: 1.5,
85
83
  },
84
+ label: {
85
+ fontSize: { base: "mobile.sm", sm: "desktop.sm" },
86
+ fontWeight: "medium",
87
+ },
86
88
  },
87
89
  sm: {
88
90
  root: {
@@ -92,6 +94,10 @@ export const choiceChipSlotRecipe = defineSlotRecipe({
92
94
  height: 6,
93
95
  paddingX: 2,
94
96
  },
97
+ label: {
98
+ fontSize: { base: "mobile.sm", sm: "desktop.sm" },
99
+ fontWeight: "bold",
100
+ },
95
101
  },
96
102
  md: {
97
103
  root: {
@@ -101,6 +107,10 @@ export const choiceChipSlotRecipe = defineSlotRecipe({
101
107
  height: 7,
102
108
  paddingX: 2,
103
109
  },
110
+ label: {
111
+ fontSize: { base: "mobile.md", sm: "desktop.md" },
112
+ fontWeight: "bold",
113
+ },
104
114
  },
105
115
  lg: {
106
116
  root: {
@@ -110,6 +120,10 @@ export const choiceChipSlotRecipe = defineSlotRecipe({
110
120
  height: 8,
111
121
  paddingX: 3,
112
122
  },
123
+ label: {
124
+ fontSize: { base: "mobile.md", sm: "desktop.md" },
125
+ fontWeight: "bold",
126
+ },
113
127
  },
114
128
  },
115
129
 
@@ -176,7 +190,7 @@ export const choiceChipSlotRecipe = defineSlotRecipe({
176
190
  },
177
191
 
178
192
  defaultVariants: {
179
- size: "md",
193
+ size: "sm",
180
194
  variant: "core",
181
195
  chipType: "choice",
182
196
  },
@@ -37,7 +37,7 @@ export const datePickerSlotRecipe = defineSlotRecipe({
37
37
  },
38
38
  },
39
39
  inputLabel: {
40
- fontSize: "mobile.xs",
40
+ fontSize: ["mobile.xs", "desktop.xs"],
41
41
  margin: 0,
42
42
  cursor: "text",
43
43
  },
@@ -59,7 +59,8 @@ export const drawerSlotRecipe = defineSlotRecipe({
59
59
  display: "flex",
60
60
  alignItems: "center",
61
61
  justifyContent: "space-between",
62
- paddingX: ["3", null, null, "5"],
62
+ paddingX: ["2", null, null, "5"],
63
+ gap: "1",
63
64
  paddingBottom: "1",
64
65
  },
65
66
  body: {
@@ -74,6 +74,10 @@ export const lineIconSlotRecipe = defineSlotRecipe({
74
74
  iconContainer: {
75
75
  backgroundColor: "linjetag.altTransport",
76
76
  },
77
+ icon: {
78
+ // eslint-disable-next-line spor/use-semantic-tokens
79
+ color: "darkGrey",
80
+ },
77
81
  },
78
82
  walk: {
79
83
  title: {