@mrshmllw/smores-react 14.1.1 → 14.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/dist/Accordion/Accordion.js +5 -3
- package/dist/Accordion/Accordion.js.map +1 -1
- package/dist/ActionDropdown/ActionDropdown.js +6 -2
- package/dist/ActionDropdown/ActionDropdown.js.map +1 -1
- package/dist/Alert/Alert.js +9 -8
- package/dist/Alert/Alert.js.map +1 -1
- package/dist/Banner/BannerItem.js +8 -2
- package/dist/Banner/BannerItem.js.map +1 -1
- package/dist/Banner/types.d.ts +3 -1
- package/dist/Banner/types.js.map +1 -1
- package/dist/Box/index.d.ts +1 -0
- package/dist/Box/index.js.map +1 -1
- package/dist/Button/Button.d.ts +2 -1
- package/dist/Button/Button.js +5 -3
- package/dist/Button/Button.js.map +1 -1
- package/dist/Card/Card.d.ts +2 -16
- package/dist/Card/Card.js +7 -4
- package/dist/Card/Card.js.map +1 -1
- package/dist/Chip/Chip.d.ts +2 -1
- package/dist/Chip/Chip.js +11 -3
- package/dist/Chip/Chip.js.map +1 -1
- package/dist/CurrencyInput/CurrencyInput.js +6 -3
- package/dist/CurrencyInput/CurrencyInput.js.map +1 -1
- package/dist/Datepicker/Datepicker.js +7 -4
- package/dist/Datepicker/Datepicker.js.map +1 -1
- package/dist/Dropdown/Dropdown.d.ts +3 -2
- package/dist/Dropdown/Dropdown.js +11 -7
- package/dist/Dropdown/Dropdown.js.map +1 -1
- package/dist/Dropdown/index.d.ts +1 -1
- package/dist/Dropdown/index.js.map +1 -1
- package/dist/Icon/Icon.js +5 -0
- package/dist/Icon/Icon.js.map +1 -1
- package/dist/Icon/index.d.ts +1 -0
- package/dist/Icon/index.js.map +1 -1
- package/dist/IconStrict/IconStrict.d.ts +1 -1
- package/dist/IconStrict/IconStrict.js +5 -0
- package/dist/IconStrict/IconStrict.js.map +1 -1
- package/dist/IconWrapper/IconWrapper.d.ts +1 -1
- package/dist/IconWrapper/IconWrapper.js.map +1 -1
- package/dist/Link/Link.d.ts +2 -1
- package/dist/Link/Link.js +7 -2
- package/dist/Link/Link.js.map +1 -1
- package/dist/Modal/Modal.js +12 -3
- package/dist/Modal/Modal.js.map +1 -1
- package/dist/NumberInput/NumberInput.js +11 -6
- package/dist/NumberInput/NumberInput.js.map +1 -1
- package/dist/Pagination/Pagination.js +5 -3
- package/dist/Pagination/Pagination.js.map +1 -1
- package/dist/ProgressIndicator/components/StepItem.js +6 -3
- package/dist/ProgressIndicator/components/StepItem.js.map +1 -1
- package/dist/RadioGroup/RadioGroup.d.ts +3 -2
- package/dist/RadioGroup/RadioGroup.js +1 -1
- package/dist/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/RadioGroup/RadioItem.d.ts +3 -2
- package/dist/RadioGroup/RadioItem.js +7 -2
- package/dist/RadioGroup/RadioItem.js.map +1 -1
- package/dist/RichText/RichText.js +4 -2
- package/dist/RichText/RichText.js.map +1 -1
- package/dist/RichTextEditor/plugins/ToolbarPlugin.js +7 -5
- package/dist/RichTextEditor/plugins/ToolbarPlugin.js.map +1 -1
- package/dist/Row/Row.d.ts +4 -2
- package/dist/Row/Row.js +8 -3
- package/dist/Row/Row.js.map +1 -1
- package/dist/SearchInput/SearchInput.d.ts +0 -9
- package/dist/SearchInput/SearchInput.js +11 -6
- package/dist/SearchInput/SearchInput.js.map +1 -1
- package/dist/Snackbar/SnackbarItem.js +8 -3
- package/dist/Snackbar/SnackbarItem.js.map +1 -1
- package/dist/Snackbar/types.d.ts +2 -1
- package/dist/Snackbar/types.js.map +1 -1
- package/dist/SupportMessage/SupportMessage.js +11 -10
- package/dist/SupportMessage/SupportMessage.js.map +1 -1
- package/dist/Table/index.d.ts +1 -0
- package/dist/Table/index.js.map +1 -1
- package/dist/Tag/Tag.d.ts +3 -2
- package/dist/Tag/Tag.js +4 -2
- package/dist/Tag/Tag.js.map +1 -1
- package/dist/Tag/Tag.spec.js +10 -0
- package/dist/Tag/Tag.spec.js.map +1 -1
- package/dist/TextInput/TextInput.js +8 -4
- package/dist/TextInput/TextInput.js.map +1 -1
- package/dist/ThemeProvider/utils/colourMap.d.ts +2 -8
- package/dist/ThemeProvider/utils/colourMap.js.map +1 -1
- package/dist/fields/commonFieldTypes.d.ts +3 -1
- package/dist/fields/commonFieldTypes.js.map +1 -1
- package/dist/fields/components/CommonInput.d.ts +10 -2
- package/dist/fields/components/CommonInput.js +16 -0
- package/dist/fields/components/CommonInput.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/sharedStyles/shared.styles.d.ts +5 -0
- package/dist/sharedStyles/shared.styles.js +22 -0
- package/dist/sharedStyles/shared.styles.js.map +1 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.js.map +1 -1
- package/dist/utils/deprecated.js +8 -2
- package/dist/utils/deprecated.js.map +1 -1
- package/dist/utils/flex.d.ts +4 -1
- package/dist/utils/flex.js +4 -4
- package/dist/utils/flex.js.map +1 -1
- package/dist/utils/space.d.ts +12 -5
- package/dist/utils/space.js +31 -21
- package/dist/utils/space.js.map +1 -1
- package/package.json +30 -27
|
@@ -2,9 +2,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import styled, { css, useTheme } from 'styled-components';
|
|
4
4
|
import { Box } from '../Box';
|
|
5
|
-
import { Icon } from '../Icon';
|
|
6
5
|
import { Text } from '../Text';
|
|
7
6
|
import { resolveToThemeColor } from '../ThemeProvider/utils/colourMap';
|
|
7
|
+
import { IconContainer } from '../sharedStyles/shared.styles';
|
|
8
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
9
|
+
import { faChevronDown } from '@awesome.me/kit-46ca99185c/icons/classic/regular';
|
|
8
10
|
export const Accordion = ({ title, children, onToggle, filledBackground, defaultIsOpen = false, borderTop = false, borderColor = 'color.illustration.neutral.300', backgroundColor = 'color.surface.base.300', subTitle, fullBorder = false, ...marginProps }) => {
|
|
9
11
|
const theme = useTheme();
|
|
10
12
|
const [isOpen, setIsOpen] = useState(defaultIsOpen);
|
|
@@ -16,7 +18,7 @@ export const Accordion = ({ title, children, onToggle, filledBackground, default
|
|
|
16
18
|
onToggle?.(nextOpenState);
|
|
17
19
|
setIsOpen(nextOpenState);
|
|
18
20
|
};
|
|
19
|
-
return (_jsxs(Wrapper, { "$borderTop": borderTop, "$fullBorder": fullBorder, "$filledBackground": filledBackground, "$borderColor": resolvedBorderColor, "$backgroundColor": resolvedBackgroundColour, ...marginProps, children: [_jsxs(TopContainer, { flex: true, alignItems: "center", justifyContent: "space-between", onClick: handleToggle, py: "16px", pr: "16px", pl: px, children: [_jsxs(TitleContainer, { children: [_jsx(Text, { tag: "h2", typo: "headline-regular", children: title }), subTitle && (_jsx(Text, { tag: "label", typo: "label", mt: { custom: 4 }, children: subTitle }))] }), _jsx(CaretIcon, {
|
|
21
|
+
return (_jsxs(Wrapper, { "$borderTop": borderTop, "$fullBorder": fullBorder, "$filledBackground": filledBackground, "$borderColor": resolvedBorderColor, "$backgroundColor": resolvedBackgroundColour, ...marginProps, children: [_jsxs(TopContainer, { flex: true, alignItems: "center", justifyContent: "space-between", onClick: handleToggle, py: "16px", pr: "16px", pl: px, children: [_jsxs(TitleContainer, { children: [_jsx(Text, { tag: "h2", typo: "headline-regular", children: title }), subTitle && (_jsx(Text, { tag: "label", typo: "label", mt: { custom: 4 }, children: subTitle }))] }), _jsx(CaretIcon, { "$size": 20, "$isOpen": isOpen, "$borderTop": borderTop, children: _jsx(FontAwesomeIcon, { icon: faChevronDown, color: theme.color.illustration.neutral[400] }) })] }), isOpen && (_jsx(Box, { pt: "12px", pb: "16px", px: px, children: children }))] }));
|
|
20
22
|
};
|
|
21
23
|
const Wrapper = styled(Box)(({ $borderTop, $fullBorder, $filledBackground, $borderColor, $backgroundColor, }) => css `
|
|
22
24
|
border-bottom: 1px solid ${$borderColor};
|
|
@@ -40,7 +42,7 @@ const TitleContainer = styled.div `
|
|
|
40
42
|
const TopContainer = styled(Box) `
|
|
41
43
|
cursor: pointer;
|
|
42
44
|
`;
|
|
43
|
-
const CaretIcon = styled(
|
|
45
|
+
const CaretIcon = styled(IconContainer)(({ $isOpen }) => css `
|
|
44
46
|
transform: ${$isOpen ? 'rotate(180deg)' : 'rotate(0deg)'};
|
|
45
47
|
transition: transform 0.6s ease;
|
|
46
48
|
`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.js","sourceRoot":"","sources":["../../src/Accordion/Accordion.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAiB,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC/C,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAGzD,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"Accordion.js","sourceRoot":"","sources":["../../src/Accordion/Accordion.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAiB,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC/C,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAGzD,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAE9B,OAAO,EAAY,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,kDAAkD,CAAA;AA4BhF,MAAM,CAAC,MAAM,SAAS,GAAuB,CAAC,EAC5C,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,aAAa,GAA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c,EAEjB,KAAC,SAAS,aAAQ,EAAE,aAAW,MAAM,gBAAc,SAAS,YAC1D,KAAC,eAAe,IACd,IAAI,EAAE,aAAa,EACnB,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,GAC5C,GACQ,IACC,EACd,MAAM,IAAI,CACT,KAAC,GAAG,IAAC,EAAE,EAAC,MAAM,EAAC,EAAE,EAAC,MAAM,EAAC,EAAE,EAAE,EAAE,YAC5B,QAAQ,GACL,CACP,IACO,CACX,CAAA;AACH,CAAC,CAAA;AAED,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAKzB,CAAC,EACC,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,GACjB,EAAE,EAAE,CAAC,GAAG,CAAA;+BACoB,YAAY;MACrC,UAAU,IAAI,yBAAyB,gBAAgB,GAAG;;MAE1D,WAAW;IACb,GAAG,CAAA;0BACmB,YAAY;;KAEjC;;MAEC,iBAAiB;IACnB,GAAG,CAAA;0BACmB,gBAAgB;KACrC;GACF,CACF,CAAA;AAED,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAA;;;CAGhC,CAAA;AACD,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;;CAE/B,CAAA;AAED,MAAM,SAAS,GAAG,MAAM,CAAC,aAAa,CAAC,CAGrC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,GAAG,CAAA;iBACL,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,cAAc;;GAEzD,CACF,CAAA","sourcesContent":["import { FC, ReactNode, useState } from 'react'\nimport styled, { css, useTheme } from 'styled-components'\n\nimport { TransientProps } from 'utils/utilTypes'\nimport { Box } from '../Box'\nimport { Text } from '../Text'\nimport { MarginProps } from '../utils/space'\nimport { NewColor, resolveToThemeColor } from '../ThemeProvider/utils/colourMap'\nimport { IconContainer } from '../sharedStyles/shared.styles'\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome'\nimport { faChevronDown } from '@awesome.me/kit-46ca99185c/icons/classic/regular'\n\ntype UsableNewColors = Extract<\n NewColor,\n | 'color.surface.base.000'\n | 'color.surface.base.100'\n | 'color.surface.base.300'\n | 'color.illustration.neutral.300'\n>\n\nexport type AccordionProps = {\n title: string\n subTitle?: string\n filledBackground?: boolean\n borderTop?: boolean\n borderColor?: 'oatmeal' | 'custard' | 'cream' | 'coconut' | UsableNewColors\n fullBorder?: boolean\n backgroundColor?:\n | 'oatmeal'\n | 'custard'\n | 'cream'\n | 'coconut'\n | UsableNewColors\n onToggle?: (isOpen: boolean) => void\n children: ReactNode\n defaultIsOpen?: boolean\n} & MarginProps\n\nexport const Accordion: FC<AccordionProps> = ({\n title,\n children,\n onToggle,\n filledBackground,\n defaultIsOpen = false,\n borderTop = false,\n borderColor = 'color.illustration.neutral.300',\n backgroundColor = 'color.surface.base.300',\n subTitle,\n fullBorder = false,\n ...marginProps\n}) => {\n const theme = useTheme()\n const [isOpen, setIsOpen] = useState(defaultIsOpen)\n const px = fullBorder ? '16px' : '0'\n\n const resolvedBorderColor = resolveToThemeColor(borderColor, theme)\n\n const resolvedBackgroundColour = resolveToThemeColor(backgroundColor, theme)\n\n const handleToggle = () => {\n const nextOpenState = !isOpen\n onToggle?.(nextOpenState)\n setIsOpen(nextOpenState)\n }\n\n return (\n <Wrapper\n $borderTop={borderTop}\n $fullBorder={fullBorder}\n $filledBackground={filledBackground}\n $borderColor={resolvedBorderColor}\n $backgroundColor={resolvedBackgroundColour}\n {...marginProps}\n >\n <TopContainer\n flex\n alignItems=\"center\"\n justifyContent=\"space-between\"\n onClick={handleToggle}\n py=\"16px\"\n pr=\"16px\"\n pl={px}\n >\n <TitleContainer>\n <Text tag=\"h2\" typo=\"headline-regular\">\n {title}\n </Text>\n {subTitle && (\n <Text tag=\"label\" typo=\"label\" mt={{ custom: 4 }}>\n {subTitle}\n </Text>\n )}\n </TitleContainer>\n\n <CaretIcon $size={20} $isOpen={isOpen} $borderTop={borderTop}>\n <FontAwesomeIcon\n icon={faChevronDown}\n color={theme.color.illustration.neutral[400]}\n />\n </CaretIcon>\n </TopContainer>\n {isOpen && (\n <Box pt=\"12px\" pb=\"16px\" px={px}>\n {children}\n </Box>\n )}\n </Wrapper>\n )\n}\n\nconst Wrapper = styled(Box)<\n TransientProps<\n Pick<AccordionProps, 'borderTop' | 'fullBorder' | 'filledBackground'>\n > & { $borderColor: string; $backgroundColor: string }\n>(\n ({\n $borderTop,\n $fullBorder,\n $filledBackground,\n $borderColor,\n $backgroundColor,\n }) => css`\n border-bottom: 1px solid ${$borderColor};\n ${$borderTop && `border-top: 1px solid ${$backgroundColor};`}\n\n ${$fullBorder &&\n css`\n border: 1px solid ${$borderColor};\n border-radius: 16px;\n `}\n\n ${$filledBackground &&\n css`\n background-color: ${$backgroundColor};\n `}\n `,\n)\n\nconst TitleContainer = styled.div`\n display: flex;\n flex-direction: column;\n`\nconst TopContainer = styled(Box)`\n cursor: pointer;\n`\n\nconst CaretIcon = styled(IconContainer)<\n TransientProps<Pick<AccordionProps, 'borderTop'>> & { $isOpen: boolean }\n>(\n ({ $isOpen }) => css`\n transform: ${$isOpen ? 'rotate(180deg)' : 'rotate(0deg)'};\n transition: transform 0.6s ease;\n `,\n)\n"]}
|
|
@@ -2,16 +2,20 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import styled, { css, useTheme } from 'styled-components';
|
|
4
4
|
import { Box } from '../Box';
|
|
5
|
-
import { Icon } from '../Icon';
|
|
6
5
|
import { Text } from '../Text';
|
|
7
6
|
import { List } from './List';
|
|
8
7
|
import { resolveToThemeColor } from '../ThemeProvider/utils/colourMap';
|
|
8
|
+
import { faChevronDown } from '@awesome.me/kit-46ca99185c/icons/classic/regular';
|
|
9
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
10
|
+
import { IconContainer } from '../sharedStyles/shared.styles';
|
|
9
11
|
export const ActionDropdown = ({ id, className = '', label, value, list, onSelect, ...marginProps }) => {
|
|
10
12
|
const [open, setOpen] = useState(false);
|
|
11
13
|
const theme = useTheme();
|
|
12
14
|
const resolvedBgColor = resolveToThemeColor(value.bgColor ?? 'color.background.100', theme);
|
|
13
15
|
const resolvedTextColor = resolveToThemeColor(value.textColor ?? 'color.text.base', theme);
|
|
14
|
-
return (_jsxs(Container, { id: id, className: className, onClick: () => setOpen((currentOpen) => !currentOpen), ...marginProps, children: [label && (_jsx(Text, { tag: "label", color: "sesame", typo: "label", children: label })), _jsxs(Label, { "$text": resolvedTextColor, "$bg": resolvedBgColor, children: [_jsx(SelectedOption, { children: value.label }), _jsx(
|
|
16
|
+
return (_jsxs(Container, { id: id, className: className, onClick: () => setOpen((currentOpen) => !currentOpen), ...marginProps, children: [label && (_jsx(Text, { tag: "label", color: "sesame", typo: "label", children: label })), _jsxs(Label, { "$text": resolvedTextColor, "$bg": resolvedBgColor, children: [_jsx(SelectedOption, { children: value.label }), _jsx(IconContainer, { "$size": 20, style: {
|
|
17
|
+
rotate: open ? '180deg' : '0deg',
|
|
18
|
+
}, children: _jsx(FontAwesomeIcon, { icon: faChevronDown, color: resolvedTextColor }) })] }), _jsx(OuterContainer, { open: open, children: _jsx(List, { options: list, selectOption: onSelect }) })] }));
|
|
15
19
|
};
|
|
16
20
|
const Label = styled.div(({ $text, $bg }) => css `
|
|
17
21
|
color: ${$text};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionDropdown.js","sourceRoot":"","sources":["../../src/ActionDropdown/ActionDropdown.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,QAAQ,EAAE,MAAM,OAAO,CAAA;AACpC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEzD,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5B,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AC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;kBAClD,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ;;;GAGvC,CACF,CAAA","sourcesContent":["import { FC, useState } from 'react'\nimport styled, { css, useTheme } from 'styled-components'\n\nimport { Box } from '../Box'\nimport { Text } from '../Text'\nimport { ActionListItem, List } from './List'\n\nimport { MarginProps } from '../utils/space'\nimport { resolveToThemeColor } from '../ThemeProvider/utils/colourMap'\nimport { faChevronDown } from '@awesome.me/kit-46ca99185c/icons/classic/regular'\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome'\nimport { IconContainer } from '../sharedStyles/shared.styles'\n\nexport type ActionDropdownProps = {\n id?: string\n className?: string\n /** label displayed above the dropdown */\n label?: string\n /** value */\n value: ActionListItem\n /** list of items for the dropdown list */\n list: ActionListItem[]\n /** onSelect handler */\n onSelect: (action: ActionListItem) => void\n} & MarginProps\n\nexport const ActionDropdown: FC<ActionDropdownProps> = ({\n id,\n className = '',\n label,\n value,\n list,\n onSelect,\n ...marginProps\n}) => {\n const [open, setOpen] = useState(false)\n\n const theme = useTheme()\n\n const resolvedBgColor = resolveToThemeColor(\n value.bgColor ?? 'color.background.100',\n theme,\n )\n const resolvedTextColor = resolveToThemeColor(\n value.textColor ?? 'color.text.base',\n theme,\n )\n\n return (\n <Container\n id={id}\n className={className}\n onClick={() => setOpen((currentOpen) => !currentOpen)}\n {...marginProps}\n >\n {label && (\n <Text tag=\"label\" color=\"sesame\" typo=\"label\">\n {label}\n </Text>\n )}\n\n <Label $text={resolvedTextColor} $bg={resolvedBgColor}>\n <SelectedOption>{value.label}</SelectedOption>\n <IconContainer\n $size={20}\n style={{\n rotate: open ? '180deg' : '0deg',\n }}\n >\n <FontAwesomeIcon icon={faChevronDown} color={resolvedTextColor} />\n </IconContainer>\n </Label>\n <OuterContainer open={open}>\n <List options={list} selectOption={onSelect} />\n </OuterContainer>\n </Container>\n )\n}\n\ninterface ISelected {\n $text: string\n $bg: string\n}\n\nconst Label = styled.div<ISelected>(\n ({ $text, $bg }) => css`\n color: ${$text};\n background-color: ${$bg};\n position: relative;\n width: 100%;\n height: 48px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n text-align: center;\n border-radius: 100px;\n padding: 16px 16px 14px;\n box-sizing: border-box;\n user-select: none;\n `,\n)\n\nconst SelectedOption = styled.span`\n font-size: 14px;\n font-weight: bold;\n white-space: nowrap;\n text-overflow: ellipsis;\n`\n\nconst Container = styled(Box)`\n position: relative;\n display: block;\n width: 210px;\n height: 48px;\n text-align: center;\n cursor: pointer;\n outline: none;\n border-radius: 8px;\n`\n\ninterface IOpen {\n open: boolean\n}\n\nconst OuterContainer = styled.div<IOpen>(\n ({ open }) => css`\n position: absolute;\n width: 100%;\n border-radius: 12px;\n margin-top: 8px;\n display: ${open ? 'block' : 'none'};\n max-height: ${open ? '235px' : '48px'};\n background-color: ${({ theme }) => theme.color.surface.base[300]};\n overflow-y: ${open ? 'auto' : 'hidden'};\n z-index: 4;\n transition: all 0.2s ease-in-out;\n `,\n)\n"]}
|
package/dist/Alert/Alert.js
CHANGED
|
@@ -3,36 +3,37 @@ import { useState } from 'react';
|
|
|
3
3
|
import styled, { css, useTheme } from 'styled-components';
|
|
4
4
|
import { resolveToThemeColor } from '../ThemeProvider/utils/colourMap';
|
|
5
5
|
import { Box } from '../Box';
|
|
6
|
-
import { IconStrict } from '../IconStrict';
|
|
7
|
-
import { Icon } from '../Icon';
|
|
8
6
|
import { Text } from '../Text';
|
|
9
7
|
import { Button } from '../Button';
|
|
10
8
|
import { Link } from '../Link';
|
|
9
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
10
|
+
import { faCircleInfo, faTriangleExclamation, faCircleExclamation, faCircleCheck, faXmark, } from '@awesome.me/kit-46ca99185c/icons/classic/regular';
|
|
11
|
+
import { IconContainer } from '../sharedStyles/shared.styles';
|
|
11
12
|
const typeConfig = {
|
|
12
13
|
info: {
|
|
13
14
|
backgroundColor: 'color.feedback.informative.100',
|
|
14
15
|
accentColor: 'color.feedback.informative.200',
|
|
15
|
-
icon:
|
|
16
|
+
icon: faCircleInfo,
|
|
16
17
|
},
|
|
17
18
|
fallback: {
|
|
18
19
|
backgroundColor: 'color.surface.base.100',
|
|
19
20
|
accentColor: 'color.surface.base.400',
|
|
20
|
-
icon:
|
|
21
|
+
icon: faCircleInfo,
|
|
21
22
|
},
|
|
22
23
|
notice: {
|
|
23
24
|
backgroundColor: 'color.feedback.notice.100',
|
|
24
25
|
accentColor: 'color.feedback.notice.200',
|
|
25
|
-
icon:
|
|
26
|
+
icon: faTriangleExclamation,
|
|
26
27
|
},
|
|
27
28
|
negative: {
|
|
28
29
|
backgroundColor: 'color.feedback.negative.100',
|
|
29
30
|
accentColor: 'color.feedback.negative.200',
|
|
30
|
-
icon:
|
|
31
|
+
icon: faCircleExclamation,
|
|
31
32
|
},
|
|
32
33
|
positive: {
|
|
33
34
|
backgroundColor: 'color.feedback.positive.100',
|
|
34
35
|
accentColor: 'color.feedback.positive.200',
|
|
35
|
-
icon:
|
|
36
|
+
icon: faCircleCheck,
|
|
36
37
|
},
|
|
37
38
|
};
|
|
38
39
|
export const Alert = ({ type = 'info', title, message, isDismissible = false, ctaType, ctaAction, ctaLabel, maxWidth = '512px', ...marginProps }) => {
|
|
@@ -40,7 +41,7 @@ export const Alert = ({ type = 'info', title, message, isDismissible = false, ct
|
|
|
40
41
|
const backgroundColor = resolveToThemeColor(typeConfig[type].backgroundColor, theme);
|
|
41
42
|
const accentColor = resolveToThemeColor(typeConfig[type].accentColor, theme);
|
|
42
43
|
const [alertClosed, setAlertClosed] = useState(false);
|
|
43
|
-
return (_jsxs(StyledAlert, { "$backgroundColor": backgroundColor, "$accentColor": accentColor, "$alertClosed": alertClosed, "$maxWidth": maxWidth, ...marginProps, children: [_jsx(
|
|
44
|
+
return (_jsxs(StyledAlert, { "$backgroundColor": backgroundColor, "$accentColor": accentColor, "$alertClosed": alertClosed, "$maxWidth": maxWidth, ...marginProps, children: [_jsx(IconContainer, { "$size": 16, style: { margin: '2px' }, children: _jsx(FontAwesomeIcon, { icon: typeConfig[type].icon, color: theme.color.icon.base }) }), _jsxs(Box, { flex: true, direction: "row", justifyContent: "space-between", alignItems: "flex-start", width: "100%", gap: "8px", children: [_jsxs(Box, { maxWidth: "512px", children: [title && (_jsx(Text, { mb: { custom: '4px' }, typo: "headline-regular", children: title })), typeof message === 'string' ? (_jsx(Text, { typo: "body-small", mb: ctaType && '8px', children: message })) : (message), ctaType === 'button' && typeof ctaAction === 'function' && (_jsx(Button, { smallButton: true, fallbackStyle: true, onClick: () => ctaAction(), children: ctaLabel })), ctaType === 'link' && typeof ctaAction === 'string' && (_jsx(Link, { href: ctaAction, children: ctaLabel }))] }), isDismissible && (_jsx(IconContainer, { as: "button", type: "button", title: "icon-button", "$size": 16, style: { cursor: 'pointer' }, onClick: () => setAlertClosed(true), children: _jsx(FontAwesomeIcon, { icon: faXmark, color: theme.color.icon.base }) }))] })] }));
|
|
44
45
|
};
|
|
45
46
|
const StyledAlert = styled(Box)(({ $backgroundColor, $accentColor, $alertClosed, $maxWidth }) => css `
|
|
46
47
|
display: flex;
|
package/dist/Alert/Alert.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.js","sourceRoot":"","sources":["../../src/Alert/Alert.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAoB,QAAQ,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAGzD,OAAO,EAAY,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AAEhF,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Alert.js","sourceRoot":"","sources":["../../src/Alert/Alert.tsx"],"names":[],"mappings":";AAAA,OAAO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EACA,OAAO,KAAK,QAAQ,IAAI,OAAO,SAAS,KAAK,UAAU,IAAI,CAC1D,KAAC,MAAM,IAAC,WAAW,QAAC,aAAa,QAAC,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,YACzD,QAAQ,GACF,CACV,EACA,OAAO,KAAK,MAAM,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,CACtD,KAAC,IAAI,IAAC,IAAI,EAAE,SAAS,YAAG,QAAQ,GAAQ,CACzC,IACG,EACL,aAAa,IAAI,CAChB,KAAC,aAAa,IACZ,EAAE,EAAC,QAAQ,EACX,IAAI,EAAC,QAAQ,EACb,KAAK,EAAC,aAAa,WACZ,EAAE,EACT,KAAK,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,EAC5B,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,YAEnC,KAAC,eAAe,IAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAI,GAClD,CACjB,IACG,IACM,CACf,CAAA;AACH,CAAC,CAAA;AASD,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,CAC7B,CAAC,EAAE,gBAAgB,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,GAAG,CAAA;;;iBAGrD,SAAS;;;;;;kBAMR,gBAAgB;;eAEnB,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;;;;;;oBAMzB,YAAY;;;;;;GAM7B,CACF,CAAA","sourcesContent":["import { FC, ReactElement, useState } from 'react'\nimport styled, { css, useTheme } from 'styled-components'\n\nimport { MarginProps } from 'utils/space'\nimport { NewColor, resolveToThemeColor } from '../ThemeProvider/utils/colourMap'\n\nimport { Box } from '../Box'\nimport { Text } from '../Text'\nimport { Button } from '../Button'\nimport { Link } from '../Link'\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome'\nimport {\n faCircleInfo,\n faTriangleExclamation,\n faCircleExclamation,\n faCircleCheck,\n faXmark,\n} from '@awesome.me/kit-46ca99185c/icons/classic/regular'\n\nimport { IconDefinition } from '@fortawesome/fontawesome-svg-core'\nimport { IconContainer } from '../sharedStyles/shared.styles'\n\ntype AlertType = 'info' | 'fallback' | 'notice' | 'negative' | 'positive'\n\ntype CtaProps =\n | {\n ctaType: 'button'\n ctaAction: () => void\n ctaLabel: string\n }\n | {\n ctaType: 'link'\n ctaAction: string\n ctaLabel: string\n }\n | {\n ctaType?: undefined\n ctaAction?: undefined\n ctaLabel?: undefined\n }\n\ntype AlertProps = {\n type?: AlertType\n title?: string\n message: string | ReactElement<unknown>\n isDismissible?: boolean\n maxWidth?: string\n} & CtaProps &\n MarginProps\n\ntype AlertTypeConfig = {\n backgroundColor: NewColor\n accentColor: NewColor\n icon: IconDefinition\n}\n\nconst typeConfig: Record<AlertType, AlertTypeConfig> = {\n info: {\n backgroundColor: 'color.feedback.informative.100',\n accentColor: 'color.feedback.informative.200',\n icon: faCircleInfo,\n },\n fallback: {\n backgroundColor: 'color.surface.base.100',\n accentColor: 'color.surface.base.400',\n icon: faCircleInfo,\n },\n notice: {\n backgroundColor: 'color.feedback.notice.100',\n accentColor: 'color.feedback.notice.200',\n icon: faTriangleExclamation,\n },\n negative: {\n backgroundColor: 'color.feedback.negative.100',\n accentColor: 'color.feedback.negative.200',\n icon: faCircleExclamation,\n },\n positive: {\n backgroundColor: 'color.feedback.positive.100',\n accentColor: 'color.feedback.positive.200',\n icon: faCircleCheck,\n },\n}\n\nexport const Alert: FC<AlertProps> = ({\n type = 'info',\n title,\n message,\n isDismissible = false,\n ctaType,\n ctaAction,\n ctaLabel,\n maxWidth = '512px',\n ...marginProps\n}) => {\n const theme = useTheme()\n\n const backgroundColor = resolveToThemeColor(\n typeConfig[type].backgroundColor,\n theme,\n )\n const accentColor = resolveToThemeColor(typeConfig[type].accentColor, theme)\n const [alertClosed, setAlertClosed] = useState(false)\n\n return (\n <StyledAlert\n $backgroundColor={backgroundColor}\n $accentColor={accentColor}\n $alertClosed={alertClosed}\n $maxWidth={maxWidth}\n {...marginProps}\n >\n <IconContainer $size={16} style={{ margin: '2px' }}>\n <FontAwesomeIcon\n icon={typeConfig[type].icon}\n color={theme.color.icon.base}\n />\n </IconContainer>\n <Box\n flex\n direction=\"row\"\n justifyContent=\"space-between\"\n alignItems=\"flex-start\"\n width=\"100%\"\n gap=\"8px\"\n >\n <Box maxWidth=\"512px\">\n {title && (\n <Text mb={{ custom: '4px' }} typo=\"headline-regular\">\n {title}\n </Text>\n )}\n {typeof message === 'string' ? (\n <Text typo=\"body-small\" mb={ctaType && '8px'}>\n {message}\n </Text>\n ) : (\n message\n )}\n {ctaType === 'button' && typeof ctaAction === 'function' && (\n <Button smallButton fallbackStyle onClick={() => ctaAction()}>\n {ctaLabel}\n </Button>\n )}\n {ctaType === 'link' && typeof ctaAction === 'string' && (\n <Link href={ctaAction}>{ctaLabel}</Link>\n )}\n </Box>\n {isDismissible && (\n <IconContainer\n as=\"button\"\n type=\"button\"\n title=\"icon-button\"\n $size={16}\n style={{ cursor: 'pointer' }}\n onClick={() => setAlertClosed(true)}\n >\n <FontAwesomeIcon icon={faXmark} color={theme.color.icon.base} />\n </IconContainer>\n )}\n </Box>\n </StyledAlert>\n )\n}\n\ninterface IStyledAlert {\n $backgroundColor: string\n $accentColor: string\n $alertClosed: boolean\n $maxWidth?: string\n}\n\nconst StyledAlert = styled(Box)<IStyledAlert>(\n ({ $backgroundColor, $accentColor, $alertClosed, $maxWidth }) => css`\n display: flex;\n width: 100%;\n max-width: ${$maxWidth};\n min-width: min-content;\n padding: 12px 12px 12px 20px;\n align-items: flex-start;\n gap: 8px;\n border-radius: 8px 16px 16px 8px;\n background: ${$backgroundColor};\n position: relative;\n display: ${$alertClosed ? 'none' : 'flex'};\n\n &:before {\n width: 8px;\n height: 100%;\n position: absolute;\n background: ${$accentColor};\n content: '';\n top: 0;\n left: 0;\n border-radius: 16px 0 0 16px;\n }\n `,\n)\n"]}
|
|
@@ -4,7 +4,11 @@ import { Box } from '../Box';
|
|
|
4
4
|
import { Icon } from '../Icon';
|
|
5
5
|
import { Text } from '../Text';
|
|
6
6
|
import { useTimeout } from '../hooks';
|
|
7
|
-
|
|
7
|
+
import { resolveToThemeColor } from '../ThemeProvider/utils/colourMap';
|
|
8
|
+
import { IconContainer } from '../sharedStyles/shared.styles';
|
|
9
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
10
|
+
import { faArrowRight, faXmark, } from '@awesome.me/kit-46ca99185c/icons/classic/regular';
|
|
11
|
+
export const BannerItem = ({ type, autoCloseTime = 4, id, message, topOffset, exploreAction, showExploreText, showExploreIcon, leadingIcon, iconComponent, canManuallyClose, showCloseIcon, deleteBanner, noTimeout, }) => {
|
|
8
12
|
const theme = useTheme();
|
|
9
13
|
const styles = {
|
|
10
14
|
upsell: {
|
|
@@ -40,7 +44,9 @@ export const BannerItem = ({ type, autoCloseTime = 4, id, message, topOffset, ex
|
|
|
40
44
|
useTimeout(() => autoCloseBaner(), autoCloseTime * 1000);
|
|
41
45
|
const textColor = styles[type].textColor;
|
|
42
46
|
const iconColor = styles[type].iconColor;
|
|
43
|
-
|
|
47
|
+
const resolvedIconColor = resolveToThemeColor(iconColor, theme);
|
|
48
|
+
const iconToRender = iconComponent ? (_jsx(IconContainer, { "$size": 24, "$iconColor": resolvedIconColor, style: { marginRight: '12px' }, children: iconComponent })) : leadingIcon ? (_jsx(Icon, { mr: "12px", render: leadingIcon, size: 24, color: iconColor })) : null;
|
|
49
|
+
return (_jsxs(BannerWrapper, { p: "24px", mt: { custom: topOffset }, flex: true, justifyContent: "space-between", "$backgroundColour": styles[type].backgroundColor, children: [_jsxs(Box, { flex: true, alignItems: "center", children: [iconToRender, _jsx(Text, { typo: "headline-small", color: textColor, children: message })] }), _jsxs(Box, { flex: true, alignItems: "center", children: [canManuallyClose && (_jsx(GenericButton, { onClick: () => deleteBanner(id), "aria-label": `close banner ${message}`, children: showCloseIcon ? (_jsx(IconContainer, { "$size": 16, children: _jsx(FontAwesomeIcon, { icon: faXmark, color: resolveToThemeColor(iconColor, theme) }) })) : (_jsx(UnderlinedText, { tag: "span", typo: "headline-small", color: textColor, children: "Dismiss" })) })), exploreAction && (_jsx(GenericButton, { onClick: exploreAction, "aria-label": `cta ${message}`, children: _jsxs(Box, { flex: true, alignItems: "center", children: [showExploreText && (_jsx(UnderlinedText, { ml: "12px", tag: "span", typo: "headline-small", color: textColor, children: "Explore" })), showExploreIcon && (_jsx(IconContainer, { "$size": 24, style: { marginLeft: '12px' }, children: _jsx(FontAwesomeIcon, { color: resolvedIconColor, icon: faArrowRight }) }))] }) }))] })] }, id));
|
|
44
50
|
};
|
|
45
51
|
const BannerWrapper = styled(Box)(({ $backgroundColour }) => css `
|
|
46
52
|
border-radius: 0px 0px 16px 16px;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BannerItem.js","sourceRoot":"","sources":["../../src/Banner/BannerItem.tsx"],"names":[],"mappings":";AACA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACzD,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"BannerItem.js","sourceRoot":"","sources":["../../src/Banner/BannerItem.tsx"],"names":[],"mappings":";AACA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACzD,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,SA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{ FC } from 'react'\nimport styled, { css, useTheme } from 'styled-components'\nimport { Box } from '../Box'\nimport { Icon } from '../Icon'\nimport { Text } from '../Text'\nimport { useTimeout } from '../hooks'\nimport { Banner } from './types'\nimport { NewColor, resolveToThemeColor } from '../ThemeProvider/utils/colourMap'\nimport { IconContainer } from '../sharedStyles/shared.styles'\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome'\nimport {\n faArrowRight,\n faXmark,\n} from '@awesome.me/kit-46ca99185c/icons/classic/regular'\n\ntype StylesItem = {\n iconColor: NewColor\n backgroundColor: string\n textColor: NewColor\n}\n\ntype BannerType = 'upsell' | 'critical' | 'general' | 'success'\n\ninterface Props extends Banner {\n deleteBanner: (id: string) => void\n}\n\nexport const BannerItem: FC<Props> = ({\n type,\n autoCloseTime = 4,\n id,\n message,\n topOffset,\n exploreAction,\n showExploreText,\n showExploreIcon,\n leadingIcon,\n iconComponent,\n canManuallyClose,\n showCloseIcon,\n deleteBanner,\n noTimeout,\n}) => {\n const theme = useTheme()\n\n const styles: Record<BannerType, StylesItem> = {\n upsell: {\n iconColor: 'color.icon.base',\n backgroundColor: theme.color.surface.brand[300],\n textColor: 'color.text.base',\n },\n critical: {\n iconColor: 'color.icon.inverse',\n backgroundColor: theme.color.feedback.negative[200],\n textColor: 'color.text.inverse',\n },\n general: {\n iconColor: 'color.icon.inverse',\n backgroundColor: theme.color.surface.base[900],\n textColor: 'color.text.inverse',\n },\n success: {\n iconColor: 'color.icon.inverse',\n backgroundColor: theme.color.feedback.positive[200],\n textColor: 'color.text.inverse',\n },\n }\n const autoCloseBaner = () => {\n if (noTimeout) return\n if (type !== 'critical') return deleteBanner(id)\n else {\n return\n }\n }\n useTimeout(() => autoCloseBaner(), autoCloseTime * 1000)\n\n const textColor = styles[type].textColor\n const iconColor = styles[type].iconColor\n const resolvedIconColor = resolveToThemeColor(iconColor, theme)\n\n const iconToRender = iconComponent ? (\n <IconContainer\n $size={24}\n $iconColor={resolvedIconColor}\n style={{ marginRight: '12px' }}\n >\n {iconComponent}\n </IconContainer>\n ) : leadingIcon ? (\n <Icon mr=\"12px\" render={leadingIcon} size={24} color={iconColor} />\n ) : null\n\n return (\n <BannerWrapper\n p=\"24px\"\n mt={{ custom: topOffset }}\n key={id}\n flex\n justifyContent=\"space-between\"\n $backgroundColour={styles[type].backgroundColor}\n >\n <Box flex alignItems=\"center\">\n {iconToRender}\n <Text typo=\"headline-small\" color={textColor}>\n {message}\n </Text>\n </Box>\n <Box flex alignItems=\"center\">\n {canManuallyClose && (\n <GenericButton\n onClick={() => deleteBanner(id)}\n aria-label={`close banner ${message}`}\n >\n {showCloseIcon ? (\n <IconContainer $size={16}>\n <FontAwesomeIcon\n icon={faXmark}\n color={resolveToThemeColor(iconColor, theme)}\n />\n </IconContainer>\n ) : (\n <UnderlinedText\n tag=\"span\"\n typo=\"headline-small\"\n color={textColor}\n >\n Dismiss\n </UnderlinedText>\n )}\n </GenericButton>\n )}\n {exploreAction && (\n <GenericButton onClick={exploreAction} aria-label={`cta ${message}`}>\n <Box flex alignItems=\"center\">\n {showExploreText && (\n <UnderlinedText\n ml=\"12px\"\n tag=\"span\"\n typo=\"headline-small\"\n color={textColor}\n >\n Explore\n </UnderlinedText>\n )}\n {showExploreIcon && (\n <IconContainer $size={24} style={{ marginLeft: '12px' }}>\n <FontAwesomeIcon\n color={resolvedIconColor}\n icon={faArrowRight}\n />\n </IconContainer>\n )}\n </Box>\n </GenericButton>\n )}\n </Box>\n </BannerWrapper>\n )\n}\n\nconst BannerWrapper = styled(Box)<{ $backgroundColour: string }>(\n ({ $backgroundColour }) => css`\n border-radius: 0px 0px 16px 16px;\n background-color: ${$backgroundColour};\n `,\n)\n\nconst GenericButton = styled.button`\n cursor: pointer;\n`\n\nconst UnderlinedText = styled(Text)`\n text-decoration: underline;\n`\n"]}
|
package/dist/Banner/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Icons } from '
|
|
1
|
+
import { Icons } from 'Icon';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
2
3
|
export interface Banner {
|
|
3
4
|
id: string;
|
|
4
5
|
message: string;
|
|
@@ -9,6 +10,7 @@ export interface Banner {
|
|
|
9
10
|
showExploreIcon?: boolean;
|
|
10
11
|
autoCloseTime?: 4 | 5 | 6 | 7 | 8 | 9 | 10;
|
|
11
12
|
leadingIcon?: Icons;
|
|
13
|
+
iconComponent?: ReactNode;
|
|
12
14
|
canManuallyClose?: boolean;
|
|
13
15
|
showCloseIcon?: boolean;
|
|
14
16
|
noTimeout?: boolean;
|
package/dist/Banner/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/Banner/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Icons } from '
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/Banner/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Icons } from 'Icon'\nimport { ReactNode } from 'react'\n\nexport interface Banner {\n id: string\n message: string\n type: 'upsell' | 'critical' | 'general' | 'success'\n topOffset: string\n exploreAction?: () => void\n showExploreText?: boolean\n showExploreIcon?: boolean\n autoCloseTime?: 4 | 5 | 6 | 7 | 8 | 9 | 10\n leadingIcon?: Icons\n iconComponent?: ReactNode\n canManuallyClose?: boolean\n showCloseIcon?: boolean\n noTimeout?: boolean\n}\n\nexport type CreateBanner = Omit<Banner, 'id'>\n\nexport interface BannerContextType {\n addBanner: (banner: CreateBanner) => void\n}\n"]}
|
package/dist/Box/index.d.ts
CHANGED
package/dist/Box/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Box/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA","sourcesContent":["export { Box } from './Box'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Box/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA","sourcesContent":["export { Box } from './Box'\nexport type { BoxProps } from './Box'\n"]}
|
package/dist/Button/Button.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ButtonHTMLAttributes, FC, FormEvent, ReactNode } from 'react';
|
|
2
|
-
import { Icons } from '../Icon
|
|
2
|
+
import { Icons } from '../Icon';
|
|
3
3
|
import { MarginProps } from '../utils/space';
|
|
4
4
|
type Props = {
|
|
5
5
|
children: ReactNode;
|
|
@@ -14,6 +14,7 @@ type Props = {
|
|
|
14
14
|
textBtn?: boolean;
|
|
15
15
|
smallButton?: boolean;
|
|
16
16
|
icon?: Icons;
|
|
17
|
+
iconComponent?: ReactNode;
|
|
17
18
|
trailingIcon?: boolean;
|
|
18
19
|
forcedWidth?: string;
|
|
19
20
|
form?: string;
|
package/dist/Button/Button.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, } from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
|
+
import { IconContainer as CommonIconContainer } from '../sharedStyles/shared.styles';
|
|
4
5
|
import { Box } from '../Box';
|
|
5
6
|
import { Icon as IconComponent } from '../Icon';
|
|
6
7
|
import { Loader } from '../Loader';
|
|
7
8
|
import { focusOutlineStyle } from '../utils/focusOutline';
|
|
8
9
|
export const Button = forwardRef((props, ref) => {
|
|
9
|
-
const { children, id, className = '', disabled = false, handleClick, loading = false, primary = false, secondary = false, fallbackStyle = false, textBtn = false, smallButton = false, icon, trailingIcon = false, forcedWidth = '', form, type, ...otherProps } = props;
|
|
10
|
-
|
|
10
|
+
const { children, id, className = '', disabled = false, handleClick, loading = false, primary = false, secondary = false, fallbackStyle = false, textBtn = false, smallButton = false, icon, iconComponent, trailingIcon = false, forcedWidth = '', form, type, ...otherProps } = props;
|
|
11
|
+
const iconToRender = iconComponent ? (_jsx(CommonIconContainer, { "$size": smallButton ? 16 : 24, children: iconComponent })) : icon ? (_jsx(IconContainer, { "$trailingIcon": trailingIcon, render: icon, size: smallButton ? 16 : 24, color: "color.icon.base" })) : null;
|
|
12
|
+
return (_jsxs(Container, { forwardedAs: "button", id: id, className: className, disabled: disabled || loading, onClick: handleClick, "$loading": loading, "$primary": primary, "$secondary": secondary, "$fallbackStyle": fallbackStyle, "$textBtn": textBtn, "$smallButton": smallButton, "$trailingIcon": trailingIcon, "$forcedWidth": forcedWidth, ...(form ? { form } : {}), type: type, ...otherProps, ref: ref, children: [loading && (_jsx(LoaderContainer, { children: _jsx(Loader, { color: "color.icon.base", height: "16" }) })), _jsxs(ContentContainer, { "$hasIcon": !!iconToRender, "$loading": loading, children: [!trailingIcon && iconToRender ? iconToRender : null, _jsx(ChildrenContainer, { className: "childrenContainer", children: children }), trailingIcon && iconToRender && textBtn ? iconToRender : null] })] }));
|
|
11
13
|
});
|
|
12
14
|
Button.displayName = 'Button';
|
|
13
15
|
const Container = styled(Box)(({ disabled, $loading, $primary, $secondary, $forcedWidth, $fallbackStyle, $textBtn, $smallButton, }) => css `
|
|
@@ -102,7 +104,7 @@ const LoaderContainer = styled.div `
|
|
|
102
104
|
const ContentContainer = styled.div `
|
|
103
105
|
display: flex;
|
|
104
106
|
align-items: center;
|
|
105
|
-
justify-content: ${({ $
|
|
107
|
+
justify-content: ${({ $hasIcon }) => ($hasIcon ? 'space-evenly' : 'center')};
|
|
106
108
|
opacity: ${({ $loading }) => ($loading ? '0' : '1')};
|
|
107
109
|
`;
|
|
108
110
|
const IconContainer = styled(IconComponent)(({ $trailingIcon }) => css `
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../src/Button/Button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAKL,UAAU,GACX,MAAM,OAAO,CAAA;AACd,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,C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;;;;;4BAOqB,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAChC,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK;;;;iBAIzD,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM;;KAElD;GACF,CACF,CAAA;AAED,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;CASjC,CAAA;AAED,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAsC;;;qBAGpD,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC;aAC1D,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;CACpD,CAAA;AAED,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC,CAGzC,CAAC,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,GAAG,CAAA;cACd,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY;GACtD,CACF,CAAA;AAED,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAA;;;CAGnC,CAAA","sourcesContent":["import {\n ButtonHTMLAttributes,\n FC,\n FormEvent,\n ReactNode,\n forwardRef,\n} from 'react'\nimport styled, { css } from 'styled-components'\n\nimport { TransientProps } from 'utils/utilTypes'\nimport { Box } from '../Box'\nimport { Icon as IconComponent } from '../Icon'\nimport { Icons } from '../Icon/iconsList'\n\nimport { Loader } from '../Loader'\nimport { focusOutlineStyle } from '../utils/focusOutline'\nimport { MarginProps } from '../utils/space'\n\ntype Props = {\n children: ReactNode\n id?: string\n className?: string\n disabled?: boolean\n handleClick?: (e: FormEvent<HTMLButtonElement>) => void\n loading?: boolean\n primary?: boolean\n secondary?: boolean\n fallbackStyle?: boolean\n textBtn?: boolean\n smallButton?: boolean\n icon?: Icons\n trailingIcon?: boolean\n forcedWidth?: string\n form?: string\n}\n\nexport type ButtonProps = Props &\n MarginProps &\n Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'color'>\n\nexport const Button: FC<ButtonProps> = forwardRef<\n HTMLButtonElement,\n ButtonProps\n>((props, ref) => {\n const {\n children,\n id,\n className = '',\n disabled = false,\n handleClick,\n loading = false,\n primary = false,\n secondary = false,\n fallbackStyle = false,\n textBtn = false,\n smallButton = false,\n icon,\n trailingIcon = false,\n forcedWidth = '',\n form,\n type,\n ...otherProps\n } = props\n\n return (\n <Container\n forwardedAs=\"button\"\n id={id}\n className={className}\n disabled={disabled || loading}\n onClick={handleClick}\n $loading={loading}\n $primary={primary}\n $secondary={secondary}\n $fallbackStyle={fallbackStyle}\n $textBtn={textBtn}\n $smallButton={smallButton}\n $trailingIcon={trailingIcon}\n $forcedWidth={forcedWidth}\n {...(form ? { form } : {})}\n type={type}\n {...otherProps}\n ref={ref}\n >\n {loading && (\n <LoaderContainer>\n <Loader color=\"color.icon.base\" height=\"16\" />\n </LoaderContainer>\n )}\n <ContentContainer $icon={icon} $loading={loading}>\n {!trailingIcon && icon && (\n <IconContainer\n $trailingIcon={trailingIcon}\n render={icon}\n size={smallButton ? 16 : 24}\n color=\"color.icon.base\"\n />\n )}\n <ChildrenContainer className=\"childrenContainer\">\n {children}\n </ChildrenContainer>\n {trailingIcon && icon && textBtn && (\n <IconContainer\n $trailingIcon={trailingIcon}\n render={icon}\n size={smallButton ? 16 : 24}\n color=\"color.icon.base\"\n className=\"iconContainer\"\n />\n )}\n </ContentContainer>\n </Container>\n )\n})\n\nButton.displayName = 'Button'\n\ntype IButton = TransientProps<\n Required<\n Pick<\n ButtonProps,\n | 'primary'\n | 'secondary'\n | 'forcedWidth'\n | 'fallbackStyle'\n | 'textBtn'\n | 'trailingIcon'\n | 'smallButton'\n >\n >\n> & {\n $loading: NonNullable<ButtonProps['loading']>\n disabled: boolean\n}\n\nconst Container = styled(Box)<IButton>(\n ({\n disabled,\n $loading,\n $primary,\n $secondary,\n $forcedWidth,\n $fallbackStyle,\n $textBtn,\n $smallButton,\n }) => css`\n position: relative;\n background-color: ${({ theme }) => theme.color.interactive.primary.base};\n box-shadow: none;\n color: ${({ theme }) => theme.color.text.base};\n padding: 0 20px;\n outline: none;\n border-radius: 10000px;\n font-weight: ${({ theme }) => theme.fontWeight[500]};\n cursor: ${disabled || $loading ? 'not-allowed' : 'pointer'};\n line-height: 100%;\n font-size: 16px;\n opacity: ${disabled ? '0.5' : '1'};\n width: ${$forcedWidth ? $forcedWidth : 'auto'};\n\n ${focusOutlineStyle}\n\n ${$primary &&\n css`\n &:hover {\n background-color: ${({ theme }) =>\n !(disabled || $loading) && theme.color.interactive.primary.hover};\n }\n &:active {\n background-color: ${({ theme }) =>\n theme.color.interactive.primary.pressed};\n }\n `}\n\n ${$secondary &&\n css`\n background-color: ${({ theme }) =>\n theme.color.interactive.secondary.base};\n\n &:hover {\n background-color: ${({ theme }) =>\n !(disabled || $loading) && theme.color.interactive.secondary.hover};\n }\n &:active {\n background-color: ${({ theme }) =>\n theme.color.interactive.secondary.pressed};\n }\n `}\n ${$fallbackStyle &&\n css`\n background-color: ${({ theme }) => theme.color.interactive.tertiary.base};\n\n &:hover {\n background-color: ${({ theme }) =>\n !(disabled || $loading) && theme.color.interactive.tertiary.hover};\n }\n &:active {\n background-color: ${({ theme }) =>\n theme.color.interactive.tertiary.pressed};\n }\n `}\n ${$smallButton &&\n css`\n padding: 0 10px;\n min-width: 54px;\n font-size: 14px;\n\n .childrenContainer {\n padding: 9px 0;\n }\n\n span {\n margin: 0 5px 0 0;\n }\n `}\n ${$textBtn &&\n css`\n background-color: transparent;\n padding: 0;\n border-radius: 0;\n text-decoration: underline;\n\n &:hover {\n background-color: ${({ theme }) =>\n !(disabled || $loading) && theme.color.interactive.primary.hover};\n }\n &:active {\n background-color: transparent;\n color: ${({ theme }) => theme.color.text.subtle};\n }\n `}\n `,\n)\n\nconst LoaderContainer = styled.div`\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n`\n\nconst ContentContainer = styled.div<{ $loading: boolean; $icon?: Icons }>`\n display: flex;\n align-items: center;\n justify-content: ${({ $icon }) => ($icon ? 'space-evenly' : 'center')};\n opacity: ${({ $loading }) => ($loading ? '0' : '1')};\n`\n\nconst IconContainer = styled(IconComponent)<\n TransientProps<Pick<ButtonProps, 'trailingIcon'>>\n>(\n ({ $trailingIcon }) => css`\n margin: ${$trailingIcon ? '0 0 0 10px' : '0 10px 0 0'};\n `,\n)\n\nconst ChildrenContainer = styled.div`\n padding: 16px 0;\n flex-grow: 1;\n`\n"]}
|
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../src/Button/Button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAKL,UAAU,GACX,MAAM,OAAO,CAAA;AACd,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,aAAa,IAAI,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AAGpF,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5B,OAAO,EAAE,IAAI,IAAI,aAAa,EAAS,MAAM,SAAS,CAAA;AAEtD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AA0BzD,MAAM,CAAC,MAAM,MAAM,GAAoB,UAAU,CAG/C,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACf,MAAM,EACJ,QAAQ,EACR,EAAE,EACF,SAAS,GAAG,EAAE,EACd,QAAQ,GAAG,KAAK,EAChB,WAAW,EACX,OAAO,GAAG,KAAK,EACf,OAAO,GAAG,KAAK,E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AC,GAAG,CAAA;;;;;;;;;CASjC,CAAA;AAED,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAA2C;;;qBAGzD,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC;aAChE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;CACpD,CAAA;AAED,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC,CAGzC,CAAC,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,GAAG,CAAA;cACd,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY;GACtD,CACF,CAAA;AAED,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAA;;;CAGnC,CAAA","sourcesContent":["import {\n ButtonHTMLAttributes,\n FC,\n FormEvent,\n ReactNode,\n forwardRef,\n} from 'react'\nimport styled, { css } from 'styled-components'\nimport { IconContainer as CommonIconContainer } from '../sharedStyles/shared.styles'\n\nimport { TransientProps } from 'utils/utilTypes'\nimport { Box } from '../Box'\nimport { Icon as IconComponent, Icons } from '../Icon'\n\nimport { Loader } from '../Loader'\nimport { focusOutlineStyle } from '../utils/focusOutline'\nimport { MarginProps } from '../utils/space'\n\ntype Props = {\n children: ReactNode\n id?: string\n className?: string\n disabled?: boolean\n handleClick?: (e: FormEvent<HTMLButtonElement>) => void\n loading?: boolean\n primary?: boolean\n secondary?: boolean\n fallbackStyle?: boolean\n textBtn?: boolean\n smallButton?: boolean\n icon?: Icons\n iconComponent?: ReactNode\n trailingIcon?: boolean\n forcedWidth?: string\n form?: string\n}\n\nexport type ButtonProps = Props &\n MarginProps &\n Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'color'>\n\nexport const Button: FC<ButtonProps> = forwardRef<\n HTMLButtonElement,\n ButtonProps\n>((props, ref) => {\n const {\n children,\n id,\n className = '',\n disabled = false,\n handleClick,\n loading = false,\n primary = false,\n secondary = false,\n fallbackStyle = false,\n textBtn = false,\n smallButton = false,\n icon,\n iconComponent,\n trailingIcon = false,\n forcedWidth = '',\n form,\n type,\n ...otherProps\n } = props\n\n const iconToRender = iconComponent ? (\n <CommonIconContainer $size={smallButton ? 16 : 24}>\n {iconComponent}\n </CommonIconContainer>\n ) : icon ? (\n <IconContainer\n $trailingIcon={trailingIcon}\n render={icon}\n size={smallButton ? 16 : 24}\n color=\"color.icon.base\"\n />\n ) : null\n\n return (\n <Container\n forwardedAs=\"button\"\n id={id}\n className={className}\n disabled={disabled || loading}\n onClick={handleClick}\n $loading={loading}\n $primary={primary}\n $secondary={secondary}\n $fallbackStyle={fallbackStyle}\n $textBtn={textBtn}\n $smallButton={smallButton}\n $trailingIcon={trailingIcon}\n $forcedWidth={forcedWidth}\n {...(form ? { form } : {})}\n type={type}\n {...otherProps}\n ref={ref}\n >\n {loading && (\n <LoaderContainer>\n <Loader color=\"color.icon.base\" height=\"16\" />\n </LoaderContainer>\n )}\n <ContentContainer $hasIcon={!!iconToRender} $loading={loading}>\n {!trailingIcon && iconToRender ? iconToRender : null}\n <ChildrenContainer className=\"childrenContainer\">\n {children}\n </ChildrenContainer>\n {trailingIcon && iconToRender && textBtn ? iconToRender : null}\n </ContentContainer>\n </Container>\n )\n})\n\nButton.displayName = 'Button'\n\ntype IButton = TransientProps<\n Required<\n Pick<\n ButtonProps,\n | 'primary'\n | 'secondary'\n | 'forcedWidth'\n | 'fallbackStyle'\n | 'textBtn'\n | 'trailingIcon'\n | 'smallButton'\n >\n >\n> & {\n $loading: NonNullable<ButtonProps['loading']>\n disabled: boolean\n}\n\nconst Container = styled(Box)<IButton>(\n ({\n disabled,\n $loading,\n $primary,\n $secondary,\n $forcedWidth,\n $fallbackStyle,\n $textBtn,\n $smallButton,\n }) => css`\n position: relative;\n background-color: ${({ theme }) => theme.color.interactive.primary.base};\n box-shadow: none;\n color: ${({ theme }) => theme.color.text.base};\n padding: 0 20px;\n outline: none;\n border-radius: 10000px;\n font-weight: ${({ theme }) => theme.fontWeight[500]};\n cursor: ${disabled || $loading ? 'not-allowed' : 'pointer'};\n line-height: 100%;\n font-size: 16px;\n opacity: ${disabled ? '0.5' : '1'};\n width: ${$forcedWidth ? $forcedWidth : 'auto'};\n\n ${focusOutlineStyle}\n\n ${$primary &&\n css`\n &:hover {\n background-color: ${({ theme }) =>\n !(disabled || $loading) && theme.color.interactive.primary.hover};\n }\n &:active {\n background-color: ${({ theme }) =>\n theme.color.interactive.primary.pressed};\n }\n `}\n\n ${$secondary &&\n css`\n background-color: ${({ theme }) =>\n theme.color.interactive.secondary.base};\n\n &:hover {\n background-color: ${({ theme }) =>\n !(disabled || $loading) && theme.color.interactive.secondary.hover};\n }\n &:active {\n background-color: ${({ theme }) =>\n theme.color.interactive.secondary.pressed};\n }\n `}\n ${$fallbackStyle &&\n css`\n background-color: ${({ theme }) => theme.color.interactive.tertiary.base};\n\n &:hover {\n background-color: ${({ theme }) =>\n !(disabled || $loading) && theme.color.interactive.tertiary.hover};\n }\n &:active {\n background-color: ${({ theme }) =>\n theme.color.interactive.tertiary.pressed};\n }\n `}\n ${$smallButton &&\n css`\n padding: 0 10px;\n min-width: 54px;\n font-size: 14px;\n\n .childrenContainer {\n padding: 9px 0;\n }\n\n span {\n margin: 0 5px 0 0;\n }\n `}\n ${$textBtn &&\n css`\n background-color: transparent;\n padding: 0;\n border-radius: 0;\n text-decoration: underline;\n\n &:hover {\n background-color: ${({ theme }) =>\n !(disabled || $loading) && theme.color.interactive.primary.hover};\n }\n &:active {\n background-color: transparent;\n color: ${({ theme }) => theme.color.text.subtle};\n }\n `}\n `,\n)\n\nconst LoaderContainer = styled.div`\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n`\n\nconst ContentContainer = styled.div<{ $loading: boolean; $hasIcon?: boolean }>`\n display: flex;\n align-items: center;\n justify-content: ${({ $hasIcon }) => ($hasIcon ? 'space-evenly' : 'center')};\n opacity: ${({ $loading }) => ($loading ? '0' : '1')};\n`\n\nconst IconContainer = styled(IconComponent)<\n TransientProps<Pick<ButtonProps, 'trailingIcon'>>\n>(\n ({ $trailingIcon }) => css`\n margin: ${$trailingIcon ? '0 0 0 10px' : '0 10px 0 0'};\n `,\n)\n\nconst ChildrenContainer = styled.div`\n padding: 16px 0;\n flex-grow: 1;\n`\n"]}
|
package/dist/Card/Card.d.ts
CHANGED
|
@@ -1,38 +1,24 @@
|
|
|
1
1
|
import { FC, MouseEventHandler, ReactNode } from 'react';
|
|
2
|
-
import { Icons } from '../Icon
|
|
2
|
+
import { Icons } from '../Icon';
|
|
3
3
|
import { MarginProps } from '../utils/space';
|
|
4
4
|
export type CardProps = {
|
|
5
5
|
children?: ReactNode;
|
|
6
|
-
/** leading card icon */
|
|
7
6
|
leadingIcon?: Icons;
|
|
8
|
-
|
|
7
|
+
iconComponent?: ReactNode;
|
|
9
8
|
title?: string;
|
|
10
|
-
/** generic card body */
|
|
11
9
|
body?: string;
|
|
12
|
-
/** card image */
|
|
13
10
|
visual?: string;
|
|
14
|
-
/** height of the image */
|
|
15
11
|
visualHeight?: string;
|
|
16
|
-
/** card tag */
|
|
17
12
|
tag?: ReactNode;
|
|
18
|
-
/** action for a fully clickable card */
|
|
19
13
|
cardOnClickAction?: MouseEventHandler<HTMLDivElement>;
|
|
20
|
-
/** action to the right of the card, chevron, chip or link text */
|
|
21
14
|
rightAction?: ReactNode;
|
|
22
|
-
/** primary button */
|
|
23
15
|
buttonAction?: ReactNode;
|
|
24
|
-
/** fallback color scheme */
|
|
25
16
|
fallbackStyle?: boolean;
|
|
26
17
|
className?: string;
|
|
27
|
-
/** margin */
|
|
28
18
|
maxWidth?: string;
|
|
29
|
-
/** left-right margin */
|
|
30
19
|
marginX?: string;
|
|
31
|
-
/** top-bottom margin */
|
|
32
20
|
marginY?: string;
|
|
33
|
-
/** Narrow padding */
|
|
34
21
|
narrow?: boolean;
|
|
35
|
-
/** Wide padding */
|
|
36
22
|
wide?: boolean;
|
|
37
23
|
} & MarginProps;
|
|
38
24
|
export declare const Card: FC<CardProps>;
|
package/dist/Card/Card.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { darken } from 'polished';
|
|
3
|
-
import styled, { css } from 'styled-components';
|
|
3
|
+
import styled, { css, useTheme } from 'styled-components';
|
|
4
4
|
import { Box } from '../Box';
|
|
5
5
|
import { Icon } from '../Icon';
|
|
6
6
|
import { Text } from '../Text';
|
|
7
7
|
import { focusOutlineStyle } from '../utils/focusOutline';
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
import { IconContainer } from '../sharedStyles/shared.styles';
|
|
9
|
+
export const Card = ({ children, leadingIcon, iconComponent, title, body, visual, tag, cardOnClickAction, rightAction, buttonAction, fallbackStyle = false, visualHeight = '', className = '', maxWidth = '', marginX = '', marginY = '', narrow = false, wide = false, ...otherProps }) => {
|
|
10
|
+
const theme = useTheme();
|
|
11
|
+
const addChildMargin = (!!iconComponent || !!leadingIcon || !!title || !!body) && children;
|
|
10
12
|
const isNotClickable = !cardOnClickAction;
|
|
11
|
-
|
|
13
|
+
const iconToRender = iconComponent ? (_jsx(IconContainer, { style: { marginRight: '12px' }, "$size": 24, "$iconColor": theme.color.icon.base, children: iconComponent })) : leadingIcon ? (_jsx(Icon, { mr: "12px", render: leadingIcon, size: 24, color: "color.icon.base" })) : null;
|
|
14
|
+
return (_jsxs(Container, { className: className, "$maxWidth": maxWidth, "$marginX": marginX, "$marginY": marginY, "$narrow": narrow, "$wide": wide, "$visual": visual, "$fallbackStyle": fallbackStyle, "$isNotClickable": isNotClickable, onClick: cardOnClickAction, tabIndex: isNotClickable ? undefined : 0, ...otherProps, children: [tag && visual && _jsx(TagWrapper, { children: tag }), visual && (_jsx(VisualWrapper, { "$visualHeight": visualHeight, children: _jsx(Visual, { "$visualUrl": visual, "$visualHeight": visualHeight }) })), _jsxs(Box, { p: visual ? '16px' : { custom: '0px' }, children: [_jsxs(Box, { flex: true, alignItems: "center", justifyContent: "space-between", children: [_jsxs(Box, { flex: true, alignItems: "center", children: [iconToRender, _jsxs(Box, { children: [title && (_jsx(Text, { typo: "headline-regular", color: "color.text.base", children: title })), body && (_jsx(Text, { typo: "body-regular", color: "color.text.subtle", children: body }))] })] }), rightAction && rightAction] }), _jsx(Box, { mt: addChildMargin ? '16px' : { custom: '0px' }, children: children }), buttonAction && _jsx(Box, { mt: "16px", children: buttonAction })] })] }));
|
|
12
15
|
};
|
|
13
16
|
const Container = styled(Box) `
|
|
14
17
|
background: ${({ $fallbackStyle, theme }) => $fallbackStyle
|
package/dist/Card/Card.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Card.js","sourceRoot":"","sources":["../../src/Card/Card.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"Card.js","sourceRoot":"","sources":["../../src/Card/Card.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEzD,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5B,OAAO,EAAE,IAAI,EAAS,MAAM,SAAS,CAAA;AAErC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAuB7D,MAAM,CAAC,MAAM,IAAI,GA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 'polished'\nimport { FC, MouseEventHandler, ReactNode } from 'react'\nimport styled, { css, useTheme } from 'styled-components'\nimport { TransientProps } from 'utils/utilTypes'\nimport { Box } from '../Box'\nimport { Icon, Icons } from '../Icon'\n\nimport { Text } from '../Text'\nimport { focusOutlineStyle } from '../utils/focusOutline'\nimport { MarginProps } from '../utils/space'\nimport { IconContainer } from '../sharedStyles/shared.styles'\n\nexport type CardProps = {\n children?: ReactNode\n leadingIcon?: Icons\n iconComponent?: ReactNode\n title?: string\n body?: string\n visual?: string\n visualHeight?: string\n tag?: ReactNode\n cardOnClickAction?: MouseEventHandler<HTMLDivElement>\n rightAction?: ReactNode\n buttonAction?: ReactNode\n fallbackStyle?: boolean\n className?: string\n maxWidth?: string\n marginX?: string\n marginY?: string\n narrow?: boolean\n wide?: boolean\n} & MarginProps\n\nexport const Card: FC<CardProps> = ({\n children,\n leadingIcon,\n iconComponent,\n title,\n body,\n visual,\n tag,\n cardOnClickAction,\n rightAction,\n buttonAction,\n fallbackStyle = false,\n visualHeight = '',\n className = '',\n maxWidth = '',\n marginX = '',\n marginY = '',\n narrow = false,\n wide = false,\n ...otherProps\n}) => {\n const theme = useTheme()\n const addChildMargin =\n (!!iconComponent || !!leadingIcon || !!title || !!body) && children\n\n const isNotClickable = !cardOnClickAction\n\n const iconToRender = iconComponent ? (\n <IconContainer\n style={{ marginRight: '12px' }}\n $size={24}\n $iconColor={theme.color.icon.base}\n >\n {iconComponent}\n </IconContainer>\n ) : leadingIcon ? (\n <Icon mr=\"12px\" render={leadingIcon} size={24} color=\"color.icon.base\" />\n ) : null\n\n return (\n <Container\n className={className}\n $maxWidth={maxWidth}\n $marginX={marginX}\n $marginY={marginY}\n $narrow={narrow}\n $wide={wide}\n $visual={visual}\n $fallbackStyle={fallbackStyle}\n $isNotClickable={isNotClickable}\n onClick={cardOnClickAction}\n tabIndex={isNotClickable ? undefined : 0}\n {...otherProps}\n >\n {tag && visual && <TagWrapper>{tag}</TagWrapper>}\n {visual && (\n <VisualWrapper $visualHeight={visualHeight}>\n <Visual $visualUrl={visual} $visualHeight={visualHeight} />\n </VisualWrapper>\n )}\n <Box p={visual ? '16px' : { custom: '0px' }}>\n <Box flex alignItems=\"center\" justifyContent=\"space-between\">\n <Box flex alignItems=\"center\">\n {iconToRender}\n <Box>\n {title && (\n <Text typo=\"headline-regular\" color=\"color.text.base\">\n {title}\n </Text>\n )}\n {body && (\n <Text typo=\"body-regular\" color=\"color.text.subtle\">\n {body}\n </Text>\n )}\n </Box>\n </Box>\n {rightAction && rightAction}\n </Box>\n <Box mt={addChildMargin ? '16px' : { custom: '0px' }}>{children}</Box>\n {buttonAction && <Box mt=\"16px\">{buttonAction}</Box>}\n </Box>\n </Container>\n )\n}\n\ntype ICard = TransientProps<\n Required<\n Pick<\n CardProps,\n 'maxWidth' | 'marginX' | 'marginY' | 'narrow' | 'wide' | 'fallbackStyle'\n >\n >\n> &\n Partial<TransientProps<Pick<CardProps, 'visual'>>> & {\n $isNotClickable?: boolean\n }\n\nconst Container = styled(Box)<ICard>`\n background: ${({ $fallbackStyle, theme }) =>\n $fallbackStyle\n ? theme.color.surface.base['000']\n : theme.color.surface.base[300]};\n box-sizing: border-box;\n border-radius: 16px;\n\n max-width: ${(p) => p.$maxWidth};\n margin-top: ${(p) => p.$marginY};\n margin-right: ${(p) => p.$marginX};\n margin-bottom: ${(p) => p.$marginY};\n margin-left: ${(p) => p.$marginX};\n\n padding: ${({ $visual }) => ($visual ? '0px' : '16px')};\n position: relative;\n overflow: hidden;\n\n ${({ $isNotClickable, $fallbackStyle, theme }) =>\n !$isNotClickable &&\n css`\n cursor: pointer;\n &:hover {\n background: ${darken(\n 0.1,\n $fallbackStyle\n ? theme.color.surface.base['000']\n : theme.color.surface.base[300],\n )};\n }\n\n ${focusOutlineStyle}\n `};\n`\n\nconst TagWrapper = styled(Box)`\n position: absolute;\n top: 12px;\n right: 12px;\n`\n\nconst VisualWrapper = styled(Box)<{ $visualHeight: string }>`\n width: 100%;\n margin-top: -16px;\n\n ${({ $visualHeight }) => $visualHeight && `height: ${$visualHeight};`}\n`\n\nconst Visual = styled(Box)<{ $visualUrl: string; $visualHeight: string }>`\n width: 100%;\n background-image: url('${(p) => p.$visualUrl}');\n background-size: cover;\n background-repeat: no-repeat;\n background-position: center;\n\n ${({ $visualHeight }) =>\n $visualHeight ? `height: ${$visualHeight};` : 'padding-top: 100%;'}\n`\n"]}
|
package/dist/Chip/Chip.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ButtonHTMLAttributes, FC, FormEvent, ReactNode } from 'react';
|
|
2
|
-
import { Icons } from '../Icon
|
|
2
|
+
import { Icons } from '../Icon';
|
|
3
3
|
import { MarginProps } from '../utils/space';
|
|
4
4
|
type Props = {
|
|
5
5
|
children: ReactNode;
|
|
@@ -7,6 +7,7 @@ type Props = {
|
|
|
7
7
|
primary?: boolean;
|
|
8
8
|
secondary?: boolean;
|
|
9
9
|
icon?: Icons;
|
|
10
|
+
iconComponent?: ReactNode;
|
|
10
11
|
disabled?: boolean;
|
|
11
12
|
loading?: boolean;
|
|
12
13
|
} & MarginProps;
|