@vygruppen/spor-react 3.7.3 → 3.7.4

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,6 +1,6 @@
1
1
  import { Box, BoxProps, useMultiStyleConfig } from "@chakra-ui/react";
2
2
  import { motion } from "framer-motion";
3
- import React from "react";
3
+ import React, { useEffect } from "react";
4
4
 
5
5
  const MotionBox = motion(Box);
6
6
 
@@ -33,10 +33,10 @@ export const FloatingActionButton = ({
33
33
  ...props
34
34
  }: FloatingActionButtonProps) => {
35
35
  const [isTextVisible, setIsTextVisible] = React.useState(
36
- externalIsTextVisible !== undefined ? externalIsTextVisible : true
36
+ externalIsTextVisible !== undefined ? externalIsTextVisible : false
37
37
  );
38
38
  const scrollDirection = useScrollDirection();
39
- React.useEffect(() => {
39
+ useEffect(() => {
40
40
  if (externalIsTextVisible !== undefined) {
41
41
  return;
42
42
  }
@@ -47,7 +47,7 @@ export const FloatingActionButton = ({
47
47
  return () => window.clearTimeout(id);
48
48
  }, [scrollDirection, externalIsTextVisible]);
49
49
 
50
- React.useEffect(() => {
50
+ useEffect(() => {
51
51
  setIsTextVisible(!!externalIsTextVisible);
52
52
  }, [externalIsTextVisible]);
53
53
 
@@ -63,12 +63,10 @@ export const FloatingActionButton = ({
63
63
  aria-label={children}
64
64
  {...props}
65
65
  >
66
- <Box __css={style.icon}>
67
- {icon}
68
- </Box>
66
+ <Box __css={style.icon}>{icon}</Box>
69
67
  <MotionBox
70
68
  animate={isTextVisible ? "show" : "hide"}
71
- initial="show"
69
+ initial={externalIsTextVisible ? "show" : "hide"}
72
70
  variants={{
73
71
  show: {
74
72
  opacity: 1,
@@ -93,7 +91,9 @@ type ScrollDirection = "up" | "down" | null;
93
91
  const useScrollDirection = () => {
94
92
  const [scrollDirection, setScrollDirection] =
95
93
  React.useState<ScrollDirection>(null);
96
- const lastScrollPosition = React.useRef(typeof window !== "undefined" ? window.scrollY : 0);
94
+ const lastScrollPosition = React.useRef(
95
+ typeof window !== "undefined" ? window.scrollY : 0
96
+ );
97
97
  React.useEffect(() => {
98
98
  const onScroll = () => {
99
99
  const delta = window.scrollY - lastScrollPosition.current;
@@ -83,6 +83,8 @@ export const ChoiceChip = forwardRef((props: ChoiceChipProps, ref) => {
83
83
  data-checked={dataAttr(state.isChecked)}
84
84
  data-hover={dataAttr(state.isHovered)}
85
85
  data-focus={dataAttr(state.isFocused)}
86
+ data-active={dataAttr(state.isActive)}
87
+ data-disabled={dataAttr(state.isDisabled)}
86
88
  >
87
89
  {icon && (
88
90
  <chakra.span __css={styles.icon}>
@@ -1,12 +1,13 @@
1
1
  import { accordionAnatomy as parts } from "@chakra-ui/anatomy";
2
2
  import { createMultiStyleConfigHelpers } from "@chakra-ui/styled-system";
3
- import { colors } from "../foundations";
3
+ import { colors, shadows } from "../foundations";
4
4
  import { getBoxShadowString } from "../utils/box-shadow-utils";
5
5
  import { focusVisible } from "../utils/focus-utils";
6
+ import { mode } from "@chakra-ui/theme-tools";
6
7
 
7
8
  const helpers = createMultiStyleConfigHelpers(parts.keys);
8
9
  const config = helpers.defineMultiStyleConfig({
9
- baseStyle: {
10
+ baseStyle: (props) => ({
10
11
  container: {
11
12
  border: "none",
12
13
  borderRadius: "sm",
@@ -19,7 +20,7 @@ const config = helpers.defineMultiStyleConfig({
19
20
  borderRadius: "sm",
20
21
  display: "flex",
21
22
  justifyContent: "space-between",
22
- color: "darkGrey",
23
+ color: mode("darkGrey", "white")(props),
23
24
  textAlign: "left",
24
25
  fontFamily: "body",
25
26
  fontWeight: "bold",
@@ -31,7 +32,7 @@ const config = helpers.defineMultiStyleConfig({
31
32
  },
32
33
  focus: {
33
34
  boxShadow: getBoxShadowString({
34
- borderColor: "greenHaze",
35
+ borderColor: mode("greenHaze", "azure")(props),
35
36
  borderWidth: 2,
36
37
  }),
37
38
  },
@@ -48,23 +49,26 @@ const config = helpers.defineMultiStyleConfig({
48
49
  icon: {
49
50
  fontSize: "1.25em",
50
51
  },
51
- },
52
+ }),
52
53
  variants: {
53
- list: {
54
+ list: (props) => ({
54
55
  button: {
55
56
  boxShadow: "none",
56
57
  _hover: {
57
- backgroundColor: "seaMist",
58
+ backgroundColor: mode("seaMist", "pine")(props),
58
59
  },
59
60
  _active: {
60
- backgroundColor: "mint",
61
+ backgroundColor: mode("mint", "whiteAlpha.200")(props),
61
62
  },
62
63
  },
63
- },
64
- outline: {
64
+ }),
65
+ outline: (props) => ({
65
66
  container: {
66
67
  boxShadow: getBoxShadowString({
67
- borderColor: colors.blackAlpha["400"],
68
+ borderColor: mode(
69
+ colors.blackAlpha["400"],
70
+ colors.whiteAlpha["400"],
71
+ )(props),
68
72
  }),
69
73
  },
70
74
  button: {
@@ -73,23 +77,24 @@ const config = helpers.defineMultiStyleConfig({
73
77
  },
74
78
  _hover: {
75
79
  boxShadow: getBoxShadowString({
76
- borderColor: "darkGrey",
80
+ borderColor: mode("darkGrey", "white")(props),
77
81
  borderWidth: 2,
78
82
  }),
79
83
  },
80
84
  _active: {
81
- backgroundColor: "mint",
85
+ backgroundColor: mode("mint", "whiteAlpha.100")(props),
82
86
  boxShadow: getBoxShadowString({
83
- borderColor: "darkGrey",
87
+ borderColor: mode("darkGrey", colors.whiteAlpha[400])(props),
84
88
  }),
85
89
  },
86
90
  },
87
- },
88
- card: {
91
+ }),
92
+ card: (props) => ({
89
93
  container: {
94
+ backgroundColor: mode("white", "whiteAlpha.100")(props),
90
95
  boxShadow: getBoxShadowString({
91
- baseShadow: "sm",
92
- borderColor: "silver",
96
+ baseShadow: mode<keyof typeof shadows>("sm", "none")(props),
97
+ borderColor: mode("silver", "whiteAlpha.400")(props),
93
98
  }),
94
99
  },
95
100
  button: {
@@ -97,13 +102,22 @@ const config = helpers.defineMultiStyleConfig({
97
102
  borderBottomRadius: "none",
98
103
  },
99
104
  _hover: {
100
- backgroundColor: "seaMist",
105
+ backgroundColor: mode("seaMist", "whiteAlpha.200")(props),
106
+ boxShadow: getBoxShadowString({
107
+ borderColor: mode("darkGrey", "white")(props),
108
+ borderWidth: 1,
109
+ }),
101
110
  },
102
111
  _active: {
103
- backgroundColor: "mint",
112
+ backgroundColor: mode("mint", "inherit")(props),
113
+ boxShadow: getBoxShadowString({
114
+ baseShadow: "none",
115
+ borderWidth: 1,
116
+ borderColor: mode("darkGrey", "whiteAlpha.400")(props),
117
+ }),
104
118
  },
105
119
  },
106
- },
120
+ }),
107
121
  },
108
122
  sizes: {
109
123
  sm: {
@@ -111,6 +125,7 @@ const config = helpers.defineMultiStyleConfig({
111
125
  fontSize: ["mobile.xs", null, "desktop.xs"],
112
126
  paddingX: 2,
113
127
  paddingY: 1,
128
+ minHeight: 6,
114
129
  },
115
130
  panel: {
116
131
  fontSize: ["mobile.xs", null, "desktop.xs"],
@@ -122,6 +137,7 @@ const config = helpers.defineMultiStyleConfig({
122
137
  fontSize: ["mobile.sm", null, "desktop.sm"],
123
138
  paddingX: 3,
124
139
  paddingY: 1,
140
+ minHeight: 7,
125
141
  },
126
142
  panel: {
127
143
  fontSize: ["mobile.sm", null, "desktop.sm"],
@@ -133,6 +149,7 @@ const config = helpers.defineMultiStyleConfig({
133
149
  fontSize: ["mobile.sm", null, "desktop.sm"],
134
150
  paddingX: 3,
135
151
  paddingY: 2,
152
+ minHeight: 8,
136
153
  },
137
154
  panel: {
138
155
  fontSize: ["mobile.sm", null, "desktop.sm"],
@@ -1,14 +1,12 @@
1
1
  import { breadcrumbAnatomy as parts } from "@chakra-ui/anatomy";
2
- import {
3
- createMultiStyleConfigHelpers,
4
- defineStyle,
5
- } from "@chakra-ui/styled-system";
2
+ import { createMultiStyleConfigHelpers, defineStyle } from "@chakra-ui/styled-system";
6
3
  import { getBoxShadowString } from "../utils/box-shadow-utils";
4
+ import { mode } from "@chakra-ui/theme-tools";
7
5
 
8
6
  const { defineMultiStyleConfig, definePartsStyle } =
9
7
  createMultiStyleConfigHelpers(parts.keys);
10
8
 
11
- const baseStyleLink = defineStyle({
9
+ const baseStyleLink = defineStyle((props) => ({
12
10
  transitionProperty: "common",
13
11
  transitionDuration: "fast",
14
12
  transitionTimingFunction: "ease-out",
@@ -21,27 +19,30 @@ const baseStyleLink = defineStyle({
21
19
  paddingX: 0.5,
22
20
  borderRadius: "xs",
23
21
  _hover: {
24
- backgroundColor: "coralGreen",
22
+ backgroundColor: mode("seaMist", "pine")(props),
25
23
  },
26
24
  _focusVisible: {
27
25
  boxShadow: getBoxShadowString({
28
- borderColor: "greenHaze",
26
+ borderColor: mode("greenHaze", "azure")(props),
29
27
  borderWidth: 2,
30
28
  }),
29
+ notFocus: {
30
+ notFocus: { boxShadow: "none" },
31
+ }
31
32
  },
32
33
  _active: {
33
- backgroundColor: "mint",
34
+ backgroundColor: mode("mint", "whiteAlpha.200")(props),
34
35
  },
35
36
  },
36
- });
37
+ }));
37
38
 
38
- const baseStyle = definePartsStyle({
39
- link: baseStyleLink,
39
+ const baseStyle = definePartsStyle((props) => ({
40
+ link: baseStyleLink(props),
40
41
  list: {
41
42
  flexWrap: "wrap",
42
43
  alignItems: "flex-start",
43
44
  },
44
- });
45
+ }));
45
46
 
46
47
  export default defineMultiStyleConfig({
47
48
  baseStyle,
@@ -29,28 +29,39 @@ const config = defineStyleConfig({
29
29
  },
30
30
  },
31
31
  variants: {
32
- control: {
33
- backgroundColor: "darkTeal",
34
- color: "white",
32
+ control: (props) => ({
33
+ backgroundColor: mode("darkTeal", "mint")(props),
34
+ color: mode("white", "darkTeal")(props),
35
35
  ...focusVisible({
36
36
  focus: {
37
- boxShadow: `inset 0 0 0 4px ${colors.darkTeal}, inset 0 0 0 6px currentColor`,
37
+ boxShadow: `inset 0 0 0 4px ${mode(
38
+ colors.darkTeal,
39
+ colors.seaMist,
40
+ )(props)}, inset 0 0 0 6px currentColor`,
38
41
  },
39
42
  notFocus: { boxShadow: "none" },
40
43
  }),
41
44
  _hover: {
42
- backgroundColor: "night",
45
+ backgroundColor: mode("night", "coralGreen")(props),
43
46
  },
44
47
  _active: {
45
- backgroundColor: "pine",
48
+ backgroundColor: mode("pine", "white")(props),
46
49
  },
47
- },
48
- primary: {
50
+ }),
51
+ primary: (props) => ({
52
+ // FIXME: Update to use a global defined background color for darkMode whenever it is available.
53
+ // hardcoded background color as alpha-"hack" below is not feasible for dark mode with solid background color
49
54
  backgroundColor: "primaryGreen",
50
55
  color: "white",
51
56
  ...focusVisible({
52
57
  focus: {
53
- boxShadow: `inset 0 0 0 4px ${colors.primaryGreen}, inset 0 0 0 4px ${colors.primaryGreen}, inset 0 0 0 6px currentColor`,
58
+ boxShadow: `inset 0 0 0 2px ${mode(
59
+ colors.greenHaze,
60
+ colors.azure,
61
+ )(props)}, inset 0 0 0 4px ${mode(
62
+ colors.white,
63
+ colors.darkGrey,
64
+ )(props)}`,
54
65
  },
55
66
  notFocus: { boxShadow: "none" },
56
67
  }),
@@ -60,25 +71,61 @@ const config = defineStyleConfig({
60
71
  _active: {
61
72
  backgroundColor: "azure",
62
73
  },
63
- },
64
- secondary: {
65
- backgroundColor: "coralGreen",
66
- color: "darkTeal",
74
+ }),
75
+ secondary: (props) => ({
76
+ // FIXME: Update to use global defined background color for darkMode whenever it is available instead of alpha
77
+ backgroundColor: mode("seaMist", "whiteAlpha.100")(props),
78
+ color: mode("darkTeal", "white")(props),
79
+ // order is important here for now while we do not have global defined background color for darkMode
80
+ _hover: {
81
+ backgroundColor: mode("coralGreen", "whiteAlpha.200")(props),
82
+ },
67
83
  ...focusVisible({
68
84
  focus: {
69
- boxShadow: `inset 0 0 0 4px ${colors.coralGreen}, inset 0 0 0 4px ${colors.coralGreen}, inset 0 0 0 6px currentColor`,
85
+ boxShadow: `inset 0 0 0 2px ${mode(
86
+ colors.greenHaze,
87
+ colors.azure,
88
+ )(props)}, inset 0 0 0 4px ${mode(
89
+ colors.white,
90
+ colors.blackAlpha[300],
91
+ )(props)}`,
92
+ _hover: {
93
+ boxShadow: `inset 0 0 0 2px ${mode(
94
+ colors.greenHaze,
95
+ colors.azure,
96
+ )(props)}, inset 0 0 0 4px ${mode(
97
+ colors.white,
98
+ colors.blackAlpha[500],
99
+ )(props)}`,
100
+ },
70
101
  },
71
102
  notFocus: {
72
103
  boxShadow: "none",
73
104
  },
74
105
  }),
75
- _hover: {
76
- backgroundColor: "blueGreen",
77
- },
78
106
  _active: {
79
- backgroundColor: "mint",
107
+ backgroundColor: mode("mint", "whiteAlpha.300")(props),
108
+ boxShadow: `inset 0 0 0 2px ${mode(
109
+ colors.greenHaze,
110
+ colors.azure,
111
+ )(props)}, inset 0 0 0 4px ${mode(
112
+ colors.white,
113
+ colors.blackAlpha[600],
114
+ )(props)}`,
115
+ _hover: {
116
+ boxShadow: `inset 0 0 0 2px ${mode(
117
+ colors.greenHaze,
118
+ colors.azure,
119
+ )(props)}, inset 0 0 0 4px ${mode(
120
+ colors.white,
121
+ colors.blackAlpha[600],
122
+ )(props)}`,
123
+ },
80
124
  },
81
- },
125
+ }),
126
+ /**
127
+ * @deprecated use `secondary` instead.
128
+ */
82
129
  tertiary: {
83
130
  backgroundColor: "mint",
84
131
  color: "darkGrey",
@@ -102,19 +149,19 @@ const config = defineStyleConfig({
102
149
  fontWeight: "normal",
103
150
  boxShadow: `inset 0 0 0 1px ${mode(
104
151
  colors.blackAlpha[400],
105
- colors.whiteAlpha[400]
152
+ colors.whiteAlpha[400],
106
153
  )(props)}`,
107
154
  ...focusVisible({
108
155
  focus: {
109
156
  boxShadow: getBoxShadowString({
110
- borderWidth: 3,
157
+ borderWidth: 2,
111
158
  borderColor: "greenHaze",
112
159
  }),
113
160
  },
114
161
  notFocus: {
115
162
  boxShadow: `inset 0 0 0 1px ${mode(
116
163
  colors.blackAlpha[400],
117
- colors.whiteAlpha[400]
164
+ colors.whiteAlpha[400],
118
165
  )(props)}`,
119
166
  },
120
167
  }),
@@ -124,7 +171,7 @@ const config = defineStyleConfig({
124
171
  _active: {
125
172
  boxShadow: `inset 0 0 0 1px ${mode(
126
173
  colors.blackAlpha[400],
127
- colors.whiteAlpha[300]
174
+ colors.whiteAlpha[300],
128
175
  )(props)}`,
129
176
  backgroundColor: mode("mint", "whiteAlpha.200")(props),
130
177
  },
@@ -182,7 +229,7 @@ const config = defineStyleConfig({
182
229
  boxShadow: getBoxShadowString({
183
230
  borderColor: mode("greenHaze", "azure")(props),
184
231
  borderWidth: 2,
185
- baseShadow: "md"
232
+ baseShadow: "md",
186
233
  }),
187
234
  },
188
235
  },
@@ -1,6 +1,8 @@
1
1
  import { createMultiStyleConfigHelpers } from "@chakra-ui/react";
2
- import { anatomy } from "@chakra-ui/theme-tools";
2
+ import { anatomy, mode } from "@chakra-ui/theme-tools";
3
3
  import { getBoxShadowString } from "../utils/box-shadow-utils";
4
+ import { colors } from "../foundations";
5
+ import { focusVisible } from "../utils/focus-utils";
4
6
 
5
7
  const parts = anatomy("choice-chip").parts("container", "icon", "label");
6
8
 
@@ -9,33 +11,44 @@ const helpers = createMultiStyleConfigHelpers(parts.keys);
9
11
  const config = helpers.defineMultiStyleConfig({
10
12
  baseStyle: (props) => ({
11
13
  container: {
12
- backgroundColor: "white",
14
+ backgroundColor: mode("white", "transparent")(props),
13
15
  boxShadow: getBoxShadowString({ borderColor: "celadon" }),
14
- color: "darkTeal",
16
+ color: mode("darkTeal", "white")(props),
15
17
  display: "inline-flex",
16
18
  alignItems: "center",
17
19
  fontSize: "16px",
18
20
  px: 1,
19
21
  _checked: {
20
- background: "seaMist",
22
+ color: "white",
23
+ background: "pine",
21
24
  boxShadow: getBoxShadowString({ borderColor: "celadon" }),
22
25
  },
23
26
  "input:focus-visible + &": {
24
- boxShadow: getBoxShadowString({
25
- borderColor: "greenHaze",
26
- borderWidth: 2,
27
- }),
27
+ boxShadow: `inset 0 0 0 2px ${mode(
28
+ colors.greenHaze,
29
+ colors.azure,
30
+ )(props)}, inset 0 0 0 4px ${mode(
31
+ colors.white,
32
+ colors.darkGrey,
33
+ )(props)}`,
28
34
  },
29
35
  "@media (hover:hover)": {
30
36
  _hover: {
37
+ color: mode("darkTeal", "white")(props),
31
38
  boxShadow: getBoxShadowString({
32
39
  borderColor: "greenHaze",
33
40
  borderWidth: 2,
34
41
  }),
35
- background: "mint",
42
+ background: mode("coralGreen", "whiteAlpha.200")(props),
36
43
  cursor: "pointer",
37
44
  },
38
45
  },
46
+ _active: {
47
+ backgroundColor: mode("mint", "whiteAlpha.300")(props),
48
+ boxShadow: getBoxShadowString({
49
+ borderColor: "pine",
50
+ }),
51
+ },
39
52
  },
40
53
  icon: {
41
54
  mr: props.hasLabel ? 1 : 0,