@vygruppen/spor-react 9.7.0 → 9.8.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 +9 -9
- package/CHANGELOG.md +10 -0
- package/dist/{CountryCodeSelect-FPOWUHQG.mjs → CountryCodeSelect-EKYAUNTI.mjs} +1 -1
- package/dist/{chunk-QGMF2EAE.mjs → chunk-3P7NVQKW.mjs} +48 -145
- package/dist/index.d.mts +151 -701
- package/dist/index.d.ts +151 -701
- package/dist/index.js +56 -154
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/card/Card.tsx +7 -0
- package/src/card/index.tsx +0 -2
- package/src/layout/PressableCard.tsx +57 -0
- package/src/layout/StaticCard.tsx +77 -0
- package/src/layout/index.tsx +2 -0
- package/src/theme/components/pressable-card.ts +13 -131
- package/src/theme/components/static-card.ts +2 -12
- package/src/theme/utils/base-utils.ts +8 -1
- package/src/card/PressableCard.tsx +0 -52
- package/src/card/StaticCard.tsx +0 -25
package/dist/index.js
CHANGED
@@ -907,12 +907,42 @@ var init_RadioCardGroup = __esm({
|
|
907
907
|
};
|
908
908
|
}
|
909
909
|
});
|
910
|
+
exports.StaticCard = void 0;
|
911
|
+
var init_StaticCard = __esm({
|
912
|
+
"src/layout/StaticCard.tsx"() {
|
913
|
+
exports.StaticCard = react.forwardRef(
|
914
|
+
({ colorScheme = "white", children, ...props }, ref) => {
|
915
|
+
const styles3 = react.useStyleConfig("StaticCard", {
|
916
|
+
colorScheme
|
917
|
+
});
|
918
|
+
return /* @__PURE__ */ React73__namespace.default.createElement(react.Box, { __css: styles3, ...props, ref }, children, /* @__PURE__ */ React73__namespace.default.createElement(react.Card, null));
|
919
|
+
}
|
920
|
+
);
|
921
|
+
}
|
922
|
+
});
|
923
|
+
exports.PressableCard = void 0;
|
924
|
+
var init_PressableCard = __esm({
|
925
|
+
"src/layout/PressableCard.tsx"() {
|
926
|
+
exports.PressableCard = ({
|
927
|
+
children,
|
928
|
+
as = "button",
|
929
|
+
size: size2 = "sm",
|
930
|
+
variant = "base",
|
931
|
+
...props
|
932
|
+
}) => {
|
933
|
+
const styles3 = react.useStyleConfig("PressableCard", { variant, size: size2 });
|
934
|
+
return /* @__PURE__ */ React73__namespace.default.createElement(react.Box, { as, __css: styles3, ...props }, children);
|
935
|
+
};
|
936
|
+
}
|
937
|
+
});
|
910
938
|
var init_layout = __esm({
|
911
939
|
"src/layout/index.tsx"() {
|
912
940
|
init_Divider();
|
913
941
|
init_Stack();
|
914
942
|
init_RadioCard();
|
915
943
|
init_RadioCardGroup();
|
944
|
+
init_StaticCard();
|
945
|
+
init_PressableCard();
|
916
946
|
}
|
917
947
|
});
|
918
948
|
var AccordionContext, AccordionProvider, useAccordionContext;
|
@@ -1938,6 +1968,9 @@ var init_Card = __esm({
|
|
1938
1968
|
"src/card/Card.tsx"() {
|
1939
1969
|
exports.Card = react.forwardRef(
|
1940
1970
|
({ size: size2 = "sm", colorScheme = "white", children, ...props }, ref) => {
|
1971
|
+
console.warn(
|
1972
|
+
"Warning: Card is deprecated. Use `StaticCard` or `PressableCard` instead."
|
1973
|
+
);
|
1941
1974
|
const styles3 = react.useStyleConfig("Card", {
|
1942
1975
|
colorScheme,
|
1943
1976
|
size: size2
|
@@ -1947,37 +1980,11 @@ var init_Card = __esm({
|
|
1947
1980
|
);
|
1948
1981
|
}
|
1949
1982
|
});
|
1950
|
-
exports.StaticCard = void 0;
|
1951
|
-
var init_StaticCard = __esm({
|
1952
|
-
"src/card/StaticCard.tsx"() {
|
1953
|
-
exports.StaticCard = ({ colorScheme, ...props }) => {
|
1954
|
-
const styles3 = react.useStyleConfig("StaticCard", { colorScheme });
|
1955
|
-
return /* @__PURE__ */ React73__namespace.default.createElement(react.Box, { __css: styles3, ...props });
|
1956
|
-
};
|
1957
|
-
}
|
1958
|
-
});
|
1959
|
-
exports.PressableCard = void 0;
|
1960
|
-
var init_PressableCard = __esm({
|
1961
|
-
"src/card/PressableCard.tsx"() {
|
1962
|
-
exports.PressableCard = ({
|
1963
|
-
children,
|
1964
|
-
as = "button",
|
1965
|
-
size: size2 = "sm",
|
1966
|
-
variant = "base",
|
1967
|
-
...props
|
1968
|
-
}) => {
|
1969
|
-
const styles3 = react.useStyleConfig("PressableCard", { variant, size: size2 });
|
1970
|
-
return /* @__PURE__ */ React73__namespace.default.createElement(react.Box, { as, __css: styles3, ...props }, children);
|
1971
|
-
};
|
1972
|
-
}
|
1973
|
-
});
|
1974
1983
|
|
1975
1984
|
// src/card/index.tsx
|
1976
1985
|
var init_card = __esm({
|
1977
1986
|
"src/card/index.tsx"() {
|
1978
1987
|
init_Card();
|
1979
|
-
init_StaticCard();
|
1980
|
-
init_PressableCard();
|
1981
1988
|
}
|
1982
1989
|
});
|
1983
1990
|
exports.Badge = void 0;
|
@@ -11231,6 +11238,12 @@ function baseBorder(state2, props) {
|
|
11231
11238
|
)(props)
|
11232
11239
|
};
|
11233
11240
|
}
|
11241
|
+
case "active": {
|
11242
|
+
return {
|
11243
|
+
outline: "2px solid",
|
11244
|
+
outlineColor: themeTools.mode("base.outline.light", "base.outline.dark")(props)
|
11245
|
+
};
|
11246
|
+
}
|
11234
11247
|
case "invalid": {
|
11235
11248
|
return {
|
11236
11249
|
outline: "2px solid",
|
@@ -15449,7 +15462,6 @@ var config43, static_card_default, getColorSchemeBaseProps2;
|
|
15449
15462
|
var init_static_card = __esm({
|
15450
15463
|
"src/theme/components/static-card.ts"() {
|
15451
15464
|
init_foundations();
|
15452
|
-
init_base_utils();
|
15453
15465
|
init_focus_utils();
|
15454
15466
|
config43 = react.defineStyleConfig({
|
15455
15467
|
baseStyle: (props) => ({
|
@@ -15459,7 +15471,6 @@ var init_static_card = __esm({
|
|
15459
15471
|
fontSize: "inherit",
|
15460
15472
|
display: "block",
|
15461
15473
|
borderRadius: "md",
|
15462
|
-
// Except for white cards, all cards are light mode always
|
15463
15474
|
color: "text.default.light",
|
15464
15475
|
...focusVisibleStyles(props),
|
15465
15476
|
...getColorSchemeBaseProps2(props)
|
@@ -15471,12 +15482,8 @@ var init_static_card = __esm({
|
|
15471
15482
|
switch (props.colorScheme) {
|
15472
15483
|
case "white":
|
15473
15484
|
return {
|
15474
|
-
|
15475
|
-
|
15476
|
-
"white",
|
15477
|
-
`color-mix(in srgb, white 10%, var(--spor-colors-bg-default-dark))`
|
15478
|
-
)(props),
|
15479
|
-
color: "inherit"
|
15485
|
+
backgroundColor: "white",
|
15486
|
+
color: "darkGrey"
|
15480
15487
|
};
|
15481
15488
|
case "grey":
|
15482
15489
|
return {
|
@@ -15511,33 +15518,13 @@ var init_static_card = __esm({
|
|
15511
15518
|
}
|
15512
15519
|
default:
|
15513
15520
|
return {
|
15514
|
-
backgroundColor: ((_a6 = colors2[props.colorScheme]) == null ? void 0 : _a6[100]) ?? "default"
|
15515
|
-
...baseText("default", props)
|
15521
|
+
backgroundColor: ((_a6 = colors2[props.colorScheme]) == null ? void 0 : _a6[100]) ?? "default"
|
15516
15522
|
};
|
15517
15523
|
}
|
15518
15524
|
};
|
15519
15525
|
}
|
15520
15526
|
});
|
15521
|
-
|
15522
|
-
switch (props.colorScheme) {
|
15523
|
-
case "default":
|
15524
|
-
return {
|
15525
|
-
...floatingBorder("default", props)
|
15526
|
-
};
|
15527
|
-
case "accent":
|
15528
|
-
return {
|
15529
|
-
...accentBackground("default", props),
|
15530
|
-
...accentText("default", props),
|
15531
|
-
_hover: {
|
15532
|
-
...accentBackground("hover", props)
|
15533
|
-
},
|
15534
|
-
_active: {
|
15535
|
-
...accentBackground("active", props)
|
15536
|
-
}
|
15537
|
-
};
|
15538
|
-
}
|
15539
|
-
}
|
15540
|
-
var config44, pressable_card_default, getColorSchemeBaseProps3, getColorSchemeHoverProps2, getColorSchemeActiveProps2;
|
15527
|
+
var config44, pressable_card_default;
|
15541
15528
|
var init_pressable_card = __esm({
|
15542
15529
|
"src/theme/components/pressable-card.ts"() {
|
15543
15530
|
init_base_utils();
|
@@ -15552,137 +15539,52 @@ var init_pressable_card = __esm({
|
|
15552
15539
|
fontSize: "inherit",
|
15553
15540
|
display: "block",
|
15554
15541
|
borderRadius: "md",
|
15555
|
-
...getColorSchemeBaseProps3(props),
|
15556
|
-
...getColorSchemeClickableProps2(props),
|
15557
15542
|
...focusVisibleStyles(props),
|
15558
|
-
...getColorSchemeActiveProps2(props),
|
15559
|
-
_hover: getColorSchemeHoverProps2(props),
|
15560
15543
|
_disabled: {
|
15561
15544
|
...baseBackground("disabled", props),
|
15562
|
-
...baseBorder("disabled", props),
|
15563
15545
|
...baseText("disabled", props),
|
15546
|
+
outline: "none",
|
15564
15547
|
pointerEvents: "none"
|
15565
15548
|
}
|
15566
15549
|
}),
|
15567
15550
|
variants: {
|
15568
15551
|
base: (props) => ({
|
15569
|
-
...
|
15552
|
+
...baseBorder("default", props),
|
15570
15553
|
_hover: {
|
15571
|
-
...
|
15554
|
+
...baseBorder("hover", props)
|
15572
15555
|
},
|
15573
15556
|
_active: {
|
15574
|
-
...baseBackground("active", props)
|
15557
|
+
...baseBackground("active", props),
|
15558
|
+
...baseBorder("active", props)
|
15575
15559
|
}
|
15576
15560
|
}),
|
15577
15561
|
accent: (props) => ({
|
15578
15562
|
...accentBackground("default", props),
|
15563
|
+
boxShadow: "sm",
|
15579
15564
|
_hover: {
|
15580
|
-
...accentBackground("hover", props)
|
15565
|
+
...accentBackground("hover", props),
|
15566
|
+
boxShadow: "sm"
|
15581
15567
|
},
|
15582
15568
|
_active: {
|
15583
|
-
...accentBackground("active", props)
|
15569
|
+
...accentBackground("active", props),
|
15570
|
+
boxShadow: "none"
|
15584
15571
|
}
|
15585
15572
|
}),
|
15586
15573
|
floating: (props) => ({
|
15587
15574
|
...floatingBackground("default", props),
|
15588
|
-
_hover: {
|
15589
|
-
...floatingBackground("hover", props)
|
15590
|
-
},
|
15591
|
-
_active: {
|
15592
|
-
...floatingBackground("active", props)
|
15593
|
-
}
|
15594
|
-
})
|
15595
|
-
},
|
15596
|
-
sizes: {
|
15597
|
-
sm: {
|
15598
15575
|
boxShadow: "sm",
|
15599
15576
|
_hover: {
|
15577
|
+
...floatingBackground("hover", props),
|
15600
15578
|
boxShadow: "md"
|
15601
15579
|
},
|
15602
15580
|
_active: {
|
15581
|
+
...floatingBackground("active", props),
|
15603
15582
|
boxShadow: "none"
|
15604
15583
|
}
|
15605
|
-
}
|
15606
|
-
lg: {
|
15607
|
-
boxShadow: "md",
|
15608
|
-
_hover: {
|
15609
|
-
boxShadow: "lg"
|
15610
|
-
},
|
15611
|
-
_active: {
|
15612
|
-
boxShadow: "sm"
|
15613
|
-
}
|
15614
|
-
}
|
15584
|
+
})
|
15615
15585
|
}
|
15616
15586
|
});
|
15617
15587
|
pressable_card_default = config44;
|
15618
|
-
getColorSchemeBaseProps3 = (props) => {
|
15619
|
-
switch (props.colorScheme) {
|
15620
|
-
case "default":
|
15621
|
-
return {
|
15622
|
-
...baseBorder("default", props),
|
15623
|
-
backgroundColor: themeTools.mode(
|
15624
|
-
"white",
|
15625
|
-
`color-mix(in srgb, white 10%, var(--spor-colors-bg-default-dark))`
|
15626
|
-
)(props),
|
15627
|
-
color: "inherit"
|
15628
|
-
};
|
15629
|
-
case "accent":
|
15630
|
-
return {
|
15631
|
-
...accentBackground("default", props),
|
15632
|
-
...accentText("default", props),
|
15633
|
-
_hover: {
|
15634
|
-
...accentBackground("hover", props)
|
15635
|
-
},
|
15636
|
-
_active: {
|
15637
|
-
...accentBackground("active", props)
|
15638
|
-
}
|
15639
|
-
};
|
15640
|
-
}
|
15641
|
-
};
|
15642
|
-
getColorSchemeHoverProps2 = (props) => {
|
15643
|
-
switch (props.colorScheme) {
|
15644
|
-
case "default":
|
15645
|
-
return {
|
15646
|
-
backgroundColor: themeTools.mode(
|
15647
|
-
"white",
|
15648
|
-
`color-mix(in srgb, white 20%, var(--spor-colors-bg-default-dark))`
|
15649
|
-
)(props),
|
15650
|
-
...floatingBorder("hover", props)
|
15651
|
-
};
|
15652
|
-
case "accent":
|
15653
|
-
return {
|
15654
|
-
...accentBackground("default", props),
|
15655
|
-
...accentText("default", props),
|
15656
|
-
_hover: {
|
15657
|
-
...accentBackground("hover", props)
|
15658
|
-
},
|
15659
|
-
_active: {
|
15660
|
-
...accentBackground("active", props)
|
15661
|
-
}
|
15662
|
-
};
|
15663
|
-
}
|
15664
|
-
};
|
15665
|
-
getColorSchemeActiveProps2 = (props) => {
|
15666
|
-
const { colorScheme } = props;
|
15667
|
-
switch (colorScheme) {
|
15668
|
-
case "default":
|
15669
|
-
return {
|
15670
|
-
backgroundColor: themeTools.mode("bg.tertiary.light", `bg.default.dark`)(props),
|
15671
|
-
...floatingBorder("active", props)
|
15672
|
-
};
|
15673
|
-
case "accent":
|
15674
|
-
return {
|
15675
|
-
...accentBackground("default", props),
|
15676
|
-
...accentText("default", props),
|
15677
|
-
_hover: {
|
15678
|
-
...accentBackground("hover", props)
|
15679
|
-
},
|
15680
|
-
_active: {
|
15681
|
-
...accentBackground("active", props)
|
15682
|
-
}
|
15683
|
-
};
|
15684
|
-
}
|
15685
|
-
};
|
15686
15588
|
}
|
15687
15589
|
});
|
15688
15590
|
|
package/dist/index.mjs
CHANGED
@@ -1 +1 @@
|
|
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, Collapse, 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, FullScreenDrawer, 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, Nudge, NumericStepper, OrderedList, Pagination, PasswordInput, PhoneNumberInput, PlayPauseButton, Portal, PressableCard, ProgressBar, ProgressIndicator, ProgressLoader, Radio, RadioCard, RadioCardGroup, RadioGroup, ScaleFade, SearchInput, Section, SimpleDrawer, SimpleGrid, Skeleton, SkeletonCircle, SkeletonText, SkipButton, Slide, SlideFade, Spacer, SporProvider, Stack, StaticAlert, StaticCard, Stepper, StepperStep, Switch, Tab, TabList, TabPanel, TabPanels, Table, TableCaption, Tabs, Tbody, Td, Text, TextLink, Textarea, Tfoot, Th, Thead, Time, TimePicker, Tooltip, Tr, TravelTag, UnorderedList, VStack, VyLogo, WizardNudge, Wrap, WrapItem, brandTheme, createTexts, defineStyleConfig, extendTheme, fontFaces, slugify, 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, Collapse, 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, FullScreenDrawer, 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, Nudge, NumericStepper, OrderedList, Pagination, PasswordInput, PhoneNumberInput, PlayPauseButton, Portal, PressableCard, ProgressBar, ProgressIndicator, ProgressLoader, Radio, RadioCard, RadioCardGroup, RadioGroup, ScaleFade, SearchInput, Section, SimpleDrawer, SimpleGrid, Skeleton, SkeletonCircle, SkeletonText, SkipButton, Slide, SlideFade, Spacer, SporProvider, Stack, StaticAlert, StaticCard, Stepper, StepperStep, Switch, Tab, TabList, TabPanel, TabPanels, Table, TableCaption, Tabs, Tbody, Td, Text, TextLink, Textarea, Tfoot, Th, Thead, Time, TimePicker, Tooltip, Tr, TravelTag, UnorderedList, VStack, VyLogo, WizardNudge, Wrap, WrapItem, brandTheme, createTexts, defineStyleConfig, extendTheme, fontFaces, slugify, theme, tokens, useBreakpointValue, useClipboard, useColorMode, useColorModePreference, useColorModeValue, useControllableProp, useDisclosure, useMediaQuery, useMergeRefs, useOutsideClick, usePrefersReducedMotion, useSize, useTheme, useToast, useToken, useTranslation } from './chunk-3P7NVQKW.mjs';
|
package/package.json
CHANGED
package/src/card/Card.tsx
CHANGED
@@ -50,8 +50,15 @@ export type CardProps = Exclude<BoxProps, "size"> & {
|
|
50
50
|
* </Card>
|
51
51
|
* ```
|
52
52
|
*/
|
53
|
+
|
54
|
+
/**
|
55
|
+
* @deprecated Card is deprecated. Use `StaticCard` or `PressableCard` instead.
|
56
|
+
*/
|
53
57
|
export const Card = forwardRef<CardProps, As>(
|
54
58
|
({ size = "sm", colorScheme = "white", children, ...props }, ref) => {
|
59
|
+
console.warn(
|
60
|
+
"Warning: Card is deprecated. Use `StaticCard` or `PressableCard` instead.",
|
61
|
+
);
|
55
62
|
const styles = useStyleConfig("Card", {
|
56
63
|
colorScheme,
|
57
64
|
size,
|
package/src/card/index.tsx
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { Box, BoxProps, useStyleConfig } from "@chakra-ui/react";
|
3
|
+
|
4
|
+
type PressableCardProps = Omit<BoxProps, "as"> & {
|
5
|
+
/** Use "floating" | "accent" | "base". Defaults to base */
|
6
|
+
variant: "floating" | "accent" | "base";
|
7
|
+
/** Use "sm" | "lg". Defaults to sm */
|
8
|
+
size?: "sm" | "lg";
|
9
|
+
/** Use "button" | "a" | "label". Defaults to button */
|
10
|
+
as: "button" | "a" | "label";
|
11
|
+
};
|
12
|
+
|
13
|
+
/**
|
14
|
+
* `PressableCard` is a component that renders a pressable card.
|
15
|
+
*
|
16
|
+
* The `PressableCard` component can be used to create a card that responds to user interactions.
|
17
|
+
* It can be rendered as a button, link, label, or any other HTML element by specifying the `as` prop.
|
18
|
+
* If no `as` prop is provided, it defaults to a button.
|
19
|
+
*
|
20
|
+
* The `size` prop can be used to control the size of the card. It defaults to "sm".
|
21
|
+
* The `variant` prop can be used to control the style variant of the card. It defaults to "base".
|
22
|
+
*
|
23
|
+
* Example usage:
|
24
|
+
*
|
25
|
+
* ```tsx
|
26
|
+
* <PressableCard>
|
27
|
+
* Content
|
28
|
+
* </PressableCard>
|
29
|
+
* ```
|
30
|
+
*
|
31
|
+
* To render the card as a different HTML element, specify the `as` prop:
|
32
|
+
*
|
33
|
+
* ```tsx
|
34
|
+
* <PressableCard as="a">
|
35
|
+
* This is now a <a /> element
|
36
|
+
* </PressableCard>
|
37
|
+
* ```
|
38
|
+
*
|
39
|
+
* For a static card with other color schemes, use the `StaticCard` component.
|
40
|
+
*
|
41
|
+
* @see StaticCard
|
42
|
+
*/
|
43
|
+
|
44
|
+
export const PressableCard = ({
|
45
|
+
children,
|
46
|
+
as = "button",
|
47
|
+
size = "sm",
|
48
|
+
variant = "base",
|
49
|
+
...props
|
50
|
+
}: PressableCardProps) => {
|
51
|
+
const styles = useStyleConfig("PressableCard", { variant, size });
|
52
|
+
return (
|
53
|
+
<Box as={as} __css={styles} {...props}>
|
54
|
+
{children}
|
55
|
+
</Box>
|
56
|
+
);
|
57
|
+
};
|
@@ -0,0 +1,77 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import {
|
3
|
+
As,
|
4
|
+
Box,
|
5
|
+
BoxProps,
|
6
|
+
useStyleConfig,
|
7
|
+
forwardRef,
|
8
|
+
Card,
|
9
|
+
} from "@chakra-ui/react";
|
10
|
+
|
11
|
+
export type StaticCardProps = BoxProps & {
|
12
|
+
children: React.ReactNode;
|
13
|
+
/** Defaults to "white" */
|
14
|
+
colorScheme:
|
15
|
+
| "white"
|
16
|
+
| "grey"
|
17
|
+
| "green"
|
18
|
+
| "orange"
|
19
|
+
| "red"
|
20
|
+
| "yellow"
|
21
|
+
| "blue"
|
22
|
+
| "darkBlue"
|
23
|
+
| "darkGreen"
|
24
|
+
| "darkYellow";
|
25
|
+
};
|
26
|
+
|
27
|
+
/**
|
28
|
+
* `StaticCard` is a component that renders a static card.
|
29
|
+
*
|
30
|
+
* The `StaticCard` component can be used to create a card that does not respond to user interactions.
|
31
|
+
* It can be rendered as any HTML element by specifying the `as` prop.
|
32
|
+
*
|
33
|
+
* The `colorScheme` prop can be used to control the color scheme of the card. It defaults to "white".
|
34
|
+
*
|
35
|
+
* Example usage:
|
36
|
+
*
|
37
|
+
* ```tsx
|
38
|
+
* <StaticCard>
|
39
|
+
* Content
|
40
|
+
* </StaticCard>
|
41
|
+
* ```
|
42
|
+
*
|
43
|
+
* To render the card as a different HTML element, specify the `as` prop:
|
44
|
+
*
|
45
|
+
* ```tsx
|
46
|
+
* <StaticCard as="section">
|
47
|
+
* This is now a <section /> element
|
48
|
+
* </StaticCard>
|
49
|
+
* ```
|
50
|
+
*
|
51
|
+
* To change the color scheme of the card, specify the `colorScheme` prop:
|
52
|
+
*
|
53
|
+
* ```tsx
|
54
|
+
* <StaticCard colorScheme="orange">
|
55
|
+
* An orange card
|
56
|
+
* </StaticCard>
|
57
|
+
* ```
|
58
|
+
*
|
59
|
+
* For a card with click functionality, use the `PressableCard` component.
|
60
|
+
*
|
61
|
+
* @see PressableCard
|
62
|
+
*/
|
63
|
+
|
64
|
+
export const StaticCard = forwardRef<StaticCardProps, As>(
|
65
|
+
({ colorScheme = "white", children, ...props }, ref) => {
|
66
|
+
const styles = useStyleConfig("StaticCard", {
|
67
|
+
colorScheme,
|
68
|
+
});
|
69
|
+
|
70
|
+
return (
|
71
|
+
<Box __css={styles} {...props} ref={ref}>
|
72
|
+
{children}
|
73
|
+
<Card />
|
74
|
+
</Box>
|
75
|
+
);
|
76
|
+
},
|
77
|
+
);
|
package/src/layout/index.tsx
CHANGED
@@ -1,179 +1,61 @@
|
|
1
1
|
import { defineStyleConfig } from "@chakra-ui/react";
|
2
|
-
import { mode } from "@chakra-ui/theme-tools";
|
3
2
|
import { baseBackground, baseBorder, baseText } from "../utils/base-utils";
|
4
|
-
import { floatingBackground
|
3
|
+
import { floatingBackground } from "../utils/floating-utils";
|
5
4
|
import { focusVisibleStyles } from "../utils/focus-utils";
|
6
|
-
import { accentBackground
|
5
|
+
import { accentBackground } from "../utils/accent-utils";
|
7
6
|
|
8
7
|
const config = defineStyleConfig({
|
9
|
-
baseStyle: (props
|
8
|
+
baseStyle: (props) => ({
|
10
9
|
appearance: "none",
|
11
10
|
border: "none",
|
12
11
|
overflow: "hidden",
|
13
12
|
fontSize: "inherit",
|
14
13
|
display: "block",
|
15
14
|
borderRadius: "md",
|
16
|
-
...getColorSchemeBaseProps(props),
|
17
|
-
...getColorSchemeClickableProps(props),
|
18
15
|
...focusVisibleStyles(props),
|
19
|
-
...getColorSchemeActiveProps(props),
|
20
|
-
_hover: getColorSchemeHoverProps(props),
|
21
16
|
_disabled: {
|
22
17
|
...baseBackground("disabled", props),
|
23
|
-
...baseBorder("disabled", props),
|
24
18
|
...baseText("disabled", props),
|
19
|
+
outline: "none",
|
25
20
|
pointerEvents: "none",
|
26
21
|
},
|
27
22
|
}),
|
28
23
|
variants: {
|
29
24
|
base: (props) => ({
|
30
|
-
...
|
25
|
+
...baseBorder("default", props),
|
31
26
|
_hover: {
|
32
|
-
...
|
27
|
+
...baseBorder("hover", props),
|
33
28
|
},
|
34
29
|
_active: {
|
35
30
|
...baseBackground("active", props),
|
31
|
+
...baseBorder("active", props),
|
36
32
|
},
|
37
33
|
}),
|
38
34
|
accent: (props) => ({
|
39
35
|
...accentBackground("default", props),
|
36
|
+
boxShadow: "sm",
|
40
37
|
_hover: {
|
41
38
|
...accentBackground("hover", props),
|
39
|
+
boxShadow: "sm",
|
42
40
|
},
|
43
41
|
_active: {
|
44
42
|
...accentBackground("active", props),
|
43
|
+
boxShadow: "none",
|
45
44
|
},
|
46
45
|
}),
|
47
46
|
floating: (props) => ({
|
48
47
|
...floatingBackground("default", props),
|
49
|
-
_hover: {
|
50
|
-
...floatingBackground("hover", props),
|
51
|
-
},
|
52
|
-
_active: {
|
53
|
-
...floatingBackground("active", props),
|
54
|
-
},
|
55
|
-
}),
|
56
|
-
},
|
57
|
-
sizes: {
|
58
|
-
sm: {
|
59
48
|
boxShadow: "sm",
|
60
|
-
|
61
49
|
_hover: {
|
50
|
+
...floatingBackground("hover", props),
|
62
51
|
boxShadow: "md",
|
63
52
|
},
|
64
|
-
|
65
53
|
_active: {
|
54
|
+
...floatingBackground("active", props),
|
66
55
|
boxShadow: "none",
|
67
56
|
},
|
68
|
-
},
|
69
|
-
lg: {
|
70
|
-
boxShadow: "md",
|
71
|
-
|
72
|
-
_hover: {
|
73
|
-
boxShadow: "lg",
|
74
|
-
},
|
75
|
-
|
76
|
-
_active: {
|
77
|
-
boxShadow: "sm",
|
78
|
-
},
|
79
|
-
},
|
57
|
+
}),
|
80
58
|
},
|
81
59
|
});
|
82
60
|
|
83
61
|
export default config;
|
84
|
-
|
85
|
-
type CardThemeProps = {
|
86
|
-
colorScheme: "accent" | "default";
|
87
|
-
theme: any;
|
88
|
-
colorMode: "light" | "dark";
|
89
|
-
};
|
90
|
-
|
91
|
-
const getColorSchemeBaseProps = (props: CardThemeProps) => {
|
92
|
-
switch (props.colorScheme) {
|
93
|
-
case "default":
|
94
|
-
return {
|
95
|
-
...baseBorder("default", props),
|
96
|
-
backgroundColor: mode(
|
97
|
-
"white",
|
98
|
-
`color-mix(in srgb, white 10%, var(--spor-colors-bg-default-dark))`,
|
99
|
-
)(props),
|
100
|
-
color: "inherit",
|
101
|
-
};
|
102
|
-
case "accent":
|
103
|
-
return {
|
104
|
-
...accentBackground("default", props),
|
105
|
-
...accentText("default", props),
|
106
|
-
_hover: {
|
107
|
-
...accentBackground("hover", props),
|
108
|
-
},
|
109
|
-
_active: {
|
110
|
-
...accentBackground("active", props),
|
111
|
-
},
|
112
|
-
};
|
113
|
-
}
|
114
|
-
};
|
115
|
-
|
116
|
-
function getColorSchemeClickableProps(props: CardThemeProps) {
|
117
|
-
switch (props.colorScheme) {
|
118
|
-
case "default":
|
119
|
-
return {
|
120
|
-
...floatingBorder("default", props),
|
121
|
-
};
|
122
|
-
case "accent":
|
123
|
-
return {
|
124
|
-
...accentBackground("default", props),
|
125
|
-
...accentText("default", props),
|
126
|
-
_hover: {
|
127
|
-
...accentBackground("hover", props),
|
128
|
-
},
|
129
|
-
_active: {
|
130
|
-
...accentBackground("active", props),
|
131
|
-
},
|
132
|
-
};
|
133
|
-
}
|
134
|
-
}
|
135
|
-
|
136
|
-
const getColorSchemeHoverProps = (props: CardThemeProps) => {
|
137
|
-
switch (props.colorScheme) {
|
138
|
-
case "default":
|
139
|
-
return {
|
140
|
-
backgroundColor: mode(
|
141
|
-
"white",
|
142
|
-
`color-mix(in srgb, white 20%, var(--spor-colors-bg-default-dark))`,
|
143
|
-
)(props),
|
144
|
-
...floatingBorder("hover", props),
|
145
|
-
};
|
146
|
-
case "accent":
|
147
|
-
return {
|
148
|
-
...accentBackground("default", props),
|
149
|
-
...accentText("default", props),
|
150
|
-
_hover: {
|
151
|
-
...accentBackground("hover", props),
|
152
|
-
},
|
153
|
-
_active: {
|
154
|
-
...accentBackground("active", props),
|
155
|
-
},
|
156
|
-
};
|
157
|
-
}
|
158
|
-
};
|
159
|
-
const getColorSchemeActiveProps = (props: CardThemeProps) => {
|
160
|
-
const { colorScheme } = props;
|
161
|
-
switch (colorScheme) {
|
162
|
-
case "default":
|
163
|
-
return {
|
164
|
-
backgroundColor: mode("bg.tertiary.light", `bg.default.dark`)(props),
|
165
|
-
...floatingBorder("active", props),
|
166
|
-
};
|
167
|
-
case "accent":
|
168
|
-
return {
|
169
|
-
...accentBackground("default", props),
|
170
|
-
...accentText("default", props),
|
171
|
-
_hover: {
|
172
|
-
...accentBackground("hover", props),
|
173
|
-
},
|
174
|
-
_active: {
|
175
|
-
...accentBackground("active", props),
|
176
|
-
},
|
177
|
-
};
|
178
|
-
}
|
179
|
-
};
|