@a-little-world/little-world-design-system 2.10.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/.babelrc +7 -0
- package/.storybook/main.ts +36 -0
- package/.storybook/preview-head.html +6 -0
- package/.storybook/preview.ts +15 -0
- package/.turbo/turbo-build.log +14 -0
- package/CHANGELOG.md +398 -0
- package/LICENSE +21 -0
- package/README.md +180 -0
- package/__mocks__/focus-trap-react.tsx +1 -0
- package/__mocks__/svg.tsx +6 -0
- package/dist/cjs/components/Accordion/Accordion.d.ts +15 -0
- package/dist/cjs/components/Accordion/Accordion.js +20 -0
- package/dist/cjs/components/Accordion/styles.d.ts +18 -0
- package/dist/cjs/components/Accordion/styles.js +100 -0
- package/dist/cjs/components/Button/Button.d.ts +9 -0
- package/dist/cjs/components/Button/Button.js +17 -0
- package/dist/cjs/components/Button/styles.d.ts +16 -0
- package/dist/cjs/components/Button/styles.js +313 -0
- package/dist/cjs/components/Card/Card.d.ts +11 -0
- package/dist/cjs/components/Card/Card.js +108 -0
- package/dist/cjs/components/Checkbox/Checkbox.d.ts +15 -0
- package/dist/cjs/components/Checkbox/Checkbox.js +24 -0
- package/dist/cjs/components/Checkbox/styles.d.ts +27 -0
- package/dist/cjs/components/Checkbox/styles.js +108 -0
- package/dist/cjs/components/CheckboxGrid/CheckboxGrid.d.ts +22 -0
- package/dist/cjs/components/CheckboxGrid/CheckboxGrid.js +73 -0
- package/dist/cjs/components/CheckboxGrid/styles.d.ts +64 -0
- package/dist/cjs/components/CheckboxGrid/styles.js +137 -0
- package/dist/cjs/components/Dropdown/Dropdown.d.ts +25 -0
- package/dist/cjs/components/Dropdown/Dropdown.js +70 -0
- package/dist/cjs/components/Dropdown/styles.d.ts +15 -0
- package/dist/cjs/components/Dropdown/styles.js +145 -0
- package/dist/cjs/components/Icon/Icon.d.ts +10 -0
- package/dist/cjs/components/Icon/Icon.js +82 -0
- package/dist/cjs/components/Icon/IconGradient.d.ts +4 -0
- package/dist/cjs/components/Icon/IconGradient.js +29 -0
- package/dist/cjs/components/Icon/createIconComponent.d.ts +10 -0
- package/dist/cjs/components/Icon/createIconComponent.js +31 -0
- package/dist/cjs/components/Icon/getDefaultIconProps.d.ts +2 -0
- package/dist/cjs/components/Icon/getDefaultIconProps.js +15 -0
- package/dist/cjs/components/Icon/index.d.ts +553 -0
- package/dist/cjs/components/Icon/index.js +342 -0
- package/dist/cjs/components/Illustrations/Illustration.d.ts +3 -0
- package/dist/cjs/components/Illustrations/Illustration.js +12 -0
- package/dist/cjs/components/Illustrations/createIllustrationComponent.d.ts +10 -0
- package/dist/cjs/components/Illustrations/createIllustrationComponent.js +23 -0
- package/dist/cjs/components/Illustrations/index.d.ts +152 -0
- package/dist/cjs/components/Illustrations/index.js +81 -0
- package/dist/cjs/components/InputError/InputError.d.ts +15 -0
- package/dist/cjs/components/InputError/InputError.js +79 -0
- package/dist/cjs/components/Label/Label.d.ts +10 -0
- package/dist/cjs/components/Label/Label.js +68 -0
- package/dist/cjs/components/Link/Link.d.ts +6 -0
- package/dist/cjs/components/Link/Link.js +48 -0
- package/dist/cjs/components/Link/styles.d.ts +22 -0
- package/dist/cjs/components/Link/styles.js +99 -0
- package/dist/cjs/components/Loading/Loading.d.ts +10 -0
- package/dist/cjs/components/Loading/Loading.js +27 -0
- package/dist/cjs/components/Loading/LoadingLogo.d.ts +8 -0
- package/dist/cjs/components/Loading/LoadingLogo.js +31 -0
- package/dist/cjs/components/Loading/styles.d.ts +15 -0
- package/dist/cjs/components/Loading/styles.js +107 -0
- package/dist/cjs/components/Modal/Modal.d.ts +20 -0
- package/dist/cjs/components/Modal/Modal.js +95 -0
- package/dist/cjs/components/Modal/styles.d.ts +4 -0
- package/dist/cjs/components/Modal/styles.js +102 -0
- package/dist/cjs/components/MultiCheckbox/MultiCheckbox.d.ts +15 -0
- package/dist/cjs/components/MultiCheckbox/MultiCheckbox.js +61 -0
- package/dist/cjs/components/MultiCheckbox/styles.d.ts +1 -0
- package/dist/cjs/components/MultiCheckbox/styles.js +15 -0
- package/dist/cjs/components/MultiDropdown/MultiDropdown.d.ts +28 -0
- package/dist/cjs/components/MultiDropdown/MultiDropdown.js +124 -0
- package/dist/cjs/components/MultiDropdown/styles.d.ts +7 -0
- package/dist/cjs/components/MultiDropdown/styles.js +44 -0
- package/dist/cjs/components/MultiSelection/MultiSelection.d.ts +16 -0
- package/dist/cjs/components/MultiSelection/MultiSelection.js +62 -0
- package/dist/cjs/components/MultiSelection/styles.d.ts +9 -0
- package/dist/cjs/components/MultiSelection/styles.js +99 -0
- package/dist/cjs/components/NavigationMenu/NavigationMenu.d.ts +35 -0
- package/dist/cjs/components/NavigationMenu/NavigationMenu.js +85 -0
- package/dist/cjs/components/NavigationMenu/styles.d.ts +81 -0
- package/dist/cjs/components/NavigationMenu/styles.js +296 -0
- package/dist/cjs/components/Popover/InfoPopover.d.ts +8 -0
- package/dist/cjs/components/Popover/InfoPopover.js +46 -0
- package/dist/cjs/components/Popover/Popover.d.ts +16 -0
- package/dist/cjs/components/Popover/Popover.js +61 -0
- package/dist/cjs/components/Popover/styles.d.ts +14 -0
- package/dist/cjs/components/Popover/styles.js +116 -0
- package/dist/cjs/components/ProgressBar/ProgressBar.d.ts +8 -0
- package/dist/cjs/components/ProgressBar/ProgressBar.js +85 -0
- package/dist/cjs/components/RadioGroup/RadioGroup.d.ts +16 -0
- package/dist/cjs/components/RadioGroup/RadioGroup.js +24 -0
- package/dist/cjs/components/RadioGroup/styles.d.ts +12 -0
- package/dist/cjs/components/RadioGroup/styles.js +126 -0
- package/dist/cjs/components/Separator/Separator.d.ts +11 -0
- package/dist/cjs/components/Separator/Separator.js +61 -0
- package/dist/cjs/components/Separator/styles.d.ts +6 -0
- package/dist/cjs/components/Separator/styles.js +57 -0
- package/dist/cjs/components/Slider/Slider.d.ts +12 -0
- package/dist/cjs/components/Slider/Slider.js +17 -0
- package/dist/cjs/components/Slider/styles.d.ts +6 -0
- package/dist/cjs/components/Slider/styles.js +57 -0
- package/dist/cjs/components/StarRating/StarRating.d.ts +22 -0
- package/dist/cjs/components/StarRating/StarRating.js +143 -0
- package/dist/cjs/components/StarRating/styles.d.ts +35 -0
- package/dist/cjs/components/StarRating/styles.js +104 -0
- package/dist/cjs/components/StatusMessage/StatusMessage.d.ts +4 -0
- package/dist/cjs/components/StatusMessage/StatusMessage.js +112 -0
- package/dist/cjs/components/Switch/Switch.d.ts +15 -0
- package/dist/cjs/components/Switch/Switch.js +19 -0
- package/dist/cjs/components/Switch/styles.d.ts +14 -0
- package/dist/cjs/components/Switch/styles.js +99 -0
- package/dist/cjs/components/Tags/Tags.d.ts +15 -0
- package/dist/cjs/components/Tags/Tags.js +17 -0
- package/dist/cjs/components/Tags/styles.d.ts +19 -0
- package/dist/cjs/components/Tags/styles.js +119 -0
- package/dist/cjs/components/Text/Text.d.ts +11 -0
- package/dist/cjs/components/Text/Text.js +13 -0
- package/dist/cjs/components/Text/styles.d.ts +8 -0
- package/dist/cjs/components/Text/styles.js +98 -0
- package/dist/cjs/components/Text/types.d.ts +8 -0
- package/dist/cjs/components/Text/types.js +2 -0
- package/dist/cjs/components/TextArea/TextArea.d.ts +19 -0
- package/dist/cjs/components/TextArea/TextArea.js +84 -0
- package/dist/cjs/components/TextArea/styles.d.ts +22 -0
- package/dist/cjs/components/TextArea/styles.js +81 -0
- package/dist/cjs/components/TextContent/TextContent.d.ts +28 -0
- package/dist/cjs/components/TextContent/TextContent.js +46 -0
- package/dist/cjs/components/TextContent/styles.d.ts +24 -0
- package/dist/cjs/components/TextContent/styles.js +75 -0
- package/dist/cjs/components/TextInput/TextInput.d.ts +8 -0
- package/dist/cjs/components/TextInput/TextInput.js +49 -0
- package/dist/cjs/components/TextInput/styles.d.ts +18 -0
- package/dist/cjs/components/TextInput/styles.js +150 -0
- package/dist/cjs/components/Toast/Toast.d.ts +5 -0
- package/dist/cjs/components/Toast/Toast.js +90 -0
- package/dist/cjs/components/Toast/styles.d.ts +27 -0
- package/dist/cjs/components/Toast/styles.js +164 -0
- package/dist/cjs/components/Tooltip/Tooltip.d.ts +9 -0
- package/dist/cjs/components/Tooltip/Tooltip.js +55 -0
- package/dist/cjs/components/Tooltip/styles.d.ts +2 -0
- package/dist/cjs/components/Tooltip/styles.js +24 -0
- package/dist/cjs/components/Widget/AttachmentWidget.d.ts +18 -0
- package/dist/cjs/components/Widget/AttachmentWidget.js +124 -0
- package/dist/cjs/components/Widget/CallWidget.d.ts +11 -0
- package/dist/cjs/components/Widget/CallWidget.js +84 -0
- package/dist/cjs/components/Widget/Widget.d.ts +26 -0
- package/dist/cjs/components/Widget/Widget.js +87 -0
- package/dist/cjs/globalStyles.d.ts +5 -0
- package/dist/cjs/globalStyles.js +66 -0
- package/dist/cjs/hooks/useAutosizeTextArea.d.ts +2 -0
- package/dist/cjs/hooks/useAutosizeTextArea.js +14 -0
- package/dist/cjs/index.d.ts +51 -0
- package/dist/cjs/index.js +139 -0
- package/dist/cjs/storybook/BreakpointDocumentation.d.ts +3 -0
- package/dist/cjs/storybook/BreakpointDocumentation.js +139 -0
- package/dist/cjs/storybook/Components.d.ts +2 -0
- package/dist/cjs/storybook/Components.js +30 -0
- package/dist/cjs/storybook/Documentation.d.ts +5 -0
- package/dist/cjs/storybook/Documentation.js +67 -0
- package/dist/cjs/storybook/RadiusDocumentation.d.ts +3 -0
- package/dist/cjs/storybook/RadiusDocumentation.js +150 -0
- package/dist/cjs/storybook/SpacingDocumentation.d.ts +3 -0
- package/dist/cjs/storybook/SpacingDocumentation.js +146 -0
- package/dist/cjs/theme/index.d.ts +17 -0
- package/dist/cjs/theme/index.js +90 -0
- package/dist/cjs/utils/animations.d.ts +12 -0
- package/dist/cjs/utils/animations.js +120 -0
- package/dist/cjs/utils/createReactSvg.d.ts +3 -0
- package/dist/cjs/utils/createReactSvg.js +77 -0
- package/dist/cjs/utils/parser.d.ts +12 -0
- package/dist/cjs/utils/parser.js +200 -0
- package/dist/cjs/utils/replaceUrlsWithAnchors.d.ts +6 -0
- package/dist/cjs/utils/replaceUrlsWithAnchors.js +32 -0
- package/dist/cjs/utils/status.d.ts +6 -0
- package/dist/cjs/utils/status.js +54 -0
- package/dist/cjs/utils/styles.d.ts +1 -0
- package/dist/cjs/utils/styles.js +5 -0
- package/dist/cjs/utils/types.d.ts +1 -0
- package/dist/cjs/utils/types.js +2 -0
- package/dist/esm/components/Accordion/Accordion.d.ts +15 -0
- package/dist/esm/components/Accordion/Accordion.js +14 -0
- package/dist/esm/components/Accordion/styles.d.ts +18 -0
- package/dist/esm/components/Accordion/styles.js +61 -0
- package/dist/esm/components/Button/Button.d.ts +9 -0
- package/dist/esm/components/Button/Button.js +10 -0
- package/dist/esm/components/Button/styles.d.ts +16 -0
- package/dist/esm/components/Button/styles.js +277 -0
- package/dist/esm/components/Card/Card.d.ts +11 -0
- package/dist/esm/components/Card/Card.js +66 -0
- package/dist/esm/components/Checkbox/Checkbox.d.ts +15 -0
- package/dist/esm/components/Checkbox/Checkbox.js +17 -0
- package/dist/esm/components/Checkbox/styles.d.ts +27 -0
- package/dist/esm/components/Checkbox/styles.js +69 -0
- package/dist/esm/components/CheckboxGrid/CheckboxGrid.d.ts +22 -0
- package/dist/esm/components/CheckboxGrid/CheckboxGrid.js +35 -0
- package/dist/esm/components/CheckboxGrid/styles.d.ts +64 -0
- package/dist/esm/components/CheckboxGrid/styles.js +98 -0
- package/dist/esm/components/Dropdown/Dropdown.d.ts +25 -0
- package/dist/esm/components/Dropdown/Dropdown.js +32 -0
- package/dist/esm/components/Dropdown/styles.d.ts +15 -0
- package/dist/esm/components/Dropdown/styles.js +106 -0
- package/dist/esm/components/Icon/Icon.d.ts +10 -0
- package/dist/esm/components/Icon/Icon.js +42 -0
- package/dist/esm/components/Icon/IconGradient.d.ts +4 -0
- package/dist/esm/components/Icon/IconGradient.js +24 -0
- package/dist/esm/components/Icon/createIconComponent.d.ts +10 -0
- package/dist/esm/components/Icon/createIconComponent.js +24 -0
- package/dist/esm/components/Icon/getDefaultIconProps.d.ts +2 -0
- package/dist/esm/components/Icon/getDefaultIconProps.js +11 -0
- package/dist/esm/components/Icon/index.d.ts +553 -0
- package/dist/esm/components/Icon/index.js +338 -0
- package/dist/esm/components/Illustrations/Illustration.d.ts +3 -0
- package/dist/esm/components/Illustrations/Illustration.js +5 -0
- package/dist/esm/components/Illustrations/createIllustrationComponent.d.ts +10 -0
- package/dist/esm/components/Illustrations/createIllustrationComponent.js +16 -0
- package/dist/esm/components/Illustrations/index.d.ts +152 -0
- package/dist/esm/components/Illustrations/index.js +78 -0
- package/dist/esm/components/InputError/InputError.d.ts +15 -0
- package/dist/esm/components/InputError/InputError.js +40 -0
- package/dist/esm/components/Label/Label.d.ts +10 -0
- package/dist/esm/components/Label/Label.js +30 -0
- package/dist/esm/components/Link/Link.d.ts +6 -0
- package/dist/esm/components/Link/Link.js +13 -0
- package/dist/esm/components/Link/styles.d.ts +22 -0
- package/dist/esm/components/Link/styles.js +63 -0
- package/dist/esm/components/Loading/Loading.d.ts +10 -0
- package/dist/esm/components/Loading/Loading.js +21 -0
- package/dist/esm/components/Loading/LoadingLogo.d.ts +8 -0
- package/dist/esm/components/Loading/LoadingLogo.js +26 -0
- package/dist/esm/components/Loading/styles.d.ts +15 -0
- package/dist/esm/components/Loading/styles.js +71 -0
- package/dist/esm/components/Modal/Modal.d.ts +20 -0
- package/dist/esm/components/Modal/Modal.js +59 -0
- package/dist/esm/components/Modal/styles.d.ts +4 -0
- package/dist/esm/components/Modal/styles.js +63 -0
- package/dist/esm/components/MultiCheckbox/MultiCheckbox.d.ts +15 -0
- package/dist/esm/components/MultiCheckbox/MultiCheckbox.js +23 -0
- package/dist/esm/components/MultiCheckbox/styles.d.ts +1 -0
- package/dist/esm/components/MultiCheckbox/styles.js +9 -0
- package/dist/esm/components/MultiDropdown/MultiDropdown.d.ts +28 -0
- package/dist/esm/components/MultiDropdown/MultiDropdown.js +86 -0
- package/dist/esm/components/MultiDropdown/styles.d.ts +7 -0
- package/dist/esm/components/MultiDropdown/styles.js +38 -0
- package/dist/esm/components/MultiSelection/MultiSelection.d.ts +16 -0
- package/dist/esm/components/MultiSelection/MultiSelection.js +24 -0
- package/dist/esm/components/MultiSelection/styles.d.ts +9 -0
- package/dist/esm/components/MultiSelection/styles.js +63 -0
- package/dist/esm/components/NavigationMenu/NavigationMenu.d.ts +35 -0
- package/dist/esm/components/NavigationMenu/NavigationMenu.js +40 -0
- package/dist/esm/components/NavigationMenu/styles.d.ts +81 -0
- package/dist/esm/components/NavigationMenu/styles.js +257 -0
- package/dist/esm/components/Popover/InfoPopover.d.ts +8 -0
- package/dist/esm/components/Popover/InfoPopover.js +8 -0
- package/dist/esm/components/Popover/Popover.d.ts +16 -0
- package/dist/esm/components/Popover/Popover.js +22 -0
- package/dist/esm/components/Popover/styles.d.ts +14 -0
- package/dist/esm/components/Popover/styles.js +80 -0
- package/dist/esm/components/ProgressBar/ProgressBar.d.ts +8 -0
- package/dist/esm/components/ProgressBar/ProgressBar.js +47 -0
- package/dist/esm/components/RadioGroup/RadioGroup.d.ts +16 -0
- package/dist/esm/components/RadioGroup/RadioGroup.js +19 -0
- package/dist/esm/components/RadioGroup/styles.d.ts +12 -0
- package/dist/esm/components/RadioGroup/styles.js +90 -0
- package/dist/esm/components/Separator/Separator.d.ts +11 -0
- package/dist/esm/components/Separator/Separator.js +23 -0
- package/dist/esm/components/Separator/styles.d.ts +6 -0
- package/dist/esm/components/Separator/styles.js +51 -0
- package/dist/esm/components/Slider/Slider.d.ts +12 -0
- package/dist/esm/components/Slider/Slider.js +12 -0
- package/dist/esm/components/Slider/styles.d.ts +6 -0
- package/dist/esm/components/Slider/styles.js +51 -0
- package/dist/esm/components/StarRating/StarRating.d.ts +22 -0
- package/dist/esm/components/StarRating/StarRating.js +107 -0
- package/dist/esm/components/StarRating/styles.d.ts +35 -0
- package/dist/esm/components/StarRating/styles.js +65 -0
- package/dist/esm/components/StatusMessage/StatusMessage.d.ts +4 -0
- package/dist/esm/components/StatusMessage/StatusMessage.js +74 -0
- package/dist/esm/components/Switch/Switch.d.ts +15 -0
- package/dist/esm/components/Switch/Switch.js +14 -0
- package/dist/esm/components/Switch/styles.d.ts +14 -0
- package/dist/esm/components/Switch/styles.js +63 -0
- package/dist/esm/components/Tags/Tags.d.ts +15 -0
- package/dist/esm/components/Tags/Tags.js +10 -0
- package/dist/esm/components/Tags/styles.d.ts +19 -0
- package/dist/esm/components/Tags/styles.js +80 -0
- package/dist/esm/components/Text/Text.d.ts +11 -0
- package/dist/esm/components/Text/Text.js +8 -0
- package/dist/esm/components/Text/styles.d.ts +8 -0
- package/dist/esm/components/Text/styles.js +62 -0
- package/dist/esm/components/Text/types.d.ts +8 -0
- package/dist/esm/components/Text/types.js +1 -0
- package/dist/esm/components/TextArea/TextArea.d.ts +19 -0
- package/dist/esm/components/TextArea/TextArea.js +45 -0
- package/dist/esm/components/TextArea/styles.d.ts +22 -0
- package/dist/esm/components/TextArea/styles.js +42 -0
- package/dist/esm/components/TextContent/TextContent.d.ts +28 -0
- package/dist/esm/components/TextContent/TextContent.js +40 -0
- package/dist/esm/components/TextContent/styles.d.ts +24 -0
- package/dist/esm/components/TextContent/styles.js +36 -0
- package/dist/esm/components/TextInput/TextInput.d.ts +8 -0
- package/dist/esm/components/TextInput/TextInput.js +42 -0
- package/dist/esm/components/TextInput/styles.d.ts +18 -0
- package/dist/esm/components/TextInput/styles.js +111 -0
- package/dist/esm/components/Toast/Toast.d.ts +5 -0
- package/dist/esm/components/Toast/Toast.js +54 -0
- package/dist/esm/components/Toast/styles.d.ts +27 -0
- package/dist/esm/components/Toast/styles.js +125 -0
- package/dist/esm/components/Tooltip/Tooltip.d.ts +9 -0
- package/dist/esm/components/Tooltip/Tooltip.js +16 -0
- package/dist/esm/components/Tooltip/styles.d.ts +2 -0
- package/dist/esm/components/Tooltip/styles.js +18 -0
- package/dist/esm/components/Widget/AttachmentWidget.d.ts +18 -0
- package/dist/esm/components/Widget/AttachmentWidget.js +85 -0
- package/dist/esm/components/Widget/CallWidget.d.ts +11 -0
- package/dist/esm/components/Widget/CallWidget.js +46 -0
- package/dist/esm/components/Widget/Widget.d.ts +26 -0
- package/dist/esm/components/Widget/Widget.js +46 -0
- package/dist/esm/globalStyles.d.ts +5 -0
- package/dist/esm/globalStyles.js +64 -0
- package/dist/esm/hooks/useAutosizeTextArea.d.ts +2 -0
- package/dist/esm/hooks/useAutosizeTextArea.js +12 -0
- package/dist/esm/index.d.ts +51 -0
- package/dist/esm/index.js +45 -0
- package/dist/esm/storybook/BreakpointDocumentation.d.ts +3 -0
- package/dist/esm/storybook/BreakpointDocumentation.js +101 -0
- package/dist/esm/storybook/Components.d.ts +2 -0
- package/dist/esm/storybook/Components.js +23 -0
- package/dist/esm/storybook/Documentation.d.ts +5 -0
- package/dist/esm/storybook/Documentation.js +62 -0
- package/dist/esm/storybook/RadiusDocumentation.d.ts +3 -0
- package/dist/esm/storybook/RadiusDocumentation.js +112 -0
- package/dist/esm/storybook/SpacingDocumentation.d.ts +3 -0
- package/dist/esm/storybook/SpacingDocumentation.js +108 -0
- package/dist/esm/theme/index.d.ts +17 -0
- package/dist/esm/theme/index.js +53 -0
- package/dist/esm/utils/animations.d.ts +12 -0
- package/dist/esm/utils/animations.js +117 -0
- package/dist/esm/utils/createReactSvg.d.ts +3 -0
- package/dist/esm/utils/createReactSvg.js +70 -0
- package/dist/esm/utils/parser.d.ts +12 -0
- package/dist/esm/utils/parser.js +195 -0
- package/dist/esm/utils/replaceUrlsWithAnchors.d.ts +6 -0
- package/dist/esm/utils/replaceUrlsWithAnchors.js +29 -0
- package/dist/esm/utils/status.d.ts +6 -0
- package/dist/esm/utils/status.js +49 -0
- package/dist/esm/utils/styles.d.ts +1 -0
- package/dist/esm/utils/styles.js +1 -0
- package/dist/esm/utils/types.d.ts +1 -0
- package/dist/esm/utils/types.js +1 -0
- package/jest.config.ts +30 -0
- package/package.json +98 -0
- package/src/components/Accordion/Accordion.stories.tsx +66 -0
- package/src/components/Accordion/Accordion.tsx +59 -0
- package/src/components/Accordion/styles.tsx +68 -0
- package/src/components/Button/Button.stories.tsx +119 -0
- package/src/components/Button/Button.tsx +59 -0
- package/src/components/Button/styles.tsx +313 -0
- package/src/components/Card/Card.stories.tsx +22 -0
- package/src/components/Card/Card.tsx +125 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +11 -0
- package/src/components/Checkbox/Checkbox.tsx +112 -0
- package/src/components/Checkbox/styles.tsx +96 -0
- package/src/components/CheckboxGrid/CheckboxGrid.stories.tsx +49 -0
- package/src/components/CheckboxGrid/CheckboxGrid.tsx +126 -0
- package/src/components/CheckboxGrid/styles.tsx +122 -0
- package/src/components/Dropdown/Dropdown.stories.tsx +59 -0
- package/src/components/Dropdown/Dropdown.tsx +128 -0
- package/src/components/Dropdown/styles.tsx +120 -0
- package/src/components/Icon/Icon.stories.tsx +44 -0
- package/src/components/Icon/Icon.test.tsx +20 -0
- package/src/components/Icon/Icon.tsx +88 -0
- package/src/components/Icon/IconDocs.mdx +22 -0
- package/src/components/Icon/IconGradient.tsx +70 -0
- package/src/components/Icon/createIconComponent.tsx +63 -0
- package/src/components/Icon/getDefaultIconProps.ts +23 -0
- package/src/components/Icon/index.ts +499 -0
- package/src/components/Illustrations/Illustration.tsx +18 -0
- package/src/components/Illustrations/Illustrations.stories.tsx +53 -0
- package/src/components/Illustrations/createIllustrationComponent.tsx +39 -0
- package/src/components/Illustrations/index.ts +118 -0
- package/src/components/InputError/InputError.tsx +86 -0
- package/src/components/Label/Label.stories.tsx +18 -0
- package/src/components/Label/Label.tsx +76 -0
- package/src/components/Link/Link.stories.tsx +14 -0
- package/src/components/Link/Link.test.tsx +27 -0
- package/src/components/Link/Link.tsx +68 -0
- package/src/components/Link/styles.tsx +86 -0
- package/src/components/Loading/Loading.stories.tsx +26 -0
- package/src/components/Loading/Loading.tsx +65 -0
- package/src/components/Loading/LoadingLogo.tsx +141 -0
- package/src/components/Loading/styles.ts +95 -0
- package/src/components/Modal/Modal.stories.tsx +52 -0
- package/src/components/Modal/Modal.test.tsx +98 -0
- package/src/components/Modal/Modal.tsx +115 -0
- package/src/components/Modal/ModalDocs.mdx +21 -0
- package/src/components/Modal/styles.tsx +67 -0
- package/src/components/MultiCheckbox/MultiCheckbox.stories.tsx +24 -0
- package/src/components/MultiCheckbox/MultiCheckbox.tsx +73 -0
- package/src/components/MultiCheckbox/styles.tsx +10 -0
- package/src/components/MultiDropdown/MultiDropdown.stories.tsx +105 -0
- package/src/components/MultiDropdown/MultiDropdown.tsx +247 -0
- package/src/components/MultiDropdown/styles.tsx +45 -0
- package/src/components/MultiSelection/MultiSelection.stories.tsx +19 -0
- package/src/components/MultiSelection/MultiSelection.tsx +74 -0
- package/src/components/MultiSelection/styles.tsx +78 -0
- package/src/components/NavigationMenu/NavigationMenu.stories.tsx +108 -0
- package/src/components/NavigationMenu/NavigationMenu.tsx +151 -0
- package/src/components/NavigationMenu/styles.tsx +293 -0
- package/src/components/Popover/InfoPopover.tsx +40 -0
- package/src/components/Popover/Popover.stories.tsx +85 -0
- package/src/components/Popover/Popover.tsx +68 -0
- package/src/components/Popover/styles.tsx +109 -0
- package/src/components/ProgressBar/ProgressBar.stories.tsx +15 -0
- package/src/components/ProgressBar/ProgressBar.tsx +76 -0
- package/src/components/RadioGroup/RadioGroup.stories.tsx +42 -0
- package/src/components/RadioGroup/RadioGroup.tsx +91 -0
- package/src/components/RadioGroup/styles.tsx +100 -0
- package/src/components/Separator/Separator.stories.tsx +27 -0
- package/src/components/Separator/Separator.tsx +52 -0
- package/src/components/Separator/styles.tsx +57 -0
- package/src/components/Slider/Slider.stories.tsx +27 -0
- package/src/components/Slider/Slider.tsx +61 -0
- package/src/components/Slider/styles.tsx +57 -0
- package/src/components/StarRating/StarRating.stories.tsx +20 -0
- package/src/components/StarRating/StarRating.tsx +212 -0
- package/src/components/StarRating/styles.ts +76 -0
- package/src/components/StatusMessage/StatusMessage.stories.tsx +44 -0
- package/src/components/StatusMessage/StatusMessage.tsx +110 -0
- package/src/components/Switch/Switch.stories.tsx +12 -0
- package/src/components/Switch/Switch.tsx +83 -0
- package/src/components/Switch/styles.tsx +75 -0
- package/src/components/Tags/Tags.stories.tsx +44 -0
- package/src/components/Tags/Tags.tsx +68 -0
- package/src/components/Tags/styles.tsx +89 -0
- package/src/components/Text/Text.stories.tsx +288 -0
- package/src/components/Text/Text.tsx +58 -0
- package/src/components/Text/styles.tsx +75 -0
- package/src/components/Text/types.ts +9 -0
- package/src/components/Text/typography.mdx +91 -0
- package/src/components/TextArea/TextArea.stories.tsx +26 -0
- package/src/components/TextArea/TextArea.tsx +117 -0
- package/src/components/TextArea/styles.tsx +58 -0
- package/src/components/TextContent/TextContent.stories.tsx +54 -0
- package/src/components/TextContent/TextContent.tsx +154 -0
- package/src/components/TextContent/styles.tsx +47 -0
- package/src/components/TextInput/TextInput.stories.tsx +43 -0
- package/src/components/TextInput/TextInput.tsx +146 -0
- package/src/components/TextInput/styles.tsx +129 -0
- package/src/components/Toast/Toast.stories.tsx +55 -0
- package/src/components/Toast/Toast.tsx +139 -0
- package/src/components/Toast/styles.tsx +142 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +31 -0
- package/src/components/Tooltip/Tooltip.tsx +48 -0
- package/src/components/Tooltip/styles.tsx +20 -0
- package/src/components/Widget/AttachmentWidget.stories.tsx +14 -0
- package/src/components/Widget/AttachmentWidget.tsx +142 -0
- package/src/components/Widget/CallWidget.stories.tsx +38 -0
- package/src/components/Widget/CallWidget.tsx +114 -0
- package/src/components/Widget/Widget.stories.tsx +10 -0
- package/src/components/Widget/Widget.tsx +104 -0
- package/src/globalStyles.ts +68 -0
- package/src/hooks/useAutosizeTextArea.tsx +19 -0
- package/src/index.ts +107 -0
- package/src/setupTests.ts +8 -0
- package/src/storybook/BreakpointDocumentation.tsx +126 -0
- package/src/storybook/Components.tsx +29 -0
- package/src/storybook/Documentation.tsx +86 -0
- package/src/storybook/RadiusDocumentation.tsx +133 -0
- package/src/storybook/SpacingDocumentation.tsx +131 -0
- package/src/storybook/breakpoints.mdx +83 -0
- package/src/storybook/colors.mdx +118 -0
- package/src/storybook/radius.mdx +48 -0
- package/src/storybook/spacing.mdx +45 -0
- package/src/testUtils.tsx +49 -0
- package/src/theme/index.tsx +98 -0
- package/src/utils/animations.ts +129 -0
- package/src/utils/createReactSvg.tsx +140 -0
- package/src/utils/parser.mdx +41 -0
- package/src/utils/parser.test.tsx +542 -0
- package/src/utils/parser.tsx +333 -0
- package/src/utils/replaceUrlsWithAnchors.test.ts +42 -0
- package/src/utils/replaceUrlsWithAnchors.ts +32 -0
- package/src/utils/status.tsx +85 -0
- package/src/utils/styles.ts +1 -0
- package/src/utils/types.ts +1 -0
- package/tsconfig.json +34 -0
- package/tsconfig.test.json +16 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import styled, { keyframes } from 'styled-components';
|
|
2
|
+
import {
|
|
3
|
+
LoadingDimensions,
|
|
4
|
+
LoadingSizes,
|
|
5
|
+
LoadingType,
|
|
6
|
+
} from '@a-little-world/little-world-design-system-core';
|
|
7
|
+
import { pixelate } from '../../utils/styles';
|
|
8
|
+
|
|
9
|
+
const loading = keyframes`
|
|
10
|
+
0% {
|
|
11
|
+
transform: rotate(0deg);
|
|
12
|
+
}
|
|
13
|
+
100% {
|
|
14
|
+
transform: rotate(360deg);
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
const logoPulse = keyframes`
|
|
19
|
+
0%, 100% {
|
|
20
|
+
transform: scale(1);
|
|
21
|
+
}
|
|
22
|
+
50% {
|
|
23
|
+
transform: scale(1.03);
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
export const LoadingContainer = styled.div<{
|
|
28
|
+
$align?: string;
|
|
29
|
+
$color?: string;
|
|
30
|
+
$inline?: boolean;
|
|
31
|
+
$size?: LoadingSizes;
|
|
32
|
+
$type?: LoadingType;
|
|
33
|
+
}>`
|
|
34
|
+
display: ${({ $inline }) => ($inline ? 'inline-flex' : 'flex')};
|
|
35
|
+
align-items: center;
|
|
36
|
+
justify-content: ${({ $align }) => $align || 'center'};
|
|
37
|
+
position: relative;
|
|
38
|
+
width: ${({ $inline, $size }) =>
|
|
39
|
+
$inline
|
|
40
|
+
? pixelate(LoadingDimensions[$size || LoadingSizes.Small])
|
|
41
|
+
: '100%'};
|
|
42
|
+
height: 100%;
|
|
43
|
+
min-height: ${({ $size }) =>
|
|
44
|
+
pixelate(LoadingDimensions[$size || LoadingSizes.Small])};
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
export const LoadingElement = styled.div<{
|
|
48
|
+
$color?: string;
|
|
49
|
+
$size?: LoadingSizes;
|
|
50
|
+
}>`
|
|
51
|
+
box-sizing: border-box;
|
|
52
|
+
display: block;
|
|
53
|
+
position: absolute;
|
|
54
|
+
width: ${({ $size }) => pixelate(LoadingDimensions[$size || LoadingSizes.Small])};
|
|
55
|
+
height: ${({ $size }) => pixelate(LoadingDimensions[$size || LoadingSizes.Small])};
|
|
56
|
+
border: 2px solid ${({ $color }) => $color || 'currentColor'};
|
|
57
|
+
border-width: ${({ $size }) => ($size === LoadingSizes.Large ? '4px' : '2px')};
|
|
58
|
+
border-radius: 50%;
|
|
59
|
+
animation: ${loading} 1.4s cubic-bezier(0.5, 0, 0.5, 1) infinite;
|
|
60
|
+
border-color: ${({ $color }) => $color || 'currentColor'} transparent
|
|
61
|
+
transparent transparent;
|
|
62
|
+
|
|
63
|
+
&:nth-child(1) {
|
|
64
|
+
animation-delay: -0.45s;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&:nth-child(2) {
|
|
68
|
+
animation-delay: -0.3s;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&:nth-child(3) {
|
|
72
|
+
animation-delay: -0.15s;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
|
|
77
|
+
export const LogoContainer = styled.div<{
|
|
78
|
+
$size?: LoadingSizes;
|
|
79
|
+
}>`
|
|
80
|
+
position: relative;
|
|
81
|
+
width: ${({ $size }) =>
|
|
82
|
+
pixelate(LoadingDimensions[$size || LoadingSizes.Small])};
|
|
83
|
+
height: ${({ $size }) =>
|
|
84
|
+
pixelate(LoadingDimensions[$size || LoadingSizes.Small])};
|
|
85
|
+
display: flex;
|
|
86
|
+
align-items: center;
|
|
87
|
+
justify-content: center;
|
|
88
|
+
animation: ${logoPulse} 3s ease-in-out infinite;
|
|
89
|
+
|
|
90
|
+
svg {
|
|
91
|
+
width: 100%;
|
|
92
|
+
height: 100%;
|
|
93
|
+
transform-origin: center center;
|
|
94
|
+
}
|
|
95
|
+
`;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import Button, { ButtonAppearance } from '../Button/Button';
|
|
4
|
+
import Card, { CardContent, CardFooter, CardHeader } from '../Card/Card';
|
|
5
|
+
import Text from '../Text/Text';
|
|
6
|
+
import Modal from './Modal';
|
|
7
|
+
import ModalDocs from './ModalDocs.mdx';
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
component: Modal,
|
|
11
|
+
title: 'Components/Modal',
|
|
12
|
+
parameters: {
|
|
13
|
+
docs: {
|
|
14
|
+
page: ModalDocs,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const Template = args => {
|
|
20
|
+
const [open, setIsOpen] = useState<string | boolean>(false);
|
|
21
|
+
return (
|
|
22
|
+
<>
|
|
23
|
+
<Button
|
|
24
|
+
appearance={ButtonAppearance.Secondary}
|
|
25
|
+
onClick={() => setIsOpen('default')}
|
|
26
|
+
style={{ marginBottom: '16px' }}
|
|
27
|
+
>
|
|
28
|
+
Open Modal
|
|
29
|
+
</Button>
|
|
30
|
+
<Button onClick={() => setIsOpen('card')}>Open Modal with Card</Button>
|
|
31
|
+
<Modal open={open} {...args} onClose={() => setIsOpen(false)}>
|
|
32
|
+
{open === 'default' ? (
|
|
33
|
+
<div>I AM A MODAL</div>
|
|
34
|
+
) : (
|
|
35
|
+
<Card>
|
|
36
|
+
<CardHeader>New match</CardHeader>
|
|
37
|
+
<CardContent $align="flex-end" $textAlign="center" $gap="40px">
|
|
38
|
+
<Text>We've found a new match for you</Text>
|
|
39
|
+
<Text>Click accept or decline to progress</Text>
|
|
40
|
+
</CardContent>
|
|
41
|
+
<CardFooter>
|
|
42
|
+
<Button onClick={() => setIsOpen(false)}>Confirm</Button>
|
|
43
|
+
</CardFooter>
|
|
44
|
+
</Card>
|
|
45
|
+
)}
|
|
46
|
+
</Modal>
|
|
47
|
+
</>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const Default = Template.bind({});
|
|
52
|
+
Default.args = {};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { render, renderWithUser, screen } from '../../testUtils';
|
|
4
|
+
import Modal, { BACKDROP_LABEL } from './Modal';
|
|
5
|
+
|
|
6
|
+
const CHILDREN_TEST_ID = 'children';
|
|
7
|
+
const PARENT_TEST_ID = 'parent';
|
|
8
|
+
|
|
9
|
+
test('Modal renders null when not open or active', () => {
|
|
10
|
+
const onCloseMock = jest.fn();
|
|
11
|
+
render(
|
|
12
|
+
<Modal open={false} onClose={onCloseMock}>
|
|
13
|
+
<div data-testid={CHILDREN_TEST_ID} />
|
|
14
|
+
</Modal>,
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
const backdrop = screen.queryByLabelText(BACKDROP_LABEL);
|
|
18
|
+
const children = screen.queryByTestId(CHILDREN_TEST_ID);
|
|
19
|
+
expect(children).not.toBeInTheDocument();
|
|
20
|
+
expect(backdrop).not.toBeInTheDocument();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('Modal renders correctly when open', () => {
|
|
24
|
+
const onCloseMock = jest.fn();
|
|
25
|
+
render(
|
|
26
|
+
<Modal open onClose={onCloseMock}>
|
|
27
|
+
<div data-testid={CHILDREN_TEST_ID} />
|
|
28
|
+
</Modal>,
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const backdrop = screen.getByLabelText(BACKDROP_LABEL);
|
|
32
|
+
const children = screen.getByTestId(CHILDREN_TEST_ID);
|
|
33
|
+
const closeBtn = screen.getByRole('button');
|
|
34
|
+
expect(children).toBeInTheDocument();
|
|
35
|
+
expect(closeBtn).toBeInTheDocument();
|
|
36
|
+
expect(backdrop).toBeInTheDocument();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('Modal is correctly appended to parent element if provided', () => {
|
|
40
|
+
const onCloseMock = jest.fn();
|
|
41
|
+
const parentEl = document.createElement('div');
|
|
42
|
+
parentEl.setAttribute('data-testid', PARENT_TEST_ID);
|
|
43
|
+
document.body.appendChild(parentEl);
|
|
44
|
+
render(
|
|
45
|
+
<Modal open onClose={onCloseMock} parent={parentEl}>
|
|
46
|
+
<div data-testid={CHILDREN_TEST_ID} />
|
|
47
|
+
</Modal>,
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const backdrop = screen.getByLabelText(BACKDROP_LABEL);
|
|
51
|
+
const closeBtn = screen.getByRole('button');
|
|
52
|
+
const parent = screen.getByTestId(PARENT_TEST_ID);
|
|
53
|
+
|
|
54
|
+
expect(parent).toBeInTheDocument();
|
|
55
|
+
expect(closeBtn).toBeInTheDocument();
|
|
56
|
+
// content gets appended to div
|
|
57
|
+
|
|
58
|
+
expect(parent.firstChild?.firstChild).toEqual(backdrop);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('Modal can be closed by clicking on close button', async () => {
|
|
62
|
+
const onCloseMock = jest.fn();
|
|
63
|
+
const { user } = renderWithUser(
|
|
64
|
+
<Modal open onClose={onCloseMock}>
|
|
65
|
+
<div data-testid={CHILDREN_TEST_ID} />
|
|
66
|
+
</Modal>,
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
const closeBtn = screen.getByRole('button');
|
|
70
|
+
await user.click(closeBtn);
|
|
71
|
+
expect(onCloseMock).toHaveBeenCalled();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('Modal can be closed by clicking on backdrop', async () => {
|
|
75
|
+
const onCloseMock = jest.fn();
|
|
76
|
+
const { user } = renderWithUser(
|
|
77
|
+
<Modal open onClose={onCloseMock}>
|
|
78
|
+
<div data-testid={CHILDREN_TEST_ID} />
|
|
79
|
+
</Modal>,
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const backdrop = screen.getByLabelText(BACKDROP_LABEL);
|
|
83
|
+
await user.click(backdrop);
|
|
84
|
+
expect(onCloseMock).toHaveBeenCalled();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test('Modal cannot be closed by clicking on backdrop when locked', async () => {
|
|
88
|
+
const onCloseMock = jest.fn();
|
|
89
|
+
const { user } = renderWithUser(
|
|
90
|
+
<Modal locked open onClose={onCloseMock}>
|
|
91
|
+
<div data-testid={CHILDREN_TEST_ID} />
|
|
92
|
+
</Modal>,
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const backdrop = screen.getByLabelText(BACKDROP_LABEL);
|
|
96
|
+
await user.click(backdrop);
|
|
97
|
+
expect(onCloseMock).not.toHaveBeenCalled();
|
|
98
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
3
|
+
|
|
4
|
+
import { ButtonVariations } from '../Button/Button';
|
|
5
|
+
import { CloseIcon } from '../Icon';
|
|
6
|
+
import { BackdropContainer, CloseButton } from './styles';
|
|
7
|
+
|
|
8
|
+
export const BACKDROP_LABEL = 'dialog backdrop';
|
|
9
|
+
const ROOT_LABEL = '#root';
|
|
10
|
+
const CLOSE_BUTTON_LABEL = 'dialog close button';
|
|
11
|
+
|
|
12
|
+
type BaseModalProps = {
|
|
13
|
+
children: any;
|
|
14
|
+
className?: string;
|
|
15
|
+
createInPortal?: boolean;
|
|
16
|
+
open: boolean;
|
|
17
|
+
parent?: any;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type UnlockedModalProps = BaseModalProps & {
|
|
21
|
+
locked?: false;
|
|
22
|
+
onClose: () => void;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type LockedModalProps = BaseModalProps & {
|
|
26
|
+
locked: true;
|
|
27
|
+
onClose?: () => void;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
type ModalProps = UnlockedModalProps | LockedModalProps;
|
|
31
|
+
|
|
32
|
+
const Modal = ({
|
|
33
|
+
children,
|
|
34
|
+
createInPortal = true,
|
|
35
|
+
open,
|
|
36
|
+
onClose,
|
|
37
|
+
locked,
|
|
38
|
+
parent,
|
|
39
|
+
className,
|
|
40
|
+
}: ModalProps) => {
|
|
41
|
+
const [active, setActive] = useState(false);
|
|
42
|
+
|
|
43
|
+
const backdrop = useRef<HTMLDialogElement>(null);
|
|
44
|
+
const el = useMemo(() => document.createElement('div'), []);
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
const target = parent?.appendChild ? parent : document.body;
|
|
48
|
+
target.appendChild(el);
|
|
49
|
+
|
|
50
|
+
return () => {
|
|
51
|
+
target.removeChild(el);
|
|
52
|
+
};
|
|
53
|
+
}, [el, parent, className]);
|
|
54
|
+
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
const { current } = backdrop;
|
|
57
|
+
const transitionEnd = () => setActive(open);
|
|
58
|
+
const keyHandler = (e: KeyboardEvent) =>
|
|
59
|
+
!locked && e.key === 'Escape' && onClose();
|
|
60
|
+
const clickHandler = (e: Event) =>
|
|
61
|
+
!locked && e.target === current && onClose();
|
|
62
|
+
|
|
63
|
+
let openTimeout: number;
|
|
64
|
+
|
|
65
|
+
if (current) {
|
|
66
|
+
current.addEventListener('transitionend', transitionEnd);
|
|
67
|
+
current.addEventListener('click', clickHandler);
|
|
68
|
+
window.addEventListener('keyup', keyHandler);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (open) {
|
|
72
|
+
openTimeout = window.setTimeout(() => {
|
|
73
|
+
(document?.activeElement as HTMLElement).blur();
|
|
74
|
+
setActive(open);
|
|
75
|
+
document.body.style.overflow = 'hidden';
|
|
76
|
+
document.querySelector(ROOT_LABEL)?.setAttribute('inert', 'true');
|
|
77
|
+
current?.focus();
|
|
78
|
+
}, 10);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return () => {
|
|
82
|
+
if (current) {
|
|
83
|
+
current.removeEventListener('transitionend', transitionEnd);
|
|
84
|
+
current.removeEventListener('click', clickHandler);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
clearTimeout(openTimeout);
|
|
88
|
+
document.querySelector(ROOT_LABEL)?.removeAttribute('inert');
|
|
89
|
+
document.body.style.overflow = 'unset';
|
|
90
|
+
|
|
91
|
+
window.removeEventListener('keyup', keyHandler);
|
|
92
|
+
};
|
|
93
|
+
}, [open, locked, onClose]);
|
|
94
|
+
|
|
95
|
+
const Backdrop = (
|
|
96
|
+
<BackdropContainer
|
|
97
|
+
aria-modal={true}
|
|
98
|
+
aria-label={BACKDROP_LABEL}
|
|
99
|
+
ref={backdrop}
|
|
100
|
+
$active={active && open}
|
|
101
|
+
>
|
|
102
|
+
{!locked && (
|
|
103
|
+
<CloseButton variation={ButtonVariations.Icon} onClick={onClose}>
|
|
104
|
+
<CloseIcon label={CLOSE_BUTTON_LABEL} height="24" width="24" />
|
|
105
|
+
</CloseButton>
|
|
106
|
+
)}
|
|
107
|
+
{children}
|
|
108
|
+
</BackdropContainer>
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
if (open) return createInPortal ? createPortal(Backdrop, el) : Backdrop;
|
|
112
|
+
return null;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export default Modal;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ArgTypes, Meta } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import { CustomThemeProvider } from '../../theme';
|
|
3
|
+
|
|
4
|
+
import Status from '../../utils/status';
|
|
5
|
+
import Modal from './Modal';
|
|
6
|
+
|
|
7
|
+
<Meta title="Components/Modal" />
|
|
8
|
+
|
|
9
|
+
<CustomThemeProvider>
|
|
10
|
+
# Modal
|
|
11
|
+
|
|
12
|
+
<Status React="Prototype" Figma="https://www.figma.com/" />
|
|
13
|
+
|
|
14
|
+
This is a Modal that should be used when an application requires a required action from the user or to communicate information to the user.
|
|
15
|
+
|
|
16
|
+
## Default
|
|
17
|
+
|
|
18
|
+
By default, the Modal is closed
|
|
19
|
+
|
|
20
|
+
<ArgTypes of={Modal} />
|
|
21
|
+
</CustomThemeProvider>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
|
|
3
|
+
import Button from '../Button/Button';
|
|
4
|
+
|
|
5
|
+
export const BackdropContainer = styled.dialog<{ $active: boolean }>`
|
|
6
|
+
position: fixed;
|
|
7
|
+
top: 0;
|
|
8
|
+
right: 0;
|
|
9
|
+
bottom: 0;
|
|
10
|
+
left: 0;
|
|
11
|
+
width: unset;
|
|
12
|
+
height: unset;
|
|
13
|
+
margin: 0;
|
|
14
|
+
padding: ${({ theme }) => theme.spacing.small};
|
|
15
|
+
border: none;
|
|
16
|
+
background-color: rgba(51, 51, 51, 0.3);
|
|
17
|
+
backdrop-filter: blur(8px);
|
|
18
|
+
opacity: 0;
|
|
19
|
+
transition: all 100ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
20
|
+
transition-delay: 200ms;
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
justify-content: center;
|
|
24
|
+
z-index: 1000;
|
|
25
|
+
overflow: auto;
|
|
26
|
+
overscroll-behavior: contain;
|
|
27
|
+
|
|
28
|
+
> div {
|
|
29
|
+
transform: translateY(100px);
|
|
30
|
+
transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
31
|
+
opacity: 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
${({ $active }) =>
|
|
35
|
+
$active &&
|
|
36
|
+
css`
|
|
37
|
+
transition-duration: 250ms;
|
|
38
|
+
transition-delay: 0ms;
|
|
39
|
+
opacity: 1;
|
|
40
|
+
|
|
41
|
+
> div {
|
|
42
|
+
transform: translateY(0);
|
|
43
|
+
opacity: 1;
|
|
44
|
+
transition-delay: 150ms;
|
|
45
|
+
transition-duration: 350ms;
|
|
46
|
+
}
|
|
47
|
+
`}
|
|
48
|
+
|
|
49
|
+
@media (min-width: ${({ theme }) => theme.breakpoints.medium}) {
|
|
50
|
+
padding: ${({ theme }) => theme.spacing.large};
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
|
+
|
|
54
|
+
export const CloseButton = styled(Button)`
|
|
55
|
+
position: absolute;
|
|
56
|
+
top: ${({ theme }) => theme.spacing.xsmall};
|
|
57
|
+
right: ${({ theme }) => theme.spacing.xsmall};
|
|
58
|
+
z-index: 2;
|
|
59
|
+
padding: 7px;
|
|
60
|
+
background: ${({ theme }) => theme.color.surface.secondary};
|
|
61
|
+
border-radius: ${({ theme }) => theme.radius.full};
|
|
62
|
+
|
|
63
|
+
@media (min-width: ${({ theme }) => theme.breakpoints.medium}) {
|
|
64
|
+
top: ${({ theme }) => theme.spacing.medium};
|
|
65
|
+
right: ${({ theme }) => theme.spacing.medium};
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import MultiCheckbox from './MultiCheckbox';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
component: MultiCheckbox,
|
|
7
|
+
title: 'Components/MultiCheckbox',
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const Default = args => <MultiCheckbox {...args} />;
|
|
11
|
+
|
|
12
|
+
Default.args = {
|
|
13
|
+
id: 'multi selector id',
|
|
14
|
+
onSelection: () => null,
|
|
15
|
+
heading: 'Select your favourite veg',
|
|
16
|
+
preSelected: ['carrots', 'Potato'],
|
|
17
|
+
options: [
|
|
18
|
+
{ label: 'Carrots', value: 'carrots' },
|
|
19
|
+
{ label: 'Beets', value: 'Beets' },
|
|
20
|
+
{ label: 'Broccoli', value: 'Broccoli' },
|
|
21
|
+
{ label: 'Potato', value: 'Potato' },
|
|
22
|
+
{ label: 'Longer sentence to test', value: 'longer' },
|
|
23
|
+
],
|
|
24
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { CheckedState } from '@radix-ui/react-checkbox';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import { useTheme } from 'styled-components';
|
|
4
|
+
|
|
5
|
+
import { CheckboxButton } from '../Checkbox/Checkbox';
|
|
6
|
+
import InputError from '../InputError/InputError';
|
|
7
|
+
import Label from '../Label/Label';
|
|
8
|
+
import { MultiCheckboxWrapper } from './styles';
|
|
9
|
+
|
|
10
|
+
type MultiCheckboxProps = {
|
|
11
|
+
heading?: string;
|
|
12
|
+
options: { label: string; value: string }[];
|
|
13
|
+
onSelection: (selected: string[]) => void;
|
|
14
|
+
preSelected?: string[];
|
|
15
|
+
error?: string;
|
|
16
|
+
name: string;
|
|
17
|
+
readOnly?: boolean;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const MultiCheckbox: React.FC<MultiCheckboxProps> = ({
|
|
21
|
+
error,
|
|
22
|
+
heading,
|
|
23
|
+
preSelected,
|
|
24
|
+
onSelection,
|
|
25
|
+
options,
|
|
26
|
+
name,
|
|
27
|
+
readOnly,
|
|
28
|
+
}) => {
|
|
29
|
+
const theme = useTheme();
|
|
30
|
+
const [selected, setSelected] = useState(preSelected || []);
|
|
31
|
+
|
|
32
|
+
const onSelect = ({
|
|
33
|
+
state,
|
|
34
|
+
value,
|
|
35
|
+
}: {
|
|
36
|
+
value: string;
|
|
37
|
+
state: CheckedState;
|
|
38
|
+
}) => {
|
|
39
|
+
const oldValues = selected || [];
|
|
40
|
+
const newValues = state
|
|
41
|
+
? [...oldValues, value]
|
|
42
|
+
: oldValues.filter(el => el !== value);
|
|
43
|
+
|
|
44
|
+
setSelected(newValues);
|
|
45
|
+
onSelection(newValues);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<div>
|
|
50
|
+
{heading && <Label bold>{heading}</Label>}
|
|
51
|
+
<MultiCheckboxWrapper>
|
|
52
|
+
{options.map(({ value, label }) => (
|
|
53
|
+
<CheckboxButton
|
|
54
|
+
key={label}
|
|
55
|
+
error={error}
|
|
56
|
+
label={label}
|
|
57
|
+
name={name}
|
|
58
|
+
checked={selected.includes(value)}
|
|
59
|
+
onCheckedChange={state => onSelect({ value, state })}
|
|
60
|
+
color={theme.color.surface.selected}
|
|
61
|
+
value={value}
|
|
62
|
+
readOnly={readOnly}
|
|
63
|
+
/>
|
|
64
|
+
))}
|
|
65
|
+
</MultiCheckboxWrapper>
|
|
66
|
+
<InputError visible={Boolean(error)} textAlign="left">
|
|
67
|
+
{error}
|
|
68
|
+
</InputError>
|
|
69
|
+
</div>
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export default MultiCheckbox;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
export const MultiCheckboxWrapper = styled.div`
|
|
4
|
+
width: 100%;
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
flex-wrap: wrap;
|
|
8
|
+
gap: ${({ theme }) => theme.spacing.xxsmall};
|
|
9
|
+
margin-bottom: ${({ theme }) => theme.spacing.xxsmall};
|
|
10
|
+
`;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import MultiDropdown from './MultiDropdown';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
component: MultiDropdown,
|
|
7
|
+
title: 'Components/MultiDropdown',
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const DEFAULT_ARGS = {
|
|
11
|
+
addMoreLabel: 'Add more',
|
|
12
|
+
onValueChange: () => null,
|
|
13
|
+
firstDropdown: {
|
|
14
|
+
ariaLabel: 'language skill',
|
|
15
|
+
options: [
|
|
16
|
+
{ value: 'german', label: 'German' },
|
|
17
|
+
{ value: 'french', label: 'French' },
|
|
18
|
+
{ value: 'english', label: 'English' },
|
|
19
|
+
],
|
|
20
|
+
placeholder: 'Select a language...',
|
|
21
|
+
label: 'Language Selector',
|
|
22
|
+
dataField: 'lang_skill',
|
|
23
|
+
errors: [],
|
|
24
|
+
values: [],
|
|
25
|
+
},
|
|
26
|
+
secondDropdown: {
|
|
27
|
+
ariaLabel: 'language level',
|
|
28
|
+
options: [
|
|
29
|
+
{ value: 'A1', label: 'A1' },
|
|
30
|
+
{ value: 'A2', label: 'A2' },
|
|
31
|
+
{ value: 'B1', label: 'B1' },
|
|
32
|
+
{
|
|
33
|
+
label: 'B2 = (fluent & spontaneous conversations, current events',
|
|
34
|
+
value: 'B2',
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
placeholder: 'Select a level...',
|
|
38
|
+
label: 'Level Selector',
|
|
39
|
+
dataField: 'lang_level',
|
|
40
|
+
errors: [],
|
|
41
|
+
values: [],
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const Default = args => <MultiDropdown {...args} />;
|
|
46
|
+
|
|
47
|
+
Default.args = DEFAULT_ARGS;
|
|
48
|
+
|
|
49
|
+
export const WithValues = args => <MultiDropdown {...args} />;
|
|
50
|
+
WithValues.args = {
|
|
51
|
+
...DEFAULT_ARGS,
|
|
52
|
+
firstDropdown: {
|
|
53
|
+
...DEFAULT_ARGS.firstDropdown,
|
|
54
|
+
values: ['german', 'french'],
|
|
55
|
+
},
|
|
56
|
+
secondDropdown: {
|
|
57
|
+
...DEFAULT_ARGS.secondDropdown,
|
|
58
|
+
values: ['A1', 'A2'],
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const LockedValue = () => (
|
|
63
|
+
<MultiDropdown
|
|
64
|
+
{...{
|
|
65
|
+
...DEFAULT_ARGS,
|
|
66
|
+
firstDropdown: {
|
|
67
|
+
...DEFAULT_ARGS.firstDropdown,
|
|
68
|
+
values: ['german', 'french'],
|
|
69
|
+
},
|
|
70
|
+
secondDropdown: {
|
|
71
|
+
...DEFAULT_ARGS.secondDropdown,
|
|
72
|
+
lockedValue: 'B1',
|
|
73
|
+
values: ['A1', 'A2'],
|
|
74
|
+
},
|
|
75
|
+
}}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
export const AllLocked = args => <MultiDropdown {...args} />;
|
|
80
|
+
AllLocked.args = {
|
|
81
|
+
...DEFAULT_ARGS,
|
|
82
|
+
firstDropdown: {
|
|
83
|
+
...DEFAULT_ARGS.firstDropdown,
|
|
84
|
+
values: ['german', 'french'],
|
|
85
|
+
},
|
|
86
|
+
secondDropdown: {
|
|
87
|
+
...DEFAULT_ARGS.secondDropdown,
|
|
88
|
+
values: ['A1', 'A2'],
|
|
89
|
+
},
|
|
90
|
+
locked: true,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const RestrictedOptions = args => <MultiDropdown {...args} />;
|
|
94
|
+
RestrictedOptions.args = {
|
|
95
|
+
...DEFAULT_ARGS,
|
|
96
|
+
restrictions: { german: ['B1', 'B2'], french: ['B1'] },
|
|
97
|
+
firstDropdown: {
|
|
98
|
+
...DEFAULT_ARGS.firstDropdown,
|
|
99
|
+
values: ['german', 'french'],
|
|
100
|
+
},
|
|
101
|
+
secondDropdown: {
|
|
102
|
+
...DEFAULT_ARGS.secondDropdown,
|
|
103
|
+
values: ['A1', 'A2'],
|
|
104
|
+
},
|
|
105
|
+
};
|