@okam/stack-ui 1.25.2 → 1.25.3
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/.eslintrc.js +32 -0
- package/.storybook/.eslintrc.js +29 -0
- package/.storybook/main.ts +33 -0
- package/.storybook/preview.js +56 -0
- package/.storybook/tsconfig.json +17 -0
- package/CHANGELOG.md +574 -0
- package/README.md +8 -0
- package/package.json +1 -1
- package/postcss.config.js +15 -0
- package/project.json +77 -0
- package/src/_stories/icons/code-brackets.svg +1 -0
- package/src/_stories/icons/colors.svg +1 -0
- package/src/_stories/icons/comments.svg +1 -0
- package/src/_stories/icons/direction.svg +1 -0
- package/src/_stories/icons/flow.svg +1 -0
- package/src/_stories/icons/plugin.svg +1 -0
- package/src/_stories/icons/repo.svg +1 -0
- package/src/_stories/icons/stackalt.svg +1 -0
- package/src/components/Accordion/accordion.stories.mdx +240 -0
- package/src/components/Accordion/components/AccordionItem.tsx +53 -0
- package/src/components/Accordion/components/AriaAccordionItem.tsx +76 -0
- package/src/components/Accordion/hooks/useAccordionState.ts +46 -0
- package/src/components/Accordion/index.tsx +38 -0
- package/{components/Accordion/interface.d.ts → src/components/Accordion/interface.ts} +23 -17
- package/src/components/Alerts/alerts.stories.mdx +282 -0
- package/src/components/Alerts/components/AlertsCloseButton.tsx +20 -0
- package/src/components/Alerts/components/AlertsItem.tsx +39 -0
- package/src/components/Alerts/components/AlertsNavigationButton.tsx +71 -0
- package/src/components/Alerts/components/AlertsSwiper.tsx +125 -0
- package/src/components/Alerts/components/pagination/AlertsPagination.tsx +32 -0
- package/src/components/Alerts/components/pagination/AlertsPaginationBullet.tsx +61 -0
- package/src/components/Alerts/index.tsx +54 -0
- package/src/components/Alerts/interface.ts +51 -0
- package/src/components/Box/box.stories.mdx +27 -0
- package/src/components/Box/index.tsx +36 -0
- package/src/components/Box/interface.ts +10 -0
- package/src/components/Button/button.stories.mdx +99 -0
- package/src/components/Button/index.tsx +92 -0
- package/src/components/Button/interface.ts +22 -0
- package/src/components/Calendar/RangeCalendar.tsx +61 -0
- package/src/components/Calendar/calendar.stories.mdx +28 -0
- package/src/components/Calendar/components/CalendarCell.tsx +60 -0
- package/src/components/Calendar/components/CalendarGrid.tsx +44 -0
- package/src/components/Calendar/index.tsx +63 -0
- package/src/components/Calendar/interface.ts +37 -0
- package/src/components/Carousel/carousel.stories.mdx +182 -0
- package/src/components/Carousel/index.tsx +99 -0
- package/src/components/Carousel/interface.ts +26 -0
- package/src/components/Date/date.stories.mdx +122 -0
- package/src/components/Date/index.tsx +35 -0
- package/src/components/Date/interface.ts +7 -0
- package/src/components/Dialog/index.tsx +14 -0
- package/src/components/Dialog/interface.ts +6 -0
- package/src/components/DirectusImg/index.tsx +59 -0
- package/src/components/DirectusImg/interface.ts +19 -0
- package/src/components/Icon/index.tsx +40 -0
- package/src/components/Icon/interface.ts +8 -0
- package/src/components/Img/img.stories.mdx +28 -0
- package/src/components/Img/index.tsx +30 -0
- package/src/components/Img/interface.ts +9 -0
- package/src/components/Lightbox/hooks/overlay/index.tsx +36 -0
- package/src/components/Lightbox/index.tsx +82 -0
- package/src/components/Lightbox/interface.ts +28 -0
- package/src/components/Lightbox/lightbox.stories.mdx +79 -0
- package/src/components/Menu/Menu.tsx +43 -0
- package/src/components/Menu/MenuSidePanel.tsx +41 -0
- package/src/components/Menu/components/InnerContent.tsx +26 -0
- package/src/components/Menu/components/MenuItems.tsx +133 -0
- package/src/components/Menu/components/TabContainer.tsx +13 -0
- package/src/components/Menu/interface.ts +41 -0
- package/src/components/Menu/menu.stories.mdx +23 -0
- package/src/components/Modal/components/ModalDialog.tsx +31 -0
- package/src/components/Modal/components/ModalOverlay.tsx +21 -0
- package/src/components/Modal/index.tsx +32 -0
- package/{components/Modal/interface.d.ts → src/components/Modal/interface.ts} +14 -11
- package/src/components/Popover/index.tsx +138 -0
- package/src/components/Popover/interface.ts +25 -0
- package/src/components/Popover/popover.stories.mdx +66 -0
- package/src/components/ShareButton/index.tsx +172 -0
- package/src/components/ShareButton/interface.ts +29 -0
- package/src/components/ShareButton/share-button.stories.mdx +48 -0
- package/src/components/ShareButton/utils/generateUtmTags.ts +4 -0
- package/src/components/ShareButton/utils/useFacebookShareUrl.ts +15 -0
- package/src/components/ShareButton/utils/useMailToShareUrl.ts +15 -0
- package/src/components/ShareButton/utils/useTwitterShareUrl.ts +15 -0
- package/src/components/ShareButton/utils/useWindow.ts +17 -0
- package/src/components/SidePanel/index.tsx +43 -0
- package/src/components/SidePanel/interface.ts +16 -0
- package/src/components/SidePanel/side-panel.stories.mdx +44 -0
- package/src/components/TabList/components/Tab/Tab.tsx +19 -0
- package/src/components/TabList/components/TabPanel/TabPanel.tsx +27 -0
- package/src/components/TabList/index.tsx +44 -0
- package/src/components/TabList/interface.ts +23 -0
- package/src/components/Typography/index.tsx +35 -0
- package/src/components/Typography/interface.ts +9 -0
- package/src/components/Typography/typo.stories.mdx +157 -0
- package/src/components/WysiwygBlock/index.tsx +20 -0
- package/src/components/WysiwygBlock/interface.ts +7 -0
- package/src/components/WysiwygBlock/wysiwyg.stories.mdx +53 -0
- package/src/components/fields/Checkbox/Checkbox.interface.ts +21 -0
- package/src/components/fields/Checkbox/Checkbox.stories.mdx +127 -0
- package/src/components/fields/Checkbox/index.tsx +62 -0
- package/src/components/fields/CheckboxGroup/checkbox-group.stories.mdx +59 -0
- package/src/components/fields/CheckboxGroup/components/CheckboxGroupItem/index.tsx +66 -0
- package/src/components/fields/CheckboxGroup/index.tsx +49 -0
- package/src/components/fields/CheckboxGroup/interface.ts +17 -0
- package/src/components/fields/DatePicker/DateRangePicker.tsx +73 -0
- package/src/components/fields/DatePicker/components/CalendarPopover.tsx +31 -0
- package/src/components/fields/DatePicker/components/DateField.tsx +61 -0
- package/src/components/fields/DatePicker/date-picker.stories.mdx +55 -0
- package/src/components/fields/DatePicker/index.tsx +71 -0
- package/src/components/fields/DatePicker/interface.ts +69 -0
- package/src/components/fields/Radio/Radio.interface.ts +30 -0
- package/src/components/fields/Radio/index.tsx +63 -0
- package/src/components/fields/RadioGroup/index.tsx +33 -0
- package/src/components/fields/RadioGroup/interface.ts +10 -0
- package/src/components/fields/RadioGroup/radio-group.stories.mdx +56 -0
- package/src/components/fields/SearchField/index.tsx +59 -0
- package/src/components/fields/SearchField/interface.ts +10 -0
- package/src/components/fields/SearchField/search.stories.mdx +91 -0
- package/src/components/fields/Select/Select.interface.ts +24 -0
- package/src/components/fields/Select/Select.stories.mdx +53 -0
- package/src/components/fields/Select/Select.tsx +108 -0
- package/{components/fields/Select/components/Listbox.interface.d.ts → src/components/fields/Select/components/Listbox.interface.ts} +11 -8
- package/src/components/fields/Select/components/Listbox.tsx +40 -0
- package/src/components/fields/Select/components/Popover.interface.ts +14 -0
- package/src/components/fields/Select/components/Popover.tsx +32 -0
- package/{components/fields/SelectItem/SelectItem.interface.d.ts → src/components/fields/SelectItem/SelectItem.interface.ts} +4 -3
- package/src/components/fields/SelectItem/SelectItem.tsx +10 -0
- package/src/components/fields/TextArea/index.tsx +105 -0
- package/src/components/fields/TextArea/textArea.stories.mdx +60 -0
- package/src/components/fields/TextInputField/index.tsx +107 -0
- package/src/components/fields/TextInputField/interface.ts +30 -0
- package/src/components/fields/TextInputField/text-input-field.stories.mdx +64 -0
- package/src/components/icons/ArrowDown.tsx +11 -0
- package/src/components/icons/ArrowLeft.tsx +18 -0
- package/src/components/icons/ArrowRight.tsx +18 -0
- package/src/components/icons/Check.tsx +11 -0
- package/src/components/icons/ChevronLeft.tsx +11 -0
- package/src/components/icons/ChevronRight.tsx +11 -0
- package/src/components/icons/CloseBtn.tsx +11 -0
- package/src/components/icons/Facebook.tsx +14 -0
- package/src/components/icons/FacebookColored.tsx +16 -0
- package/src/components/icons/FacebookRounded.tsx +16 -0
- package/src/components/icons/Globe.tsx +38 -0
- package/src/components/icons/IconFallback.tsx +8 -0
- package/src/components/icons/Instagram.tsx +14 -0
- package/src/components/icons/InstagramColored.tsx +59 -0
- package/src/components/icons/Link.tsx +14 -0
- package/src/components/icons/LinkedIn.tsx +16 -0
- package/src/components/icons/Mail.tsx +16 -0
- package/src/components/icons/Plus.tsx +18 -0
- package/src/components/icons/Search.tsx +19 -0
- package/src/components/icons/Share.tsx +16 -0
- package/src/components/icons/Twitter.tsx +16 -0
- package/src/components/icons/TwitterColored.tsx +16 -0
- package/src/components/icons/Upload.tsx +14 -0
- package/src/components/icons/X.tsx +14 -0
- package/src/components/icons/YouTube.tsx +16 -0
- package/src/components/icons/YouTubeColored.tsx +17 -0
- package/src/components/icons/index.ts +24 -0
- package/src/examples/PageLayout/index.tsx +61 -0
- package/src/examples/PageLayout/layout.stories.mdx +35 -0
- package/{index.d.ts → src/index.ts} +72 -57
- package/src/message.tsx +8 -0
- package/src/providers/Accordion/index.tsx +15 -0
- package/src/providers/Accordion/interface.ts +14 -0
- package/src/providers/Alerts/index.tsx +15 -0
- package/src/providers/Alerts/interface.ts +11 -0
- package/src/providers/CheckboxGroup/index.tsx +22 -0
- package/{providers/CheckboxGroup/interface.d.ts → src/providers/CheckboxGroup/interface.ts} +5 -4
- package/src/providers/Client/index.tsx +21 -0
- package/src/providers/Client/interface.ts +13 -0
- package/src/providers/Menu/index.tsx +43 -0
- package/src/providers/Menu/interface.ts +32 -0
- package/src/providers/RadioGroup/RadioGroup.interface.ts +8 -0
- package/src/providers/RadioGroup/RadioGroup.tsx +25 -0
- package/src/providers/SidePanel/index.tsx +55 -0
- package/src/providers/SidePanel/interface.ts +26 -0
- package/src/providers/Theme/hooks.ts +25 -0
- package/src/providers/Theme/index.tsx +40 -0
- package/src/providers/Theme/interface.ts +28 -0
- package/src/providers/Theme/utils.ts +3 -0
- package/src/providers/UserSearchQuery/index.tsx +20 -0
- package/src/providers/UserSearchQuery/interface.ts +12 -0
- package/src/storybook/Lightbox/LightboxControlledState.tsx +28 -0
- package/src/storybook/Menu/Menu.tsx +177 -0
- package/src/storybook/Menu/NestedMenu.tsx +24 -0
- package/src/storybook/Menu/mock.tsx +84 -0
- package/src/storybook/SelectField/index.tsx +57 -0
- package/src/storybook/ShareButtonExample/index.tsx +66 -0
- package/src/tailwind.css +3 -0
- package/src/theme/Accordion/index.tsx +101 -0
- package/src/theme/Alerts/index.ts +97 -0
- package/src/theme/Box/index.ts +45 -0
- package/src/theme/Button/index.tsx +72 -0
- package/src/theme/Calendar/index.tsx +167 -0
- package/src/theme/Carousel/index.ts +36 -0
- package/src/theme/Checkbox/index.ts +49 -0
- package/src/theme/CheckboxGroup/index.ts +14 -0
- package/src/theme/DatePicker/index.tsx +42 -0
- package/src/theme/Image/index.ts +8 -0
- package/src/theme/LightBox/index.ts +56 -0
- package/src/theme/Radio/index.ts +31 -0
- package/src/theme/RadioGroup/index.ts +14 -0
- package/src/theme/Search/index.ts +20 -0
- package/src/theme/ShareButton/index.tsx +76 -0
- package/src/theme/SidePanel/index.ts +9 -0
- package/src/theme/TextArea/index.ts +25 -0
- package/src/theme/Typography/index.tsx +44 -0
- package/src/theme/index.tsx +178 -0
- package/src/transitions/AccordionTransition.tsx +26 -0
- package/src/transitions/ModalTransition.tsx +38 -0
- package/src/transitions/RenderWithOpacity.tsx +25 -0
- package/src/transitions/RenderWithSlide.tsx +21 -0
- package/src/transitions/SidePanelTransition.tsx +30 -0
- package/src/types/components.ts +34 -0
- package/static/images/image.png +0 -0
- package/tailwind.config.js +14 -0
- package/tsconfig.json +20 -0
- package/tsconfig.lib.json +25 -0
- package/vite.config.ts +58 -0
- package/components/Accordion/components/AccordionItem.d.ts +0 -3
- package/components/Accordion/components/AriaAccordionItem.d.ts +0 -3
- package/components/Accordion/hooks/useAccordionState.d.ts +0 -10
- package/components/Accordion/index.d.ts +0 -3
- package/components/Alerts/components/AlertsCloseButton.d.ts +0 -4
- package/components/Alerts/components/AlertsItem.d.ts +0 -3
- package/components/Alerts/components/AlertsNavigationButton.d.ts +0 -8
- package/components/Alerts/components/AlertsSwiper.d.ts +0 -3
- package/components/Alerts/components/pagination/AlertsPagination.d.ts +0 -3
- package/components/Alerts/components/pagination/AlertsPaginationBullet.d.ts +0 -3
- package/components/Alerts/index.d.ts +0 -3
- package/components/Alerts/interface.d.ts +0 -41
- package/components/Box/index.d.ts +0 -5
- package/components/Box/interface.d.ts +0 -10
- package/components/Button/index.d.ts +0 -6
- package/components/Button/interface.d.ts +0 -20
- package/components/Calendar/RangeCalendar.d.ts +0 -3
- package/components/Calendar/components/CalendarCell.d.ts +0 -3
- package/components/Calendar/components/CalendarGrid.d.ts +0 -3
- package/components/Calendar/index.d.ts +0 -3
- package/components/Calendar/interface.d.ts +0 -32
- package/components/Carousel/index.d.ts +0 -3
- package/components/Carousel/interface.d.ts +0 -24
- package/components/Date/index.d.ts +0 -3
- package/components/Date/interface.d.ts +0 -6
- package/components/Dialog/index.d.ts +0 -2
- package/components/Dialog/interface.d.ts +0 -6
- package/components/DirectusImg/index.d.ts +0 -3
- package/components/DirectusImg/interface.d.ts +0 -13
- package/components/Icon/index.d.ts +0 -3
- package/components/Icon/interface.d.ts +0 -7
- package/components/Img/index.d.ts +0 -3
- package/components/Img/interface.d.ts +0 -6
- package/components/Lightbox/index.d.ts +0 -3
- package/components/Lightbox/interface.d.ts +0 -25
- package/components/Menu/Menu.d.ts +0 -3
- package/components/Menu/MenuSidePanel.d.ts +0 -3
- package/components/Menu/components/InnerContent.d.ts +0 -3
- package/components/Menu/components/MenuItems.d.ts +0 -3
- package/components/Menu/components/TabContainer.d.ts +0 -3
- package/components/Menu/interface.d.ts +0 -31
- package/components/Modal/components/ModalDialog.d.ts +0 -3
- package/components/Modal/components/ModalOverlay.d.ts +0 -3
- package/components/Modal/index.d.ts +0 -3
- package/components/Popover/index.d.ts +0 -3
- package/components/Popover/interface.d.ts +0 -21
- package/components/ShareButton/index.d.ts +0 -4
- package/components/ShareButton/interface.d.ts +0 -26
- package/components/ShareButton/utils/generateUtmTags.d.ts +0 -2
- package/components/ShareButton/utils/useFacebookShareUrl.d.ts +0 -2
- package/components/ShareButton/utils/useMailToShareUrl.d.ts +0 -2
- package/components/ShareButton/utils/useTwitterShareUrl.d.ts +0 -2
- package/components/ShareButton/utils/useWindow.d.ts +0 -5
- package/components/SidePanel/index.d.ts +0 -4
- package/components/SidePanel/interface.d.ts +0 -12
- package/components/TabList/components/TabPanel/TabPanel.d.ts +0 -4
- package/components/TabList/interface.d.ts +0 -18
- package/components/Typography/index.d.ts +0 -5
- package/components/Typography/interface.d.ts +0 -9
- package/components/WysiwygBlock/index.d.ts +0 -3
- package/components/WysiwygBlock/interface.d.ts +0 -5
- package/components/fields/Checkbox/Checkbox.interface.d.ts +0 -18
- package/components/fields/Checkbox/index.d.ts +0 -3
- package/components/fields/CheckboxGroup/components/CheckboxGroupItem/index.d.ts +0 -3
- package/components/fields/CheckboxGroup/index.d.ts +0 -3
- package/components/fields/CheckboxGroup/interface.d.ts +0 -13
- package/components/fields/DatePicker/DateRangePicker.d.ts +0 -3
- package/components/fields/DatePicker/components/CalendarPopover.d.ts +0 -2
- package/components/fields/DatePicker/components/DateField.d.ts +0 -4
- package/components/fields/DatePicker/index.d.ts +0 -3
- package/components/fields/DatePicker/interface.d.ts +0 -37
- package/components/fields/Radio/Radio.interface.d.ts +0 -26
- package/components/fields/Radio/index.d.ts +0 -4
- package/components/fields/RadioGroup/index.d.ts +0 -3
- package/components/fields/RadioGroup/interface.d.ts +0 -9
- package/components/fields/SearchField/index.d.ts +0 -3
- package/components/fields/SearchField/interface.d.ts +0 -9
- package/components/fields/Select/Select.d.ts +0 -4
- package/components/fields/Select/Select.interface.d.ts +0 -26
- package/components/fields/Select/components/Listbox.d.ts +0 -4
- package/components/fields/Select/components/Popover.d.ts +0 -3
- package/components/fields/Select/components/Popover.interface.d.ts +0 -13
- package/components/fields/SelectItem/SelectItem.d.ts +0 -3
- package/components/fields/TextArea/index.d.ts +0 -4
- package/components/fields/TextInputField/index.d.ts +0 -4
- package/components/fields/TextInputField/interface.d.ts +0 -24
- package/components/icons/ArrowDown.d.ts +0 -3
- package/components/icons/ArrowLeft.d.ts +0 -3
- package/components/icons/ArrowRight.d.ts +0 -3
- package/components/icons/Check.d.ts +0 -3
- package/components/icons/ChevronLeft.d.ts +0 -3
- package/components/icons/ChevronRight.d.ts +0 -3
- package/components/icons/CloseBtn.d.ts +0 -3
- package/components/icons/Facebook.d.ts +0 -3
- package/components/icons/FacebookColored.d.ts +0 -3
- package/components/icons/FacebookRounded.d.ts +0 -3
- package/components/icons/Globe.d.ts +0 -3
- package/components/icons/IconFallback.d.ts +0 -3
- package/components/icons/Instagram.d.ts +0 -3
- package/components/icons/InstagramColored.d.ts +0 -3
- package/components/icons/Link.d.ts +0 -3
- package/components/icons/LinkedIn.d.ts +0 -3
- package/components/icons/Mail.d.ts +0 -3
- package/components/icons/Plus.d.ts +0 -3
- package/components/icons/Search.d.ts +0 -3
- package/components/icons/Share.d.ts +0 -3
- package/components/icons/Twitter.d.ts +0 -3
- package/components/icons/TwitterColored.d.ts +0 -3
- package/components/icons/Upload.d.ts +0 -3
- package/components/icons/X.d.ts +0 -3
- package/components/icons/YouTube.d.ts +0 -3
- package/components/icons/YouTubeColored.d.ts +0 -3
- package/components/icons/index.d.ts +0 -24
- package/index.js +0 -110
- package/index.mjs +0 -12897
- package/providers/Accordion/index.d.ts +0 -4
- package/providers/Accordion/interface.d.ts +0 -12
- package/providers/Alerts/index.d.ts +0 -4
- package/providers/Alerts/interface.d.ts +0 -9
- package/providers/CheckboxGroup/index.d.ts +0 -5
- package/providers/Client/index.d.ts +0 -4
- package/providers/Client/interface.d.ts +0 -10
- package/providers/Menu/index.d.ts +0 -4
- package/providers/Menu/interface.d.ts +0 -28
- package/providers/RadioGroup/RadioGroup.d.ts +0 -5
- package/providers/RadioGroup/RadioGroup.interface.d.ts +0 -7
- package/providers/SidePanel/index.d.ts +0 -4
- package/providers/SidePanel/interface.d.ts +0 -23
- package/providers/Theme/hooks.d.ts +0 -3
- package/providers/Theme/index.d.ts +0 -10
- package/providers/Theme/interface.d.ts +0 -24
- package/providers/Theme/utils.d.ts +0 -2
- package/providers/UserSearchQuery/index.d.ts +0 -4
- package/providers/UserSearchQuery/interface.d.ts +0 -10
- package/style.css +0 -1
- package/theme/Accordion/index.d.ts +0 -274
- package/theme/Alerts/index.d.ts +0 -1167
- package/theme/Box/index.d.ts +0 -214
- package/theme/Button/index.d.ts +0 -121
- package/theme/Calendar/index.d.ts +0 -366
- package/theme/Carousel/index.d.ts +0 -9
- package/theme/Checkbox/index.d.ts +0 -159
- package/theme/CheckboxGroup/index.d.ts +0 -30
- package/theme/DatePicker/index.d.ts +0 -43
- package/theme/Image/index.d.ts +0 -3
- package/theme/LightBox/index.d.ts +0 -455
- package/theme/Radio/index.d.ts +0 -108
- package/theme/RadioGroup/index.d.ts +0 -30
- package/theme/Search/index.d.ts +0 -30
- package/theme/ShareButton/index.d.ts +0 -174
- package/theme/SidePanel/index.d.ts +0 -3
- package/theme/TextArea/index.d.ts +0 -29
- package/theme/Typography/index.d.ts +0 -233
- package/theme/index.d.ts +0 -5
- package/transitions/AccordionTransition.d.ts +0 -3
- package/transitions/ModalTransition.d.ts +0 -7
- package/transitions/RenderWithOpacity.d.ts +0 -3
- package/transitions/RenderWithSlide.d.ts +0 -7
- package/transitions/SidePanelTransition.d.ts +0 -7
- package/types/components.d.ts +0 -28
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { Canvas, Meta, Story } from '@storybook/addon-docs'
|
|
2
|
+
import { ArgTypes } from '@storybook/blocks'
|
|
3
|
+
import Carousel from './index'
|
|
4
|
+
import Button from '../Button'
|
|
5
|
+
|
|
6
|
+
<Meta
|
|
7
|
+
title="Base Components/Carousel"
|
|
8
|
+
component={Carousel}
|
|
9
|
+
argTypes={{
|
|
10
|
+
navigationButtons: {
|
|
11
|
+
description: 'This prop allows the override of the button proposed in the default state',
|
|
12
|
+
},
|
|
13
|
+
slides: {
|
|
14
|
+
description: 'Slides takes in an array of object with an `id` and a `child` being a ReactNode',
|
|
15
|
+
},
|
|
16
|
+
}}
|
|
17
|
+
parameters={{
|
|
18
|
+
layout: 'fullscreen',
|
|
19
|
+
}}
|
|
20
|
+
args={{
|
|
21
|
+
slides: [
|
|
22
|
+
{
|
|
23
|
+
id: 1,
|
|
24
|
+
child: <div>Slide 1</div>,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: 2,
|
|
28
|
+
child: <div>Slide 2</div>,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: 3,
|
|
32
|
+
child: <div>Slide 3</div>,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 4,
|
|
36
|
+
child: <div>Slide 4</div>,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
}}
|
|
40
|
+
/>
|
|
41
|
+
|
|
42
|
+
export const Template = (args) => {
|
|
43
|
+
return <Carousel {...args} />
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
# Carousel
|
|
47
|
+
|
|
48
|
+
Carousel component. More commonly used for a showcase of images. When using the carousel component, you must import React Swiper CSS files
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import 'swiper/css'
|
|
52
|
+
import 'swiper/css/pagination'
|
|
53
|
+
import 'swiper/css/a11y'
|
|
54
|
+
import 'swiper/css/autoplay'
|
|
55
|
+
import 'swiper/css/navigation'
|
|
56
|
+
import 'swiper/css/mousewheel'
|
|
57
|
+
import 'swiper/css/keyboard'
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Props
|
|
61
|
+
|
|
62
|
+
<ArgTypes />
|
|
63
|
+
|
|
64
|
+
## Showcase
|
|
65
|
+
|
|
66
|
+
### Basic carousel with 2 slides per view
|
|
67
|
+
|
|
68
|
+
<Canvas>
|
|
69
|
+
<Story
|
|
70
|
+
name="Carousel"
|
|
71
|
+
args={{
|
|
72
|
+
id: 1,
|
|
73
|
+
navigation: true,
|
|
74
|
+
slidesPerView: 2,
|
|
75
|
+
}}
|
|
76
|
+
>
|
|
77
|
+
{Template.bind({})}
|
|
78
|
+
</Story>
|
|
79
|
+
</Canvas>
|
|
80
|
+
|
|
81
|
+
### Carousel with autoplay
|
|
82
|
+
|
|
83
|
+
<Canvas>
|
|
84
|
+
<Story
|
|
85
|
+
name="Carousel with autoplay"
|
|
86
|
+
args={{
|
|
87
|
+
id: 2,
|
|
88
|
+
autoplay: true,
|
|
89
|
+
navigation: true,
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
92
|
+
{Template.bind({})}
|
|
93
|
+
</Story>
|
|
94
|
+
</Canvas>
|
|
95
|
+
|
|
96
|
+
### Carousel with infinite looping
|
|
97
|
+
|
|
98
|
+
<Canvas>
|
|
99
|
+
<Story
|
|
100
|
+
name="Carousel with infinite looping"
|
|
101
|
+
args={{
|
|
102
|
+
id: 3,
|
|
103
|
+
loop: true,
|
|
104
|
+
navigation: true,
|
|
105
|
+
}}
|
|
106
|
+
>
|
|
107
|
+
{Template.bind({})}
|
|
108
|
+
</Story>
|
|
109
|
+
</Canvas>
|
|
110
|
+
|
|
111
|
+
### Carousel with pagination
|
|
112
|
+
|
|
113
|
+
<Canvas>
|
|
114
|
+
<Story
|
|
115
|
+
name="Carousel with pagination"
|
|
116
|
+
args={{
|
|
117
|
+
id: 4,
|
|
118
|
+
slides: [
|
|
119
|
+
{
|
|
120
|
+
id: 1,
|
|
121
|
+
child: (
|
|
122
|
+
<div>
|
|
123
|
+
Slide 1<br />
|
|
124
|
+
​
|
|
125
|
+
</div>
|
|
126
|
+
),
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
id: 2,
|
|
130
|
+
child: (
|
|
131
|
+
<div>
|
|
132
|
+
Slide 2<br />
|
|
133
|
+
​
|
|
134
|
+
</div>
|
|
135
|
+
),
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
id: 3,
|
|
139
|
+
child: (
|
|
140
|
+
<div>
|
|
141
|
+
Slide 3<br />
|
|
142
|
+
​
|
|
143
|
+
</div>
|
|
144
|
+
),
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
id: 4,
|
|
148
|
+
child: (
|
|
149
|
+
<div>
|
|
150
|
+
Slide 4<br />
|
|
151
|
+
​
|
|
152
|
+
</div>
|
|
153
|
+
),
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
pagination: {
|
|
157
|
+
clickable: true,
|
|
158
|
+
},
|
|
159
|
+
navigation: false,
|
|
160
|
+
}}
|
|
161
|
+
>
|
|
162
|
+
{Template.bind({})}
|
|
163
|
+
</Story>
|
|
164
|
+
</Canvas>
|
|
165
|
+
|
|
166
|
+
### Carousel with custom buttons
|
|
167
|
+
|
|
168
|
+
<Canvas>
|
|
169
|
+
<Story
|
|
170
|
+
name="Carousel custom buttons"
|
|
171
|
+
args={{
|
|
172
|
+
id: 4,
|
|
173
|
+
navigation: true,
|
|
174
|
+
navigationButtons: {
|
|
175
|
+
leftButton: <Button>Previous slide</Button>,
|
|
176
|
+
rightButton: <Button>Next slide</Button>,
|
|
177
|
+
},
|
|
178
|
+
}}
|
|
179
|
+
>
|
|
180
|
+
{Template.bind({})}
|
|
181
|
+
</Story>
|
|
182
|
+
</Canvas>
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import React, { useState } from 'react'
|
|
4
|
+
import type { PressEvent } from 'react-aria'
|
|
5
|
+
import type Swiper from 'swiper'
|
|
6
|
+
import { Navigation, Mousewheel, Keyboard, Pagination, Autoplay, A11y } from 'swiper/modules'
|
|
7
|
+
import { Swiper as SwiperComponent, SwiperSlide } from 'swiper/react'
|
|
8
|
+
import useThemeContext from '../../providers/Theme/hooks'
|
|
9
|
+
import Box from '../Box'
|
|
10
|
+
import Button from '../Button'
|
|
11
|
+
import Icon from '../Icon'
|
|
12
|
+
import type { TCarouselButtonProps, TCarouselProps } from './interface'
|
|
13
|
+
|
|
14
|
+
const CarouselButton = (props: TCarouselButtonProps) => {
|
|
15
|
+
const { navigationButton, icon, themeName = 'carousel', tokens, id, swiperFn } = props
|
|
16
|
+
const onKeyDown = (key: React.KeyboardEvent | PressEvent) => {
|
|
17
|
+
if (('pointerType' in key && key.pointerType === 'keyboard') || ('code' in key && key.code === 'Enter'))
|
|
18
|
+
swiperFn?.()
|
|
19
|
+
}
|
|
20
|
+
return navigationButton ? (
|
|
21
|
+
React.cloneElement(navigationButton, {
|
|
22
|
+
onKeyDown,
|
|
23
|
+
handlePress: onKeyDown,
|
|
24
|
+
})
|
|
25
|
+
) : (
|
|
26
|
+
<Button themeName={`${themeName}.navigationButtons`} tokens={{ ...tokens, className: id }} handlePress={onKeyDown}>
|
|
27
|
+
<Icon icon={icon} />
|
|
28
|
+
</Button>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const Carousel = (props: TCarouselProps) => {
|
|
33
|
+
const { id, slides, children, navigationButtons, themeName = 'carousel', tokens, customTheme, ...rest } = props
|
|
34
|
+
const showNavigation = slides && slides?.length > 1
|
|
35
|
+
|
|
36
|
+
const { navigation, slidesPerView } = props
|
|
37
|
+
|
|
38
|
+
const swiperTheme = useThemeContext(`${themeName}.swiper`, tokens)
|
|
39
|
+
const swiperWrapperTheme = useThemeContext(`${themeName}.swiperWrapper`, tokens)
|
|
40
|
+
const slideWrapperTheme = useThemeContext(`${themeName}.slideWrapper`, tokens)
|
|
41
|
+
|
|
42
|
+
const [swiper, setSwiper] = useState<Swiper>()
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<Box themeName={`${themeName}.container`} tokens={tokens} customTheme={customTheme} {...rest}>
|
|
46
|
+
{showNavigation && navigation && (
|
|
47
|
+
<CarouselButton
|
|
48
|
+
themeName={themeName}
|
|
49
|
+
tokens={tokens}
|
|
50
|
+
navigationButton={navigationButtons?.leftButton}
|
|
51
|
+
id={`button-prev-${id}`}
|
|
52
|
+
icon="ArrowLeft"
|
|
53
|
+
swiperFn={() => swiper?.slidePrev()}
|
|
54
|
+
swiper={swiper}
|
|
55
|
+
/>
|
|
56
|
+
)}
|
|
57
|
+
<SwiperComponent
|
|
58
|
+
modules={[Navigation, Mousewheel, Keyboard, Pagination, Autoplay, A11y]}
|
|
59
|
+
{...rest}
|
|
60
|
+
navigation={{
|
|
61
|
+
prevEl: `.button-prev-${id}`,
|
|
62
|
+
nextEl: `.button-next-${id}`,
|
|
63
|
+
disabledClass: `button-disabled`,
|
|
64
|
+
}}
|
|
65
|
+
onSwiper={setSwiper}
|
|
66
|
+
wrapperClass={swiperWrapperTheme}
|
|
67
|
+
className={swiperTheme}
|
|
68
|
+
mousewheel
|
|
69
|
+
keyboard
|
|
70
|
+
watchOverflow
|
|
71
|
+
slidesPerView={slidesPerView ?? 1}
|
|
72
|
+
>
|
|
73
|
+
{slides?.map((slide) => {
|
|
74
|
+
return (
|
|
75
|
+
<SwiperSlide key={slide.id} className={slideWrapperTheme}>
|
|
76
|
+
<Box themeName={`${themeName}.slideContainer`} tokens={tokens}>
|
|
77
|
+
{slide.child}
|
|
78
|
+
</Box>
|
|
79
|
+
</SwiperSlide>
|
|
80
|
+
)
|
|
81
|
+
})}
|
|
82
|
+
</SwiperComponent>
|
|
83
|
+
{showNavigation && navigation && (
|
|
84
|
+
<CarouselButton
|
|
85
|
+
themeName={themeName}
|
|
86
|
+
tokens={tokens}
|
|
87
|
+
navigationButton={navigationButtons?.rightButton}
|
|
88
|
+
id={`button-next-${id}`}
|
|
89
|
+
icon="ArrowRight"
|
|
90
|
+
swiperFn={() => swiper?.slideNext()}
|
|
91
|
+
swiper={swiper}
|
|
92
|
+
/>
|
|
93
|
+
)}
|
|
94
|
+
{children}
|
|
95
|
+
</Box>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export default Carousel
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type React from 'react'
|
|
2
|
+
import type Swiper from 'swiper'
|
|
3
|
+
import type { SwiperOptions } from 'swiper/types/swiper-options'
|
|
4
|
+
import type { TDefaultComponent } from '../../types/components'
|
|
5
|
+
|
|
6
|
+
export type TSlide = {
|
|
7
|
+
id?: string
|
|
8
|
+
child?: React.ReactNode
|
|
9
|
+
}
|
|
10
|
+
export interface TCarouselProps extends TDefaultComponent, SwiperOptions {
|
|
11
|
+
id?: React.Key
|
|
12
|
+
children?: React.ReactNode
|
|
13
|
+
slides?: TSlide[]
|
|
14
|
+
navigationButtons?: {
|
|
15
|
+
leftButton: React.ReactElement
|
|
16
|
+
rightButton: React.ReactElement
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface TCarouselButtonProps extends TDefaultComponent {
|
|
21
|
+
navigationButton?: React.ReactElement
|
|
22
|
+
icon: string
|
|
23
|
+
id: string
|
|
24
|
+
swiperFn: () => void
|
|
25
|
+
swiper: Swiper | undefined
|
|
26
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
{/* Date.stories.mdx */}
|
|
2
|
+
import { I18nProvider } from 'react-aria'
|
|
3
|
+
import { Canvas, Meta, Story } from '@storybook/addon-docs'
|
|
4
|
+
import Date from './index'
|
|
5
|
+
|
|
6
|
+
<Meta title="BASE COMPONENTS/Date" component={Date} />
|
|
7
|
+
|
|
8
|
+
export const Template = (args) => <Date {...args} />
|
|
9
|
+
export const FrenchTemplate = (args) => (
|
|
10
|
+
<I18nProvider locale="fr-FR">
|
|
11
|
+
<Date {...args} />
|
|
12
|
+
</I18nProvider>
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
# Date
|
|
16
|
+
|
|
17
|
+
Date component. Must pass a valid ISO `date`. You can also pass an object `dateFormatterOptions` to change the format, e.g. `MMM dd, yyyy` or `MM/DD/YY`.
|
|
18
|
+
The language is handled by the `I18nProvider` of `react-aria`.
|
|
19
|
+
|
|
20
|
+
<Canvas>
|
|
21
|
+
<Story
|
|
22
|
+
name="Different Language"
|
|
23
|
+
args={{
|
|
24
|
+
date: '2021-12-31T00:01:00-0500',
|
|
25
|
+
dateFormatterOptions: {
|
|
26
|
+
month: 'long',
|
|
27
|
+
day: 'numeric',
|
|
28
|
+
year: 'numeric',
|
|
29
|
+
},
|
|
30
|
+
tokens: {
|
|
31
|
+
size: 'paragraph',
|
|
32
|
+
},
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
{FrenchTemplate.bind({})}
|
|
36
|
+
</Story>
|
|
37
|
+
</Canvas>
|
|
38
|
+
|
|
39
|
+
<Canvas>
|
|
40
|
+
<Story
|
|
41
|
+
name="Short"
|
|
42
|
+
args={{
|
|
43
|
+
date: '2021-12-31T00:01:00-0500',
|
|
44
|
+
dateFormatterOptions: {
|
|
45
|
+
month: 'short',
|
|
46
|
+
day: 'numeric',
|
|
47
|
+
year: 'numeric',
|
|
48
|
+
},
|
|
49
|
+
tokens: {
|
|
50
|
+
size: 'paragraph',
|
|
51
|
+
},
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
{Template.bind({})}
|
|
55
|
+
</Story>
|
|
56
|
+
</Canvas>
|
|
57
|
+
|
|
58
|
+
<Canvas>
|
|
59
|
+
<Story
|
|
60
|
+
name="Long"
|
|
61
|
+
args={{
|
|
62
|
+
date: '2021-12-31T00:01:00-0500',
|
|
63
|
+
dateFormatterOptions: {
|
|
64
|
+
month: 'long',
|
|
65
|
+
day: 'numeric',
|
|
66
|
+
year: 'numeric',
|
|
67
|
+
},
|
|
68
|
+
}}
|
|
69
|
+
>
|
|
70
|
+
{Template.bind({})}
|
|
71
|
+
</Story>
|
|
72
|
+
</Canvas>
|
|
73
|
+
|
|
74
|
+
<Canvas>
|
|
75
|
+
<Story
|
|
76
|
+
name="Time with h4 style"
|
|
77
|
+
args={{
|
|
78
|
+
date: '2021-12-31T00:01:00-0500',
|
|
79
|
+
dateFormatterOptions: {
|
|
80
|
+
month: 'long',
|
|
81
|
+
day: 'numeric',
|
|
82
|
+
year: 'numeric',
|
|
83
|
+
},
|
|
84
|
+
tokens: {
|
|
85
|
+
size: 'h4',
|
|
86
|
+
},
|
|
87
|
+
}}
|
|
88
|
+
>
|
|
89
|
+
{Template.bind({})}
|
|
90
|
+
</Story>
|
|
91
|
+
</Canvas>
|
|
92
|
+
|
|
93
|
+
<Canvas>
|
|
94
|
+
<Story
|
|
95
|
+
name="Month and Day only"
|
|
96
|
+
args={{
|
|
97
|
+
date: '2021-12-31T00:01:00-0500',
|
|
98
|
+
dateFormatterOptions: {
|
|
99
|
+
month: 'long',
|
|
100
|
+
day: 'numeric',
|
|
101
|
+
},
|
|
102
|
+
}}
|
|
103
|
+
>
|
|
104
|
+
{Template.bind({})}
|
|
105
|
+
</Story>
|
|
106
|
+
</Canvas>
|
|
107
|
+
|
|
108
|
+
<Canvas>
|
|
109
|
+
<Story
|
|
110
|
+
name="2 digits"
|
|
111
|
+
args={{
|
|
112
|
+
date: '2021-12-31T00:01:00-0500',
|
|
113
|
+
dateFormatterOptions: {
|
|
114
|
+
month: '2-digit',
|
|
115
|
+
day: '2-digit',
|
|
116
|
+
year: '2-digit',
|
|
117
|
+
},
|
|
118
|
+
}}
|
|
119
|
+
>
|
|
120
|
+
{Template.bind({})}
|
|
121
|
+
</Story>
|
|
122
|
+
</Canvas>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useDateFormatter } from '@react-aria/i18n'
|
|
4
|
+
import { isEmpty } from 'lodash'
|
|
5
|
+
import { useIsSSR } from 'react-aria'
|
|
6
|
+
import useThemeContext from '../../providers/Theme/hooks'
|
|
7
|
+
import type { TDateProps } from './interface'
|
|
8
|
+
|
|
9
|
+
const DateComponent = (props: TDateProps) => {
|
|
10
|
+
const {
|
|
11
|
+
as: Component = 'time',
|
|
12
|
+
date,
|
|
13
|
+
tokens,
|
|
14
|
+
customTheme,
|
|
15
|
+
dateFormatterOptions = { month: 'long', day: 'numeric', year: 'numeric' },
|
|
16
|
+
themeName = 'typography',
|
|
17
|
+
...rest
|
|
18
|
+
} = props
|
|
19
|
+
const isSSR = useIsSSR()
|
|
20
|
+
|
|
21
|
+
const parsedDate = new Date(date)
|
|
22
|
+
|
|
23
|
+
const formatter = useDateFormatter(dateFormatterOptions)
|
|
24
|
+
|
|
25
|
+
const formattedDate = formatter.format(parsedDate)
|
|
26
|
+
const theme = useThemeContext(themeName, tokens, customTheme)
|
|
27
|
+
|
|
28
|
+
return isSSR || isEmpty(formattedDate) ? null : (
|
|
29
|
+
<Component {...rest} dateTime={parsedDate.toISOString()} className={theme}>
|
|
30
|
+
{formattedDate}
|
|
31
|
+
</Component>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default DateComponent
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useRef } from 'react'
|
|
2
|
+
import { useDialog } from 'react-aria'
|
|
3
|
+
import type { TDialogProps } from './interface'
|
|
4
|
+
|
|
5
|
+
export function Dialog({ title, children, ...props }: TDialogProps) {
|
|
6
|
+
const ref = useRef(null)
|
|
7
|
+
const { dialogProps } = useDialog(props, ref)
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<div {...dialogProps} ref={ref}>
|
|
11
|
+
{children}
|
|
12
|
+
</div>
|
|
13
|
+
)
|
|
14
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { createPngDataUri } from 'unlazy/thumbhash'
|
|
2
|
+
import Img from '../Img'
|
|
3
|
+
import type TDirectusImageProps from './interface'
|
|
4
|
+
|
|
5
|
+
const envImgDomain = process.env.NEXT_PUBLIC_IMG_DOMAIN
|
|
6
|
+
|
|
7
|
+
const DirectusImg = (props: TDirectusImageProps) => {
|
|
8
|
+
const {
|
|
9
|
+
fit,
|
|
10
|
+
customTheme,
|
|
11
|
+
thumbhash,
|
|
12
|
+
description,
|
|
13
|
+
width,
|
|
14
|
+
height,
|
|
15
|
+
id,
|
|
16
|
+
filenameDownload,
|
|
17
|
+
imgDomain = envImgDomain,
|
|
18
|
+
...rest
|
|
19
|
+
} = props
|
|
20
|
+
|
|
21
|
+
if (!id || !filenameDownload) return null
|
|
22
|
+
|
|
23
|
+
if (!imgDomain) {
|
|
24
|
+
// eslint-disable-next-line no-console
|
|
25
|
+
console.warn('No image domain was provided')
|
|
26
|
+
return null
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const getDirectusImage = () => {
|
|
30
|
+
try {
|
|
31
|
+
const img = new URL(`/assets/${id}/${filenameDownload}`, `https://${imgDomain}`)
|
|
32
|
+
img.searchParams.set('fit', fit ?? 'contain')
|
|
33
|
+
return img
|
|
34
|
+
} catch (error) {
|
|
35
|
+
// eslint-disable-next-line no-console
|
|
36
|
+
console.warn(error)
|
|
37
|
+
return null
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const directusImageUrl = getDirectusImage()
|
|
42
|
+
|
|
43
|
+
if (directusImageUrl == null) {
|
|
44
|
+
return null
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Img
|
|
49
|
+
alt={description ?? ''}
|
|
50
|
+
{...(thumbhash ? { blurDataURL: createPngDataUri(thumbhash), placeholder: 'blur' } : {})}
|
|
51
|
+
src={directusImageUrl.href}
|
|
52
|
+
{...rest}
|
|
53
|
+
width={width ?? undefined}
|
|
54
|
+
height={height ?? undefined}
|
|
55
|
+
/>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export default DirectusImg
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Nullable } from '../../types/components'
|
|
2
|
+
import type TImgProps from '../Img/interface'
|
|
3
|
+
|
|
4
|
+
type TDirectusImageProps = Omit<TImgProps, 'src' | 'id' | 'width' | 'height' | 'alt'> & {
|
|
5
|
+
description?: Nullable<string>
|
|
6
|
+
fit?: 'cover' | 'contain' | 'inside' | 'outside'
|
|
7
|
+
caption?: Nullable<string>
|
|
8
|
+
thumbhash?: Nullable<string>
|
|
9
|
+
width: Nullable<number>
|
|
10
|
+
height: Nullable<number>
|
|
11
|
+
id: Nullable<string>
|
|
12
|
+
filenameDownload: Nullable<string>
|
|
13
|
+
/**
|
|
14
|
+
* @default NEXT_PUBLIC_IMG_DOMAIN
|
|
15
|
+
*/
|
|
16
|
+
imgDomain?: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default TDirectusImageProps
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import React, { Suspense, lazy, useMemo } from 'react'
|
|
4
|
+
import useThemeContext from '../../providers/Theme/hooks'
|
|
5
|
+
import Fallback from '../icons/IconFallback'
|
|
6
|
+
import type { TIconProps } from './interface'
|
|
7
|
+
|
|
8
|
+
const Icon = (props: TIconProps) => {
|
|
9
|
+
const { icon, ...rest } = props
|
|
10
|
+
const ImportedIcon = useMemo(() => lazy(() => import(`../icons/${icon || 'ArrowRight'}.tsx`)), [icon])
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<Suspense fallback={<Fallback className="overflow-visible pointer-events-none" />}>
|
|
14
|
+
<ImportedIcon {...rest} className="overflow-visible pointer-events-none" {...props} />
|
|
15
|
+
</Suspense>
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const IconDispatcher = (props: TIconProps) => {
|
|
20
|
+
const { icon, as: Component = 'span', tokens, customTheme, themeName = 'icon', children, ...rest } = props
|
|
21
|
+
const theme = useThemeContext(themeName, tokens, customTheme)
|
|
22
|
+
|
|
23
|
+
if (typeof icon !== 'string') {
|
|
24
|
+
return (
|
|
25
|
+
<Component {...rest} className={theme}>
|
|
26
|
+
{children}
|
|
27
|
+
{icon}
|
|
28
|
+
</Component>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<Component className={theme}>
|
|
34
|
+
{children}
|
|
35
|
+
<Icon icon={icon} {...rest} />
|
|
36
|
+
</Component>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default IconDispatcher
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type React from 'react'
|
|
2
|
+
import type { SVGProps } from 'react'
|
|
3
|
+
import type { TDefaultComponent } from '../../types/components'
|
|
4
|
+
|
|
5
|
+
export interface TIconProps extends TDefaultComponent, SVGProps<SVGSVGElement> {
|
|
6
|
+
icon?: string | React.ReactNode
|
|
7
|
+
children?: React.ReactNode
|
|
8
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Canvas, Meta, Story } from '@storybook/addon-docs'
|
|
2
|
+
import { ArgTypes } from '@storybook/blocks'
|
|
3
|
+
import Img from './'
|
|
4
|
+
import image from '../../../static/images/image.png'
|
|
5
|
+
|
|
6
|
+
<Meta title="BASE COMPONENTS/Img" component={Img} />
|
|
7
|
+
|
|
8
|
+
export const Template = (args) => <Img {...args} />
|
|
9
|
+
|
|
10
|
+
# Img
|
|
11
|
+
|
|
12
|
+
#### Img component. This component wraps the Next Image component
|
|
13
|
+
|
|
14
|
+
<Canvas>
|
|
15
|
+
<Story
|
|
16
|
+
name="Img"
|
|
17
|
+
args={{
|
|
18
|
+
src: image,
|
|
19
|
+
alt: 'Image',
|
|
20
|
+
}}
|
|
21
|
+
>
|
|
22
|
+
{Template.bind({})}
|
|
23
|
+
</Story>
|
|
24
|
+
</Canvas>
|
|
25
|
+
|
|
26
|
+
## Props
|
|
27
|
+
|
|
28
|
+
<ArgTypes />
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Image from 'next/image'
|
|
2
|
+
import useThemeContext from '../../providers/Theme/hooks'
|
|
3
|
+
import type TImgProps from './interface'
|
|
4
|
+
|
|
5
|
+
const Img = (props: TImgProps) => {
|
|
6
|
+
const { src, width, height, themeName = 'img', tokens, customTheme, ...rest } = props
|
|
7
|
+
const theme = useThemeContext(themeName, tokens, customTheme)
|
|
8
|
+
|
|
9
|
+
if (typeof src === 'object') {
|
|
10
|
+
const { blurWidth, blurHeight, width: srcWidth, height: srcHeight, ...withoutBlurDimensions } = src
|
|
11
|
+
const blur = {
|
|
12
|
+
blurwidth: blurWidth,
|
|
13
|
+
blurheight: blurHeight,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Image
|
|
18
|
+
className={theme}
|
|
19
|
+
{...withoutBlurDimensions}
|
|
20
|
+
{...rest}
|
|
21
|
+
{...blur}
|
|
22
|
+
width={srcWidth ?? width}
|
|
23
|
+
height={srcHeight ?? height}
|
|
24
|
+
/>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
return <Image width={width} height={height} className={theme} src={src} {...rest} />
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default Img
|