@vygruppen/spor-react 6.1.0 → 6.2.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.
- package/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +12 -0
- package/dist/{CountryCodeSelect-KRCJWBUE.mjs → CountryCodeSelect-QBDQ3HTF.mjs} +1 -1
- package/dist/{chunk-2L6AHVGG.mjs → chunk-UIM4MXLY.mjs} +138 -118
- package/dist/index.d.mts +121 -38
- package/dist/index.d.ts +121 -38
- package/dist/index.js +136 -117
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/button/Button.tsx +44 -43
- package/src/button/IconButton.tsx +4 -0
- package/src/linjetag/InfoTag.tsx +23 -2
- package/src/linjetag/LineIcon.tsx +38 -5
- package/src/linjetag/TravelTag.tsx +21 -1
- package/src/linjetag/types.d.ts +17 -2
- package/src/theme/components/button.ts +47 -74
- package/src/theme/components/line-icon.ts +5 -0
- package/src/theme/components/travel-tag.ts +5 -0
@@ -3,10 +3,23 @@ import React from "react";
|
|
3
3
|
import { getCorrectIcon } from "./icons";
|
4
4
|
import { TagProps } from "./types";
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
type DefaultVariants = Exclude<TagProps["variant"], "custom">;
|
7
|
+
|
8
|
+
type DefaultVariantProps = {
|
9
|
+
variant: DefaultVariants;
|
10
|
+
};
|
11
|
+
type CustomVariantProps = {
|
12
|
+
variant: "custom";
|
13
|
+
customIconVariant: DefaultVariants;
|
14
|
+
foregroundColor: string;
|
15
|
+
backgroundColor: string;
|
9
16
|
};
|
17
|
+
type VariantProps = DefaultVariantProps | CustomVariantProps;
|
18
|
+
|
19
|
+
export type LineIconProps = Exclude<BoxProps, "variant"> &
|
20
|
+
VariantProps & {
|
21
|
+
size: TagProps["size"];
|
22
|
+
};
|
10
23
|
|
11
24
|
/**
|
12
25
|
* A line icon component.
|
@@ -23,6 +36,18 @@ export type LineIconProps = BoxProps & {
|
|
23
36
|
* <LineIcon variant="subway" size="lg" />
|
24
37
|
* ```
|
25
38
|
*
|
39
|
+
* If you require some one-off colors, but still want to use the line tag component,
|
40
|
+
* you can do so like this:
|
41
|
+
*
|
42
|
+
* ```tsx
|
43
|
+
* <LineIcon
|
44
|
+
* variant="custom"
|
45
|
+
* customIconVariant="ferry"
|
46
|
+
* foregroundColor="#b4da55"
|
47
|
+
* backgroundColor="#c0ffee"
|
48
|
+
* />
|
49
|
+
* ```
|
50
|
+
*
|
26
51
|
* @see https://spor.vy.no/components/line-tags
|
27
52
|
*/
|
28
53
|
export const LineIcon = ({
|
@@ -31,8 +56,16 @@ export const LineIcon = ({
|
|
31
56
|
sx,
|
32
57
|
...rest
|
33
58
|
}: LineIconProps) => {
|
34
|
-
const styles = useMultiStyleConfig("LineIcon", { variant, size });
|
35
|
-
const Icon: any = getCorrectIcon({
|
59
|
+
const styles = useMultiStyleConfig("LineIcon", { variant, size, ...rest });
|
60
|
+
const Icon: any = getCorrectIcon({
|
61
|
+
variant:
|
62
|
+
variant === "custom" && "customIconVariant" in rest
|
63
|
+
? rest.customIconVariant
|
64
|
+
: variant === "custom"
|
65
|
+
? "local-train"
|
66
|
+
: variant,
|
67
|
+
size,
|
68
|
+
});
|
36
69
|
if (!Icon) {
|
37
70
|
return null;
|
38
71
|
}
|
@@ -58,6 +58,19 @@ export type TravelTagProps = TagProps &
|
|
58
58
|
* />
|
59
59
|
* ```
|
60
60
|
*
|
61
|
+
* If required, you can also override the colors and icons in these travel tags:
|
62
|
+
*
|
63
|
+
* ```tsx
|
64
|
+
* <TravelTag
|
65
|
+
* variant="custom"
|
66
|
+
* customIconVariant="ferry"
|
67
|
+
* foregroundColor="#b4da55"
|
68
|
+
* backgroundColor="#c0ffee"
|
69
|
+
* title="3"
|
70
|
+
* description="Ringen"
|
71
|
+
* />
|
72
|
+
* ```
|
73
|
+
*
|
61
74
|
* @see https://spor.vy.no/components/line-tags
|
62
75
|
*/
|
63
76
|
export const TravelTag = forwardRef<TravelTagProps, As>(
|
@@ -77,13 +90,20 @@ export const TravelTag = forwardRef<TravelTagProps, As>(
|
|
77
90
|
variant,
|
78
91
|
size,
|
79
92
|
deviationLevel,
|
93
|
+
foregroundColor: variant === "custom" ? rest.foregroundColor : undefined,
|
94
|
+
backgroundColor: variant === "custom" ? rest.backgroundColor : undefined,
|
80
95
|
});
|
81
96
|
|
82
97
|
const DeviationLevelIcon = getDeviationLevelIcon({ deviationLevel, size });
|
83
98
|
|
84
99
|
return (
|
85
100
|
<Box sx={styles.container} aria-disabled={isDisabled} ref={ref} {...rest}>
|
86
|
-
<LineIcon
|
101
|
+
<LineIcon
|
102
|
+
variant={variant}
|
103
|
+
size={size}
|
104
|
+
sx={styles.iconContainer}
|
105
|
+
{...(rest as any)}
|
106
|
+
/>
|
87
107
|
<Box sx={styles.textContainer}>
|
88
108
|
{title && (
|
89
109
|
<Box as="span" sx={styles.title}>
|
package/src/linjetag/types.d.ts
CHANGED
@@ -16,9 +16,24 @@ export type Size = "sm" | "md" | "lg";
|
|
16
16
|
|
17
17
|
export type TagType = "info" | "travel";
|
18
18
|
|
19
|
-
export type TagProps = {
|
20
|
-
variant: Variant;
|
19
|
+
export type TagProps = VariantProps & {
|
21
20
|
size: Size;
|
22
21
|
title: string;
|
23
22
|
description?: string;
|
24
23
|
};
|
24
|
+
|
25
|
+
type DefaultVariantProps = {
|
26
|
+
variant: Variant;
|
27
|
+
};
|
28
|
+
type CustomVariantProps = {
|
29
|
+
variant: "custom";
|
30
|
+
/** When variant="custom", the foreground color of the tag */
|
31
|
+
foregroundColor: string;
|
32
|
+
/** When variant="custom", the background color of the tag */
|
33
|
+
backgroundColor: string;
|
34
|
+
/** When variant="custom", this is the icon you want to display.
|
35
|
+
* It should be one of the other variants
|
36
|
+
*/
|
37
|
+
customIconVariant: Variant;
|
38
|
+
};
|
39
|
+
type VariantProps = DefaultVariantProps | CustomVariantProps;
|
@@ -2,13 +2,11 @@ import { defineStyleConfig } from "@chakra-ui/react";
|
|
2
2
|
import { mode } from "@chakra-ui/theme-tools";
|
3
3
|
import { colors } from "../foundations";
|
4
4
|
import { getBoxShadowString } from "../utils/box-shadow-utils";
|
5
|
-
import { focusVisible } from "../utils/focus-utils";
|
6
5
|
|
7
6
|
const config = defineStyleConfig({
|
8
7
|
baseStyle: {
|
9
8
|
border: 0,
|
10
9
|
borderRadius: "xl",
|
11
|
-
fontWeight: "bold",
|
12
10
|
transitionProperty: "common",
|
13
11
|
transitionDuration: "normal",
|
14
12
|
textWrap: "wrap",
|
@@ -36,18 +34,15 @@ const config = defineStyleConfig({
|
|
36
34
|
// hardcoded background color as alpha-"hack" below is not feasible for dark mode with solid background color
|
37
35
|
backgroundColor: mode("pine", "coralGreen")(props),
|
38
36
|
color: mode("white", "darkTeal")(props),
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
},
|
49
|
-
notFocus: { boxShadow: "none" },
|
50
|
-
}),
|
37
|
+
_focusVisible: {
|
38
|
+
boxShadow: `inset 0 0 0 2px ${mode(
|
39
|
+
colors.greenHaze,
|
40
|
+
colors.azure,
|
41
|
+
)(props)}, inset 0 0 0 4px ${mode(
|
42
|
+
colors.white,
|
43
|
+
colors.darkGrey,
|
44
|
+
)(props)}`,
|
45
|
+
},
|
51
46
|
_hover: {
|
52
47
|
backgroundColor: mode("darkTeal", "blueGreen")(props),
|
53
48
|
},
|
@@ -58,34 +53,29 @@ const config = defineStyleConfig({
|
|
58
53
|
secondary: (props) => ({
|
59
54
|
// FIXME: Update to use global defined background color for darkMode whenever it is available instead of alpha
|
60
55
|
backgroundColor: mode("seaMist", "primaryGreen")(props),
|
61
|
-
color: mode("darkTeal", "
|
56
|
+
color: mode("darkTeal", "seaMist")(props),
|
62
57
|
// order is important here for now while we do not have global defined background color for darkMode
|
63
58
|
_hover: {
|
64
59
|
backgroundColor: mode("coralGreen", "greenHaze")(props),
|
65
60
|
},
|
66
|
-
|
67
|
-
|
61
|
+
_focusVisible: {
|
62
|
+
boxShadow: `inset 0 0 0 2px ${mode(
|
63
|
+
colors.greenHaze,
|
64
|
+
colors.primaryGreen,
|
65
|
+
)(props)}, inset 0 0 0 4px ${mode(
|
66
|
+
colors.white,
|
67
|
+
colors.darkTeal,
|
68
|
+
)(props)}`,
|
69
|
+
_hover: {
|
68
70
|
boxShadow: `inset 0 0 0 2px ${mode(
|
69
71
|
colors.greenHaze,
|
70
|
-
colors.
|
72
|
+
colors.azure,
|
71
73
|
)(props)}, inset 0 0 0 4px ${mode(
|
72
74
|
colors.white,
|
73
|
-
colors.
|
75
|
+
colors.blackAlpha[500],
|
74
76
|
)(props)}`,
|
75
|
-
_hover: {
|
76
|
-
boxShadow: `inset 0 0 0 2px ${mode(
|
77
|
-
colors.greenHaze,
|
78
|
-
colors.azure,
|
79
|
-
)(props)}, inset 0 0 0 4px ${mode(
|
80
|
-
colors.white,
|
81
|
-
colors.blackAlpha[500],
|
82
|
-
)(props)}`,
|
83
|
-
},
|
84
77
|
},
|
85
|
-
|
86
|
-
boxShadow: "none",
|
87
|
-
},
|
88
|
-
}),
|
78
|
+
},
|
89
79
|
_active: {
|
90
80
|
backgroundColor: mode("mint", "darkTeal")(props),
|
91
81
|
boxShadow: `inset 0 0 0 2px ${mode(
|
@@ -109,25 +99,16 @@ const config = defineStyleConfig({
|
|
109
99
|
tertiary: (props) => ({
|
110
100
|
backgroundColor: "transparent",
|
111
101
|
color: mode("darkGrey", "white")(props),
|
112
|
-
fontWeight: "normal",
|
113
102
|
boxShadow: `inset 0 0 0 1px ${mode(
|
114
103
|
colors.blackAlpha[400],
|
115
104
|
colors.whiteAlpha[400],
|
116
105
|
)(props)}`,
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
},
|
124
|
-
notFocus: {
|
125
|
-
boxShadow: `inset 0 0 0 1px ${mode(
|
126
|
-
colors.blackAlpha[400],
|
127
|
-
colors.whiteAlpha[400],
|
128
|
-
)(props)}`,
|
129
|
-
},
|
130
|
-
}),
|
106
|
+
_focusVisible: {
|
107
|
+
boxShadow: getBoxShadowString({
|
108
|
+
borderWidth: 2,
|
109
|
+
borderColor: "azure",
|
110
|
+
}),
|
111
|
+
},
|
131
112
|
_hover: {
|
132
113
|
boxShadow: `inset 0 0 0 2px currentColor`,
|
133
114
|
},
|
@@ -142,18 +123,12 @@ const config = defineStyleConfig({
|
|
142
123
|
ghost: (props) => ({
|
143
124
|
backgroundColor: "transparent",
|
144
125
|
color: mode("darkGrey", "white")(props),
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
}),
|
152
|
-
},
|
153
|
-
notFocus: {
|
154
|
-
outline: "none",
|
155
|
-
},
|
156
|
-
}),
|
126
|
+
_focusVisible: {
|
127
|
+
boxShadow: getBoxShadowString({
|
128
|
+
borderColor: mode("greenHaze", "azure")(props),
|
129
|
+
borderWidth: 2,
|
130
|
+
}),
|
131
|
+
},
|
157
132
|
_hover: {
|
158
133
|
backgroundColor: mode("seaMist", "whiteAlpha.200")(props),
|
159
134
|
_disabled: {
|
@@ -181,26 +156,20 @@ const config = defineStyleConfig({
|
|
181
156
|
borderWidth: 2,
|
182
157
|
}),
|
183
158
|
},
|
184
|
-
|
185
|
-
|
159
|
+
_focusVisible: {
|
160
|
+
boxShadow: getBoxShadowString({
|
161
|
+
borderColor: mode("greenHaze", "azure")(props),
|
162
|
+
borderWidth: 2,
|
163
|
+
baseShadow: "sm",
|
164
|
+
}),
|
165
|
+
_hover: {
|
186
166
|
boxShadow: getBoxShadowString({
|
187
167
|
borderColor: mode("greenHaze", "azure")(props),
|
188
168
|
borderWidth: 2,
|
189
|
-
baseShadow: "
|
169
|
+
baseShadow: "md",
|
190
170
|
}),
|
191
|
-
_hover: {
|
192
|
-
boxShadow: getBoxShadowString({
|
193
|
-
borderColor: mode("greenHaze", "azure")(props),
|
194
|
-
borderWidth: 2,
|
195
|
-
baseShadow: "md",
|
196
|
-
}),
|
197
|
-
},
|
198
171
|
},
|
199
|
-
|
200
|
-
outline: "none",
|
201
|
-
boxShadow: "sm",
|
202
|
-
},
|
203
|
-
}),
|
172
|
+
},
|
204
173
|
}),
|
205
174
|
},
|
206
175
|
sizes: {
|
@@ -208,22 +177,26 @@ const config = defineStyleConfig({
|
|
208
177
|
minHeight: 8,
|
209
178
|
minWidth: 8,
|
210
179
|
fontSize: "18px",
|
180
|
+
fontWeight: "bold",
|
211
181
|
},
|
212
182
|
md: {
|
213
183
|
minHeight: 7,
|
214
184
|
minWidth: 7,
|
215
185
|
fontSize: "18px",
|
186
|
+
fontWeight: "bold",
|
216
187
|
},
|
217
188
|
sm: {
|
218
189
|
minHeight: 6,
|
219
190
|
minWidth: 6,
|
220
191
|
fontSize: "16px",
|
192
|
+
fontWeight: "normal",
|
221
193
|
},
|
222
194
|
xs: {
|
223
195
|
minHeight: 5,
|
224
196
|
minWidth: 5,
|
225
197
|
fontSize: "16px",
|
226
198
|
paddingX: 2,
|
199
|
+
fontWeight: "normal",
|
227
200
|
},
|
228
201
|
},
|
229
202
|
defaultProps: {
|