@vygruppen/spor-react 5.2.0 → 5.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.
@@ -1,16 +1,13 @@
1
1
  import { mode, StyleFunctionProps } from "@chakra-ui/theme-tools";
2
2
  import { getBoxShadowString } from "./box-shadow-utils";
3
+ import { State, Subset } from "./types";
3
4
 
4
- type State =
5
- | "default"
6
- | "hover"
7
- | "active"
8
- | "focus"
9
- | "selected"
10
- | "invalid"
11
- | "disabled";
5
+ type BorderState = Subset<
6
+ State,
7
+ "hover" | "focus" | "disabled" | "selected" | "invalid" | "default"
8
+ >;
12
9
 
13
- export function baseBorder(state: State, props: StyleFunctionProps) {
10
+ export function baseBorder(state: BorderState, props: StyleFunctionProps) {
14
11
  switch (state) {
15
12
  case "hover":
16
13
  return {
@@ -57,3 +54,37 @@ export function baseBorder(state: State, props: StyleFunctionProps) {
57
54
  };
58
55
  }
59
56
  }
57
+
58
+ type FloatingBorderState = Subset<
59
+ State,
60
+ "default" | "hover" | "focus" | "active" | "selected"
61
+ >;
62
+ export function floatingBorder(
63
+ state: FloatingBorderState,
64
+ props: StyleFunctionProps,
65
+ ) {
66
+ switch (state) {
67
+ case "hover":
68
+ return {
69
+ boxShadow: getBoxShadowString({
70
+ borderColor: mode("grey.300", "white")(props),
71
+ }),
72
+ };
73
+ case "selected":
74
+ case "focus":
75
+ return {
76
+ boxShadow: getBoxShadowString({
77
+ borderColor: mode("greenHaze", "azure")(props),
78
+ borderWidth: 2,
79
+ }),
80
+ };
81
+ case "active":
82
+ case "default":
83
+ default:
84
+ return {
85
+ boxShadow: getBoxShadowString({
86
+ borderColor: mode("grey.200", "whiteAlpha.400")(props),
87
+ }),
88
+ };
89
+ }
90
+ }
@@ -0,0 +1,11 @@
1
+ export type State =
2
+ | "default"
3
+ | "hover"
4
+ | "active"
5
+ | "focus"
6
+ | "selected"
7
+ | "invalid"
8
+ | "disabled";
9
+
10
+ // Helper type to extract subset of union types
11
+ export type Subset<T, U extends T> = T extends U ? T : never;