@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,146 @@
|
|
|
1
|
+
import { ButtonVariations } from '../Button/Button';
|
|
2
|
+
import { EyeClosedIcon, EyeOpenIcon } from '../Icon';
|
|
3
|
+
import InputError from '../InputError/InputError';
|
|
4
|
+
import Label from '../Label/Label';
|
|
5
|
+
import {
|
|
6
|
+
Input,
|
|
7
|
+
InputContainer,
|
|
8
|
+
InputWrapper,
|
|
9
|
+
ShowPasswordToggle,
|
|
10
|
+
TelephoneInput,
|
|
11
|
+
} from './styles';
|
|
12
|
+
import {
|
|
13
|
+
InputHeight,
|
|
14
|
+
InputWidth,
|
|
15
|
+
TextInputBaseProps,
|
|
16
|
+
} from '@a-little-world/little-world-design-system-core';
|
|
17
|
+
import React, { ChangeEvent } from 'react';
|
|
18
|
+
|
|
19
|
+
const PASSWORD_TOGGLE_ICON_SIZE = 20;
|
|
20
|
+
|
|
21
|
+
export { InputWidth, InputHeight };
|
|
22
|
+
export interface Props
|
|
23
|
+
extends Omit<
|
|
24
|
+
React.ComponentPropsWithoutRef<'input'>,
|
|
25
|
+
'height' | 'onSubmit' | 'width'
|
|
26
|
+
>,
|
|
27
|
+
TextInputBaseProps {
|
|
28
|
+
inputRef?: React.RefObject<HTMLInputElement>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const TextInput: React.FC<Props> = ({
|
|
32
|
+
error,
|
|
33
|
+
height,
|
|
34
|
+
id,
|
|
35
|
+
inline,
|
|
36
|
+
inputRef,
|
|
37
|
+
label,
|
|
38
|
+
labelTooltip,
|
|
39
|
+
onChange,
|
|
40
|
+
onSubmit,
|
|
41
|
+
onlyCountries,
|
|
42
|
+
type = 'text',
|
|
43
|
+
width = InputWidth.Large,
|
|
44
|
+
...inputProps
|
|
45
|
+
}: Props) => {
|
|
46
|
+
const [inputType, setInputType] = React.useState(type); // ['text', 'password'
|
|
47
|
+
const [showPassword, setShowPassword] = React.useState(false);
|
|
48
|
+
const { defaultValue, value, ...propsWithoutValues } = inputProps;
|
|
49
|
+
const defaultTelephoneVal = (value ?? defaultValue)?.toString() as
|
|
50
|
+
| string
|
|
51
|
+
| undefined;
|
|
52
|
+
|
|
53
|
+
const errorProps = inline ? { bottom: '-16px', right: '0px' } : {};
|
|
54
|
+
|
|
55
|
+
const handlePasswordVisibilityToggle = () => {
|
|
56
|
+
if (inputType === 'password') {
|
|
57
|
+
setInputType('text');
|
|
58
|
+
setShowPassword(true);
|
|
59
|
+
} else {
|
|
60
|
+
setInputType('password');
|
|
61
|
+
setShowPassword(false);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const handleTelephoneChange = (
|
|
66
|
+
value: string,
|
|
67
|
+
country: string,
|
|
68
|
+
e: ChangeEvent<HTMLInputElement>,
|
|
69
|
+
) => {
|
|
70
|
+
onChange?.(e);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const handleKeyDown = async (e: React.KeyboardEvent<HTMLInputElement>) => {
|
|
74
|
+
if (onSubmit && e.key === 'Enter' && !e.shiftKey) {
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
await onSubmit();
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<InputWrapper $width={width}>
|
|
82
|
+
{label && (
|
|
83
|
+
<Label bold htmlFor={id} tooltipText={labelTooltip}>
|
|
84
|
+
{label}
|
|
85
|
+
</Label>
|
|
86
|
+
)}
|
|
87
|
+
<InputContainer>
|
|
88
|
+
{type === 'tel' ? (
|
|
89
|
+
<TelephoneInput
|
|
90
|
+
country="de"
|
|
91
|
+
onlyCountries={onlyCountries}
|
|
92
|
+
disableDropdown={onlyCountries?.length === 1}
|
|
93
|
+
onChange={handleTelephoneChange}
|
|
94
|
+
inputProps={{ ...propsWithoutValues, ref: inputRef }}
|
|
95
|
+
$hasError={!!error}
|
|
96
|
+
value={defaultTelephoneVal}
|
|
97
|
+
countryCodeEditable={false}
|
|
98
|
+
$height={height}
|
|
99
|
+
/>
|
|
100
|
+
) : (
|
|
101
|
+
<Input
|
|
102
|
+
ref={inputRef}
|
|
103
|
+
$hasError={Boolean(error)}
|
|
104
|
+
type={inputType}
|
|
105
|
+
id={id}
|
|
106
|
+
onChange={onChange}
|
|
107
|
+
onKeyDown={handleKeyDown}
|
|
108
|
+
$height={height}
|
|
109
|
+
{...inputProps}
|
|
110
|
+
/>
|
|
111
|
+
)}
|
|
112
|
+
{type === 'password' && (
|
|
113
|
+
<ShowPasswordToggle
|
|
114
|
+
type="button"
|
|
115
|
+
variation={ButtonVariations.Icon}
|
|
116
|
+
onClick={handlePasswordVisibilityToggle}
|
|
117
|
+
>
|
|
118
|
+
{showPassword ? (
|
|
119
|
+
<EyeClosedIcon
|
|
120
|
+
label="show password"
|
|
121
|
+
width={PASSWORD_TOGGLE_ICON_SIZE}
|
|
122
|
+
height={PASSWORD_TOGGLE_ICON_SIZE}
|
|
123
|
+
/>
|
|
124
|
+
) : (
|
|
125
|
+
<EyeOpenIcon
|
|
126
|
+
label="hide password"
|
|
127
|
+
width={PASSWORD_TOGGLE_ICON_SIZE}
|
|
128
|
+
height={PASSWORD_TOGGLE_ICON_SIZE}
|
|
129
|
+
/>
|
|
130
|
+
)}
|
|
131
|
+
</ShowPasswordToggle>
|
|
132
|
+
)}
|
|
133
|
+
</InputContainer>
|
|
134
|
+
|
|
135
|
+
<InputError
|
|
136
|
+
visible={Boolean(error)}
|
|
137
|
+
textAlign={width === InputWidth.Large ? 'right' : 'left'}
|
|
138
|
+
{...errorProps}
|
|
139
|
+
>
|
|
140
|
+
{error}
|
|
141
|
+
</InputError>
|
|
142
|
+
</InputWrapper>
|
|
143
|
+
);
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export default TextInput;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import PhoneInput from 'react-phone-input-2';
|
|
2
|
+
import 'react-phone-input-2/lib/style.css';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
|
|
5
|
+
import Button from '../Button/Button';
|
|
6
|
+
import { INPUT_ERROR_CSS } from '../InputError/InputError';
|
|
7
|
+
import {
|
|
8
|
+
InputHeight,
|
|
9
|
+
InputWidth,
|
|
10
|
+
} from '@a-little-world/little-world-design-system-core';
|
|
11
|
+
import { pixelate } from '../../utils/styles';
|
|
12
|
+
|
|
13
|
+
export const InputWrapper = styled.div<{ $width: InputWidth }>`
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
width: 100%;
|
|
17
|
+
max-width: ${({ $width }) => pixelate($width)};
|
|
18
|
+
position: relative;
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
export const InputContainer = styled.div`
|
|
22
|
+
position: relative;
|
|
23
|
+
width: 100%;
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
export const INPUT_CSS = css<{ $height?: InputHeight }>`
|
|
27
|
+
width: 100%;
|
|
28
|
+
border: 2px solid ${({ theme }) => theme.color.border.subtle};
|
|
29
|
+
background: ${({ theme }) => theme.color.surface.primary};
|
|
30
|
+
color: ${({ theme }) => theme.color.text.primary};
|
|
31
|
+
border-radius: 6px;
|
|
32
|
+
box-sizing: border-box;
|
|
33
|
+
padding: ${({ theme, $height }) =>
|
|
34
|
+
$height === InputHeight.Small ? '5px 8px' : theme.spacing.xxsmall};
|
|
35
|
+
|
|
36
|
+
margin-bottom: ${({ theme }) => theme.spacing.xxxxsmall};
|
|
37
|
+
font-size: 1rem;
|
|
38
|
+
height: unset;
|
|
39
|
+
line-height: 1.25;
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
export const Input = styled.input<{
|
|
43
|
+
$hasError: boolean;
|
|
44
|
+
$height?: InputHeight;
|
|
45
|
+
}>`
|
|
46
|
+
${INPUT_CSS}
|
|
47
|
+
`;
|
|
48
|
+
|
|
49
|
+
export const TelephoneInput = styled(PhoneInput)<{
|
|
50
|
+
$hasError: boolean;
|
|
51
|
+
$height?: InputHeight;
|
|
52
|
+
}>`
|
|
53
|
+
> input.form-control {
|
|
54
|
+
${INPUT_CSS}
|
|
55
|
+
padding-left: 52px;
|
|
56
|
+
|
|
57
|
+
${({ $hasError }) => $hasError && INPUT_ERROR_CSS}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.flag-dropdown {
|
|
61
|
+
overflow: hidden;
|
|
62
|
+
border: 2px solid
|
|
63
|
+
${({ theme, $hasError }) =>
|
|
64
|
+
$hasError ? theme.color.border.error : theme.color.border.subtle};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.flag-dropdown.open {
|
|
68
|
+
overflow: visible;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.flag-dropdown,
|
|
72
|
+
.flag-dropdown.open {
|
|
73
|
+
background: none;
|
|
74
|
+
border-radius: 6px 0 0 6px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.react-tel-input .country-list {
|
|
78
|
+
background: ${({ theme }) => theme.color.surface.elevated};
|
|
79
|
+
background-color: ${({ theme }) => theme.color.surface.elevated};
|
|
80
|
+
color: ${({ theme }) => theme.color.text.primary};
|
|
81
|
+
border-radius: ${({ theme }) => theme.radius.xxxsmall};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.react-tel-input .country-list .country.highlight {
|
|
85
|
+
background-color: ${({ theme }) => theme.color.surface.quaternary};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.react-tel-input .flag-dropdown.open .selected-flag {
|
|
89
|
+
background: none;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.react-tel-input .selected-flag {
|
|
93
|
+
padding: 0 0 0 14px;
|
|
94
|
+
scale: 1.3;
|
|
95
|
+
width: 51px;
|
|
96
|
+
transition: background ease 0.2s;
|
|
97
|
+
|
|
98
|
+
> .flag {
|
|
99
|
+
margin-top: -6px;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.react-tel-input .selected-flag:focus {
|
|
104
|
+
background: none;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.flag-dropdown .selected-flag:hover {
|
|
108
|
+
background: ${({ theme }) => theme.color.border.subtle};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.react-tel-input .flag-dropdown.open .selected-flag {
|
|
112
|
+
&:hover {
|
|
113
|
+
background: none;
|
|
114
|
+
filter: brightness(0.8);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.react-tel-input .selected-flag,
|
|
119
|
+
.react-tel-input .flag-dropdown.open .selected-flag {
|
|
120
|
+
border-radius: 8px 0 0 8px;
|
|
121
|
+
}
|
|
122
|
+
`;
|
|
123
|
+
|
|
124
|
+
export const ShowPasswordToggle = styled(Button)`
|
|
125
|
+
position: absolute;
|
|
126
|
+
right: ${({ theme }) => theme.spacing.xxsmall};
|
|
127
|
+
top: calc(50% - 1px);
|
|
128
|
+
transform: translateY(-50%);
|
|
129
|
+
`;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ToastBaseProps } from '@a-little-world/little-world-design-system-core';
|
|
3
|
+
import Button from '../Button/Button';
|
|
4
|
+
import { Logo } from '../Icon';
|
|
5
|
+
import Toast from './Toast';
|
|
6
|
+
import { ToastProvider, ToastViewport } from './styles';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
component: Toast,
|
|
10
|
+
title: 'Components/Toast',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const Default = args => {
|
|
14
|
+
const [open, setOpen] = React.useState(false);
|
|
15
|
+
const timerRef = React.useRef(0);
|
|
16
|
+
|
|
17
|
+
const props: ToastBaseProps = {
|
|
18
|
+
icon: <Logo label={'ToastLogoIcon'} />,
|
|
19
|
+
headline: 'This is the headline',
|
|
20
|
+
title: `This is the title`,
|
|
21
|
+
description: 'This is the description',
|
|
22
|
+
timestamp: new Date().toLocaleTimeString(),
|
|
23
|
+
actionText: 'Click me',
|
|
24
|
+
actionAltText: 'Click me',
|
|
25
|
+
duration: 3000,
|
|
26
|
+
onClose: () => console.log('toast onClose'),
|
|
27
|
+
onDismiss: () => console.log('toast onDismiss'),
|
|
28
|
+
onClick: () => console.log('toast onClick'),
|
|
29
|
+
onActionClick: () => {
|
|
30
|
+
console.log('toast onActionClick');
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const showToast = () => {
|
|
35
|
+
setOpen(false);
|
|
36
|
+
window.clearTimeout(timerRef.current);
|
|
37
|
+
timerRef.current = window.setTimeout(() => {
|
|
38
|
+
setOpen(true);
|
|
39
|
+
}, 100);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<>
|
|
44
|
+
<Button onClick={() => showToast()}>Show Toast</Button>
|
|
45
|
+
<ToastProvider swipeDirection="right">
|
|
46
|
+
<ToastViewport />
|
|
47
|
+
{open && <Toast {...props}></Toast>}
|
|
48
|
+
</ToastProvider>
|
|
49
|
+
</>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
Default.args = {
|
|
54
|
+
href: 'www.little-world.com',
|
|
55
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { Close } from '@radix-ui/react-toast';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import {
|
|
4
|
+
ToastBaseProps,
|
|
5
|
+
TOAST_DEFAULT_DURATION,
|
|
6
|
+
} from '@a-little-world/little-world-design-system-core';
|
|
7
|
+
|
|
8
|
+
import Button, { ButtonSizes, ButtonVariations } from '../Button/Button';
|
|
9
|
+
import { InfoIcon } from '../Icon';
|
|
10
|
+
import {
|
|
11
|
+
ToastAction,
|
|
12
|
+
ToastCloseButton,
|
|
13
|
+
ToastCloseIcon,
|
|
14
|
+
ToastContent,
|
|
15
|
+
ToastDescription,
|
|
16
|
+
ToastHeader,
|
|
17
|
+
ToastHeadline,
|
|
18
|
+
ToastRoot,
|
|
19
|
+
ToastTitle,
|
|
20
|
+
} from './styles';
|
|
21
|
+
|
|
22
|
+
export const TOAST_ICON_SIZE = '24px';
|
|
23
|
+
|
|
24
|
+
const Toast: React.FC<ToastBaseProps> = ({
|
|
25
|
+
className,
|
|
26
|
+
icon,
|
|
27
|
+
headline,
|
|
28
|
+
title,
|
|
29
|
+
description,
|
|
30
|
+
timestamp,
|
|
31
|
+
actionText,
|
|
32
|
+
actionAltText,
|
|
33
|
+
duration = TOAST_DEFAULT_DURATION,
|
|
34
|
+
onClose,
|
|
35
|
+
onDismiss,
|
|
36
|
+
onClick,
|
|
37
|
+
onActionClick,
|
|
38
|
+
}: ToastBaseProps) => {
|
|
39
|
+
const actionWellDefined =
|
|
40
|
+
!!actionText === !!actionAltText && !!actionText === !!onActionClick;
|
|
41
|
+
if (!actionWellDefined) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
'The action text, click event and alt text must all be set or unset',
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const [open, setOpen] = useState(true);
|
|
48
|
+
|
|
49
|
+
function closeToast(): void {
|
|
50
|
+
setOpen(false);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function onClickInternal(
|
|
54
|
+
event: React.MouseEvent<HTMLLIElement, MouseEvent>,
|
|
55
|
+
): void {
|
|
56
|
+
event.stopPropagation();
|
|
57
|
+
onClick?.();
|
|
58
|
+
closeToast();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function onDismissClick(event: React.MouseEvent<HTMLButtonElement>) {
|
|
62
|
+
event.stopPropagation(); // prevent toast onClick event from firing
|
|
63
|
+
onDismiss?.();
|
|
64
|
+
closeToast();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function onActionClickInternal(event: React.MouseEvent<HTMLButtonElement>) {
|
|
68
|
+
event.stopPropagation();
|
|
69
|
+
onActionClick?.();
|
|
70
|
+
closeToast();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function onOpenChange(open: boolean): void {
|
|
74
|
+
if (!open) {
|
|
75
|
+
onClose?.();
|
|
76
|
+
closeToast();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<div className={className}>
|
|
82
|
+
<ToastRoot
|
|
83
|
+
className="ToastRoot"
|
|
84
|
+
open={open}
|
|
85
|
+
onOpenChange={onOpenChange}
|
|
86
|
+
duration={duration}
|
|
87
|
+
onClick={onClickInternal}
|
|
88
|
+
>
|
|
89
|
+
<Close asChild>
|
|
90
|
+
<ToastCloseButton
|
|
91
|
+
variation={ButtonVariations.Icon}
|
|
92
|
+
size={ButtonSizes.Small}
|
|
93
|
+
onClick={onDismissClick}
|
|
94
|
+
>
|
|
95
|
+
<ToastCloseIcon
|
|
96
|
+
label={'ToastCloseIcon'}
|
|
97
|
+
width={TOAST_ICON_SIZE}
|
|
98
|
+
height={TOAST_ICON_SIZE}
|
|
99
|
+
></ToastCloseIcon>
|
|
100
|
+
</ToastCloseButton>
|
|
101
|
+
</Close>
|
|
102
|
+
<ToastHeader>
|
|
103
|
+
<ToastHeadline>
|
|
104
|
+
{icon ?? (
|
|
105
|
+
<InfoIcon
|
|
106
|
+
label={'ToastInfoIcon'}
|
|
107
|
+
width={TOAST_ICON_SIZE}
|
|
108
|
+
height={TOAST_ICON_SIZE}
|
|
109
|
+
/>
|
|
110
|
+
)}
|
|
111
|
+
<span>{headline}</span>
|
|
112
|
+
</ToastHeadline>
|
|
113
|
+
<div>{timestamp}</div>
|
|
114
|
+
</ToastHeader>
|
|
115
|
+
<ToastContent>
|
|
116
|
+
{title && <ToastTitle className="ToastTitle">{title}</ToastTitle>}
|
|
117
|
+
{description && <ToastDescription>{description}</ToastDescription>}
|
|
118
|
+
{actionText && actionAltText && onActionClick && (
|
|
119
|
+
<ToastAction
|
|
120
|
+
className="ToastAction"
|
|
121
|
+
asChild
|
|
122
|
+
altText={actionAltText}
|
|
123
|
+
>
|
|
124
|
+
<Button
|
|
125
|
+
variation={ButtonVariations.Basic}
|
|
126
|
+
size={ButtonSizes.Small}
|
|
127
|
+
onClick={onActionClickInternal}
|
|
128
|
+
>
|
|
129
|
+
{actionText}
|
|
130
|
+
</Button>
|
|
131
|
+
</ToastAction>
|
|
132
|
+
)}
|
|
133
|
+
</ToastContent>
|
|
134
|
+
</ToastRoot>
|
|
135
|
+
</div>
|
|
136
|
+
);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export default Toast;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import * as RadixToast from '@radix-ui/react-toast';
|
|
2
|
+
import styled, { keyframes } from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import Button from '../Button/Button';
|
|
5
|
+
import { CloseIcon } from '../Icon';
|
|
6
|
+
|
|
7
|
+
const slideIn = keyframes`
|
|
8
|
+
from {
|
|
9
|
+
transform: translateX(calc(100% + var(--viewport-padding)));
|
|
10
|
+
}
|
|
11
|
+
to {
|
|
12
|
+
transform: translateX(0);
|
|
13
|
+
}
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
const slideOut = keyframes`
|
|
17
|
+
from {
|
|
18
|
+
transform: translateX(0);
|
|
19
|
+
}
|
|
20
|
+
to {
|
|
21
|
+
transform: translateX(calc(100% + var(--viewport-padding)));
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
const swipeOut = keyframes`
|
|
26
|
+
from {
|
|
27
|
+
transform: translateX(var(--radix-toast-swipe-end-x));
|
|
28
|
+
}
|
|
29
|
+
to {
|
|
30
|
+
transform: translateX(calc(100% + var(--viewport-padding)));
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
export const ToastProvider = styled(RadixToast.ToastProvider)``;
|
|
35
|
+
|
|
36
|
+
export const ToastViewport = styled(RadixToast.Viewport)`
|
|
37
|
+
--viewport-padding: ${({ theme }) => theme.spacing.medium};
|
|
38
|
+
position: fixed;
|
|
39
|
+
top: 0;
|
|
40
|
+
right: 0;
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-direction: column;
|
|
43
|
+
padding: var(--viewport-padding);
|
|
44
|
+
gap: ${({ theme }) => theme.spacing.xxsmall};
|
|
45
|
+
width: 390px;
|
|
46
|
+
max-width: 100vw;
|
|
47
|
+
margin: 0;
|
|
48
|
+
list-style: none;
|
|
49
|
+
z-index: 1000;
|
|
50
|
+
outline: none;
|
|
51
|
+
`;
|
|
52
|
+
|
|
53
|
+
export const ToastRoot = styled(RadixToast.Root)`
|
|
54
|
+
position: relative;
|
|
55
|
+
--border-radius: ${({ theme }) => theme.radius.xxsmall};
|
|
56
|
+
background-color: ${({ theme }) => theme.color.surface.primary};
|
|
57
|
+
border-radius: var(--border-radius);
|
|
58
|
+
box-shadow:
|
|
59
|
+
hsl(206 22% 7% / 35%) 0px 10px 38px -10px,
|
|
60
|
+
hsl(206 22% 7% / 20%) 0px 10px 20px -15px;
|
|
61
|
+
|
|
62
|
+
&[data-state='open'] {
|
|
63
|
+
animation: ${slideIn} 150ms cubic-bezier(0.16, 1, 0.3, 1);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&[data-state='closed'] {
|
|
67
|
+
animation: ${slideOut} 150ms cubic-bezier(0.16, 1, 0.3, 1);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&[data-swipe='move'] {
|
|
71
|
+
transform: translateX(var(--radix-toast-swipe-move-x));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&[data-swipe='cancel'] {
|
|
75
|
+
transform: translateX(0);
|
|
76
|
+
transition: transform 200ms ease-out;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&[data-swipe='end'] {
|
|
80
|
+
animation: ${swipeOut} 100ms ease-out;
|
|
81
|
+
}
|
|
82
|
+
`;
|
|
83
|
+
|
|
84
|
+
export const ToastCloseButton = styled(Button)<{ $visible?: boolean }>`
|
|
85
|
+
position: absolute;
|
|
86
|
+
top: -8px;
|
|
87
|
+
right: -8px;
|
|
88
|
+
border-radius: ${({ theme }) => theme.radius.half};
|
|
89
|
+
background-color: ${({ theme }) => theme.color.surface.secondary};
|
|
90
|
+
width: 16px;
|
|
91
|
+
height: 16px;
|
|
92
|
+
box-shadow: 0px 0px 1px 1px ${({ theme }) => theme.color.border.subtle};
|
|
93
|
+
`;
|
|
94
|
+
|
|
95
|
+
export const ToastCloseIcon = styled(CloseIcon)`
|
|
96
|
+
scale: 0.8;
|
|
97
|
+
`;
|
|
98
|
+
|
|
99
|
+
export const ToastContent = styled.div`
|
|
100
|
+
padding: ${({ theme }) => theme.spacing.small};
|
|
101
|
+
display: grid;
|
|
102
|
+
grid-template-areas: 'headline headline' 'title action' 'description action';
|
|
103
|
+
grid-template-columns: auto max-content;
|
|
104
|
+
column-gap: ${({ theme }) => theme.spacing.small};
|
|
105
|
+
align-items: center;
|
|
106
|
+
`;
|
|
107
|
+
|
|
108
|
+
export const ToastHeader = styled.div<{ $backgroundColor?: string }>`
|
|
109
|
+
padding: ${({ theme }) =>
|
|
110
|
+
`${theme.spacing.xxxsmall} ${theme.spacing.xxsmall}`};
|
|
111
|
+
border-radius: var(--border-radius) var(--border-radius) 0 0;
|
|
112
|
+
display: flex;
|
|
113
|
+
flex-direction: row;
|
|
114
|
+
align-items: center;
|
|
115
|
+
background-color: ${({ $backgroundColor, theme }) =>
|
|
116
|
+
$backgroundColor || theme.color.surface.secondary};
|
|
117
|
+
justify-content: space-between;
|
|
118
|
+
`;
|
|
119
|
+
|
|
120
|
+
export const ToastHeadline = styled.div`
|
|
121
|
+
display: flex;
|
|
122
|
+
flex-direction: row;
|
|
123
|
+
align-items: center;
|
|
124
|
+
gap: ${({ theme }) => theme.spacing.xxxsmall};
|
|
125
|
+
`;
|
|
126
|
+
|
|
127
|
+
export const ToastTitle = styled(RadixToast.ToastTitle)`
|
|
128
|
+
grid-area: title;
|
|
129
|
+
margin-bottom: ${({ theme }) => theme.spacing.xxxsmall};
|
|
130
|
+
font-weight: bold;
|
|
131
|
+
color: ${({ theme }) => theme.color.text.primary};
|
|
132
|
+
`;
|
|
133
|
+
|
|
134
|
+
export const ToastDescription = styled(RadixToast.ToastDescription)`
|
|
135
|
+
grid-area: description;
|
|
136
|
+
margin: 0;
|
|
137
|
+
color: ${({ theme }) => theme.color.text.primary};
|
|
138
|
+
`;
|
|
139
|
+
|
|
140
|
+
export const ToastAction = styled(RadixToast.ToastAction)`
|
|
141
|
+
grid-area: action;
|
|
142
|
+
`;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Tooltip from './Tooltip';
|
|
3
|
+
import Button, { ButtonVariations } from '../Button/Button';
|
|
4
|
+
import { QuestionIcon } from '../Icon';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
component: Tooltip,
|
|
8
|
+
title: 'Components/Tooltip',
|
|
9
|
+
argTypes: {
|
|
10
|
+
open: { control: 'boolean' },
|
|
11
|
+
text: { control: 'text' },
|
|
12
|
+
side: { control: 'select', options: ['top', 'left', 'right', 'bottom'] },
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const Default = args => {
|
|
17
|
+
return (
|
|
18
|
+
<Tooltip
|
|
19
|
+
trigger={
|
|
20
|
+
<Button variation={ButtonVariations.Icon}>
|
|
21
|
+
<QuestionIcon label="questionIcon" />
|
|
22
|
+
</Button>
|
|
23
|
+
}
|
|
24
|
+
{...args}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
Default.args = {
|
|
30
|
+
text: 'this is a descriptor tooltip',
|
|
31
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as RadixTooltip from '@radix-ui/react-tooltip';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
import Text from '../Text/Text';
|
|
5
|
+
import { TextTypes } from '@a-little-world/little-world-design-system-core';
|
|
6
|
+
import { StyledTooltipContent, StyledTooltipArrow } from './styles';
|
|
7
|
+
|
|
8
|
+
type Props = {
|
|
9
|
+
text: string;
|
|
10
|
+
trigger?: React.ReactNode;
|
|
11
|
+
} & RadixTooltip.TooltipProps &
|
|
12
|
+
RadixTooltip.TooltipContentProps;
|
|
13
|
+
|
|
14
|
+
export const TooltipProvider = RadixTooltip.Provider;
|
|
15
|
+
|
|
16
|
+
const DEFAULT_SIDE_OFFSET = 0; //px
|
|
17
|
+
const DEFAULT_DELAY_DURATION = 300;
|
|
18
|
+
|
|
19
|
+
const Tooltip: React.FC<Props> = ({
|
|
20
|
+
defaultOpen,
|
|
21
|
+
open,
|
|
22
|
+
side,
|
|
23
|
+
sideOffset = DEFAULT_SIDE_OFFSET,
|
|
24
|
+
trigger,
|
|
25
|
+
text,
|
|
26
|
+
...rest
|
|
27
|
+
}: Props) => (
|
|
28
|
+
<RadixTooltip.Provider>
|
|
29
|
+
<RadixTooltip.Root
|
|
30
|
+
defaultOpen={defaultOpen}
|
|
31
|
+
delayDuration={DEFAULT_DELAY_DURATION}
|
|
32
|
+
open={open}
|
|
33
|
+
{...rest}
|
|
34
|
+
>
|
|
35
|
+
{trigger && (
|
|
36
|
+
<RadixTooltip.Trigger asChild>{trigger}</RadixTooltip.Trigger>
|
|
37
|
+
)}
|
|
38
|
+
<RadixTooltip.Portal>
|
|
39
|
+
<StyledTooltipContent side={side} sideOffset={sideOffset}>
|
|
40
|
+
<StyledTooltipArrow />
|
|
41
|
+
<Text type={TextTypes.Body5}>{text}</Text>
|
|
42
|
+
</StyledTooltipContent>
|
|
43
|
+
</RadixTooltip.Portal>
|
|
44
|
+
</RadixTooltip.Root>
|
|
45
|
+
</RadixTooltip.Provider>
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
export default Tooltip;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TooltipArrow, TooltipContent } from '@radix-ui/react-tooltip';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
export const StyledTooltipContent = styled(TooltipContent)`
|
|
5
|
+
background: ${({ theme }) => theme.color.surface.dim};
|
|
6
|
+
border-radius: ${({ theme }) => theme.radius.xxxsmall};
|
|
7
|
+
color: ${({ theme }) => theme.color.text.reversed};
|
|
8
|
+
padding: ${({ theme }) => theme.spacing.xxsmall};
|
|
9
|
+
box-shadow:
|
|
10
|
+
hsl(206 22% 7% / 35%) 0px 10px 38px -10px,
|
|
11
|
+
hsl(206 22% 7% / 20%) 0px 10px 20px -15px;
|
|
12
|
+
user-select: none;
|
|
13
|
+
animation-duration: 400ms;
|
|
14
|
+
animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
|
|
15
|
+
will-change: transform, opacity;
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
export const StyledTooltipArrow = styled(TooltipArrow)`
|
|
19
|
+
fill: ${({ theme }) => theme.color.surface.dim};
|
|
20
|
+
`;
|