@helsenorge/designsystem-react 10.1.0 → 10.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/AnchorLink.js +2 -2
- package/AnchorLink.js.map +1 -1
- package/Avatar.js +2 -2
- package/Avatar.js.map +1 -1
- package/Badge.js +3 -3
- package/Badge.js.map +1 -1
- package/Button.js +4 -4
- package/Button.js.map +1 -1
- package/CHANGELOG.md +1392 -801
- package/Checkbox.js +2 -2
- package/Checkbox.js.map +1 -1
- package/Close.js +2 -2
- package/Close.js.map +1 -1
- package/ErrorBoundary.js +2 -2
- package/ErrorBoundary.js.map +1 -1
- package/FormGroup.js +12 -12
- package/FormGroup.js.map +1 -1
- package/FormLayout.js +3 -3
- package/FormLayout.js.map +1 -1
- package/HelpBubble.js +2 -2
- package/HelpBubble.js.map +1 -1
- package/HighlightPanel.js +2 -2
- package/HighlightPanel.js.map +1 -1
- package/Icon.js +3 -3
- package/Icon.js.map +1 -1
- package/Illustration.js +3 -3
- package/Illustration.js.map +1 -1
- package/Input.js +2 -2
- package/Input.js.map +1 -1
- package/Label.js +8 -8
- package/Label.js.map +1 -1
- package/LazyIcon.js +1 -1
- package/LazyIllustration.js +3 -3
- package/LazyIllustration.js.map +1 -1
- package/LinkList.js +6 -6
- package/LinkList.js.map +1 -1
- package/ListHeader.js +7 -7
- package/ListHeader.js.map +1 -1
- package/Panel.js +2 -2
- package/Panel.js.map +1 -1
- package/PopOver.js +2 -2
- package/PopOver.js.map +1 -1
- package/RadioButton.js +2 -2
- package/RadioButton.js.map +1 -1
- package/Select.js +2 -2
- package/Select.js.map +1 -1
- package/Slider.js +3 -3
- package/Slider.js.map +1 -1
- package/Spacer.js +2 -2
- package/Spacer.js.map +1 -1
- package/StatusDot.js +1 -1
- package/StepButtons.js +4 -4
- package/StepButtons.js.map +1 -1
- package/TabList.js +4 -4
- package/TabList.js.map +1 -1
- package/Table.js +2 -2
- package/Table.js.map +1 -1
- package/TableBody.js +2 -2
- package/TableBody.js.map +1 -1
- package/TableExpandedRow.js +2 -2
- package/TableExpandedRow.js.map +1 -1
- package/TableHead.js +2 -2
- package/TableHead.js.map +1 -1
- package/TableRow.js +2 -2
- package/TableRow.js.map +1 -1
- package/Textarea.js +2 -2
- package/Textarea.js.map +1 -1
- package/Title.js +2 -2
- package/Title.js.map +1 -1
- package/TooltipWord.js +2 -2
- package/TooltipWord.js.map +1 -1
- package/Trigger.js +3 -3
- package/Trigger.js.map +1 -1
- package/components/AnchorLink/styles.module.scss +8 -9
- package/components/Avatar/styles.module.scss +9 -9
- package/components/Badge/styles.module.scss +9 -9
- package/components/Button/styles.module.scss +68 -57
- package/components/Checkbox/styles.module.scss +103 -103
- package/components/Chip/styles.module.scss +22 -22
- package/components/Close/styles.module.scss +4 -4
- package/components/DictionaryTrigger/index.js +2 -2
- package/components/DictionaryTrigger/index.js.map +1 -1
- package/components/DictionaryTrigger/styles.module.scss +5 -5
- package/components/Drawer/Drawer.d.ts +41 -0
- package/components/Drawer/Drawer.test.d.ts +1 -0
- package/components/Drawer/index.d.ts +3 -0
- package/components/Drawer/index.js +350 -0
- package/components/Drawer/index.js.map +1 -0
- package/components/Drawer/styles.module.scss +127 -0
- package/components/Drawer/styles.module.scss.d.ts +16 -0
- package/components/Dropdown/index.js +3 -3
- package/components/Dropdown/index.js.map +1 -1
- package/components/Dropdown/styles.module.scss +51 -51
- package/components/Duolist/index.js +6 -5
- package/components/Duolist/index.js.map +1 -1
- package/components/Duolist/styles.module.scss +57 -35
- package/components/Duolist/styles.module.scss.d.ts +1 -0
- package/components/EmptyState/styles.module.scss +12 -12
- package/components/ErrorWrapper/styles.module.scss +11 -21
- package/components/ErrorWrapper/styles.module.scss.d.ts +0 -1
- package/components/Expander/styles.module.scss +46 -46
- package/components/ExpanderHierarchy/expander.module.scss +29 -29
- package/components/ExpanderHierarchy/index.js +5 -5
- package/components/ExpanderHierarchy/index.js.map +1 -1
- package/components/ExpanderHierarchy/styles.module.scss +4 -5
- package/components/ExpanderList/index.js +8 -8
- package/components/ExpanderList/index.js.map +1 -1
- package/components/ExpanderList/styles.module.scss +30 -30
- package/components/EyebrowHeader/styles.module.scss +0 -2
- package/components/FormGroup/styles.module.scss +9 -9
- package/components/FormLayout/styles.module.scss +4 -5
- package/components/HelpBubble/styles.module.scss +13 -13
- package/components/HelpPanel/styles.module.scss +2 -2
- package/components/HelpQuestion/index.js +2 -2
- package/components/HelpQuestion/index.js.map +1 -1
- package/components/HelpQuestion/styles.module.scss +19 -19
- package/components/HighlightPanel/styles.module.scss +22 -54
- package/components/HighlightPanel/styles.module.scss.d.ts +1 -2
- package/components/HorizontalScroll/styles.module.scss +4 -3
- package/components/Icons/EuropeanHealthCard.js +1 -1
- package/components/Icons/GroupTwins.js +1 -1
- package/components/Icons/Inbox.js +1 -1
- package/components/Icons/LawBook.js +1 -1
- package/components/Icons/PersonCancel.js +1 -1
- package/components/Icons/PersonWithBrain.js +1 -1
- package/components/Icons/Puzzle.js +1 -1
- package/components/Icons/Snapchat.js +1 -1
- package/components/Illustrations/IllustrationNames.d.ts +1 -1
- package/components/Illustrations/IllustrationNames.js +4 -2
- package/components/Illustrations/IllustrationNames.js.map +1 -1
- package/components/Illustrations/ReadLetters.d.ts +9 -0
- package/components/Illustrations/ReadLetters.js +11 -0
- package/components/Illustrations/ReadLetters.js.map +1 -0
- package/components/Illustrations/ReadLettersMedium.d.ts +4 -0
- package/components/Illustrations/ReadLettersMedium.js +110 -0
- package/components/Illustrations/ReadLettersMedium.js.map +1 -0
- package/components/Illustrations/Support2.d.ts +9 -0
- package/components/Illustrations/Support2.js +11 -0
- package/components/Illustrations/Support2.js.map +1 -0
- package/components/Illustrations/Support2Medium.d.ts +4 -0
- package/components/Illustrations/Support2Medium.js +232 -0
- package/components/Illustrations/Support2Medium.js.map +1 -0
- package/components/Input/styles.module.scss +12 -12
- package/components/Label/styles.module.scss +28 -24
- package/components/Label/styles.module.scss.d.ts +3 -1
- package/components/LinkList/styles.module.scss +33 -33
- package/components/List/styles.module.scss +7 -7
- package/components/ListHeader/styles.module.scss +8 -8
- package/components/Loader/styles.module.scss +14 -14
- package/components/MaxCharacters/styles.module.scss +11 -11
- package/components/Modal/index.js +71 -82
- package/components/Modal/index.js.map +1 -1
- package/components/Modal/styles.module.scss +45 -39
- package/components/NotificationPanel/index.js +3 -3
- package/components/NotificationPanel/index.js.map +1 -1
- package/components/NotificationPanel/styles.module.scss +33 -33
- package/components/Panel/styles.module.scss +45 -45
- package/components/PanelList/index.js +5 -5
- package/components/PanelList/index.js.map +1 -1
- package/components/PanelList/styles.module.scss +5 -5
- package/components/PopMenu/index.js +5 -5
- package/components/PopMenu/index.js.map +1 -1
- package/components/PopMenu/styles.module.scss +15 -15
- package/components/PopOver/styles.module.scss +13 -14
- package/components/PopOver/styles.module.scss.d.ts +0 -3
- package/components/Portal/index.js +3 -3
- package/components/Portal/index.js.map +1 -1
- package/components/Progressbar/styles.module.scss +4 -4
- package/components/PromoPanel/index.js +2 -2
- package/components/PromoPanel/index.js.map +1 -1
- package/components/PromoPanel/styles.module.scss +22 -22
- package/components/RadioButton/styles.module.scss +99 -99
- package/components/Select/styles.module.scss +21 -21
- package/components/ServiceMessage/styles.module.scss +49 -49
- package/components/SharingStatus/styles.module.scss +13 -13
- package/components/Slider/styles.module.scss +24 -24
- package/components/Spacer/styles.module.scss +14 -14
- package/components/StatusDot/styles.module.scss +22 -22
- package/components/Step/styles.module.scss +3 -3
- package/components/StepButtons/styles.module.scss +9 -9
- package/components/Stepper/styles.module.scss +23 -15
- package/components/StickyNote/styles.module.scss +3 -3
- package/components/Table/styles.module.scss +32 -32
- package/components/Tabs/TabList/styles.module.scss +1 -1
- package/components/Tabs/TabPanel/styles.module.scss +5 -5
- package/components/Tabs/index.js +3 -3
- package/components/Tabs/index.js.map +1 -1
- package/components/Tabs/styles.module.scss +1 -1
- package/components/Tag/styles.module.scss +16 -16
- package/components/TagList/index.js +2 -2
- package/components/TagList/index.js.map +1 -1
- package/components/TagList/styles.module.scss +4 -4
- package/components/Textarea/styles.module.scss +9 -9
- package/components/Tile/index.js +6 -6
- package/components/Tile/index.js.map +1 -1
- package/components/Tile/styles.module.scss +25 -25
- package/components/Title/styles.module.scss +8 -8
- package/components/Toggle/index.js +3 -3910
- package/components/Toggle/index.js.map +1 -1
- package/components/Toggle/styles.module.scss +14 -14
- package/components/Tooltip/TooltipWord/styles.module.scss +4 -4
- package/components/Tooltip/index.js +2 -2
- package/components/Tooltip/index.js.map +1 -1
- package/components/Trigger/styles.module.scss +21 -21
- package/components/Validation/index.js +6 -6
- package/components/Validation/index.js.map +1 -1
- package/components/Validation/styles.module.scss +10 -10
- package/constants.d.ts +1 -0
- package/constants.js +1 -0
- package/constants.js.map +1 -1
- package/hoc/withBreakpoint/withBreakpoint.js +2 -2
- package/hoc/withBreakpoint/withBreakpoint.js.map +1 -1
- package/hooks/useBreakpoint.d.ts +0 -4
- package/hooks/useBreakpoint.js +23 -18
- package/hooks/useBreakpoint.js.map +1 -1
- package/hooks/useEventListenerState.js +3 -3
- package/hooks/useEventListenerState.js.map +1 -1
- package/hooks/useReturnFocusOnUnmount.d.ts +5 -0
- package/hooks/useReturnFocusOnUnmount.js +20 -0
- package/hooks/useReturnFocusOnUnmount.js.map +1 -0
- package/package.json +1 -1
- package/scss/_body.scss +5 -6
- package/scss/_breakpoints.scss +8 -2
- package/scss/_font-mixins.scss +57 -2
- package/scss/_fonts.scss +0 -2
- package/scss/_input.scss +53 -50
- package/scss/_print.scss +2 -2
- package/scss/layout.module.scss +2 -2
- package/scss/typography.module.scss +62 -37
- package/scss/typography.module.scss.d.ts +6 -0
- package/scss/typography.stories.tsx +24 -0
- package/theme/index.js +2 -2
- package/use-animate.js +3952 -0
- package/use-animate.js.map +1 -0
- package/utils/accessibility.d.ts +1 -0
- package/utils/accessibility.js +6 -1
- package/utils/accessibility.js.map +1 -1
- package/utils/component.js +4 -4
- package/utils/component.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/Modal/Modal.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\n\nimport cn from 'classnames';\n\nimport { AnalyticsId, ZIndex } from '../../constants';\nimport useFocusTrap from '../../hooks/useFocusTrap';\nimport { useIsVisible } from '../../hooks/useIsVisible';\nimport { palette } from '../../theme/palette';\nimport { uuid } from '../../utils/uuid';\nimport Button from '../Button';\nimport Close from '../Close';\nimport Icon, { IconSize } from '../Icon';\nimport AlertSignFill from '../Icons/AlertSignFill';\nimport AlertSignStroke from '../Icons/AlertSignStroke';\nimport CheckOutline from '../Icons/CheckOutline';\nimport Portal from '../Portal';\nimport Title from '../Title/Title';\n\nimport styles from './styles.module.scss';\n\nexport enum ModalVariants {\n normal = 'normal',\n warning = 'warning',\n error = 'error',\n success = 'success',\n image = 'image',\n}\n\nexport enum ModalSize {\n large = 'large',\n medium = 'medium',\n}\n\nexport interface ModalProps {\n /** Title of the modal */\n title: string;\n /** id of the modal title */\n titleId?: string;\n /** Description of the modal. Will not render if the modal has children. */\n description?: string;\n /** Changes the visual representation of the modal */\n variant?: keyof typeof ModalVariants;\n /** Change width of the modal (default: large) */\n size?: keyof typeof ModalSize;\n /** Icon displayed in title */\n icon?: React.ReactElement;\n /** Hides the close button */\n noCloseButton?: boolean;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Primary button text */\n primaryButtonText?: string;\n /** Secondary button text */\n secondaryButtonText?: string;\n /** Sets the aria-label of the modal */\n ariaLabel?: string;\n /** Sets the aria-labelledby of the modal */\n ariaLabelledBy?: string;\n /** Close button aria-label */\n ariaLabelCloseBtn?: string;\n /** Alternative component to modal */\n children?: React.ReactNode;\n /** Component shown after title */\n afterTitleChildren?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Customize the z-index of the modal */\n zIndex?: number;\n /** Function is called when user clicks primary button */\n onSuccess?: () => void;\n /** Function is called when user clicks secondary button, clicks escape or outside the modal */\n onClose?: () => void;\n /** When enabled the component will be rendered in the bottom of document.body */\n printable?: boolean;\n /** If disabled, clicking escape or outside the modal will not close it */\n disableCloseEvents?: boolean;\n}\n\nconst getVariantIcon = (variant?: ModalProps['variant']): JSX.Element | null => {\n if (variant === ModalVariants.error) {\n return <Icon size={IconSize.Small} svgIcon={AlertSignFill} color={palette.cherry500} />;\n } else if (variant === ModalVariants.warning) {\n return <Icon size={IconSize.Small} svgIcon={AlertSignStroke} color={palette.black} />;\n } else if (variant === ModalVariants.success) {\n return <Icon size={IconSize.Small} svgIcon={CheckOutline} color={palette.kiwi900} />;\n }\n return null;\n};\n\nconst getIcon = (variant?: ModalProps['variant'], icon?: ModalProps['icon']): JSX.Element | null => {\n const variantIcon = getVariantIcon(variant);\n if (variantIcon) {\n return <div className={styles.modal__iconWrapper}>{variantIcon}</div>;\n }\n if (icon) {\n return (\n <div className={styles.modal__iconWrapper}>\n {React.cloneElement(icon, {\n size: IconSize.Small,\n })}\n </div>\n );\n }\n return null;\n};\n\nconst Modal: React.FC<ModalProps> = props => {\n const {\n variant = ModalVariants.normal,\n primaryButtonText = 'OK',\n titleId = uuid(),\n className = '',\n size = ModalSize.large,\n zIndex = ZIndex.Modal,\n } = props;\n\n const topContent = React.useRef<HTMLDivElement>(null);\n const modalContentRef = React.useRef<HTMLDivElement>(null);\n const dialogRef = React.useRef<HTMLDivElement>(null);\n useFocusTrap(dialogRef, true);\n const topContentVisible = useIsVisible(topContent);\n const bottomContent = React.useRef<HTMLDivElement>(null);\n const bottomContentVisible = useIsVisible(bottomContent);\n const contentIsScrollable = modalContentRef.current && modalContentRef.current.scrollHeight > modalContentRef.current.clientHeight;\n\n function handleKeyboardEvent(e: KeyboardEvent): void {\n if (e.key === 'Escape' && props.onClose) {\n e.stopPropagation();\n props.onClose();\n }\n }\n\n function handleClickEvent(event: MouseEvent): void {\n if (event.target && overlayRef.current === event.target && props.onClose) {\n event.stopPropagation();\n props.onClose();\n }\n }\n\n function disableBodyScroll(): void {\n document.body.style.overflow = 'hidden';\n }\n\n function enableBodyScroll(): void {\n document.body.style.removeProperty('overflow');\n }\n\n /* Displays a full window size modal with image */\n const imageView = variant === ModalVariants.image;\n\n const overlayRef = React.useRef<HTMLDivElement>(null);\n\n const showActions = (props.secondaryButtonText && props.secondaryButtonText?.length > 0) || props.onSuccess;\n\n // ariaLabelledBy prioriteres over ariaLabel, men dersom ariaLabel brukes trengs ikke ariaLabelledBy\n const ariaLabel = !props.ariaLabelledBy ? props.ariaLabel : undefined;\n const ariaLabelledBy = props.ariaLabelledBy ? props.ariaLabelledBy : !props.ariaLabel ? titleId : undefined;\n\n useEffect(() => {\n const overlayElement = overlayRef.current;\n disableBodyScroll();\n if (!props.disableCloseEvents && overlayElement) {\n overlayElement.addEventListener('keydown', handleKeyboardEvent);\n overlayElement.addEventListener('click', handleClickEvent);\n }\n return (): void => {\n enableBodyScroll();\n if (!props.disableCloseEvents && overlayElement) {\n overlayElement.removeEventListener('keydown', handleKeyboardEvent);\n overlayElement.removeEventListener('click', handleClickEvent);\n }\n };\n }, [props.disableCloseEvents]);\n\n useEffect(() => {\n dialogRef.current?.focus();\n }, []);\n\n const dialogClasses = cn(\n className,\n styles.modal,\n variant && styles[`modal--${variant}`],\n size && styles[`modal--${size}`],\n contentIsScrollable && !showActions && styles['modal--no-actions']\n );\n\n const titleClasses = cn({\n [styles['modal__title--error']]: variant === ModalVariants.error,\n [styles['modal__title--success']]: variant === ModalVariants.success,\n });\n\n const Component = (\n <div data-testid=\"dialog-container\">\n <div\n ref={overlayRef}\n className={styles['modal-overlay']}\n data-testid={props.testId}\n data-analyticsid={AnalyticsId.Modal}\n style={{ zIndex }}\n >\n <div className={styles.align}>\n <div\n className={dialogClasses}\n role=\"dialog\"\n aria-modal=\"true\"\n tabIndex={-1}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n ref={dialogRef}\n >\n <div\n className={cn(styles['modal__shadow'], styles['modal__shadow--top'], {\n [styles['modal__shadow--show']]: !topContentVisible && contentIsScrollable,\n })}\n />\n <div\n className={cn(styles.modal__contentWrapper, {\n [styles['modal__contentWrapper--image']]: imageView,\n })}\n tabIndex={contentIsScrollable ? 0 : undefined}\n role={contentIsScrollable ? 'region' : undefined}\n aria-label={contentIsScrollable ? ariaLabel : undefined}\n aria-labelledby={contentIsScrollable ? ariaLabelledBy : undefined}\n ref={modalContentRef}\n >\n {!props.noCloseButton && (\n <div className={styles.modal__closeWrapper}>\n <div className={cn(styles.modal__closeWrapper__close)}>\n <Close onClick={props.onClose} ariaLabel={props.ariaLabelCloseBtn} />\n </div>\n </div>\n )}\n <div\n className={cn(size && styles[`modal__contentWrapper__scroll--${size}`], {\n [styles['modal__contentWrapper__scroll--image']]: imageView,\n })}\n >\n <div ref={topContent} />\n <div className={styles.modal__contentWrapper__title}>\n {getIcon(variant, props.icon)}\n <Title id={ariaLabelledBy} htmlMarkup=\"h3\" appearance=\"title3\" className={titleClasses}>\n {props.title}\n </Title>\n {props.afterTitleChildren && <div className={styles['modal__afterTitleChildren']}>{props.afterTitleChildren}</div>}\n </div>\n {imageView && (\n <div>\n <div className={styles['modal__contentWrapper__imageWrapper']}>{props.children}</div>\n <span className={styles['modal__contentWrapper__imageDescription']}>{props.description}</span>\n </div>\n )}\n {!imageView && props.children && <div>{props.children}</div>}\n {!imageView && !props.children && <p className={styles.modal__description}>{props.description}</p>}\n <div ref={bottomContent} />\n </div>\n </div>\n <div\n className={cn(styles['modal__shadow'], styles['modal__shadow--bottom'], {\n [styles['modal__shadow--show']]: !bottomContentVisible && contentIsScrollable,\n })}\n />\n {showActions && (\n <div className={cn(styles['modal__call-to-action'], size && styles[`modal__call-to-action--${size}`])}>\n {props.onSuccess && <Button onClick={props.onSuccess}>{primaryButtonText}</Button>}\n {props.secondaryButtonText && props.secondaryButtonText?.length > 0 && (\n <Button variant=\"borderless\" onClick={props.onClose}>\n {props.secondaryButtonText}\n </Button>\n )}\n </div>\n )}\n </div>\n </div>\n </div>\n </div>\n );\n\n if (props.printable) {\n const printModal = 'print-modal';\n return (\n <Portal className={printModal} testId=\"print-modal\">\n <style media=\"print\">{`body > *:not(.${printModal}) {display: none;}`}</style>\n {Component}\n </Portal>\n );\n }\n\n return Component;\n};\n\nexport default Modal;\n"],"names":["ModalVariants","ModalSize","_a","cn"],"mappings":";;;;;;;;;;;;;;;;;AAoBY,IAAA,kCAAAA,mBAAL;AACLA,iBAAA,QAAS,IAAA;AACTA,iBAAA,SAAU,IAAA;AACVA,iBAAA,OAAQ,IAAA;AACRA,iBAAA,SAAU,IAAA;AACVA,iBAAA,OAAQ,IAAA;AALEA,SAAAA;AAAA,GAAA,iBAAA,CAAA,CAAA;AAQA,IAAA,8BAAAC,eAAL;AACLA,aAAA,OAAQ,IAAA;AACRA,aAAA,QAAS,IAAA;AAFCA,SAAAA;AAAA,GAAA,aAAA,CAAA,CAAA;AAkDZ,MAAM,iBAAiB,CAAC,YAAwD;AAC9E,MAAI,YAAY,SAAqB;AAC5B,WAAA,oBAAC,QAAK,MAAM,SAAS,OAAO,SAAS,eAAe,OAAO,QAAQ,UAAW,CAAA;AAAA,EAAA,WAC5E,YAAY,WAAuB;AACrC,WAAA,oBAAC,QAAK,MAAM,SAAS,OAAO,SAAS,iBAAiB,OAAO,QAAQ,MAAO,CAAA;AAAA,EAAA,WAC1E,YAAY,WAAuB;AACrC,WAAA,oBAAC,QAAK,MAAM,SAAS,OAAO,SAAS,cAAc,OAAO,QAAQ,QAAS,CAAA;AAAA,EAAA;AAE7E,SAAA;AACT;AAEA,MAAM,UAAU,CAAC,SAAiC,SAAkD;AAC5F,QAAA,cAAc,eAAe,OAAO;AAC1C,MAAI,aAAa;AACf,WAAQ,oBAAA,OAAA,EAAI,WAAW,OAAO,oBAAqB,UAAY,aAAA;AAAA,EAAA;AAEjE,MAAI,MAAM;AACR,+BACG,OAAI,EAAA,WAAW,OAAO,oBACpB,UAAA,MAAM,aAAa,MAAM;AAAA,MACxB,MAAM,SAAS;AAAA,IAChB,CAAA,GACH;AAAA,EAAA;A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M,aAAa;AACnB,WACG,qBAAA,QAAA,EAAO,WAAW,YAAY,QAAO,eACpC,UAAA;AAAA,MAAA,oBAAC,SAAM,EAAA,OAAM,SAAS,UAAA,iBAAiB,UAAU,sBAAqB;AAAA,MACrE;AAAA,IAAA,GACH;AAAA,EAAA;AAIG,SAAA;AACT;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/Modal/Modal.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\n\nimport cn from 'classnames';\n\nimport { AnalyticsId, ZIndex } from '../../constants';\nimport useFocusTrap from '../../hooks/useFocusTrap';\nimport { useIsVisible } from '../../hooks/useIsVisible';\nimport { useReturnFocusOnUnmount } from '../../hooks/useReturnFocusOnUnmount';\nimport { palette } from '../../theme/palette';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport { uuid } from '../../utils/uuid';\nimport Button from '../Button';\nimport Close from '../Close';\nimport Icon, { IconSize } from '../Icon';\nimport AlertSignFill from '../Icons/AlertSignFill';\nimport AlertSignStroke from '../Icons/AlertSignStroke';\nimport CheckOutline from '../Icons/CheckOutline';\nimport Portal from '../Portal';\nimport Title from '../Title/Title';\n\nimport styles from './styles.module.scss';\n\nexport enum ModalVariants {\n normal = 'normal',\n warning = 'warning',\n error = 'error',\n success = 'success',\n image = 'image',\n}\n\nexport enum ModalSize {\n large = 'large',\n medium = 'medium',\n}\n\nexport interface ModalProps {\n /** Title of the modal */\n title: string;\n /** id of the modal title */\n titleId?: string;\n /** Description of the modal. Will not render if the modal has children. */\n description?: string;\n /** Changes the visual representation of the modal */\n variant?: keyof typeof ModalVariants;\n /** Change width of the modal (default: large) */\n size?: keyof typeof ModalSize;\n /** Icon displayed in title */\n icon?: React.ReactElement;\n /** Hides the close button */\n noCloseButton?: boolean;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Primary button text */\n primaryButtonText?: string;\n /** Secondary button text */\n secondaryButtonText?: string;\n /** Sets the aria-label of the modal */\n ariaLabel?: string;\n /** Sets the aria-labelledby of the modal */\n ariaLabelledBy?: string;\n /** Close button aria-label */\n ariaLabelCloseBtn?: string;\n /** Alternative component to modal */\n children?: React.ReactNode;\n /** Component shown after title */\n afterTitleChildren?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Customize the z-index of the modal */\n zIndex?: number;\n /** Function is called when user clicks primary button */\n onSuccess?: () => void;\n /** Function is called when user clicks secondary button, clicks escape or outside the modal */\n onClose?: () => void;\n /** When enabled the component will be rendered in the bottom of document.body */\n printable?: boolean;\n /** If disabled, clicking escape or outside the modal will not close it */\n disableCloseEvents?: boolean;\n}\n\nconst getVariantIcon = (variant?: ModalProps['variant']): JSX.Element | null => {\n if (variant === ModalVariants.error) {\n return <Icon size={IconSize.Small} svgIcon={AlertSignFill} color={palette.cherry500} />;\n } else if (variant === ModalVariants.warning) {\n return <Icon size={IconSize.Small} svgIcon={AlertSignStroke} color={palette.black} />;\n } else if (variant === ModalVariants.success) {\n return <Icon size={IconSize.Small} svgIcon={CheckOutline} color={palette.kiwi900} />;\n }\n return null;\n};\n\nconst getIcon = (variant?: ModalProps['variant'], icon?: ModalProps['icon']): JSX.Element | null => {\n const variantIcon = getVariantIcon(variant);\n if (variantIcon) {\n return <div className={styles.modal__iconWrapper}>{variantIcon}</div>;\n }\n if (icon) {\n return (\n <div className={styles.modal__iconWrapper}>\n {React.cloneElement(icon, {\n size: IconSize.Small,\n })}\n </div>\n );\n }\n return null;\n};\n\nconst Modal: React.FC<ModalProps> = props => {\n const {\n variant = ModalVariants.normal,\n primaryButtonText = 'OK',\n titleId = uuid(),\n className = '',\n size = ModalSize.large,\n zIndex = ZIndex.Modal,\n } = props;\n\n const topContent = React.useRef<HTMLDivElement>(null);\n const modalContentRef = React.useRef<HTMLDivElement>(null);\n const dialogRef = React.useRef<HTMLDivElement>(null);\n useFocusTrap(dialogRef, true);\n const topContentVisible = useIsVisible(topContent);\n const bottomContent = React.useRef<HTMLDivElement>(null);\n const bottomContentVisible = useIsVisible(bottomContent);\n const contentIsScrollable = modalContentRef.current && modalContentRef.current.scrollHeight > modalContentRef.current.clientHeight;\n useReturnFocusOnUnmount(dialogRef);\n\n function handleKeyboardEvent(e: KeyboardEvent): void {\n if (e.key === 'Escape' && props.onClose) {\n e.stopPropagation();\n props.onClose();\n }\n }\n\n function handleClickEvent(event: MouseEvent): void {\n if (event.target && overlayRef.current === event.target && props.onClose) {\n event.stopPropagation();\n props.onClose();\n }\n }\n\n function disableBodyScroll(): void {\n document.body.style.overflow = 'hidden';\n }\n\n function enableBodyScroll(): void {\n document.body.style.removeProperty('overflow');\n }\n\n /* Displays a full window size modal with image */\n const imageView = variant === ModalVariants.image;\n\n const overlayRef = React.useRef<HTMLDivElement>(null);\n\n const showActions = (props.secondaryButtonText && props.secondaryButtonText?.length > 0) || props.onSuccess;\n\n const ariaLabelAttributes = getAriaLabelAttributes({ label: props.ariaLabel, id: props.ariaLabelledBy, fallbackId: titleId });\n\n useEffect(() => {\n const overlayElement = overlayRef.current;\n disableBodyScroll();\n if (!props.disableCloseEvents && overlayElement) {\n overlayElement.addEventListener('keydown', handleKeyboardEvent);\n overlayElement.addEventListener('click', handleClickEvent);\n }\n return (): void => {\n enableBodyScroll();\n if (!props.disableCloseEvents && overlayElement) {\n overlayElement.removeEventListener('keydown', handleKeyboardEvent);\n overlayElement.removeEventListener('click', handleClickEvent);\n }\n };\n }, [props.disableCloseEvents]);\n\n useEffect(() => {\n dialogRef.current?.focus();\n }, []);\n\n const dialogClasses = cn(\n className,\n styles.modal,\n variant && styles[`modal--${variant}`],\n size && styles[`modal--${size}`],\n contentIsScrollable && !showActions && styles['modal--no-actions']\n );\n\n const titleClasses = cn({\n [styles['modal__title--error']]: variant === ModalVariants.error,\n [styles['modal__title--success']]: variant === ModalVariants.success,\n });\n\n const Component = (\n <div data-testid=\"dialog-container\">\n <div\n ref={overlayRef}\n className={styles['modal-overlay']}\n data-testid={props.testId}\n data-analyticsid={AnalyticsId.Modal}\n style={{ zIndex }}\n >\n <div className={styles.align}>\n <div className={dialogClasses} role=\"dialog\" aria-modal=\"true\" tabIndex={-1} {...ariaLabelAttributes} ref={dialogRef}>\n <div\n className={cn(styles['modal__shadow'], styles['modal__shadow--top'], {\n [styles['modal__shadow--show']]: !topContentVisible && contentIsScrollable,\n })}\n />\n <div\n className={cn(styles.modal__contentWrapper, {\n [styles['modal__contentWrapper--image']]: imageView,\n })}\n tabIndex={contentIsScrollable ? 0 : undefined}\n role={contentIsScrollable ? 'region' : undefined}\n {...(contentIsScrollable ? ariaLabelAttributes : {})}\n ref={modalContentRef}\n >\n {!props.noCloseButton && (\n <div className={styles.modal__closeWrapper}>\n <div className={cn(styles.modal__closeWrapper__close)}>\n <Close onClick={props.onClose} ariaLabel={props.ariaLabelCloseBtn} />\n </div>\n </div>\n )}\n <div\n className={cn(size && styles[`modal__contentWrapper__scroll--${size}`], {\n [styles['modal__contentWrapper__scroll--image']]: imageView,\n })}\n >\n <div ref={topContent} />\n <div className={styles.modal__contentWrapper__title}>\n {getIcon(variant, props.icon)}\n <Title id={ariaLabelAttributes?.['aria-labelledby']} htmlMarkup=\"h3\" appearance=\"title3\" className={titleClasses}>\n {props.title}\n </Title>\n {props.afterTitleChildren && <div className={styles['modal__afterTitleChildren']}>{props.afterTitleChildren}</div>}\n </div>\n {imageView && (\n <div>\n <div className={styles['modal__contentWrapper__imageWrapper']}>{props.children}</div>\n <span className={styles['modal__contentWrapper__imageDescription']}>{props.description}</span>\n </div>\n )}\n {!imageView && props.children && <div>{props.children}</div>}\n {!imageView && !props.children && <p className={styles.modal__description}>{props.description}</p>}\n <div ref={bottomContent} />\n </div>\n </div>\n <div\n className={cn(styles['modal__shadow'], styles['modal__shadow--bottom'], {\n [styles['modal__shadow--show']]: !bottomContentVisible && contentIsScrollable,\n })}\n />\n {showActions && (\n <div className={cn(styles['modal__call-to-action'], size && styles[`modal__call-to-action--${size}`])}>\n {props.onSuccess && <Button onClick={props.onSuccess}>{primaryButtonText}</Button>}\n {props.secondaryButtonText && props.secondaryButtonText?.length > 0 && (\n <Button variant=\"borderless\" onClick={props.onClose}>\n {props.secondaryButtonText}\n </Button>\n )}\n </div>\n )}\n </div>\n </div>\n </div>\n </div>\n );\n\n if (props.printable) {\n const printModal = 'print-modal';\n return (\n <Portal className={printModal} testId=\"print-modal\">\n <style media=\"print\">{`body > *:not(.${printModal}) {display: none;}`}</style>\n {Component}\n </Portal>\n );\n }\n\n return Component;\n};\n\nexport default Modal;\n"],"names":["ModalVariants","ModalSize","React","_a","cn"],"mappings":";;;;;;;;;;;;;;;;;;;AAsBY,IAAA,kCAAAA,mBAAL;AACLA,iBAAA,QAAS,IAAA;AACTA,iBAAA,SAAU,IAAA;AACVA,iBAAA,OAAQ,IAAA;AACRA,iBAAA,SAAU,IAAA;AACVA,iBAAA,OAAQ,IAAA;AALEA,SAAAA;AAAA,GAAA,iBAAA,CAAA,CAAA;AAQA,IAAA,8BAAAC,eAAL;AACLA,aAAA,OAAQ,IAAA;AACRA,aAAA,QAAS,IAAA;AAFCA,SAAAA;AAAA,GAAA,aAAA,CAAA,CAAA;AAkDZ,MAAM,iBAAiB,CAAC,YAAwD;AAC9E,MAAI,YAAY,SAAqB;AAC5B,WAAA,oBAAC,QAAK,MAAM,SAAS,OAAO,SAAS,eAAe,OAAO,QAAQ,UAAW,CAAA;AAAA,EAAA,WAC5E,YAAY,WAAuB;AACrC,WAAA,oBAAC,QAAK,MAAM,SAAS,OAAO,SAAS,iBAAiB,OAAO,QAAQ,MAAO,CAAA;AAAA,EAAA,WAC1E,YAAY,WAAuB;AACrC,WAAA,oBAAC,QAAK,MAAM,SAAS,OAAO,SAAS,cAAc,OAAO,QAAQ,QAAS,CAAA;AAAA,EAAA;AAE7E,SAAA;AACT;AAEA,MAAM,UAAU,CAAC,SAAiC,SAAkD;AAC5F,QAAA,cAAc,eAAe,OAAO;AAC1C,MAAI,aAAa;AACf,WAAQ,oBAAA,OAAA,EAAI,WAAW,OAAO,oBAAqB,UAAY,aAAA;AAAA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,UAAM,aAAa;AACnB,WACG,qBAAA,QAAA,EAAO,WAAW,YAAY,QAAO,eACpC,UAAA;AAAA,MAAA,oBAAC,SAAM,EAAA,OAAM,SAAS,UAAA,iBAAiB,UAAU,sBAAqB;AAAA,MACrE;AAAA,IAAA,GACH;AAAA,EAAA;AAIG,SAAA;AACT;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
@use 'sass:map';
|
|
2
|
-
@
|
|
3
|
-
@
|
|
4
|
-
@
|
|
5
|
-
@
|
|
2
|
+
@use '../../scss/spacers' as spacers;
|
|
3
|
+
@use '../../scss/palette' as palette;
|
|
4
|
+
@use '../../scss/font-settings' as font-settings;
|
|
5
|
+
@use '../../scss/breakpoints' as *;
|
|
6
6
|
|
|
7
7
|
.modal-overlay {
|
|
8
8
|
background: rgb(51 51 51 / 75%);
|
|
@@ -32,25 +32,26 @@
|
|
|
32
32
|
.modal {
|
|
33
33
|
pointer-events: auto;
|
|
34
34
|
box-shadow: 0 0 5px 0 rgb(0 0 0 / 50%);
|
|
35
|
-
background-color:
|
|
35
|
+
background-color: palette.$white;
|
|
36
36
|
animation: open 200ms 1;
|
|
37
|
+
outline: none;
|
|
37
38
|
|
|
38
39
|
&__title {
|
|
39
40
|
&--error {
|
|
40
|
-
color:
|
|
41
|
+
color: palette.$cherry600;
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
&--success {
|
|
44
|
-
color:
|
|
45
|
+
color: palette.$kiwi900;
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
&__iconWrapper {
|
|
49
|
-
padding-right: getSpacer(xs);
|
|
50
|
+
padding-right: spacers.getSpacer(xs);
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
&__afterTitleChildren {
|
|
53
|
-
padding-left: getSpacer(xs);
|
|
54
|
+
padding-left: spacers.getSpacer(xs);
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
p {
|
|
@@ -58,24 +59,24 @@
|
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
&--normal {
|
|
61
|
-
background-color:
|
|
62
|
+
background-color: palette.$white;
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
&--error {
|
|
65
|
-
background-color:
|
|
66
|
+
background-color: palette.$cherry100;
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
&--warning {
|
|
69
|
-
background-color:
|
|
70
|
+
background-color: palette.$banana50;
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
&--success {
|
|
73
|
-
background-color:
|
|
74
|
+
background-color: palette.$kiwi50;
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
&--large {
|
|
77
78
|
width: calc(100vw - 0.75rem);
|
|
78
|
-
padding-bottom: getSpacer(l);
|
|
79
|
+
padding-bottom: spacers.getSpacer(l);
|
|
79
80
|
|
|
80
81
|
@media (max-width: map.get($grid-breakpoints, sm)) {
|
|
81
82
|
p {
|
|
@@ -84,7 +85,7 @@
|
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
@media (min-width: map.get($grid-breakpoints, md)) {
|
|
87
|
-
padding-bottom: getSpacer(xl);
|
|
88
|
+
padding-bottom: spacers.getSpacer(xl);
|
|
88
89
|
width: 612px;
|
|
89
90
|
}
|
|
90
91
|
|
|
@@ -92,14 +93,14 @@
|
|
|
92
93
|
width: 696px;
|
|
93
94
|
}
|
|
94
95
|
|
|
95
|
-
@
|
|
96
|
-
padding-bottom: getSpacer(2xs);
|
|
96
|
+
@include tiny-screens-media-query {
|
|
97
|
+
padding-bottom: spacers.getSpacer(2xs);
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
&--medium {
|
|
101
102
|
width: calc(100vw - 0.75rem);
|
|
102
|
-
padding-bottom: getSpacer(m);
|
|
103
|
+
padding-bottom: spacers.getSpacer(m);
|
|
103
104
|
|
|
104
105
|
@media (min-width: map.get($grid-breakpoints, md)) {
|
|
105
106
|
width: 335px;
|
|
@@ -159,8 +160,8 @@
|
|
|
159
160
|
|
|
160
161
|
&__close {
|
|
161
162
|
position: absolute;
|
|
162
|
-
right: getSpacer(3xs);
|
|
163
|
-
top: getSpacer(3xs);
|
|
163
|
+
right: spacers.getSpacer(3xs);
|
|
164
|
+
top: spacers.getSpacer(3xs);
|
|
164
165
|
}
|
|
165
166
|
}
|
|
166
167
|
|
|
@@ -170,12 +171,17 @@
|
|
|
170
171
|
overflow: auto;
|
|
171
172
|
overflow-x: hidden;
|
|
172
173
|
|
|
174
|
+
&:focus-visible {
|
|
175
|
+
outline: 1px solid palette.$black;
|
|
176
|
+
outline-offset: -1px;
|
|
177
|
+
}
|
|
178
|
+
|
|
173
179
|
@media print {
|
|
174
180
|
overflow: hidden;
|
|
175
181
|
max-height: none;
|
|
176
182
|
}
|
|
177
183
|
|
|
178
|
-
@
|
|
184
|
+
@include tiny-screens-media-query {
|
|
179
185
|
max-height: calc(100dvh - 4rem);
|
|
180
186
|
}
|
|
181
187
|
|
|
@@ -185,30 +191,30 @@
|
|
|
185
191
|
|
|
186
192
|
&__scroll {
|
|
187
193
|
&--large {
|
|
188
|
-
padding: getSpacer(xl) getSpacer(m) getSpacer(2xs);
|
|
194
|
+
padding: spacers.getSpacer(xl) spacers.getSpacer(m) spacers.getSpacer(2xs);
|
|
189
195
|
|
|
190
196
|
@media (min-width: map.get($grid-breakpoints, md)) {
|
|
191
|
-
padding: getSpacer(xl) getSpacer(xl) getSpacer(2xs);
|
|
197
|
+
padding: spacers.getSpacer(xl) spacers.getSpacer(xl) spacers.getSpacer(2xs);
|
|
192
198
|
}
|
|
193
199
|
|
|
194
|
-
@
|
|
195
|
-
padding: getSpacer(2xs) getSpacer(2xs) getSpacer(4xs);
|
|
200
|
+
@include tiny-screens-media-query {
|
|
201
|
+
padding: spacers.getSpacer(2xs) spacers.getSpacer(2xs) spacers.getSpacer(4xs);
|
|
196
202
|
}
|
|
197
203
|
}
|
|
198
204
|
|
|
199
205
|
&--medium {
|
|
200
|
-
padding: getSpacer(l) getSpacer(m) getSpacer(2xs);
|
|
206
|
+
padding: spacers.getSpacer(l) spacers.getSpacer(m) spacers.getSpacer(2xs);
|
|
201
207
|
|
|
202
208
|
@media (min-width: map.get($grid-breakpoints, md)) {
|
|
203
|
-
padding: getSpacer(xl) getSpacer(m) getSpacer(2xs);
|
|
209
|
+
padding: spacers.getSpacer(xl) spacers.getSpacer(m) spacers.getSpacer(2xs);
|
|
204
210
|
}
|
|
205
211
|
|
|
206
|
-
@
|
|
207
|
-
padding: getSpacer(2xs) getSpacer(3xs) getSpacer(4xs);
|
|
212
|
+
@include tiny-screens-media-query {
|
|
213
|
+
padding: spacers.getSpacer(2xs) spacers.getSpacer(3xs) spacers.getSpacer(4xs);
|
|
208
214
|
}
|
|
209
215
|
}
|
|
210
216
|
&--large#{&}--image {
|
|
211
|
-
padding: getSpacer(xl) getSpacer(2xs) getSpacer(l);
|
|
217
|
+
padding: spacers.getSpacer(xl) spacers.getSpacer(2xs) spacers.getSpacer(l);
|
|
212
218
|
}
|
|
213
219
|
}
|
|
214
220
|
|
|
@@ -234,8 +240,8 @@
|
|
|
234
240
|
}
|
|
235
241
|
|
|
236
242
|
&__imageDescription {
|
|
237
|
-
font-size:
|
|
238
|
-
padding-top: getSpacer(s);
|
|
243
|
+
font-size: font-settings.$font-size-xs;
|
|
244
|
+
padding-top: spacers.getSpacer(s);
|
|
239
245
|
display: block;
|
|
240
246
|
}
|
|
241
247
|
}
|
|
@@ -252,22 +258,22 @@
|
|
|
252
258
|
}
|
|
253
259
|
|
|
254
260
|
&--large {
|
|
255
|
-
padding: getSpacer(l) getSpacer(m) 0;
|
|
261
|
+
padding: spacers.getSpacer(l) spacers.getSpacer(m) 0;
|
|
256
262
|
|
|
257
263
|
@media (min-width: map.get($grid-breakpoints, md)) {
|
|
258
|
-
padding: getSpacer(l) getSpacer(xl) 0;
|
|
264
|
+
padding: spacers.getSpacer(l) spacers.getSpacer(xl) 0;
|
|
259
265
|
}
|
|
260
266
|
|
|
261
|
-
@
|
|
262
|
-
padding: getSpacer(2xs) getSpacer(2xs) 0;
|
|
267
|
+
@include tiny-screens-media-query {
|
|
268
|
+
padding: spacers.getSpacer(2xs) spacers.getSpacer(2xs) 0;
|
|
263
269
|
}
|
|
264
270
|
}
|
|
265
271
|
|
|
266
272
|
&--medium {
|
|
267
|
-
padding: getSpacer(m) getSpacer(m) 0;
|
|
273
|
+
padding: spacers.getSpacer(m) spacers.getSpacer(m) 0;
|
|
268
274
|
|
|
269
|
-
@
|
|
270
|
-
padding: getSpacer(2xs) getSpacer(2xs) 0;
|
|
275
|
+
@include tiny-screens-media-query {
|
|
276
|
+
padding: spacers.getSpacer(2xs) spacers.getSpacer(2xs) 0;
|
|
271
277
|
}
|
|
272
278
|
}
|
|
273
279
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import React__default from "react";
|
|
3
3
|
import classNames from "classnames";
|
|
4
4
|
import { AnalyticsId, IconSize } from "../../constants.js";
|
|
5
5
|
import { useUuid } from "../../hooks/useUuid.js";
|
|
@@ -16,7 +16,7 @@ const FluidWrapper = ({ fluid, children }) => {
|
|
|
16
16
|
}
|
|
17
17
|
return children;
|
|
18
18
|
};
|
|
19
|
-
const NotificationPanel =
|
|
19
|
+
const NotificationPanel = React__default.forwardRef((props, ref) => {
|
|
20
20
|
const {
|
|
21
21
|
children,
|
|
22
22
|
variant = "info",
|
|
@@ -51,7 +51,7 @@ const NotificationPanel = React.forwardRef((props, ref) => {
|
|
|
51
51
|
[styles["notification-panel__children--outline"]]: outlineVariant
|
|
52
52
|
});
|
|
53
53
|
const CustomTag = labelHtmlMarkup;
|
|
54
|
-
const [expanderOpen, setExpanderOpen] =
|
|
54
|
+
const [expanderOpen, setExpanderOpen] = React__default.useState(expanderOpenFromStart);
|
|
55
55
|
return /* @__PURE__ */ jsxs("div", { className: contentClasses, id: !label ? uuid : void 0, children: [
|
|
56
56
|
label && /* @__PURE__ */ jsx(CustomTag, { className: labelClasses, id: uuid, children: label }),
|
|
57
57
|
children && /* @__PURE__ */ jsx("div", { className: childrenClasses, children }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/NotificationPanel/NotificationPanel.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, IconSize } from '../../constants';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getColor } from '../../theme/currys';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport NotificationBadge from '../Badge/NotificationBadge';\nimport Close from '../Close';\nimport Expander from '../Expander';\n\nimport styles from './styles.module.scss';\n\nexport type NotificationPanelVariants = 'info' | 'warn' | 'error' | 'success';\nexport type NotificationCompactVariants = 'basic' | 'outline';\nexport type NotificationPanelSizes = 'small' | 'medium' | 'large';\nexport type LabelTags = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'span';\n\nexport interface NotificationPanelProps {\n /** Adds custom classes to the element. */\n className?: string;\n /** Adds inner child elements. */\n children?: React.ReactNode;\n /** Adds inner expander elements. */\n expanderChildren?: React.ReactNode;\n /** Text for expanderButton. */\n expanderButtonText?: string;\n /** Text for expanderButton when closed. */\n expanderButtonClosedText?: string;\n /** Makes expander be open from start. */\n expanderOpenFromStart?: boolean;\n /** Changes the visual representation of the notification panel. */\n variant?: NotificationPanelVariants;\n /** Makes the panel more compact. Available in basic and outline. */\n compactVariant?: NotificationCompactVariants;\n /** Sets a fixed size for the content container. */\n size?: NotificationPanelSizes;\n /** Used in combination with dismissiable property to close the notification panel. */\n onClick?: (e?: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Toggles the close button in the top right corner. */\n dismissable?: boolean;\n /** Enables a fluid outer container that spans the entire width of parent. */\n fluid?: boolean;\n /** Sets a label for the notification panel. */\n label?: string;\n /** Changes the underlying element of the label. */\n labelHtmlMarkup?: LabelTags;\n /** Close button aria-label */\n ariaLabelCloseBtn?: string;\n /** Custom id for the label */\n labelId?: string;\n /** Custom role for the panel. Default is no role. If variant is alert or crisis, the aria role will be set to \"alert\" unless the role-prop is also set. */\n role?: 'region' | 'alert';\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\ntype WrapFluidProps = Pick<NotificationPanelProps, 'fluid'> & {\n children: React.ReactElement;\n};\n\nconst FluidWrapper: React.FC<WrapFluidProps> = ({ fluid, children }) => {\n if (fluid) {\n const fluidClasses = classNames(styles['fluid-wrapper']);\n\n return <div className={fluidClasses}>{children}</div>;\n }\n return children;\n};\n\nconst NotificationPanel = React.forwardRef<HTMLDivElement, NotificationPanelProps>((props, ref) => {\n const {\n children,\n variant = 'info',\n dismissable = false,\n onClick,\n expanderChildren,\n expanderButtonText,\n expanderButtonClosedText,\n expanderOpenFromStart = false,\n compactVariant,\n label,\n labelHtmlMarkup = 'h1',\n fluid = false,\n size,\n className,\n labelId,\n role,\n testId,\n } = props;\n const uuid = useUuid(labelId);\n const renderContent = (): JSX.Element => {\n const outlineVariant = compactVariant === 'outline';\n const contentClasses = classNames(styles['notification-panel__content']);\n const labelClasses = classNames(styles['notification-panel__label'], {\n [styles['notification-panel__label--no-content']]: !children && !expanderChildren,\n [styles['notification-panel__label--compact']]: !!compactVariant,\n [styles['notification-panel__label--outline']]: outlineVariant,\n });\n const childrenClasses = classNames(styles['notification-panel__children'], {\n [styles['notification-panel__children--with-label']]: label,\n [styles['notification-panel__children--expander-no-label']]: expanderChildren && !label,\n [styles['notification-panel__children--outline']]: outlineVariant,\n });\n const CustomTag = labelHtmlMarkup;\n\n const [expanderOpen, setExpanderOpen] = React.useState(expanderOpenFromStart);\n return (\n <div className={contentClasses} id={!label ? uuid : undefined}>\n {label && (\n <CustomTag className={labelClasses} id={uuid}>\n {label}\n </CustomTag>\n )}\n {children && <div className={childrenClasses}>{children}</div>}\n {expanderChildren && expanderButtonText && expanderButtonClosedText && !compactVariant && (\n <Expander\n title={expanderOpen ? expanderButtonText : expanderButtonClosedText}\n onExpand={setExpanderOpen}\n expanded={expanderOpen}\n testId=\"expand\"\n >\n {expanderChildren}\n </Expander>\n )}\n </div>\n );\n };\n\n const notificationPanelClasses = classNames(\n styles['notification-panel'],\n styles[`notification-panel--${variant}`],\n size && styles[`notification-panel--${size}`],\n {\n [styles['notification-panel--compact']]: !!compactVariant,\n [styles['notification-panel--compact--basic']]: compactVariant === 'basic',\n [styles['notification-panel--compact--outline']]: compactVariant === 'outline',\n [styles['notification-panel--with-content']]: expanderChildren || (label && children),\n [styles['notification-panel--dismissable']]: dismissable,\n },\n className\n );\n\n const ariaRole = role || (variant === 'error' && 'alert') || undefined;\n const ariaLabelAttributes = ariaRole ? getAriaLabelAttributes({ label, id: uuid }) : undefined;\n\n return (\n <FluidWrapper fluid={fluid}>\n <div\n ref={ref}\n role={ariaRole}\n data-testid={testId}\n data-analyticsid={AnalyticsId.NotificationPanel}\n className={notificationPanelClasses}\n {...ariaLabelAttributes}\n >\n <NotificationBadge\n variant={variant}\n size={compactVariant ? IconSize.XSmall : IconSize.Small}\n className={styles['notification-panel__icon']}\n />\n {dismissable && (\n <span className={styles['notification-panel__close']}>\n <Close ariaLabel={props.ariaLabelCloseBtn} onClick={onClick} color={getColor('black')} />\n </span>\n )}\n {renderContent()}\n </div>\n </FluidWrapper>\n );\n});\n\nexport default NotificationPanel;\n"],"names":[],"mappings":";;;;;;;;;;;AA8DA,MAAM,eAAyC,CAAC,EAAE,OAAO,eAAe;AACtE,MAAI,OAAO;AACT,UAAM,eAAe,WAAW,OAAO,eAAe,CAAC;AAEvD,WAAQ,oBAAA,OAAA,EAAI,WAAW,cAAe,SAAS,CAAA;AAAA,EAAA;AAE1C,SAAA;AACT;AAEA,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/NotificationPanel/NotificationPanel.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, IconSize } from '../../constants';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getColor } from '../../theme/currys';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport NotificationBadge from '../Badge/NotificationBadge';\nimport Close from '../Close';\nimport Expander from '../Expander';\n\nimport styles from './styles.module.scss';\n\nexport type NotificationPanelVariants = 'info' | 'warn' | 'error' | 'success';\nexport type NotificationCompactVariants = 'basic' | 'outline';\nexport type NotificationPanelSizes = 'small' | 'medium' | 'large';\nexport type LabelTags = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'span';\n\nexport interface NotificationPanelProps {\n /** Adds custom classes to the element. */\n className?: string;\n /** Adds inner child elements. */\n children?: React.ReactNode;\n /** Adds inner expander elements. */\n expanderChildren?: React.ReactNode;\n /** Text for expanderButton. */\n expanderButtonText?: string;\n /** Text for expanderButton when closed. */\n expanderButtonClosedText?: string;\n /** Makes expander be open from start. */\n expanderOpenFromStart?: boolean;\n /** Changes the visual representation of the notification panel. */\n variant?: NotificationPanelVariants;\n /** Makes the panel more compact. Available in basic and outline. */\n compactVariant?: NotificationCompactVariants;\n /** Sets a fixed size for the content container. */\n size?: NotificationPanelSizes;\n /** Used in combination with dismissiable property to close the notification panel. */\n onClick?: (e?: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Toggles the close button in the top right corner. */\n dismissable?: boolean;\n /** Enables a fluid outer container that spans the entire width of parent. */\n fluid?: boolean;\n /** Sets a label for the notification panel. */\n label?: string;\n /** Changes the underlying element of the label. */\n labelHtmlMarkup?: LabelTags;\n /** Close button aria-label */\n ariaLabelCloseBtn?: string;\n /** Custom id for the label */\n labelId?: string;\n /** Custom role for the panel. Default is no role. If variant is alert or crisis, the aria role will be set to \"alert\" unless the role-prop is also set. */\n role?: 'region' | 'alert';\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\ntype WrapFluidProps = Pick<NotificationPanelProps, 'fluid'> & {\n children: React.ReactElement;\n};\n\nconst FluidWrapper: React.FC<WrapFluidProps> = ({ fluid, children }) => {\n if (fluid) {\n const fluidClasses = classNames(styles['fluid-wrapper']);\n\n return <div className={fluidClasses}>{children}</div>;\n }\n return children;\n};\n\nconst NotificationPanel = React.forwardRef<HTMLDivElement, NotificationPanelProps>((props, ref) => {\n const {\n children,\n variant = 'info',\n dismissable = false,\n onClick,\n expanderChildren,\n expanderButtonText,\n expanderButtonClosedText,\n expanderOpenFromStart = false,\n compactVariant,\n label,\n labelHtmlMarkup = 'h1',\n fluid = false,\n size,\n className,\n labelId,\n role,\n testId,\n } = props;\n const uuid = useUuid(labelId);\n const renderContent = (): JSX.Element => {\n const outlineVariant = compactVariant === 'outline';\n const contentClasses = classNames(styles['notification-panel__content']);\n const labelClasses = classNames(styles['notification-panel__label'], {\n [styles['notification-panel__label--no-content']]: !children && !expanderChildren,\n [styles['notification-panel__label--compact']]: !!compactVariant,\n [styles['notification-panel__label--outline']]: outlineVariant,\n });\n const childrenClasses = classNames(styles['notification-panel__children'], {\n [styles['notification-panel__children--with-label']]: label,\n [styles['notification-panel__children--expander-no-label']]: expanderChildren && !label,\n [styles['notification-panel__children--outline']]: outlineVariant,\n });\n const CustomTag = labelHtmlMarkup;\n\n const [expanderOpen, setExpanderOpen] = React.useState(expanderOpenFromStart);\n return (\n <div className={contentClasses} id={!label ? uuid : undefined}>\n {label && (\n <CustomTag className={labelClasses} id={uuid}>\n {label}\n </CustomTag>\n )}\n {children && <div className={childrenClasses}>{children}</div>}\n {expanderChildren && expanderButtonText && expanderButtonClosedText && !compactVariant && (\n <Expander\n title={expanderOpen ? expanderButtonText : expanderButtonClosedText}\n onExpand={setExpanderOpen}\n expanded={expanderOpen}\n testId=\"expand\"\n >\n {expanderChildren}\n </Expander>\n )}\n </div>\n );\n };\n\n const notificationPanelClasses = classNames(\n styles['notification-panel'],\n styles[`notification-panel--${variant}`],\n size && styles[`notification-panel--${size}`],\n {\n [styles['notification-panel--compact']]: !!compactVariant,\n [styles['notification-panel--compact--basic']]: compactVariant === 'basic',\n [styles['notification-panel--compact--outline']]: compactVariant === 'outline',\n [styles['notification-panel--with-content']]: expanderChildren || (label && children),\n [styles['notification-panel--dismissable']]: dismissable,\n },\n className\n );\n\n const ariaRole = role || (variant === 'error' && 'alert') || undefined;\n const ariaLabelAttributes = ariaRole ? getAriaLabelAttributes({ label, id: uuid }) : undefined;\n\n return (\n <FluidWrapper fluid={fluid}>\n <div\n ref={ref}\n role={ariaRole}\n data-testid={testId}\n data-analyticsid={AnalyticsId.NotificationPanel}\n className={notificationPanelClasses}\n {...ariaLabelAttributes}\n >\n <NotificationBadge\n variant={variant}\n size={compactVariant ? IconSize.XSmall : IconSize.Small}\n className={styles['notification-panel__icon']}\n />\n {dismissable && (\n <span className={styles['notification-panel__close']}>\n <Close ariaLabel={props.ariaLabelCloseBtn} onClick={onClick} color={getColor('black')} />\n </span>\n )}\n {renderContent()}\n </div>\n </FluidWrapper>\n );\n});\n\nexport default NotificationPanel;\n"],"names":["React"],"mappings":";;;;;;;;;;;AA8DA,MAAM,eAAyC,CAAC,EAAE,OAAO,eAAe;AACtE,MAAI,OAAO;AACT,UAAM,eAAe,WAAW,OAAO,eAAe,CAAC;AAEvD,WAAQ,oBAAA,OAAA,EAAI,WAAW,cAAe,SAAS,CAAA;AAAA,EAAA;AAE1C,SAAA;AACT;AAEA,MAAM,oBAAoBA,eAAM,WAAmD,CAAC,OAAO,QAAQ;AAC3F,QAAA;AAAA,IACJ;AAAA,IACA,UAAU;AAAA,IACV,cAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,wBAAwB;AAAA,IACxB;AAAA,IACA;AAAA,IACA,kBAAkB;AAAA,IAClB,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACE;AACE,QAAA,OAAO,QAAQ,OAAO;AAC5B,QAAM,gBAAgB,MAAmB;AACvC,UAAM,iBAAiB,mBAAmB;AAC1C,UAAM,iBAAiB,WAAW,OAAO,6BAA6B,CAAC;AACvE,UAAM,eAAe,WAAW,OAAO,2BAA2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AC,OAAO,kCAAkC,CAAC,GAAG,oBAAqB,SAAS;AAAA,MAC5E,CAAC,OAAO,iCAAiC,CAAC,GAAG;AAAA,IAC/C;AAAA,IACA;AAAA,EACF;AAEA,QAAM,WAAW,QAAS,YAAY,WAAW,WAAY;AACvD,QAAA,sBAAsB,WAAW,uBAAuB,EAAE,OAAO,IAAI,KAAM,CAAA,IAAI;AAGnF,SAAA,oBAAC,gBAAa,OACZ,UAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,MAAM;AAAA,MACN,eAAa;AAAA,MACb,oBAAkB,YAAY;AAAA,MAC9B,WAAW;AAAA,MACV,GAAG;AAAA,MAEJ,UAAA;AAAA,QAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC;AAAA,YACA,MAAM,iBAAiB,SAAS,SAAS,SAAS;AAAA,YAClD,WAAW,OAAO,0BAA0B;AAAA,UAAA;AAAA,QAC9C;AAAA,QACC,eACE,oBAAA,QAAA,EAAK,WAAW,OAAO,2BAA2B,GACjD,UAAA,oBAAC,OAAM,EAAA,WAAW,MAAM,mBAAmB,SAAkB,OAAO,SAAS,OAAO,EAAG,CAAA,GACzF;AAAA,QAED,cAAc;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,GAEnB;AAEJ,CAAC;"}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
@use 'sass:map';
|
|
2
|
-
@
|
|
3
|
-
@
|
|
4
|
-
@
|
|
5
|
-
@
|
|
6
|
-
@
|
|
2
|
+
@use '../../scss/spacers' as spacers;
|
|
3
|
+
@use '../../scss/font-settings' as font-settings;
|
|
4
|
+
@use '../../scss/palette' as palette;
|
|
5
|
+
@use '../AnchorLink/styles.module' as anchorlink;
|
|
6
|
+
@use '../../scss/breakpoints' as *;
|
|
7
7
|
|
|
8
8
|
.notification-panel {
|
|
9
9
|
$panel: &;
|
|
10
10
|
|
|
11
11
|
display: flex;
|
|
12
|
-
padding: getSpacer(2xs) getSpacer(s) getSpacer(2xs) getSpacer(2xs);
|
|
12
|
+
padding: spacers.getSpacer(2xs) spacers.getSpacer(s) spacers.getSpacer(2xs) spacers.getSpacer(2xs);
|
|
13
13
|
box-shadow: 0.25rem 0.25rem 0.375rem rgb(0 0 0 / 15%);
|
|
14
14
|
border-radius: 0.25rem;
|
|
15
15
|
|
|
16
16
|
@media (min-width: map.get($grid-breakpoints, md)) {
|
|
17
|
-
padding-left: getSpacer(s);
|
|
18
|
-
padding-right: getSpacer(m);
|
|
17
|
+
padding-left: spacers.getSpacer(s);
|
|
18
|
+
padding-right: spacers.getSpacer(m);
|
|
19
19
|
#{$panel}__icon {
|
|
20
|
-
margin-right: getSpacer(m);
|
|
20
|
+
margin-right: spacers.getSpacer(m);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
&--compact {
|
|
25
25
|
width: fit-content;
|
|
26
|
-
font-size:
|
|
26
|
+
font-size: font-settings.$font-size-xs;
|
|
27
27
|
line-height: 1.25rem;
|
|
28
28
|
box-shadow: none;
|
|
29
29
|
|
|
30
30
|
@media (min-width: map.get($grid-breakpoints, md)) {
|
|
31
|
-
padding-left: getSpacer(2xs);
|
|
32
|
-
padding-right: getSpacer(s);
|
|
31
|
+
padding-left: spacers.getSpacer(2xs);
|
|
32
|
+
padding-right: spacers.getSpacer(s);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
&--outline {
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
#{$panel}__icon {
|
|
40
|
-
margin-right: getSpacer(2xs);
|
|
40
|
+
margin-right: spacers.getSpacer(2xs);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
&--dismissable {
|
|
44
|
-
padding: getSpacer(2xs) getSpacer(2xs) getSpacer(m);
|
|
44
|
+
padding: spacers.getSpacer(2xs) spacers.getSpacer(2xs) spacers.getSpacer(m);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
&--small {
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
&--info {
|
|
60
|
-
border: 0.125rem solid
|
|
61
|
-
background-color:
|
|
60
|
+
border: 0.125rem solid palette.$blueberry700;
|
|
61
|
+
background-color: palette.$blueberry50;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
&--info#{&}--compact {
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
&--warn {
|
|
74
|
-
border: 0.125rem solid
|
|
75
|
-
background-color:
|
|
74
|
+
border: 0.125rem solid palette.$banana700;
|
|
75
|
+
background-color: palette.$banana50;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
&--warn#{&}--compact {
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
&--error {
|
|
88
|
-
border: 0.125rem solid
|
|
89
|
-
background-color:
|
|
88
|
+
border: 0.125rem solid palette.$cherry700;
|
|
89
|
+
background-color: palette.$cherry50;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
&--error#{&}--compact {
|
|
@@ -99,8 +99,8 @@
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
&--success {
|
|
102
|
-
border: 0.125rem solid
|
|
103
|
-
background-color:
|
|
102
|
+
border: 0.125rem solid palette.$kiwi900;
|
|
103
|
+
background-color: palette.$kiwi50;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
&--success#{&}--compact {
|
|
@@ -115,36 +115,36 @@
|
|
|
115
115
|
&__close {
|
|
116
116
|
order: 1;
|
|
117
117
|
margin-left: auto;
|
|
118
|
-
padding-left: getSpacer(2xs);
|
|
118
|
+
padding-left: spacers.getSpacer(2xs);
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
&__content {
|
|
122
122
|
align-self: center;
|
|
123
123
|
|
|
124
124
|
a {
|
|
125
|
-
@include anchorlink;
|
|
126
|
-
@include anchorlink-icon;
|
|
125
|
+
@include anchorlink.anchorlink;
|
|
126
|
+
@include anchorlink.anchorlink-icon;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
&__label,
|
|
131
131
|
&__children {
|
|
132
|
-
font-size:
|
|
133
|
-
line-height:
|
|
132
|
+
font-size: font-settings.$font-size-xs;
|
|
133
|
+
line-height: font-settings.$lineheight-size-xs;
|
|
134
134
|
margin: 0;
|
|
135
135
|
|
|
136
136
|
@media (min-width: map.get($grid-breakpoints, md)) {
|
|
137
|
-
font-size:
|
|
137
|
+
font-size: font-settings.$font-size-sm;
|
|
138
138
|
line-height: 1.625rem;
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
&__label {
|
|
143
143
|
font-weight: 700;
|
|
144
|
-
margin: getSpacer(2xs) 0 0;
|
|
144
|
+
margin: spacers.getSpacer(2xs) 0 0;
|
|
145
145
|
|
|
146
146
|
&--compact {
|
|
147
|
-
font-size:
|
|
147
|
+
font-size: font-settings.$font-size-xs;
|
|
148
148
|
line-height: 1.25rem;
|
|
149
149
|
}
|
|
150
150
|
|
|
@@ -164,14 +164,14 @@
|
|
|
164
164
|
|
|
165
165
|
&__children {
|
|
166
166
|
font-weight: 600;
|
|
167
|
-
padding: getSpacer(3xs) 0;
|
|
167
|
+
padding: spacers.getSpacer(3xs) 0;
|
|
168
168
|
|
|
169
169
|
&--with-label {
|
|
170
170
|
font-weight: 500;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
&--expander-no-label {
|
|
174
|
-
margin: getSpacer(2xs) 0 0;
|
|
174
|
+
margin: spacers.getSpacer(2xs) 0 0;
|
|
175
175
|
|
|
176
176
|
@media (max-width: map.get($grid-breakpoints, lg)) {
|
|
177
177
|
padding-top: 0;
|
|
@@ -188,7 +188,7 @@
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
&--with-content {
|
|
191
|
-
padding-bottom: getSpacer(xs);
|
|
191
|
+
padding-bottom: spacers.getSpacer(xs);
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
|