@vygruppen/spor-react 13.3.1 → 13.4.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.
@@ -13,74 +13,52 @@ export const badgeRecipie = defineRecipe({
13
13
  neutral: {
14
14
  backgroundColor: "surface",
15
15
  color: "text",
16
- "& svg": {
17
- color: "icon",
18
- },
16
+ "& svg": { color: "icon" },
19
17
  },
20
18
  grey: {
21
19
  backgroundColor: "surface.neutral",
22
20
  color: "text.neutral",
23
- "& svg": {
24
- color: "icon.neutral",
25
- },
21
+ "& svg": { color: "icon.neutral" },
26
22
  },
27
23
  green: {
28
24
  backgroundColor: "surface.success",
29
25
  color: "text.success",
30
- "& svg": {
31
- color: "icon.success",
32
- },
26
+ "& svg": { color: "icon.success" },
33
27
  },
34
28
  blue: {
35
29
  backgroundColor: "surface.info",
36
30
  color: "text.info",
37
- "& svg": {
38
- color: "icon.info",
39
- },
31
+ "& svg": { color: "icon.info" },
40
32
  },
41
33
  cream: {
42
34
  backgroundColor: "surface.warning",
43
35
  color: "text.warning",
44
- "& svg": {
45
- color: "icon.warning",
46
- },
36
+ "& svg": { color: "icon.warning" },
47
37
  },
48
38
  yellow: {
49
39
  backgroundColor: "surface.notice",
50
40
  color: "text.notice",
51
- "& svg": {
52
- color: "icon.notice",
53
- },
41
+ "& svg": { color: "icon.notice" },
54
42
  },
55
43
  orange: {
56
44
  backgroundColor: "surface.caution",
57
45
  color: "text.caution",
58
- "& svg": {
59
- color: "icon.caution",
60
- },
46
+ "& svg": { color: "icon.caution" },
61
47
  },
62
48
  red: {
63
49
  backgroundColor: "surface.critical",
64
50
  color: "text.critical",
65
- "& svg": {
66
- color: "icon.critical",
67
- },
51
+ "& svg": { color: "icon.critical" },
68
52
  },
69
53
  brightRed: {
70
- backgroundColor: {
71
- _light: "brightRed",
72
- _dark: "brightRed",
73
- },
74
- color: {
75
- _light: "pink",
76
- _dark: "pink",
77
- },
78
- "& svg": {
79
- color: {
80
- _light: "pink",
81
- _dark: "pink",
82
- },
83
- },
54
+ backgroundColor: { _light: "brightRed", _dark: "brightRed" },
55
+ color: { _light: "pink", _dark: "pink" },
56
+ "& svg": { color: { _light: "pink", _dark: "pink" } },
57
+ },
58
+ disabled: {
59
+ backgroundColor: "surface.disabled",
60
+ color: "text.disabled",
61
+ "& svg": { color: "icon.disabled" },
84
62
  },
85
63
  },
86
64
  size: {
@@ -106,11 +84,7 @@ export const badgeRecipie = defineRecipe({
106
84
  borderRadius: "xs",
107
85
  },
108
86
  },
109
- attached: {
110
- true: {
111
- borderBottomRadius: "none",
112
- },
113
- },
87
+ attached: { true: { borderBottomRadius: "none" } },
114
88
  inverted: { true: {} },
115
89
  },
116
90
  defaultVariants: {
@@ -124,60 +98,27 @@ export const badgeRecipie = defineRecipe({
124
98
  colorPalette: "blue",
125
99
  inverted: true,
126
100
  css: {
127
- backgroundColor: {
128
- _light: "darkBlue",
129
- _dark: "lightBlue",
130
- },
131
- color: {
132
- _light: "icyBlue",
133
- _dark: "royal",
134
- },
135
- "& svg": {
136
- color: {
137
- _light: "royal",
138
- _dark: "icyBlue",
139
- },
140
- },
101
+ backgroundColor: { _light: "darkBlue", _dark: "lightBlue" },
102
+ color: { _light: "icyBlue", _dark: "royal" },
103
+ "& svg": { color: { _light: "royal", _dark: "icyBlue" } },
141
104
  },
142
105
  },
143
106
  {
144
107
  colorPalette: "green",
145
108
  inverted: true,
146
109
  css: {
147
- backgroundColor: {
148
- _light: "darkTeal",
149
- _dark: "seaMist",
150
- },
151
- color: {
152
- _light: "mint",
153
- _dark: "jungle",
154
- },
155
- "& svg": {
156
- color: {
157
- _light: "mint",
158
- _dark: "jungle",
159
- },
160
- },
110
+ backgroundColor: { _light: "darkTeal", _dark: "seaMist" },
111
+ color: { _light: "mint", _dark: "jungle" },
112
+ "& svg": { color: { _light: "mint", _dark: "jungle" } },
161
113
  },
162
114
  },
163
115
  {
164
116
  colorPalette: "grey",
165
117
  inverted: true,
166
118
  css: {
167
- backgroundColor: {
168
- _light: "carbon",
169
- _dark: "platinum",
170
- },
171
- color: {
172
- _light: "white",
173
- _dark: "darkGrey",
174
- },
175
- "& svg": {
176
- color: {
177
- _light: "white",
178
- _dark: "darkGrey",
179
- },
180
- },
119
+ backgroundColor: { _light: "carbon", _dark: "platinum" },
120
+ color: { _light: "white", _dark: "darkGrey" },
121
+ "& svg": { color: { _light: "white", _dark: "darkGrey" } },
181
122
  },
182
123
  },
183
124
  {
@@ -185,80 +126,36 @@ export const badgeRecipie = defineRecipe({
185
126
  colorPalette: "cream",
186
127
  inverted: true,
187
128
  css: {
188
- backgroundColor: {
189
- _light: "coffee",
190
- _dark: "blonde",
191
- },
192
- color: {
193
- _light: "cornsilk",
194
- _dark: "coffee",
195
- },
196
- "& svg": {
197
- color: {
198
- _light: "cornsilk",
199
- _dark: "coffee",
200
- },
201
- },
129
+ backgroundColor: { _light: "coffee", _dark: "blonde" },
130
+ color: { _light: "cornsilk", _dark: "coffee" },
131
+ "& svg": { color: { _light: "cornsilk", _dark: "coffee" } },
202
132
  },
203
133
  },
204
134
  {
205
135
  colorPalette: "yellow",
206
136
  inverted: true,
207
137
  css: {
208
- backgroundColor: {
209
- _light: "bronze",
210
- _dark: "banana",
211
- },
212
- color: {
213
- _light: "cornsilk",
214
- _dark: "coffee",
215
- },
216
- "& svg": {
217
- color: {
218
- _light: "cornsilk",
219
- _dark: "coffee",
220
- },
221
- },
138
+ backgroundColor: { _light: "bronze", _dark: "banana" },
139
+ color: { _light: "cornsilk", _dark: "coffee" },
140
+ "& svg": { color: { _light: "cornsilk", _dark: "coffee" } },
222
141
  },
223
142
  },
224
143
  {
225
144
  colorPalette: "orange",
226
145
  inverted: true,
227
146
  css: {
228
- backgroundColor: {
229
- _light: "wood",
230
- _dark: "champagne",
231
- },
232
- color: {
233
- _light: "bisque",
234
- _dark: "wood",
235
- },
236
- "& svg": {
237
- color: {
238
- _light: "bisque",
239
- _dark: "wood",
240
- },
241
- },
147
+ backgroundColor: { _light: "wood", _dark: "champagne" },
148
+ color: { _light: "bisque", _dark: "wood" },
149
+ "& svg": { color: { _light: "bisque", _dark: "wood" } },
242
150
  },
243
151
  },
244
152
  {
245
153
  colorPalette: "red",
246
154
  inverted: true,
247
155
  css: {
248
- backgroundColor: {
249
- _light: "burgundy",
250
- _dark: "lightRed",
251
- },
252
- color: {
253
- _light: "pink",
254
- _dark: "maroon",
255
- },
256
- "& svg": {
257
- color: {
258
- _light: "pink",
259
- _dark: "maroon",
260
- },
261
- },
156
+ backgroundColor: { _light: "burgundy", _dark: "lightRed" },
157
+ color: { _light: "pink", _dark: "maroon" },
158
+ "& svg": { color: { _light: "pink", _dark: "maroon" } },
262
159
  },
263
160
  },
264
161
  {
@@ -266,20 +163,9 @@ export const badgeRecipie = defineRecipe({
266
163
  colorPalette: "neutral",
267
164
  inverted: true,
268
165
  css: {
269
- backgroundColor: {
270
- _light: "ink",
271
- _dark: "white",
272
- },
273
- color: {
274
- _light: "white",
275
- _dark: "darkGrey",
276
- },
277
- "& svg": {
278
- color: {
279
- _light: "white",
280
- _dark: "darkGrey",
281
- },
282
- },
166
+ backgroundColor: { _light: "ink", _dark: "white" },
167
+ color: { _light: "white", _dark: "darkGrey" },
168
+ "& svg": { color: { _light: "white", _dark: "darkGrey" } },
283
169
  },
284
170
  },
285
171
  ],
@@ -13,10 +13,6 @@ export const inputRecipe = defineRecipe({
13
13
  transitionDuration: "fast",
14
14
  color: "text",
15
15
  position: "relative",
16
- paddingX: 3,
17
- paddingTop: 3,
18
- height: 8,
19
- fontSize: "mobile.md",
20
16
 
21
17
  _disabled: {
22
18
  backgroundColor: "surface.disabled",
@@ -83,8 +79,23 @@ export const inputRecipe = defineRecipe({
83
79
  },
84
80
  },
85
81
  },
82
+ size: {
83
+ sm: {
84
+ paddingTop: 2,
85
+ height: 7,
86
+ fontSize: "xs",
87
+ paddingX: 2,
88
+ },
89
+ md: {
90
+ paddingX: 3,
91
+ paddingTop: 3,
92
+ height: 8,
93
+ fontSize: "mobile.md",
94
+ },
95
+ },
86
96
  },
87
97
  defaultVariants: {
88
98
  variant: "core",
99
+ size: "md",
89
100
  },
90
101
  });
@@ -201,12 +201,10 @@ export const selectAnatomy = createAnatomy("select").parts(
201
201
  "root",
202
202
  "trigger",
203
203
  "indicatorGroup",
204
- "indicator",
205
- "selectContent",
204
+ "content",
206
205
  "item",
207
206
  "control",
208
207
  "itemText",
209
- "itemDescription",
210
208
  "itemGroup",
211
209
  "itemGroupLabel",
212
210
  "label",
@@ -14,7 +14,6 @@ export const breadcrumbSlotRecipe = defineSlotRecipe({
14
14
  },
15
15
  link: {
16
16
  cursor: "pointer",
17
- padding: 0.5,
18
17
  borderRadius: "xs",
19
18
  },
20
19
  currentLink: {
@@ -14,17 +14,15 @@ export const fieldSlotRecipe = defineSlotRecipe({
14
14
  },
15
15
  requiredIndicator: {
16
16
  marginStart: 1,
17
- // eslint-disable-next-line spor/use-semantic-tokens
18
- color: "brightRed",
17
+ color: "outline.error",
19
18
  },
20
19
  label: {
21
20
  display: "flex",
22
21
  },
23
22
  helperText: {
24
- marginTop: 2,
25
23
  color: "text.subtle",
26
24
  lineHeight: "normal",
27
- fontSize: "sm",
25
+ fontSize: ["mobile.sm", "desktop.sm"],
28
26
  },
29
27
  errorText: {
30
28
  borderRadius: "xs",
@@ -52,4 +50,40 @@ export const fieldSlotRecipe = defineSlotRecipe({
52
50
  },
53
51
  },
54
52
  },
53
+ variants: {
54
+ size: {
55
+ sm: {
56
+ label: {
57
+ fontSize: ["mobile.xs", "desktop.xs"],
58
+ paddingX: 2,
59
+
60
+ "&[data-float]": {
61
+ fontSize: ["mobile.2xs", "desktop.2xs"],
62
+ top: 0,
63
+ },
64
+ top: "0.5rem",
65
+ },
66
+ helperText: {
67
+ color: "text.subtle",
68
+ lineHeight: "normal",
69
+ fontSize: ["mobile.xs", "desktop.xs"],
70
+ },
71
+ },
72
+ md: {
73
+ label: {
74
+ paddingX: 3,
75
+ fontSize: ["mobile.sm", "desktop.sm"],
76
+ "&[data-float]": {
77
+ fontSize: ["mobile.2xs", "desktop.2xs"],
78
+ color: "text.subtle",
79
+ top: "0.3rem",
80
+ },
81
+ top: "0.9rem",
82
+ },
83
+ },
84
+ },
85
+ },
86
+ defaultVariants: {
87
+ size: "md",
88
+ },
55
89
  });
@@ -55,5 +55,20 @@ export const nativeSelectSlotRecipe = defineSlotRecipe({
55
55
  },
56
56
  },
57
57
  },
58
+ size: {
59
+ sm: {
60
+ field: {
61
+ ...inputRecipe.variants?.size?.sm,
62
+ },
63
+ },
64
+ md: {
65
+ field: {
66
+ ...inputRecipe.variants?.size?.md,
67
+ },
68
+ },
69
+ },
70
+ },
71
+ defaultVariants: {
72
+ size: "md",
58
73
  },
59
74
  });
@@ -16,15 +16,9 @@ export const selectSlotRecipe = defineSlotRecipe({
16
16
  label: {
17
17
  fontSize: ["mobile.sm", "desktop.sm"],
18
18
  top: 0,
19
- left: 3,
20
19
  zIndex: 0,
21
20
  position: "absolute",
22
21
  color: "text",
23
- marginY: 2,
24
-
25
- _selected: {
26
- transform: ["scale(0.825) translateY(-10px)"],
27
- },
28
22
 
29
23
  transitionProperty: "transform",
30
24
  transitionDuration: "fast",
@@ -36,14 +30,10 @@ export const selectSlotRecipe = defineSlotRecipe({
36
30
  display: "flex",
37
31
  appearance: "none",
38
32
  width: "100%",
39
- height: 8,
40
33
  color: "text",
41
- paddingY: 1.5,
42
- paddingX: 3,
43
34
 
44
35
  justifyContent: "space-between",
45
36
  alignItems: "center",
46
- fontSize: "mobile.md",
47
37
  borderRadius: "sm",
48
38
  cursor: "pointer",
49
39
 
@@ -52,11 +42,14 @@ export const selectSlotRecipe = defineSlotRecipe({
52
42
  transform: "rotate(180deg)",
53
43
  },
54
44
  },
45
+ _active: {
46
+ backgroundColor: "surface",
47
+ },
55
48
  },
56
49
  indicatorGroup: {
57
50
  display: "flex",
58
51
  alignItems: "center",
59
- gap: "1",
52
+ gap: "0.5",
60
53
  position: "absolute",
61
54
  right: "0",
62
55
  top: "0",
@@ -64,22 +57,22 @@ export const selectSlotRecipe = defineSlotRecipe({
64
57
  paddingX: 2,
65
58
 
66
59
  pointerEvents: "none",
67
- },
68
- indicator: {
69
- display: "flex",
70
- alignItems: "center",
71
- justifyContent: "center",
72
- color: {
73
- base: "text",
74
- _disabled: "text.disabled",
75
- _invalid: "text.highlight",
76
- },
77
- _icon: {
78
- width: 3,
79
- height: 3,
60
+ "& [data-part='indicator']": {
61
+ display: "flex",
62
+ alignItems: "center",
63
+ justifyContent: "center",
64
+ color: {
65
+ base: "text",
66
+ _disabled: "text.disabled",
67
+ _invalid: "text.highlight",
68
+ },
69
+ _icon: {
70
+ width: 3,
71
+ height: 3,
72
+ },
80
73
  },
81
74
  },
82
- selectContent: {
75
+ content: {
83
76
  backgroundColor: "surface",
84
77
  boxShadow: "sm",
85
78
  overflowY: "auto",
@@ -134,8 +127,6 @@ export const selectSlotRecipe = defineSlotRecipe({
134
127
  },
135
128
  _hover: {
136
129
  backgroundColor: "surface.accent.hover",
137
- outline: "2px solid core.outline",
138
- outlineOffset: "2px",
139
130
  },
140
131
  _selected: {
141
132
  backgroundColor: "surface.accent",
@@ -144,6 +135,10 @@ export const selectSlotRecipe = defineSlotRecipe({
144
135
  width: 3,
145
136
  height: 3,
146
137
  },
138
+ "& [data-part='item-description']": {
139
+ fontSize: ["mobile.xs", "desktop.xs"],
140
+ color: "text.ghost",
141
+ },
147
142
  },
148
143
  control: {
149
144
  position: "relative",
@@ -162,6 +157,7 @@ export const selectSlotRecipe = defineSlotRecipe({
162
157
  },
163
158
  itemText: {
164
159
  flex: "1",
160
+ alignItems: "center",
165
161
  },
166
162
  itemGroup: {
167
163
  _first: { mt: "0" },
@@ -170,14 +166,6 @@ export const selectSlotRecipe = defineSlotRecipe({
170
166
  py: "1",
171
167
  fontWeight: "medium",
172
168
  },
173
- valueText: {},
174
- itemDescription: {
175
- fontSize: ["mobile.xs", "desktop.xs"],
176
- color: "text.ghost",
177
- "[aria-selected='true'] &": {
178
- color: "text.ghost",
179
- },
180
- },
181
169
  },
182
170
  variants: {
183
171
  variant: {
@@ -198,6 +186,10 @@ export const selectSlotRecipe = defineSlotRecipe({
198
186
  backgroundColor: "surface.disabled",
199
187
  },
200
188
  },
189
+ content: {
190
+ outline: "2px solid",
191
+ outlineColor: "outline.core",
192
+ },
201
193
  },
202
194
  floating: {
203
195
  control: {
@@ -242,5 +234,66 @@ export const selectSlotRecipe = defineSlotRecipe({
242
234
  },
243
235
  },
244
236
  },
237
+ size: {
238
+ sm: {
239
+ trigger: {
240
+ height: 7,
241
+ paddingY: 1.5,
242
+ fontSize: "xs",
243
+ paddingX: 2,
244
+ },
245
+ label: {
246
+ fontSize: ["mobile.xs", "desktop.xs"],
247
+ left: 2,
248
+ marginY: 1.5,
249
+ _selected: {
250
+ transform: ["scale(0.85) translateY(-9px)"],
251
+ fontSize: "desktop.2xs",
252
+ color: "text.subtle",
253
+ },
254
+ },
255
+ item: {
256
+ paddingX: 2,
257
+ paddingY: 1,
258
+ fontSize: "xs",
259
+ "& [data-part='item-description']": {
260
+ fontSize: ["mobile.2xs", "desktop.2xs"],
261
+ },
262
+ },
263
+ itemGroupLabel: {
264
+ py: 0.5,
265
+ fontSize: "xs",
266
+ },
267
+ valueText: {
268
+ paddingTop: 0,
269
+ "&[data-with-placeholder]": {
270
+ paddingTop: "1.5",
271
+ },
272
+ },
273
+ },
274
+ md: {
275
+ trigger: {
276
+ height: 8,
277
+ paddingY: 1.5,
278
+ paddingX: 3,
279
+ fontSize: "sm",
280
+ },
281
+ label: {
282
+ left: 3,
283
+ marginY: 2,
284
+ _selected: {
285
+ transform: ["scale(0.825) translateY(-10px)"],
286
+ },
287
+ },
288
+ valueText: {
289
+ "&[data-with-placeholder]": {
290
+ paddingTop: "4",
291
+ },
292
+ },
293
+ },
294
+ },
295
+ },
296
+ defaultVariants: {
297
+ size: "md",
245
298
  },
246
299
  });
@@ -6,18 +6,14 @@ import {
6
6
  } from "@chakra-ui/react";
7
7
  import { IconComponent } from "@vygruppen/spor-icon-react";
8
8
 
9
- export type BadgeProps = ChakraBadgeProps & {
10
- icon?: IconComponent;
11
- };
9
+ export type BadgeProps = ChakraBadgeProps & { icon?: IconComponent };
12
10
 
13
11
  export const Badge = function Badge({
14
12
  ref,
15
13
  icon,
16
14
  children,
17
15
  ...props
18
- }: BadgeProps & {
19
- ref?: React.Ref<HTMLSpanElement>;
20
- }) {
16
+ }: BadgeProps & { ref?: React.Ref<HTMLSpanElement> }) {
21
17
  return (
22
18
  <ChakraBadge ref={ref} {...props}>
23
19
  {children}
package/tsconfig.json CHANGED
@@ -6,9 +6,7 @@
6
6
  "lib": ["dom", "es2023"],
7
7
  "rootDir": ".",
8
8
 
9
- "paths": {
10
- "@/*": ["./src/*"]
11
- },
9
+ "paths": { "@/*": ["./src/*"] },
12
10
  "resolveJsonModule": true
13
11
  }
14
12
  }
@@ -0,0 +1,12 @@
1
+ import { defineConfig } from "vitest/config";
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ globals: true, // Allows using 'describe', 'test', and 'expect' without importing them
6
+ environment: "jsdom",
7
+ setupFiles: "./setupTests.ts", // Global test helpers or mocks
8
+ typecheck: {
9
+ enabled: true,
10
+ },
11
+ },
12
+ });