@vygruppen/spor-react 4.0.1 → 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.
@@ -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
+ }