@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.
- package/.turbo/turbo-build.log +11 -11
- package/CHANGELOG.md +20 -0
- package/dist/{CountryCodeSelect-IUVBFVKP.mjs → CountryCodeSelect-HHNSD6TX.mjs} +1 -1
- package/dist/{chunk-HOS74XL2.mjs → chunk-S2IJI3LY.mjs} +325 -92
- package/dist/index.d.mts +130 -57
- package/dist/index.d.ts +130 -57
- package/dist/index.js +372 -111
- package/dist/index.mjs +1 -1
- package/package.json +2 -1
- package/src/datepicker/DateRangePicker.tsx +6 -4
- package/src/index.tsx +1 -0
- package/src/input/CardSelect.tsx +5 -1
- package/src/input/InfoSelect.tsx +6 -0
- package/src/progress-indicator/ProgressDot.tsx +23 -0
- package/src/progress-indicator/ProgressIndicator.tsx +56 -0
- package/src/progress-indicator/index.tsx +1 -0
- package/src/provider/SporProvider.tsx +9 -2
- package/src/theme/components/card-select.ts +31 -24
- package/src/theme/components/index.ts +1 -0
- package/src/theme/components/info-select.ts +32 -3
- package/src/theme/components/listbox.ts +10 -12
- package/src/theme/components/progress-indicator.ts +45 -0
- package/src/theme/index.ts +18 -0
- package/src/theme/utils/background-utils.ts +96 -11
- package/src/theme/utils/border-utils.ts +40 -9
- package/src/theme/utils/types.ts +11 -0
package/dist/index.mjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export { Accordion, AccordionButton, AccordionIcon, AccordionItem, AccordionPanel, AttachedInputs, Badge, Box, Breadcrumb, BreadcrumbItem, BreadcrumbLink, Button, ButtonGroup, Card, CardSelect, Center, Checkbox, CheckboxGroup, ChoiceChip, ClosableAlert, CloseButton, Code, ColorInlineLoader, ColorSpinner, Combobox, Container, ContentLoader, DarkFullScreenLoader, DarkInlineLoader, DarkMode, DarkSpinner, DatePicker, DateRangePicker, Divider, Drawer, DrawerBody, DrawerCloseButton, DrawerContent, DrawerFooter, ModalHeader as DrawerHeader, DrawerOverlay, Expandable, ExpandableAlert, ExpandableItem, Fade, Flex, FloatingActionButton, FormControl, FormErrorMessage, FormHelperText, FormLabel, Grid, GridItem, HStack, Heading, IconButton, Image, Img, InfoSelect, InfoTag, Input, InputGroup, InputLeftElement, InputRightElement, Item, ItemDescription, ItemLabel, JumpButton, Language, LanguageProvider, LightFullScreenLoader, LightInlineLoader, LightMode, LightSpinner, LineIcon, ListBox, ListItem, Modal, ModalBody, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalOverlay, NativeSelect, NumericStepper, OrderedList, PasswordInput, PhoneNumberInput, PlayPauseButton, Popover, PopoverAnchor, PopoverArrow, PopoverBody, PopoverCloseButton, PopoverContent, PopoverFooter, PopoverHeader, PopoverTrigger, PopoverWizardBody, Portal, ProgressBar, ProgressLoader, Radio, RadioGroup, ScaleFade, SearchInput, Section, SimpleDrawer, SimpleGrid, SimplePopover, Skeleton, SkeletonCircle, SkeletonText, SkipButton, Slide, SlideFade, Spacer, SporProvider, Stack, StaticAlert, Stepper, StepperStep, Switch, Tab, TabList, TabPanel, TabPanels, Table, TableCaption, Tabs, Tbody, Td, Text, TextLink, Textarea, Tfoot, Th, Thead, Time, TimePicker, Tr, TravelTag, UnorderedList, VStack, VyLogo, WizardPopover, Wrap, WrapItem, createTexts, defineStyleConfig, extendTheme, fontFaces, theme, tokens, useBreakpointValue, useClipboard, useColorMode, useColorModePreference, useColorModeValue, useControllableProp, useDisclosure, useMediaQuery, useMergeRefs, useOutsideClick, usePrefersReducedMotion, useSize, useTheme, useToast, useToken, useTranslation } from './chunk-
|
1
|
+
export { Accordion, AccordionButton, AccordionIcon, AccordionItem, AccordionPanel, AttachedInputs, Badge, Box, Brand, Breadcrumb, BreadcrumbItem, BreadcrumbLink, Button, ButtonGroup, Card, CardSelect, Center, Checkbox, CheckboxGroup, ChoiceChip, ClosableAlert, CloseButton, Code, ColorInlineLoader, ColorSpinner, Combobox, Container, ContentLoader, DarkFullScreenLoader, DarkInlineLoader, DarkMode, DarkSpinner, DatePicker, DateRangePicker, Divider, Drawer, DrawerBody, DrawerCloseButton, DrawerContent, DrawerFooter, ModalHeader as DrawerHeader, DrawerOverlay, Expandable, ExpandableAlert, ExpandableItem, Fade, Flex, FloatingActionButton, FormControl, FormErrorMessage, FormHelperText, FormLabel, Grid, GridItem, HStack, Heading, IconButton, Image, Img, InfoSelect, InfoTag, Input, InputGroup, InputLeftElement, InputRightElement, Item, ItemDescription, ItemLabel, JumpButton, Language, LanguageProvider, LightFullScreenLoader, LightInlineLoader, LightMode, LightSpinner, LineIcon, ListBox, ListItem, Modal, ModalBody, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalOverlay, NativeSelect, NumericStepper, OrderedList, PasswordInput, PhoneNumberInput, PlayPauseButton, Popover, PopoverAnchor, PopoverArrow, PopoverBody, PopoverCloseButton, PopoverContent, PopoverFooter, PopoverHeader, PopoverTrigger, PopoverWizardBody, Portal, ProgressBar, ProgressIndicator, ProgressLoader, Radio, RadioGroup, ScaleFade, SearchInput, Section, SimpleDrawer, SimpleGrid, SimplePopover, Skeleton, SkeletonCircle, SkeletonText, SkipButton, Slide, SlideFade, Spacer, SporProvider, Stack, StaticAlert, Stepper, StepperStep, Switch, Tab, TabList, TabPanel, TabPanels, Table, TableCaption, Tabs, Tbody, Td, Text, TextLink, Textarea, Tfoot, Th, Thead, Time, TimePicker, Tr, TravelTag, UnorderedList, VStack, VyLogo, WizardPopover, Wrap, WrapItem, brandTheme, createTexts, defineStyleConfig, extendTheme, fontFaces, theme, tokens, useBreakpointValue, useClipboard, useColorMode, useColorModePreference, useColorModeValue, useControllableProp, useDisclosure, useMediaQuery, useMergeRefs, useOutsideClick, usePrefersReducedMotion, useSize, useTheme, useToast, useToken, useTranslation } from './chunk-S2IJI3LY.mjs';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vygruppen/spor-react",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.4.0",
|
4
4
|
"main": "./dist/index.js",
|
5
5
|
"module": "./dist/index.mjs",
|
6
6
|
"types": "./dist/index.d.ts",
|
@@ -26,6 +26,7 @@
|
|
26
26
|
"@vygruppen/spor-icon-react": "*",
|
27
27
|
"@vygruppen/spor-loader": "*",
|
28
28
|
"awesome-phonenumber": "^5.10.0",
|
29
|
+
"deepmerge": "^4.3.1",
|
29
30
|
"framer-motion": "^9.1.7",
|
30
31
|
"lottie-react": "^2.3.1",
|
31
32
|
"react-aria": "^3.30.0",
|
@@ -40,10 +40,12 @@ type DateRangePickerProps = Omit<
|
|
40
40
|
endName?: string;
|
41
41
|
variant: ResponsiveValue<"base" | "floating" | "ghost">;
|
42
42
|
withPortal?: boolean;
|
43
|
-
onChange?: (
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
onChange?: (
|
44
|
+
dates: {
|
45
|
+
start: DateValue | null;
|
46
|
+
end: DateValue | null;
|
47
|
+
} | null,
|
48
|
+
) => void;
|
47
49
|
};
|
48
50
|
/**
|
49
51
|
* A date range picker component.
|
package/src/index.tsx
CHANGED
package/src/input/CardSelect.tsx
CHANGED
@@ -59,6 +59,7 @@ type CardSelectProps = BoxProps & {
|
|
59
59
|
* ```
|
60
60
|
*
|
61
61
|
* @see https://spor.vy.no/components/card-select
|
62
|
+
*
|
62
63
|
*/
|
63
64
|
export const CardSelect = forwardRef<CardSelectProps, "button">(
|
64
65
|
(
|
@@ -96,7 +97,10 @@ export const CardSelect = forwardRef<CardSelectProps, "button">(
|
|
96
97
|
|
97
98
|
const { buttonProps } = useButton(triggerProps, triggerRef);
|
98
99
|
|
99
|
-
const styles = useMultiStyleConfig("CardSelect", {
|
100
|
+
const styles = useMultiStyleConfig("CardSelect", {
|
101
|
+
variant,
|
102
|
+
size,
|
103
|
+
});
|
100
104
|
useForceRerender(state.isOpen);
|
101
105
|
|
102
106
|
const ChevronIcon =
|
package/src/input/InfoSelect.tsx
CHANGED
@@ -113,6 +113,7 @@ type InfoSelectProps<T extends object> = {
|
|
113
113
|
disabledKeys?: string[];
|
114
114
|
/** Whether or not the input is invalid */
|
115
115
|
"aria-invalid"?: boolean;
|
116
|
+
variant?: "base" | "floating";
|
116
117
|
};
|
117
118
|
/**
|
118
119
|
* A styled select component.
|
@@ -157,6 +158,7 @@ export function InfoSelect<T extends object>({
|
|
157
158
|
value,
|
158
159
|
isLabelSrOnly,
|
159
160
|
defaultValue,
|
161
|
+
variant = "base",
|
160
162
|
...props
|
161
163
|
}: InfoSelectProps<T>) {
|
162
164
|
const renamedProps = {
|
@@ -174,9 +176,13 @@ export function InfoSelect<T extends object>({
|
|
174
176
|
triggerRef,
|
175
177
|
);
|
176
178
|
|
179
|
+
const stateStyle = "completed";
|
180
|
+
|
177
181
|
const styles = useMultiStyleConfig("InfoSelect", {
|
178
182
|
isOpen: state.isOpen,
|
179
183
|
isLabelSrOnly,
|
184
|
+
variant,
|
185
|
+
stateStyle,
|
180
186
|
});
|
181
187
|
const { buttonProps } = useButton(triggerProps, triggerRef);
|
182
188
|
const { t } = useTranslation();
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { Box } from "..";
|
3
|
+
import { useMultiStyleConfig } from "@chakra-ui/react";
|
4
|
+
|
5
|
+
type ProgressDot = {
|
6
|
+
isActive: boolean;
|
7
|
+
};
|
8
|
+
|
9
|
+
export const ProgressDot = ({ isActive }: ProgressDot) => {
|
10
|
+
const style = useMultiStyleConfig("ProgressIndicator");
|
11
|
+
return (
|
12
|
+
<Box
|
13
|
+
as="svg"
|
14
|
+
display="block"
|
15
|
+
__css={style.progressDot}
|
16
|
+
xmlns="http://www.w3.org/2000/svg"
|
17
|
+
viewBox="0 0 100 100"
|
18
|
+
aria-current={isActive ? "step" : undefined}
|
19
|
+
>
|
20
|
+
<Box as="circle" cx="50" cy="50" r="50" />
|
21
|
+
</Box>
|
22
|
+
);
|
23
|
+
};
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import { useMultiStyleConfig } from "@chakra-ui/react";
|
2
|
+
import React from "react";
|
3
|
+
import { Box, createTexts, useTranslation } from "..";
|
4
|
+
import { ProgressDot } from "./ProgressDot";
|
5
|
+
|
6
|
+
type ProgressIndicatorProps = {
|
7
|
+
numberOfSteps: number;
|
8
|
+
activeStep: number;
|
9
|
+
};
|
10
|
+
|
11
|
+
/**
|
12
|
+
* A progress indicator is used to show which step of a process a user is currently in
|
13
|
+
* to give them a sense of progress.
|
14
|
+
*
|
15
|
+
* You specify the active step, which starts at 1 (not 0)
|
16
|
+
*
|
17
|
+
* ```tsx
|
18
|
+
* <ProgressIndicator
|
19
|
+
* numberOfSteps={3}
|
20
|
+
* activeStep={2}
|
21
|
+
* />
|
22
|
+
* ```
|
23
|
+
*/
|
24
|
+
export const ProgressIndicator = ({
|
25
|
+
numberOfSteps,
|
26
|
+
activeStep,
|
27
|
+
}: ProgressIndicatorProps) => {
|
28
|
+
const { t } = useTranslation();
|
29
|
+
const style = useMultiStyleConfig("ProgressIndicator");
|
30
|
+
|
31
|
+
return (
|
32
|
+
<Box
|
33
|
+
__css={style.root}
|
34
|
+
role="progressbar"
|
35
|
+
aria-valuemin={1}
|
36
|
+
aria-valuemax={numberOfSteps}
|
37
|
+
aria-valuenow={activeStep}
|
38
|
+
aria-valuetext={t(texts.stepsOf(activeStep, numberOfSteps))}
|
39
|
+
>
|
40
|
+
<Box __css={style.container}>
|
41
|
+
{Array.from({ length: numberOfSteps }, (_, i) => (
|
42
|
+
<ProgressDot aria-value={i + 1} isActive={activeStep === i + 1} />
|
43
|
+
))}
|
44
|
+
</Box>
|
45
|
+
</Box>
|
46
|
+
);
|
47
|
+
};
|
48
|
+
|
49
|
+
const texts = createTexts({
|
50
|
+
stepsOf: (activeStep, numberOfSteps) => ({
|
51
|
+
nb: `Steg ${activeStep} av ${numberOfSteps}`,
|
52
|
+
nn: `Steg ${activeStep} av ${numberOfSteps}`,
|
53
|
+
sv: `Steg ${activeStep} av ${numberOfSteps}`,
|
54
|
+
en: `Step ${activeStep} of ${numberOfSteps}`,
|
55
|
+
}),
|
56
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./ProgressIndicator";
|
@@ -1,11 +1,13 @@
|
|
1
1
|
import { ChakraProvider, ChakraProviderProps } from "@chakra-ui/react";
|
2
2
|
import { Global } from "@emotion/react";
|
3
|
+
import deepmerge from "deepmerge";
|
3
4
|
import React from "react";
|
4
5
|
import { Language, LanguageProvider } from "..";
|
5
|
-
import { theme as defaultSporTheme, fontFaces } from "../";
|
6
|
+
import { Brand, brandTheme, theme as defaultSporTheme, fontFaces } from "../";
|
6
7
|
|
7
8
|
type SporProviderProps = ChakraProviderProps & {
|
8
9
|
language?: Language;
|
10
|
+
brand?: Brand;
|
9
11
|
};
|
10
12
|
|
11
13
|
/**
|
@@ -47,12 +49,17 @@ type SporProviderProps = ChakraProviderProps & {
|
|
47
49
|
export const SporProvider = ({
|
48
50
|
theme = defaultSporTheme,
|
49
51
|
language = Language.NorwegianBokmal,
|
52
|
+
brand = Brand.VyDigital,
|
50
53
|
children,
|
51
54
|
...props
|
52
55
|
}: SporProviderProps) => {
|
56
|
+
const brandCustomizations = brandTheme[brand] ?? {};
|
57
|
+
|
58
|
+
const extendedTheme = deepmerge(theme, brandCustomizations);
|
59
|
+
|
53
60
|
return (
|
54
61
|
<LanguageProvider language={language}>
|
55
|
-
<ChakraProvider theme={
|
62
|
+
<ChakraProvider theme={extendedTheme} {...props}>
|
56
63
|
<Global styles={fontFaces} />
|
57
64
|
{children}
|
58
65
|
</ChakraProvider>
|
@@ -1,8 +1,13 @@
|
|
1
1
|
import { anatomy } from "@chakra-ui/anatomy";
|
2
2
|
import { createMultiStyleConfigHelpers } from "@chakra-ui/styled-system";
|
3
|
-
import { mode } from "@chakra-ui/theme-tools";
|
3
|
+
import { StyleFunctionProps, mode } from "@chakra-ui/theme-tools";
|
4
4
|
import { getBoxShadowString } from "../utils/box-shadow-utils";
|
5
5
|
import { focusVisible } from "../utils/focus-utils";
|
6
|
+
import {
|
7
|
+
baseBackground,
|
8
|
+
floatingBackground,
|
9
|
+
ghostBackground,
|
10
|
+
} from "../utils/background-utils";
|
6
11
|
|
7
12
|
const parts = anatomy("card-select").parts("trigger", "card");
|
8
13
|
|
@@ -13,9 +18,6 @@ const config = helpers.defineMultiStyleConfig({
|
|
13
18
|
appearance: "none",
|
14
19
|
display: "flex",
|
15
20
|
alignItems: "center",
|
16
|
-
_expanded: {
|
17
|
-
backgroundColor: mode("mint", "night")(props),
|
18
|
-
},
|
19
21
|
...focusVisible({
|
20
22
|
notFocus: {},
|
21
23
|
focus: {
|
@@ -31,20 +33,11 @@ const config = helpers.defineMultiStyleConfig({
|
|
31
33
|
borderRadius: "sm",
|
32
34
|
boxShadow: "md",
|
33
35
|
padding: 3,
|
36
|
+
color: mode("darkGrey", "white")(props),
|
34
37
|
},
|
35
38
|
}),
|
36
39
|
variants: {
|
37
|
-
|
38
|
-
trigger: {
|
39
|
-
_hover: {
|
40
|
-
backgroundColor: mode("seaMist", "pine")(props),
|
41
|
-
},
|
42
|
-
_active: {
|
43
|
-
backgroundColor: mode("mint", "whiteAlpha.200")(props),
|
44
|
-
},
|
45
|
-
},
|
46
|
-
}),
|
47
|
-
outline: (props) => ({
|
40
|
+
base: (props) => ({
|
48
41
|
trigger: {
|
49
42
|
boxShadow: getBoxShadowString({
|
50
43
|
borderColor: mode("blackAlpha.400", "whiteAlpha.400")(props),
|
@@ -66,20 +59,20 @@ const config = helpers.defineMultiStyleConfig({
|
|
66
59
|
}),
|
67
60
|
},
|
68
61
|
_active: {
|
69
|
-
|
62
|
+
...baseBackground("active", props),
|
70
63
|
boxShadow: getBoxShadowString({
|
71
64
|
borderColor: mode("darkGrey", "whiteAlpha.400")(props),
|
72
65
|
borderWidth: 1,
|
73
66
|
}),
|
74
67
|
},
|
75
|
-
|
76
68
|
_expanded: {
|
69
|
+
...baseBackground("active", props),
|
77
70
|
_hover: {
|
78
|
-
|
71
|
+
...baseBackground("active", props),
|
79
72
|
boxShadow: "none",
|
80
73
|
},
|
81
74
|
_active: {
|
82
|
-
|
75
|
+
...baseBackground("active", props),
|
83
76
|
boxShadow: getBoxShadowString({
|
84
77
|
borderColor: mode("blackAlpha.400", "whiteAlpha.400")(props),
|
85
78
|
borderWidth: 1,
|
@@ -88,13 +81,26 @@ const config = helpers.defineMultiStyleConfig({
|
|
88
81
|
},
|
89
82
|
},
|
90
83
|
}),
|
91
|
-
|
84
|
+
ghost: (props) => ({
|
85
|
+
trigger: {
|
86
|
+
_hover: {
|
87
|
+
...ghostBackground("hover", props),
|
88
|
+
},
|
89
|
+
_active: {
|
90
|
+
...ghostBackground("active", props),
|
91
|
+
},
|
92
|
+
_expanded: {
|
93
|
+
...ghostBackground("selected", props),
|
94
|
+
},
|
95
|
+
},
|
96
|
+
}),
|
97
|
+
floating: (props) => ({
|
92
98
|
trigger: {
|
93
|
-
|
99
|
+
...floatingBackground("default", props),
|
94
100
|
boxShadow: "sm",
|
95
101
|
transition: "all .1s ease-out",
|
96
102
|
_hover: {
|
97
|
-
|
103
|
+
...floatingBackground("hover", props),
|
98
104
|
boxShadow: getBoxShadowString({
|
99
105
|
borderColor: mode("silver", "whiteAlpha.400")(props),
|
100
106
|
borderWidth: 1,
|
@@ -102,7 +108,7 @@ const config = helpers.defineMultiStyleConfig({
|
|
102
108
|
}),
|
103
109
|
},
|
104
110
|
_active: {
|
105
|
-
|
111
|
+
...floatingBackground("active", props),
|
106
112
|
boxShadow: getBoxShadowString({
|
107
113
|
borderColor: mode("silver", "whiteAlpha.400")(props),
|
108
114
|
borderWidth: mode(0, 1)(props),
|
@@ -110,6 +116,7 @@ const config = helpers.defineMultiStyleConfig({
|
|
110
116
|
}),
|
111
117
|
},
|
112
118
|
_expanded: {
|
119
|
+
...floatingBackground("active", props),
|
113
120
|
_hover: {
|
114
121
|
boxShadow: getBoxShadowString({
|
115
122
|
borderColor: "darkGrey",
|
@@ -117,7 +124,7 @@ const config = helpers.defineMultiStyleConfig({
|
|
117
124
|
}),
|
118
125
|
},
|
119
126
|
_active: {
|
120
|
-
|
127
|
+
...floatingBackground("active", props),
|
121
128
|
boxShadow: "none",
|
122
129
|
},
|
123
130
|
},
|
@@ -25,6 +25,7 @@ export { default as ListBox } from "./listbox";
|
|
25
25
|
export { default as MediaControllerButton } from "./media-controller-button";
|
26
26
|
export { default as Modal } from "./modal";
|
27
27
|
export { default as Popover } from "./popover";
|
28
|
+
export { default as ProgressIndicator } from "./progress-indicator";
|
28
29
|
export { default as Radio } from "./radio";
|
29
30
|
export { default as Select } from "./select";
|
30
31
|
export { default as Skeleton } from "./skeleton";
|
@@ -2,8 +2,9 @@ import { anatomy } from "@chakra-ui/anatomy";
|
|
2
2
|
import { createMultiStyleConfigHelpers } from "@chakra-ui/react";
|
3
3
|
import { focusVisible } from "../utils/focus-utils";
|
4
4
|
import { srOnly } from "../utils/sr-utils";
|
5
|
-
import { baseBorder } from "../utils/border-utils";
|
6
|
-
import { baseBackground } from "../utils/background-utils";
|
5
|
+
import { baseBorder, floatingBorder } from "../utils/border-utils";
|
6
|
+
import { baseBackground, floatingBackground } from "../utils/background-utils";
|
7
|
+
import { PartsStyleInterpolation } from "@chakra-ui/styled-system";
|
7
8
|
|
8
9
|
const parts = anatomy("InfoSelect").parts(
|
9
10
|
"container",
|
@@ -55,7 +56,6 @@ const config = helpers.defineMultiStyleConfig({
|
|
55
56
|
...baseBorder("focus", props),
|
56
57
|
},
|
57
58
|
_expanded: {
|
58
|
-
...baseBackground("active", props),
|
59
59
|
...baseBorder("focus", props),
|
60
60
|
},
|
61
61
|
_invalid: {
|
@@ -75,5 +75,34 @@ const config = helpers.defineMultiStyleConfig({
|
|
75
75
|
},
|
76
76
|
arrowIcon: {},
|
77
77
|
}),
|
78
|
+
variants: {
|
79
|
+
base: (props) => ({}),
|
80
|
+
floating: (props) => ({
|
81
|
+
button: {
|
82
|
+
...floatingBackground("default", props),
|
83
|
+
...floatingBorder("default", props),
|
84
|
+
_hover: {
|
85
|
+
...floatingBorder("hover", props),
|
86
|
+
...floatingBackground("hover", props),
|
87
|
+
},
|
88
|
+
...focusVisible({
|
89
|
+
focus: {
|
90
|
+
...floatingBorder("focus", props),
|
91
|
+
outline: "none",
|
92
|
+
},
|
93
|
+
notFocus: {
|
94
|
+
...floatingBorder("default", props),
|
95
|
+
},
|
96
|
+
}),
|
97
|
+
_active: {
|
98
|
+
...floatingBorder("active", props),
|
99
|
+
...floatingBackground("active", props),
|
100
|
+
},
|
101
|
+
},
|
102
|
+
}),
|
103
|
+
},
|
104
|
+
defaultProps: {
|
105
|
+
variant: "base",
|
106
|
+
},
|
78
107
|
});
|
79
108
|
export default config;
|
@@ -2,7 +2,8 @@ import { anatomy } from "@chakra-ui/anatomy";
|
|
2
2
|
import { createMultiStyleConfigHelpers } from "@chakra-ui/react";
|
3
3
|
import { mode } from "@chakra-ui/theme-tools";
|
4
4
|
import { colors } from "../foundations";
|
5
|
-
import { baseBackground } from "../utils/background-utils";
|
5
|
+
import { baseBackground, ghostBackground } from "../utils/background-utils";
|
6
|
+
import { baseBorder } from "../utils/border-utils";
|
6
7
|
|
7
8
|
const parts = anatomy("ListBox").parts(
|
8
9
|
"container",
|
@@ -19,7 +20,7 @@ const config = helpers.defineMultiStyleConfig({
|
|
19
20
|
// avoiding extra div by blending a transparent color into darkGrey for dark mode
|
20
21
|
backgroundColor: mode(
|
21
22
|
"white",
|
22
|
-
`color-mix(in srgb, ${colors.
|
23
|
+
`color-mix(in srgb, ${props.theme.colors.accent}, ${colors.white} 10%)`,
|
23
24
|
)(props),
|
24
25
|
boxShadow: "sm",
|
25
26
|
overflowY: "auto",
|
@@ -36,21 +37,18 @@ const config = helpers.defineMultiStyleConfig({
|
|
36
37
|
borderRadius: "sm",
|
37
38
|
color: mode("darkGrey", "white")(props),
|
38
39
|
cursor: "pointer",
|
39
|
-
|
40
|
-
backgroundColor: mode("seaMist", "pine")(props),
|
41
|
-
outline: "none",
|
42
|
-
},
|
40
|
+
outline: "none",
|
43
41
|
_active: {
|
44
|
-
|
45
|
-
outline: "none",
|
42
|
+
...ghostBackground("active", props),
|
46
43
|
},
|
47
44
|
_focus: {
|
48
|
-
|
49
|
-
|
45
|
+
...ghostBackground("focus", props),
|
46
|
+
},
|
47
|
+
_hover: {
|
48
|
+
...ghostBackground("hover", props),
|
50
49
|
},
|
51
50
|
_selected: {
|
52
|
-
...
|
53
|
-
color: "white",
|
51
|
+
...ghostBackground("selected", props),
|
54
52
|
},
|
55
53
|
},
|
56
54
|
label: {},
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import { createMultiStyleConfigHelpers } from "@chakra-ui/react";
|
2
|
+
import { anatomy, mode, StyleFunctionProps } from "@chakra-ui/theme-tools";
|
3
|
+
|
4
|
+
const parts = anatomy("progress-indicator").parts(
|
5
|
+
"root",
|
6
|
+
"container",
|
7
|
+
"progressDot",
|
8
|
+
);
|
9
|
+
|
10
|
+
const helpers = createMultiStyleConfigHelpers(parts.keys);
|
11
|
+
|
12
|
+
const config = helpers.defineMultiStyleConfig({
|
13
|
+
baseStyle: (props) => ({
|
14
|
+
root: {
|
15
|
+
width: "100%",
|
16
|
+
},
|
17
|
+
container: {
|
18
|
+
display: "flex",
|
19
|
+
alignItems: "center",
|
20
|
+
gap: 1,
|
21
|
+
justifyContent: ["space-between", "center"],
|
22
|
+
},
|
23
|
+
progressDot: {
|
24
|
+
height: 1,
|
25
|
+
width: 1,
|
26
|
+
"&[aria-current='step']": {
|
27
|
+
circle: {
|
28
|
+
fill: mode("pine", "coralGreen")(props),
|
29
|
+
},
|
30
|
+
},
|
31
|
+
circle: {
|
32
|
+
fill: mode("blackAlpha.400", "whiteAlpha.400")(props),
|
33
|
+
},
|
34
|
+
},
|
35
|
+
}),
|
36
|
+
|
37
|
+
variants: {
|
38
|
+
base: (props) => ({}),
|
39
|
+
},
|
40
|
+
defaultProps: {
|
41
|
+
variant: "base",
|
42
|
+
},
|
43
|
+
});
|
44
|
+
|
45
|
+
export default config;
|
package/src/theme/index.ts
CHANGED
@@ -2,6 +2,11 @@ import { theme as defaultTheme } from "@chakra-ui/theme";
|
|
2
2
|
import * as components from "./components";
|
3
3
|
import * as foundations from "./foundations";
|
4
4
|
|
5
|
+
export enum Brand {
|
6
|
+
VyDigital = "VyDigital",
|
7
|
+
VyUtvikling = "VyUtvikling",
|
8
|
+
}
|
9
|
+
|
5
10
|
export const theme = {
|
6
11
|
...defaultTheme,
|
7
12
|
...foundations,
|
@@ -11,4 +16,17 @@ export const theme = {
|
|
11
16
|
},
|
12
17
|
};
|
13
18
|
|
19
|
+
export const brandTheme = {
|
20
|
+
[Brand.VyDigital]: {
|
21
|
+
colors: {
|
22
|
+
accent: foundations.colors.night,
|
23
|
+
},
|
24
|
+
},
|
25
|
+
[Brand.VyUtvikling]: {
|
26
|
+
colors: {
|
27
|
+
accent: foundations.colors.darkGrey,
|
28
|
+
},
|
29
|
+
},
|
30
|
+
};
|
31
|
+
|
14
32
|
export { fontFaces } from "./font-faces";
|
@@ -1,14 +1,15 @@
|
|
1
1
|
import { mode, StyleFunctionProps } from "@chakra-ui/theme-tools";
|
2
|
+
import { State, Subset } from "./types";
|
3
|
+
import { colors } from "../foundations";
|
2
4
|
|
3
|
-
type
|
4
|
-
|
5
|
-
| "
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
export function baseBackground(state: State, props: StyleFunctionProps) {
|
5
|
+
type BaseBackgroundState = Subset<
|
6
|
+
State,
|
7
|
+
"default" | "active" | "selected" | "disabled"
|
8
|
+
>;
|
9
|
+
export function baseBackground(
|
10
|
+
state: BaseBackgroundState,
|
11
|
+
props: StyleFunctionProps,
|
12
|
+
) {
|
12
13
|
switch (state) {
|
13
14
|
case "active":
|
14
15
|
return {
|
@@ -16,13 +17,97 @@ export function baseBackground(state: State, props: StyleFunctionProps) {
|
|
16
17
|
};
|
17
18
|
case "selected":
|
18
19
|
return {
|
19
|
-
backgroundColor: "pine",
|
20
|
+
backgroundColor: mode("pine", "coralGreen")(props),
|
20
21
|
};
|
21
22
|
case "disabled":
|
22
23
|
return {
|
23
24
|
backgroundColor: mode("silver", "whiteAlpha.100")(props),
|
24
25
|
};
|
25
26
|
default:
|
26
|
-
return {
|
27
|
+
return {
|
28
|
+
backgroundColor: "transparent",
|
29
|
+
};
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
type GhostBackgroundState = Subset<
|
34
|
+
State,
|
35
|
+
"default" | "hover" | "focus" | "active" | "selected"
|
36
|
+
>;
|
37
|
+
|
38
|
+
export function ghostBackground(
|
39
|
+
state: GhostBackgroundState,
|
40
|
+
props: StyleFunctionProps,
|
41
|
+
) {
|
42
|
+
switch (state) {
|
43
|
+
case "hover": {
|
44
|
+
return {
|
45
|
+
backgroundColor: mode("seaMist", "whiteAlpha.100")(props),
|
46
|
+
};
|
47
|
+
}
|
48
|
+
case "active":
|
49
|
+
return {
|
50
|
+
backgroundColor: mode("seaMist", "whiteAlpha.200")(props),
|
51
|
+
};
|
52
|
+
case "focus":
|
53
|
+
return {
|
54
|
+
backgroundColor: "transparent",
|
55
|
+
};
|
56
|
+
case "selected": {
|
57
|
+
return {
|
58
|
+
backgroundColor: mode("mint", "whiteAlpha.200")(props),
|
59
|
+
};
|
60
|
+
}
|
61
|
+
case "default":
|
62
|
+
default:
|
63
|
+
return {
|
64
|
+
backgroundColor: "transparent",
|
65
|
+
};
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
type FloatingBackgroundState = Subset<
|
70
|
+
State,
|
71
|
+
"default" | "hover" | "focus" | "active" | "selected"
|
72
|
+
>;
|
73
|
+
|
74
|
+
export function floatingBackground(
|
75
|
+
state: FloatingBackgroundState,
|
76
|
+
props: StyleFunctionProps,
|
77
|
+
) {
|
78
|
+
switch (state) {
|
79
|
+
case "selected":
|
80
|
+
return {
|
81
|
+
backgroundColor: mode("mint", "pine")(props),
|
82
|
+
};
|
83
|
+
case "active":
|
84
|
+
return {
|
85
|
+
backgroundColor: mode(
|
86
|
+
"mint",
|
87
|
+
`color-mix(in srgb, ${props.theme.colors.accent}, ${colors.white} 30%)`,
|
88
|
+
)(props),
|
89
|
+
};
|
90
|
+
case "hover":
|
91
|
+
return {
|
92
|
+
backgroundColor: mode(
|
93
|
+
"white",
|
94
|
+
`color-mix(in srgb, ${props.theme.colors.accent}, ${colors.white} 20%)`,
|
95
|
+
)(props),
|
96
|
+
};
|
97
|
+
case "focus":
|
98
|
+
return {
|
99
|
+
backgroundColor: mode(
|
100
|
+
"white",
|
101
|
+
`color-mix(in srgb, ${props.theme.colors.accent}, ${colors.white} 40%)`,
|
102
|
+
)(props),
|
103
|
+
};
|
104
|
+
case "default":
|
105
|
+
default:
|
106
|
+
return {
|
107
|
+
backgroundColor: mode(
|
108
|
+
"white",
|
109
|
+
`color-mix(in srgb, ${props.theme.colors.accent}, ${colors.white} 10%)`,
|
110
|
+
)(props),
|
111
|
+
};
|
27
112
|
}
|
28
113
|
}
|