@vygruppen/spor-react 9.8.3 → 9.10.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.
@@ -1,60 +1,99 @@
1
- import { defineStyleConfig } from "@chakra-ui/react";
1
+ import {
2
+ createMultiStyleConfigHelpers,
3
+ defineStyleConfig,
4
+ } from "@chakra-ui/react";
2
5
  import { baseBackground, baseBorder, baseText } from "../utils/base-utils";
3
6
  import { floatingBackground, floatingBorder } from "../utils/floating-utils";
4
7
  import { focusVisibleStyles } from "../utils/focus-utils";
8
+ import { anatomy } from "@chakra-ui/theme-tools";
9
+ import { outlineBorder } from "../utils/outline-utils";
5
10
 
6
- const config = defineStyleConfig({
11
+ const parts = anatomy("radio-card").parts("container", "checked", "radioInput");
12
+ const helpers = createMultiStyleConfigHelpers(parts.keys);
13
+
14
+ const config = helpers.defineMultiStyleConfig({
7
15
  baseStyle: (props: any) => ({
8
- appearance: "none",
9
- border: "none",
10
- overflow: "hidden",
11
- fontSize: "inherit",
12
- display: "block",
13
- borderRadius: "sm",
14
- ...focusVisibleStyles(props),
15
- _checked: {
16
- outline: "1px solid",
17
- outlineColor: "greenHaze",
18
- ...floatingBackground("active", props),
19
- _hover: {
20
- ...floatingBackground("active", props),
16
+ container: {
17
+ appearance: "none",
18
+ border: "none",
19
+ overflow: "hidden",
20
+ fontSize: "inherit",
21
+ display: "block",
22
+ cursor: "pointer",
23
+ borderRadius: "sm",
24
+ ...focusVisibleStyles(props),
25
+ transitionProperty: "common",
26
+ transitionDuration: "fast",
27
+ _disabled: {
28
+ pointerEvents: "none",
29
+ ...baseBackground("disabled", props),
30
+ ...baseBorder("disabled", props),
31
+ ...baseText("disabled", props),
21
32
  },
22
33
  },
23
- _disabled: {
24
- pointerEvents: "none",
25
- ...baseBackground("disabled", props),
26
- ...baseBorder("disabled", props),
27
- ...baseText("disabled", props),
34
+ checked: {
35
+ outline: "2px solid",
36
+ ...outlineBorder("focus", props),
37
+ ...floatingBackground("active", props),
38
+ },
39
+ radioInput: {
40
+ appearance: "none",
41
+ position: "absolute",
42
+ opacity: 0,
43
+ zIndex: -1,
28
44
  },
29
45
  }),
30
46
  variants: {
31
47
  base: (props) => ({
32
- ...baseBackground("default", props),
33
- ...baseBorder("default", props),
34
- _hover: {
35
- ...baseBackground("hover", props),
36
- ...baseBorder("hover", props),
48
+ container: {
49
+ ...baseText("default", props),
50
+ ...baseBackground("default", props),
51
+ ...baseBorder("default", props),
52
+ _hover: {
53
+ ...baseBackground("hover", props),
54
+ ...baseBorder("hover", props),
55
+ },
56
+ _active: {
57
+ ...baseBackground("active", props),
58
+ ...baseBorder("active", props),
59
+ },
37
60
  },
38
- _active: {
39
- ...baseBackground("active", props),
61
+ checked: {
62
+ _hover: {
63
+ ...baseBorder("hover", props),
64
+ },
65
+ _active: {
66
+ ...baseBackground("active", props),
67
+ ...baseBorder("active", props),
68
+ },
40
69
  },
41
70
  }),
42
71
  floating: (props) => ({
43
- ...floatingBackground("default", props),
44
- boxShadow: "sm",
45
- _hover: {
46
- ...floatingBackground("hover", props),
47
- ...floatingBorder("hover", props),
48
- boxShadow: "md",
49
- },
50
- _active: {
51
- ...floatingBackground("active", props),
52
- ...floatingBorder("active", props),
72
+ container: {
73
+ ...baseText("default", props),
74
+ ...baseBackground("default", props),
75
+ ...floatingBackground("default", props),
76
+ ...floatingBorder("default", props),
77
+ boxShadow: "sm",
78
+ _hover: {
79
+ ...floatingBackground("hover", props),
80
+ ...floatingBorder("hover", props),
81
+ boxShadow: "md",
82
+ },
83
+ _active: {
84
+ ...floatingBackground("active", props),
85
+ ...floatingBorder("active", props),
86
+ },
53
87
  },
54
- _checked: {
88
+ checked: {
89
+ cursor: "normal",
90
+
55
91
  _hover: {
56
- outline: "1px solid",
57
- outlineColor: "silver",
92
+ ...floatingBorder("hover", props),
93
+ },
94
+ _active: {
95
+ ...floatingBackground("active", props),
96
+ ...floatingBorder("active", props),
58
97
  },
59
98
  },
60
99
  }),
@@ -60,8 +60,11 @@ export function baseBorder(state: BorderState, props: StyleFunctionProps) {
60
60
  }
61
61
  case "active": {
62
62
  return {
63
- outline: "2px solid",
64
- outlineColor: mode("base.outline.light", "base.outline.dark")(props),
63
+ outline: "1px solid",
64
+ outlineColor: mode(
65
+ "base.outline.default.light",
66
+ "base.outline.default.dark",
67
+ )(props),
65
68
  };
66
69
  }
67
70
  case "invalid": {
@@ -25,14 +25,14 @@ export function floatingBackground(
25
25
  return {
26
26
  backgroundColor: mode(
27
27
  "floating.surface.hover.light",
28
- "floating.surface.hover.dark",
28
+ `color-mix(in srgb, white 10%, var(--spor-colors-bg-default-dark))`,
29
29
  )(props),
30
30
  };
31
31
  case "default":
32
32
  return {
33
33
  backgroundColor: mode(
34
- "floating.surface.default.light",
35
- "floating.surface.default.dark",
34
+ "white",
35
+ `color-mix(in srgb, white 10%, var(--spor-colors-bg-default-dark))`,
36
36
  )(props),
37
37
  };
38
38
  }
@@ -29,7 +29,10 @@ export function ghostBackground(
29
29
  };
30
30
  case "selected": {
31
31
  return {
32
- backgroundColor: mode("mint", "whiteAlpha.200")(props),
32
+ backgroundColor: mode(
33
+ "ghost.surface.selected.light",
34
+ "ghost.surface.selected.dark",
35
+ )(props),
33
36
  };
34
37
  }
35
38
  case "default":
@@ -38,3 +41,18 @@ export function ghostBackground(
38
41
  };
39
42
  }
40
43
  }
44
+
45
+ type GhostTextState = Subset<State, "default" | "selected">;
46
+
47
+ export function ghostText(state: GhostTextState, props: StyleFunctionProps) {
48
+ switch (state) {
49
+ case "selected":
50
+ return {
51
+ color: mode("ghost.text.light", "ghost.text.dark")(props),
52
+ };
53
+ default:
54
+ return {
55
+ color: mode("ghost.text.light", "ghost.text.dark")(props),
56
+ };
57
+ }
58
+ }
@@ -0,0 +1,26 @@
1
+ import { mode, StyleFunctionProps } from "@chakra-ui/theme-tools";
2
+ import { State, Subset } from "./types";
3
+
4
+ type OutlineBorderState = Subset<State, "default" | "error" | "focus">;
5
+ export function outlineBorder(
6
+ state: OutlineBorderState,
7
+ props: StyleFunctionProps,
8
+ ) {
9
+ switch (state) {
10
+ case "error":
11
+ return {
12
+ outlineColor: mode("outline.error.light", "outline.error.dark")(props),
13
+ };
14
+ case "focus":
15
+ return {
16
+ outlineColor: mode("outline.focus.light", "outline.focus.dark")(props),
17
+ };
18
+ default:
19
+ return {
20
+ outlineColor: mode(
21
+ "outline.default.light",
22
+ "outline.default.dark",
23
+ )(props),
24
+ };
25
+ }
26
+ }
@@ -5,7 +5,9 @@ export type State =
5
5
  | "focus"
6
6
  | "selected"
7
7
  | "invalid"
8
- | "disabled";
8
+ | "disabled"
9
+ | "error"
10
+ | "focus";
9
11
 
10
12
  // Helper type to extract subset of union types
11
13
  export type Subset<T, U extends T> = T extends U ? T : never;