@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,57 @@
|
|
|
1
|
+
import { Range, Root, Thumb, Track } from '@radix-ui/react-slider';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
export const SliderWrapper = styled.div``;
|
|
5
|
+
|
|
6
|
+
export const SliderRoot = styled(Root)`
|
|
7
|
+
position: relative;
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
user-select: none;
|
|
11
|
+
touch-action: none;
|
|
12
|
+
width: 100%:
|
|
13
|
+
max-width: 400px;
|
|
14
|
+
height: 20px;
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
export const SliderTrack = styled(Track)`
|
|
18
|
+
position: relative;
|
|
19
|
+
background-color: ${props => props.theme.color.surface.secondary};
|
|
20
|
+
flex-grow: 1;
|
|
21
|
+
border-radius: 9999px;
|
|
22
|
+
height: 3px;
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
export const SliderRange = styled(Range)`
|
|
26
|
+
position: absolute;
|
|
27
|
+
background-color: ${props => props.theme.color.surface.bold};
|
|
28
|
+
border-radius: 9999px;
|
|
29
|
+
height: 100%;
|
|
30
|
+
`;
|
|
31
|
+
|
|
32
|
+
export const SliderThumb = styled(Thumb)`
|
|
33
|
+
display: block;
|
|
34
|
+
width: ${({ theme }) => theme.spacing.small};
|
|
35
|
+
height: ${({ theme }) => theme.spacing.small};
|
|
36
|
+
background-color: ${({ theme }) => theme.color.surface.primary};
|
|
37
|
+
border-radius: 10px;
|
|
38
|
+
border: 1px solid ${props => props.theme.color.border.moderate};
|
|
39
|
+
|
|
40
|
+
&:hover {
|
|
41
|
+
background-color: ${props => props.theme.color.surface.primary};
|
|
42
|
+
cursor: grab;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&:focus {
|
|
46
|
+
outline: none;
|
|
47
|
+
box-shadow: 0 0px 4px ${props => props.theme.color.surface.contrast};
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
export const Steps = styled.div`
|
|
52
|
+
width: 100%;
|
|
53
|
+
display: flex;
|
|
54
|
+
flex: 1;
|
|
55
|
+
align-items: center;
|
|
56
|
+
justify-content: space-between;
|
|
57
|
+
`;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import StarRating from './StarRating';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
component: StarRating,
|
|
7
|
+
title: 'Components/StarRating',
|
|
8
|
+
argTypes: {
|
|
9
|
+
step: { control: 'number' },
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const Default = args => {
|
|
14
|
+
return <StarRating {...args} />;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
Default.args = {
|
|
18
|
+
maxRating: 5,
|
|
19
|
+
initialRating: 0,
|
|
20
|
+
};
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import React, { KeyboardEvent, useCallback, useState } from 'react';
|
|
2
|
+
import { useTheme } from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import { StarIcon } from '../Icon';
|
|
5
|
+
import {
|
|
6
|
+
Rating,
|
|
7
|
+
RatingContainer,
|
|
8
|
+
StarContainer,
|
|
9
|
+
StarOverlay,
|
|
10
|
+
Stars,
|
|
11
|
+
TextRating,
|
|
12
|
+
VisuallyHidden,
|
|
13
|
+
} from './styles';
|
|
14
|
+
|
|
15
|
+
const roundToHalf = (value: number): number => {
|
|
16
|
+
const rounded = Math.round(value * 2) / 2;
|
|
17
|
+
return Math.max(0, Math.min(rounded, 5));
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const DEFAULT_RATINGS = ['Poor', 'Fair', 'Average', 'Good', 'Excellent'];
|
|
21
|
+
|
|
22
|
+
export enum StarRatingSizes {
|
|
23
|
+
Small = 24, // px
|
|
24
|
+
Medium = 32,
|
|
25
|
+
Large = 48,
|
|
26
|
+
}
|
|
27
|
+
export interface StarRatingProps {
|
|
28
|
+
className?: string;
|
|
29
|
+
color?: string;
|
|
30
|
+
displayNumber?: boolean;
|
|
31
|
+
displayTextRatings?: boolean;
|
|
32
|
+
enableHalfRatings?: boolean;
|
|
33
|
+
id?: string;
|
|
34
|
+
initialRating?: number;
|
|
35
|
+
ratings?: string[];
|
|
36
|
+
maxRating?: number;
|
|
37
|
+
name?: string;
|
|
38
|
+
onChange?: (rating: number) => void;
|
|
39
|
+
size?: StarRatingSizes;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const StarRating = ({
|
|
43
|
+
className,
|
|
44
|
+
color,
|
|
45
|
+
displayNumber = false,
|
|
46
|
+
displayTextRatings = false,
|
|
47
|
+
enableHalfRatings = false,
|
|
48
|
+
id = 'star-rating',
|
|
49
|
+
initialRating = 0,
|
|
50
|
+
name = 'rating',
|
|
51
|
+
maxRating = 5,
|
|
52
|
+
onChange,
|
|
53
|
+
ratings = DEFAULT_RATINGS,
|
|
54
|
+
size = StarRatingSizes.Small,
|
|
55
|
+
}: StarRatingProps) => {
|
|
56
|
+
const [rating, setRating] = useState(initialRating);
|
|
57
|
+
const [hoverRating, setHoverRating] = useState(0);
|
|
58
|
+
const [focusedStar, setFocusedStar] = useState<number | null>(null);
|
|
59
|
+
const theme = useTheme();
|
|
60
|
+
const ratingIncrement = enableHalfRatings ? 0.5 : 1;
|
|
61
|
+
|
|
62
|
+
const handleMouseMove = (
|
|
63
|
+
e: React.MouseEvent<HTMLButtonElement>,
|
|
64
|
+
starIndex: number,
|
|
65
|
+
) => {
|
|
66
|
+
const { left, width } = e.currentTarget.getBoundingClientRect();
|
|
67
|
+
const percent = (e.clientX - left) / width;
|
|
68
|
+
const newRating =
|
|
69
|
+
enableHalfRatings && percent <= 0.5 ? starIndex + 0.5 : starIndex + 1;
|
|
70
|
+
setHoverRating(roundToHalf(newRating));
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const handleMouseLeave = () => {
|
|
74
|
+
setHoverRating(0);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const updateRating = useCallback(
|
|
78
|
+
(newRating: number) => {
|
|
79
|
+
const roundedRating = enableHalfRatings
|
|
80
|
+
? roundToHalf(newRating)
|
|
81
|
+
: newRating;
|
|
82
|
+
setRating(roundedRating);
|
|
83
|
+
onChange?.(roundedRating);
|
|
84
|
+
},
|
|
85
|
+
[onChange],
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const calculateRating = (starNumber: number) => {
|
|
89
|
+
// Toggle between whole, half, and unrated for clicked star
|
|
90
|
+
let newRating;
|
|
91
|
+
|
|
92
|
+
if (rating === starNumber) {
|
|
93
|
+
newRating = starNumber - ratingIncrement;
|
|
94
|
+
} else {
|
|
95
|
+
newRating = starNumber;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
updateRating(newRating);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const handleKeyDown = (
|
|
102
|
+
e: KeyboardEvent<HTMLButtonElement>,
|
|
103
|
+
starIndex: number,
|
|
104
|
+
) => {
|
|
105
|
+
let newRating = rating;
|
|
106
|
+
setHoverRating(0);
|
|
107
|
+
switch (e.key) {
|
|
108
|
+
case 'ArrowLeft':
|
|
109
|
+
e.preventDefault();
|
|
110
|
+
// If we're at a whole number, go down by 0.5, otherwise go down by 1
|
|
111
|
+
newRating =
|
|
112
|
+
Math.floor(rating) === rating
|
|
113
|
+
? Math.max(0, rating - ratingIncrement)
|
|
114
|
+
: Math.max(0, Math.floor(rating));
|
|
115
|
+
updateRating(newRating);
|
|
116
|
+
|
|
117
|
+
setFocusedStar(Math.max(0, newRating - 1));
|
|
118
|
+
break;
|
|
119
|
+
case 'ArrowRight':
|
|
120
|
+
e.preventDefault();
|
|
121
|
+
// If we're at a whole number, go up by 0.5, otherwise go up by 1
|
|
122
|
+
newRating =
|
|
123
|
+
Math.floor(rating) === rating
|
|
124
|
+
? Math.min(maxRating, rating + ratingIncrement)
|
|
125
|
+
: Math.min(maxRating, Math.ceil(rating));
|
|
126
|
+
|
|
127
|
+
updateRating(newRating);
|
|
128
|
+
setFocusedStar(Math.min(maxRating - 1, newRating - 1));
|
|
129
|
+
break;
|
|
130
|
+
case ' ':
|
|
131
|
+
case 'Enter':
|
|
132
|
+
e.preventDefault();
|
|
133
|
+
calculateRating((focusedStar ?? starIndex) + 1);
|
|
134
|
+
break;
|
|
135
|
+
default:
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const currentRating = hoverRating || rating;
|
|
141
|
+
|
|
142
|
+
return (
|
|
143
|
+
<RatingContainer
|
|
144
|
+
className={className}
|
|
145
|
+
role="group"
|
|
146
|
+
aria-label="Star rating"
|
|
147
|
+
>
|
|
148
|
+
<VisuallyHidden id={`${id}-label`}>
|
|
149
|
+
Rating: {currentRating} out of {maxRating} stars
|
|
150
|
+
</VisuallyHidden>
|
|
151
|
+
<Stars>
|
|
152
|
+
{[...Array(maxRating)].map((_, index) => {
|
|
153
|
+
const fillAmount = Math.max(0, Math.min(1, currentRating - index));
|
|
154
|
+
const starNumber = index + 1;
|
|
155
|
+
const handleClick = () => {
|
|
156
|
+
// tap devices cannot use hover rating
|
|
157
|
+
const crossDeviceFillAmount = hoverRating ? fillAmount : 1;
|
|
158
|
+
calculateRating(index + crossDeviceFillAmount);
|
|
159
|
+
};
|
|
160
|
+
return (
|
|
161
|
+
<StarContainer
|
|
162
|
+
key={index}
|
|
163
|
+
onClick={handleClick}
|
|
164
|
+
onMouseMove={e => handleMouseMove(e, index)}
|
|
165
|
+
onMouseLeave={handleMouseLeave}
|
|
166
|
+
onKeyDown={e => handleKeyDown(e, index)}
|
|
167
|
+
onFocus={() => setFocusedStar(index)}
|
|
168
|
+
onBlur={() => setFocusedStar(null)}
|
|
169
|
+
tabIndex={0}
|
|
170
|
+
role="radio"
|
|
171
|
+
aria-checked={rating >= starNumber}
|
|
172
|
+
aria-label={`${starNumber} star${starNumber === 1 ? '' : 's'}`}
|
|
173
|
+
aria-describedby={`${id}-label`}
|
|
174
|
+
name={name}
|
|
175
|
+
type="button"
|
|
176
|
+
>
|
|
177
|
+
{/* Background star */}
|
|
178
|
+
<StarIcon
|
|
179
|
+
label="background star"
|
|
180
|
+
width={size}
|
|
181
|
+
height={size}
|
|
182
|
+
color={theme.color.surface.disabled}
|
|
183
|
+
aria-hidden="true"
|
|
184
|
+
/>
|
|
185
|
+
|
|
186
|
+
{/* Filled overlay star */}
|
|
187
|
+
<StarOverlay $fillAmount={fillAmount}>
|
|
188
|
+
<StarIcon
|
|
189
|
+
label="filled star"
|
|
190
|
+
width={size}
|
|
191
|
+
height={size}
|
|
192
|
+
color={color || theme.color.surface.selected}
|
|
193
|
+
aria-hidden="true"
|
|
194
|
+
/>
|
|
195
|
+
</StarOverlay>
|
|
196
|
+
</StarContainer>
|
|
197
|
+
);
|
|
198
|
+
})}
|
|
199
|
+
{displayNumber && (
|
|
200
|
+
<Rating aria-hidden="true" tag="span">
|
|
201
|
+
{currentRating || 0}
|
|
202
|
+
</Rating>
|
|
203
|
+
)}
|
|
204
|
+
</Stars>
|
|
205
|
+
{displayTextRatings && (
|
|
206
|
+
<TextRating>{ratings[Math.ceil(currentRating - 1)]}</TextRating>
|
|
207
|
+
)}
|
|
208
|
+
</RatingContainer>
|
|
209
|
+
);
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
export default StarRating;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
|
|
3
|
+
import Text from '../Text/Text';
|
|
4
|
+
|
|
5
|
+
export const RatingContainer = styled.div`
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
align-items: center;
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
export const Stars = styled.div`
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
export const StarContainer = styled.button<{ isFocused?: boolean }>`
|
|
18
|
+
position: relative;
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
background: none;
|
|
21
|
+
border: none;
|
|
22
|
+
outline: none;
|
|
23
|
+
border-radius: ${({ theme }) => theme.radius.xxxsmall};
|
|
24
|
+
f &:focus-visible {
|
|
25
|
+
box-shadow: 0 0 0 2px #4f46e5;
|
|
26
|
+
}
|
|
27
|
+
padding: ${({ theme }) => theme.spacing.xxsmall};
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
export const StarOverlay = styled.div<{
|
|
31
|
+
$fillAmount: number;
|
|
32
|
+
}>`
|
|
33
|
+
position: absolute;
|
|
34
|
+
top: 0;
|
|
35
|
+
left: 0;
|
|
36
|
+
overflow: hidden;
|
|
37
|
+
width: ${props => props.$fillAmount * 100}%;
|
|
38
|
+
pointer-events: none;
|
|
39
|
+
padding: ${({ theme }) => theme.spacing.xxsmall};
|
|
40
|
+
|
|
41
|
+
transition: width 0.3s ease-in-out;
|
|
42
|
+
&:hover {
|
|
43
|
+
transition: width 1s ease-in-out;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
> svg {
|
|
47
|
+
transition: width 0.3s ease-in-out;
|
|
48
|
+
${({ $fillAmount }) =>
|
|
49
|
+
!$fillAmount &&
|
|
50
|
+
css`
|
|
51
|
+
transition: width 0.3s ease-in-out;
|
|
52
|
+
width: 0;
|
|
53
|
+
`}:
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
|
|
57
|
+
export const Rating = styled(Text)`
|
|
58
|
+
margin-left: ${({ theme }) => theme.spacing.xxsmall};
|
|
59
|
+
width: 24px;
|
|
60
|
+
`;
|
|
61
|
+
|
|
62
|
+
export const TextRating = styled(Text)`
|
|
63
|
+
height: 16px;
|
|
64
|
+
`;
|
|
65
|
+
|
|
66
|
+
export const VisuallyHidden = styled.span`
|
|
67
|
+
position: absolute;
|
|
68
|
+
width: 1px;
|
|
69
|
+
height: 1px;
|
|
70
|
+
padding: 0;
|
|
71
|
+
margin: -1px;
|
|
72
|
+
overflow: hidden;
|
|
73
|
+
clip: rect(0, 0, 0, 0);
|
|
74
|
+
white-space: nowrap;
|
|
75
|
+
border: 0;
|
|
76
|
+
`;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
|
|
3
|
+
import StatusMessage from './StatusMessage';
|
|
4
|
+
import { StatusTypes } from '@a-little-world/little-world-design-system-core';
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof StatusMessage> = {
|
|
7
|
+
component: StatusMessage,
|
|
8
|
+
title: 'Components/StatusMessage',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default meta;
|
|
12
|
+
|
|
13
|
+
type Story = StoryObj<typeof StatusMessage>;
|
|
14
|
+
|
|
15
|
+
export const Error: Story = {
|
|
16
|
+
args: {
|
|
17
|
+
visible: true,
|
|
18
|
+
type: StatusTypes.Error,
|
|
19
|
+
children: 'This is an error message to indicate something went wrong!',
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const Success: Story = {
|
|
24
|
+
args: {
|
|
25
|
+
visible: true,
|
|
26
|
+
type: StatusTypes.Success,
|
|
27
|
+
children: 'This is a succes message to indicate something went right!',
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const Warning: Story = {
|
|
32
|
+
args: {
|
|
33
|
+
visible: true,
|
|
34
|
+
type: StatusTypes.Warning,
|
|
35
|
+
children: 'This is a warning message to indicate something went awry!',
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const Info: Story = {
|
|
40
|
+
args: {
|
|
41
|
+
visible: true,
|
|
42
|
+
children: 'This is a info message to indicate some info',
|
|
43
|
+
},
|
|
44
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
import {
|
|
4
|
+
StatusBaseProps,
|
|
5
|
+
StatusTypes,
|
|
6
|
+
} from '@a-little-world/little-world-design-system-core';
|
|
7
|
+
import Text from '../Text/Text';
|
|
8
|
+
import { ExclamationIcon } from '../Icon';
|
|
9
|
+
|
|
10
|
+
const StatusMessageWrapper = styled.div<{
|
|
11
|
+
$type: StatusTypes;
|
|
12
|
+
$visible?: boolean;
|
|
13
|
+
$withBorder?: boolean;
|
|
14
|
+
$withIcon?: boolean;
|
|
15
|
+
}>`
|
|
16
|
+
display: flex;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
gap: ${({ theme }) => theme.spacing.xxsmall};
|
|
19
|
+
width: 100%;
|
|
20
|
+
min-height: ${({ theme }) => theme.spacing.xlarge};
|
|
21
|
+
padding: ${({ theme, $withBorder }) =>
|
|
22
|
+
$withBorder ? theme.spacing.small : theme.spacing.xxsmall};
|
|
23
|
+
opacity: ${({ $visible }) => ($visible ? 1 : 0)};
|
|
24
|
+
transition: ${({ $visible }) => ($visible ? 'opacity 1s' : 'none')};
|
|
25
|
+
text-align: ${({ $withIcon }) => ($withIcon ? 'left' : 'center')};
|
|
26
|
+
margin: ${({ theme, $withBorder }) =>
|
|
27
|
+
$withBorder ? 0 : theme.spacing.xxsmall}
|
|
28
|
+
0;
|
|
29
|
+
border-radius: ${({ theme, $withBorder }) =>
|
|
30
|
+
$withBorder ? theme.radius.xxsmall : 0};
|
|
31
|
+
|
|
32
|
+
${({ $type, theme, $withBorder }) => {
|
|
33
|
+
if ($type === StatusTypes.Error)
|
|
34
|
+
return css`
|
|
35
|
+
background: ${theme.color.surface.error};
|
|
36
|
+
color: ${theme.color.text.error};
|
|
37
|
+
border: ${$withBorder
|
|
38
|
+
? `1px solid ${theme.color.border.error}`
|
|
39
|
+
: 'none'};
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
if ($type === StatusTypes.Success)
|
|
43
|
+
return css`
|
|
44
|
+
background: ${theme.color.surface.success};
|
|
45
|
+
color: ${theme.color.text.success};
|
|
46
|
+
border: ${$withBorder
|
|
47
|
+
? `1px solid ${theme.color.border.success}`
|
|
48
|
+
: 'none'};
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
if ($type === StatusTypes.Warning)
|
|
52
|
+
return css`
|
|
53
|
+
background: ${theme.color.surface.warning};
|
|
54
|
+
color: ${theme.color.text.warning};
|
|
55
|
+
border: ${$withBorder
|
|
56
|
+
? `1px solid ${theme.color.border.warning}`
|
|
57
|
+
: 'none'};
|
|
58
|
+
`;
|
|
59
|
+
|
|
60
|
+
// default is Info type
|
|
61
|
+
return css`
|
|
62
|
+
background: ${theme.color.surface.subtle};
|
|
63
|
+
color: ${theme.color.text.info};
|
|
64
|
+
border: ${$withBorder ? `1px solid ${theme.color.border.info}` : 'none'};
|
|
65
|
+
`;
|
|
66
|
+
}})
|
|
67
|
+
`;
|
|
68
|
+
|
|
69
|
+
const StyledIcon = styled.svg`
|
|
70
|
+
flex-shrink: 0;
|
|
71
|
+
margin-top: 3px;
|
|
72
|
+
`;
|
|
73
|
+
|
|
74
|
+
const STATUS_ICONS = {
|
|
75
|
+
[StatusTypes.Error]: {
|
|
76
|
+
Icon: ExclamationIcon,
|
|
77
|
+
label: 'error icon',
|
|
78
|
+
},
|
|
79
|
+
[StatusTypes.Warning]: {
|
|
80
|
+
Icon: ExclamationIcon,
|
|
81
|
+
label: 'warning icon',
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const StatusMessage = ({
|
|
86
|
+
className,
|
|
87
|
+
type,
|
|
88
|
+
visible,
|
|
89
|
+
children,
|
|
90
|
+
withBorder,
|
|
91
|
+
}: StatusBaseProps) => {
|
|
92
|
+
const icon = STATUS_ICONS[type as keyof typeof STATUS_ICONS];
|
|
93
|
+
const Icon = withBorder && icon?.Icon;
|
|
94
|
+
return (
|
|
95
|
+
<StatusMessageWrapper
|
|
96
|
+
className={className}
|
|
97
|
+
$type={type}
|
|
98
|
+
$visible={visible}
|
|
99
|
+
$withBorder={withBorder}
|
|
100
|
+
$withIcon={!!Icon}
|
|
101
|
+
>
|
|
102
|
+
{Icon && (
|
|
103
|
+
<StyledIcon as={Icon} label={icon.label} width={18} height={18} />
|
|
104
|
+
)}
|
|
105
|
+
<Text>{children}</Text>
|
|
106
|
+
</StatusMessageWrapper>
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export default StatusMessage;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import * as RadixSwitch from '@radix-ui/react-switch';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
import InputError from '../InputError/InputError';
|
|
5
|
+
import Label from '../Label/Label';
|
|
6
|
+
import Text from '../Text/Text';
|
|
7
|
+
import {
|
|
8
|
+
LabelContainer,
|
|
9
|
+
SwitchContainer,
|
|
10
|
+
SwitchRoot,
|
|
11
|
+
SwitchThumb,
|
|
12
|
+
SwitchWrapper,
|
|
13
|
+
} from './styles';
|
|
14
|
+
|
|
15
|
+
type Props = {
|
|
16
|
+
className?: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
error?: string;
|
|
19
|
+
fullWidth?: boolean;
|
|
20
|
+
label?: string;
|
|
21
|
+
labelBold?: boolean;
|
|
22
|
+
labelInline?: boolean;
|
|
23
|
+
labelTooltip?: string;
|
|
24
|
+
inputRef: React.RefObject<HTMLButtonElement>;
|
|
25
|
+
} & RadixSwitch.SwitchProps;
|
|
26
|
+
|
|
27
|
+
const Switch: React.FC<Props> = ({
|
|
28
|
+
className,
|
|
29
|
+
description,
|
|
30
|
+
error,
|
|
31
|
+
fullWidth,
|
|
32
|
+
label,
|
|
33
|
+
labelBold = true,
|
|
34
|
+
labelInline,
|
|
35
|
+
labelTooltip,
|
|
36
|
+
inputRef,
|
|
37
|
+
checked,
|
|
38
|
+
onCheckedChange,
|
|
39
|
+
value,
|
|
40
|
+
...rest
|
|
41
|
+
}: Props) => (
|
|
42
|
+
<SwitchWrapper
|
|
43
|
+
className={className}
|
|
44
|
+
$fullWidth={fullWidth}
|
|
45
|
+
$labelInline={labelInline}
|
|
46
|
+
$labelAndDescription={Boolean(label && description)}
|
|
47
|
+
>
|
|
48
|
+
{(label || description) && (
|
|
49
|
+
<LabelContainer $inline={labelInline}>
|
|
50
|
+
{label && (
|
|
51
|
+
<Label
|
|
52
|
+
bold={labelBold}
|
|
53
|
+
htmlFor={label}
|
|
54
|
+
tooltipText={labelTooltip}
|
|
55
|
+
marginBottom="0"
|
|
56
|
+
>
|
|
57
|
+
{label}
|
|
58
|
+
</Label>
|
|
59
|
+
)}
|
|
60
|
+
{description && <Text>{description}</Text>}
|
|
61
|
+
</LabelContainer>
|
|
62
|
+
)}
|
|
63
|
+
|
|
64
|
+
<SwitchContainer>
|
|
65
|
+
<SwitchRoot
|
|
66
|
+
ref={inputRef}
|
|
67
|
+
checked={checked}
|
|
68
|
+
value={value}
|
|
69
|
+
name={label}
|
|
70
|
+
onCheckedChange={onCheckedChange}
|
|
71
|
+
$hasError={Boolean(error)}
|
|
72
|
+
{...rest}
|
|
73
|
+
>
|
|
74
|
+
<SwitchThumb />
|
|
75
|
+
</SwitchRoot>
|
|
76
|
+
<InputError visible={Boolean(error)} textAlign="left">
|
|
77
|
+
{error}
|
|
78
|
+
</InputError>
|
|
79
|
+
</SwitchContainer>
|
|
80
|
+
</SwitchWrapper>
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
export default Switch;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as Switch from '@radix-ui/react-switch';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
|
|
4
|
+
export const SwitchWrapper = styled.div<{
|
|
5
|
+
$fullWidth?: boolean;
|
|
6
|
+
$labelInline?: boolean;
|
|
7
|
+
$labelAndDescription: boolean;
|
|
8
|
+
}>`
|
|
9
|
+
${({ theme, $fullWidth, $labelInline, $labelAndDescription }) =>
|
|
10
|
+
$labelInline &&
|
|
11
|
+
css`
|
|
12
|
+
display: flex;
|
|
13
|
+
gap: ${theme.spacing.small};
|
|
14
|
+
align-items: ${$labelAndDescription ? 'flex-start' : 'center'};
|
|
15
|
+
${$fullWidth &&
|
|
16
|
+
css`
|
|
17
|
+
width: 100%;
|
|
18
|
+
justify-content: space-between;
|
|
19
|
+
`}
|
|
20
|
+
`}
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
export const LabelContainer = styled.div<{ $inline?: boolean }>`
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
gap: ${({ theme }) => theme.spacing.xxsmall};
|
|
27
|
+
margin-bottom: ${({ theme, $inline }) =>
|
|
28
|
+
$inline ? '20px' : theme.spacing.xxsmall};
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
export const SwitchRoot = styled(Switch.Root)<{ $hasError?: boolean }>`
|
|
32
|
+
width: 56px;
|
|
33
|
+
height: 32px;
|
|
34
|
+
background-color: ${({ theme }) => theme.color.border.subtle};
|
|
35
|
+
border-radius: 9999px;
|
|
36
|
+
position: relative;
|
|
37
|
+
-webkit-tap-highlight-color: ${({ theme }) => theme.color.surface.on};
|
|
38
|
+
|
|
39
|
+
&:focus {
|
|
40
|
+
box-shadow: 0 0 0 2px ${({ theme }) => theme.color.border.minimal};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
${({ $hasError }) =>
|
|
44
|
+
$hasError &&
|
|
45
|
+
css`
|
|
46
|
+
box-shadow: 0 0 0 2px ${({ theme }) => theme.color.border.error};
|
|
47
|
+
background-color: ${({ theme }) => theme.color.surface.secondary};
|
|
48
|
+
|
|
49
|
+
&:focus {
|
|
50
|
+
box-shadow: 0 0 0 2px ${({ theme }) => theme.color.border.error};
|
|
51
|
+
}
|
|
52
|
+
`}
|
|
53
|
+
|
|
54
|
+
&[data-state='checked'] {
|
|
55
|
+
background-color: ${({ theme }) => theme.color.surface.on};
|
|
56
|
+
}
|
|
57
|
+
`;
|
|
58
|
+
|
|
59
|
+
export const SwitchContainer = styled.div``;
|
|
60
|
+
|
|
61
|
+
export const SwitchThumb = styled(Switch.Thumb)`
|
|
62
|
+
display: block;
|
|
63
|
+
width: 24px;
|
|
64
|
+
height: 24px;
|
|
65
|
+
background-color: ${({ theme }) => theme.color.surface.primary};
|
|
66
|
+
border-radius: 9999px;
|
|
67
|
+
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
|
|
68
|
+
transition: transform 100ms;
|
|
69
|
+
transform: translateX(4px);
|
|
70
|
+
will-change: transform;
|
|
71
|
+
|
|
72
|
+
&[data-state='checked'] {
|
|
73
|
+
transform: translateX(28px);
|
|
74
|
+
}
|
|
75
|
+
`;
|