@mrshmllw/smores-react 15.1.6 → 15.1.7

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.
@@ -45,8 +45,8 @@ export const BannerItem = ({ type, autoCloseTime = 4, id, message, topOffset, ex
45
45
  const textColor = styles[type].textColor;
46
46
  const iconColor = styles[type].iconColor;
47
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));
48
+ const iconToRender = iconComponent ? (_jsx(IconContainer, { "$size": 24, "$iconColor": resolvedIconColor, style: { marginRight: '12px' }, children: iconComponent })) : leadingIcon ? (_jsx(Icon, { mr: "space.150", render: leadingIcon, size: 24, color: iconColor })) : null;
49
+ return (_jsxs(BannerWrapper, { p: "space.300", 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: "space.150", 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));
50
50
  };
51
51
  const BannerWrapper = styled(Box)(({ $backgroundColour }) => css `
52
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;AAErC,OAAO,EAAY,mBAAmB,EAAE,MAA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,OAAO,EAAE,YAEpC,aAAa,CAAC,CAAC,CAAC,CACf,KAAC,aAAa,aAAQ,EAAE,YACtB,KAAC,eAAe,IACd,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,mBAAmB,CAAC,SAAS,EAAE,KAAK,CAAC,GAC5C,GACY,CACjB,CAAC,CAAC,CAAC,CACF,KAAC,cAAc,IACb,GAAG,EAAC,MAAM,EACV,IAAI,EAAC,gBAAgB,EACrB,KAAK,EAAE,SAAS,wBAGD,CAClB,GACa,CACjB,EACA,aAAa,IAAI,CAChB,KAAC,aAAa,IAAC,OAAO,EAAE,aAAa,gBAAc,OAAO,OAAO,EAAE,YACjE,MAAC,GAAG,IAAC,IAAI,QAAC,UAAU,EAAC,QAAQ,aAC1B,eAAe,IAAI,CAClB,KAAC,cAAc,IACb,EAAE,EAAC,MAAM,EACT,GAAG,EAAC,MAAM,EACV,IAAI,EAAC,gBAAgB,EACrB,KAAK,EAAE,SAAS,wBAGD,CAClB,EACA,eAAe,IAAI,CAClB,KAAC,aAAa,aAAQ,EAAE,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,YACrD,KAAC,eAAe,IACd,KAAK,EAAE,iBAAiB,EACxB,IAAI,EAAE,YAAY,GAClB,GACY,CACjB,IACG,GACQ,CACjB,IACG,KA3DD,EAAE,CA4DO,CACjB,CAAA;AACH,CAAC,CAAA;AAED,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,CAC/B,CAAC,EAAE,iBAAiB,EAAE,EAAE,EAAE,CAAC,GAAG,CAAA;;wBAER,iBAAiB;GACtC,CACF,CAAA;AAED,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAA;;CAElC,CAAA;AAED,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;CAElC,CAAA","sourcesContent":["import { 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"]}
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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;CAElC,CAAA;AAED,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;CAElC,CAAA","sourcesContent":["import { 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=\"space.150\" render={leadingIcon} size={24} color={iconColor} />\n ) : null\n\n return (\n <BannerWrapper\n p=\"space.300\"\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=\"space.150\"\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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrshmllw/smores-react",
3
- "version": "15.1.6",
3
+ "version": "15.1.7",
4
4
  "description": "Collection of React components used by Marshmallow Technology",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",