@vygruppen/spor-react 5.1.1 → 5.3.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 +24 -0
- package/dist/{CountryCodeSelect-ZM527OHZ.mjs → CountryCodeSelect-BITN7VNA.mjs} +1 -1
- package/dist/{chunk-J6I7IHRU.mjs → chunk-55HLEY3T.mjs} +584 -116
- package/dist/index.d.mts +120 -46
- package/dist/index.d.ts +120 -46
- package/dist/index.js +823 -389
- package/dist/index.mjs +1 -1
- package/package.json +2 -1
- package/src/datepicker/DatePicker.tsx +2 -1
- package/src/datepicker/DateRangePicker.tsx +10 -1
- package/src/datepicker/TimePicker.tsx +1 -1
- package/src/index.tsx +1 -0
- package/src/input/InfoSelect.tsx +6 -0
- package/src/input/NumericStepper.tsx +2 -2
- 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/stepper/StepperStep.tsx +2 -2
- 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 +103 -10
- 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-55HLEY3T.mjs';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vygruppen/spor-react",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.3.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",
|
@@ -25,12 +25,13 @@ import { DateField } from "./DateField";
|
|
25
25
|
import { StyledField } from "./StyledField";
|
26
26
|
import { useCurrentLocale } from "./utils";
|
27
27
|
|
28
|
-
type DatePickerProps = AriaDatePickerProps<DateValue> &
|
28
|
+
type DatePickerProps = Omit<AriaDatePickerProps<DateValue>, "onChange"> &
|
29
29
|
Pick<BoxProps, "minHeight" | "width"> & {
|
30
30
|
variant: ResponsiveValue<"base" | "floating" | "ghost">;
|
31
31
|
name?: string;
|
32
32
|
showYearNavigation?: boolean;
|
33
33
|
withPortal?: boolean;
|
34
|
+
onChange?: (value: DateValue | null) => void;
|
34
35
|
};
|
35
36
|
|
36
37
|
/**
|
@@ -29,7 +29,10 @@ import { RangeCalendar } from "./RangeCalendar";
|
|
29
29
|
import { StyledField } from "./StyledField";
|
30
30
|
import { useCurrentLocale } from "./utils";
|
31
31
|
|
32
|
-
type DateRangePickerProps =
|
32
|
+
type DateRangePickerProps = Omit<
|
33
|
+
AriaDateRangePickerProps<DateValue>,
|
34
|
+
"onChange"
|
35
|
+
> &
|
33
36
|
Pick<BoxProps, "minHeight"> & {
|
34
37
|
startLabel?: string;
|
35
38
|
startName?: string;
|
@@ -37,6 +40,12 @@ type DateRangePickerProps = AriaDateRangePickerProps<DateValue> &
|
|
37
40
|
endName?: string;
|
38
41
|
variant: ResponsiveValue<"base" | "floating" | "ghost">;
|
39
42
|
withPortal?: boolean;
|
43
|
+
onChange?: (
|
44
|
+
dates: {
|
45
|
+
start: DateValue | null;
|
46
|
+
end: DateValue | null;
|
47
|
+
} | null,
|
48
|
+
) => void;
|
40
49
|
};
|
41
50
|
/**
|
42
51
|
* A date range picker component.
|
@@ -31,7 +31,7 @@ type TimePickerProps = Omit<BoxProps, "defaultValue" | "onChange"> & {
|
|
31
31
|
**/
|
32
32
|
defaultValue?: TimeValue | null;
|
33
33
|
/** Callback for when the time changes */
|
34
|
-
onChange?: (value: TimeValue) => void;
|
34
|
+
onChange?: (value: TimeValue | null) => void;
|
35
35
|
/** The maxiumum number of minutes to move when the step buttons are used.
|
36
36
|
*
|
37
37
|
* Defaults to 30 minutes.
|
package/src/index.tsx
CHANGED
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();
|
@@ -91,7 +91,7 @@ export function NumericStepper({
|
|
91
91
|
return (
|
92
92
|
<Flex alignItems="center" {...boxProps}>
|
93
93
|
<VerySmallButton
|
94
|
-
icon={<SubtractIcon
|
94
|
+
icon={<SubtractIcon stepLabel={clampedStepSize} />}
|
95
95
|
aria-label={t(texts.decrementButtonAriaLabel(clampedStepSize))}
|
96
96
|
onClick={() => onChange(Math.max(value - clampedStepSize, minValue))}
|
97
97
|
visibility={value <= minValue ? "hidden" : "visible"}
|
@@ -164,7 +164,7 @@ export function NumericStepper({
|
|
164
164
|
</chakra.text>
|
165
165
|
)}
|
166
166
|
<VerySmallButton
|
167
|
-
icon={<AddIcon
|
167
|
+
icon={<AddIcon stepLabel={clampedStepSize} />}
|
168
168
|
aria-label={t(texts.incrementButtonAriaLabel(clampedStepSize))}
|
169
169
|
onClick={() => onChange(Math.min(value + clampedStepSize, maxValue))}
|
170
170
|
visibility={value >= maxValue ? "hidden" : "visible"}
|
@@ -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>
|
@@ -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 {
|
@@ -23,6 +24,98 @@ export function baseBackground(state: State, props: StyleFunctionProps) {
|
|
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, ${
|
88
|
+
props.theme.darkBackgroundColor ?? colors.darkGrey
|
89
|
+
}, ${colors.white} 30%)`,
|
90
|
+
)(props),
|
91
|
+
};
|
92
|
+
case "hover":
|
93
|
+
return {
|
94
|
+
backgroundColor: mode(
|
95
|
+
"white",
|
96
|
+
`color-mix(in srgb, ${
|
97
|
+
props.theme.darkBackgroundColor ?? colors.darkGrey
|
98
|
+
}, ${colors.white} 20%)`,
|
99
|
+
)(props),
|
100
|
+
};
|
101
|
+
case "focus":
|
102
|
+
return {
|
103
|
+
backgroundColor: mode(
|
104
|
+
"white",
|
105
|
+
`color-mix(in srgb, ${
|
106
|
+
props.theme.darkBackgroundColor ?? colors.darkGrey
|
107
|
+
}, ${colors.white} 40%)`,
|
108
|
+
)(props),
|
109
|
+
};
|
110
|
+
case "default":
|
111
|
+
default:
|
112
|
+
return {
|
113
|
+
backgroundColor: mode(
|
114
|
+
"white",
|
115
|
+
`color-mix(in srgb, ${
|
116
|
+
props.theme.darkBackgroundColor ?? colors.darkGrey
|
117
|
+
}, ${colors.white} 10%)`,
|
118
|
+
)(props),
|
119
|
+
};
|
27
120
|
}
|
28
121
|
}
|
@@ -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
|
5
|
-
|
6
|
-
| "
|
7
|
-
|
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:
|
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
|
+
}
|