polpo 0.1.7 → 0.1.8
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/dist/components.cjs +31 -0
- package/dist/components.cjs.map +1 -0
- package/dist/components.d.cts +1866 -0
- package/dist/components.d.ts +1866 -0
- package/dist/components.js +31 -0
- package/dist/components.js.map +1 -0
- package/dist/{get-modal-position-drle0OjP.d.cts → get-modal-position-C5jQsaGx.d.cts} +1 -1
- package/dist/{get-modal-position-drle0OjP.d.ts → get-modal-position-C5jQsaGx.d.ts} +1 -1
- package/dist/helpers.cjs +1 -1
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.d.cts +2 -2
- package/dist/helpers.d.ts +2 -2
- package/dist/helpers.js +1 -1
- package/dist/helpers.js.map +1 -1
- package/dist/hooks.cjs +1 -1
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +15 -13
- package/dist/hooks.d.ts +15 -13
- package/dist/hooks.js +1 -1
- package/dist/hooks.js.map +1 -1
- package/dist/layouts.cjs +4 -0
- package/dist/layouts.cjs.map +1 -0
- package/dist/{ui.d.cts → layouts.d.cts} +237 -2202
- package/dist/{ui.d.ts → layouts.d.ts} +237 -2202
- package/dist/layouts.js +4 -0
- package/dist/layouts.js.map +1 -0
- package/dist/types.cjs +3 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +8 -0
- package/dist/types.d.ts +8 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/{use-modal-transition-XQHye62R.d.cts → use-modal-transition-C0lyjvkD.d.ts} +4 -4
- package/dist/{use-modal-transition-DPZFWFFf.d.ts → use-modal-transition-C7DzbnY5.d.cts} +4 -4
- package/package.json +76 -76
- package/.eslintrc.cjs +0 -9
- package/.storybook/decorators.tsx +0 -61
- package/.storybook/main.ts +0 -47
- package/.storybook/manager-head.html +0 -2
- package/.storybook/manager.ts +0 -7
- package/.storybook/preview-head.html +0 -2
- package/.storybook/preview.ts +0 -38
- package/.storybook/theme.ts +0 -47
- package/.turbo/turbo-lint.log +0 -4
- package/README.md +0 -65
- package/dist/chunk-CF5MBMWG.js +0 -3
- package/dist/chunk-CF5MBMWG.js.map +0 -1
- package/dist/chunk-MAWW6AA7.js +0 -3
- package/dist/chunk-MAWW6AA7.js.map +0 -1
- package/dist/ui.cjs +0 -2279
- package/dist/ui.cjs.map +0 -1
- package/dist/ui.js +0 -2279
- package/dist/ui.js.map +0 -1
- package/src/components/accordion/accordion-item.stories.tsx +0 -128
- package/src/components/accordion/accordion-item.tsx +0 -119
- package/src/components/accordion/accordion.stories.tsx +0 -74
- package/src/components/accordion/accordion.style.ts +0 -42
- package/src/components/accordion/accordion.tsx +0 -74
- package/src/components/accordion/index.ts +0 -2
- package/src/components/buttons/button/button.stories.tsx +0 -103
- package/src/components/buttons/button/button.style.ts +0 -152
- package/src/components/buttons/button/button.tsx +0 -107
- package/src/components/buttons/button/index.ts +0 -1
- package/src/components/buttons/index.ts +0 -1
- package/src/components/cards/flip-card/flip-card.stories.tsx +0 -61
- package/src/components/cards/flip-card/flip-card.style.ts +0 -45
- package/src/components/cards/flip-card/flip-card.tsx +0 -55
- package/src/components/cards/flip-card/index.ts +0 -1
- package/src/components/cards/hover-card/hover-card.stories.tsx +0 -45
- package/src/components/cards/hover-card/hover-card.style.ts +0 -13
- package/src/components/cards/hover-card/hover-card.tsx +0 -71
- package/src/components/cards/hover-card/index.ts +0 -1
- package/src/components/cards/index.ts +0 -3
- package/src/components/cards/slide-card/index.ts +0 -1
- package/src/components/cards/slide-card/slide-card.stories.tsx +0 -47
- package/src/components/cards/slide-card/slide-card.tsx +0 -42
- package/src/components/cursor/cursor.stories.tsx +0 -36
- package/src/components/cursor/cursor.style.ts +0 -73
- package/src/components/cursor/cursor.tsx +0 -49
- package/src/components/cursor/index.ts +0 -1
- package/src/components/form/checkbox/checkbox.stories.tsx +0 -85
- package/src/components/form/checkbox/checkbox.style.ts +0 -109
- package/src/components/form/checkbox/checkbox.tsx +0 -120
- package/src/components/form/checkbox/index.ts +0 -1
- package/src/components/form/controller/controller.tsx +0 -42
- package/src/components/form/controller/index.ts +0 -1
- package/src/components/form/date-picker/date-picker.stories.tsx +0 -38
- package/src/components/form/date-picker/date-picker.tsx +0 -67
- package/src/components/form/date-picker/index.ts +0 -1
- package/src/components/form/field/field.stories.tsx +0 -52
- package/src/components/form/field/field.style.ts +0 -94
- package/src/components/form/field/field.tsx +0 -86
- package/src/components/form/field/field.types.ts +0 -34
- package/src/components/form/field/index.ts +0 -2
- package/src/components/form/form.stories.types.tsx +0 -50
- package/src/components/form/form.types.ts +0 -37
- package/src/components/form/index.ts +0 -14
- package/src/components/form/input/index.ts +0 -1
- package/src/components/form/input/input.stories.tsx +0 -41
- package/src/components/form/input/input.tsx +0 -73
- package/src/components/form/input-color/index.ts +0 -1
- package/src/components/form/input-color/input-color.stories.tsx +0 -46
- package/src/components/form/input-color/input-color.style.ts +0 -94
- package/src/components/form/input-color/input-color.tsx +0 -162
- package/src/components/form/input-file/index.ts +0 -1
- package/src/components/form/input-file/input-file.stories.tsx +0 -40
- package/src/components/form/input-file/input-file.style.ts +0 -143
- package/src/components/form/input-file/input-file.tsx +0 -214
- package/src/components/form/input-password/index.ts +0 -1
- package/src/components/form/input-password/input-password.stories.tsx +0 -37
- package/src/components/form/input-password/input-password.tsx +0 -83
- package/src/components/form/radio/index.ts +0 -1
- package/src/components/form/radio/radio.stories.tsx +0 -68
- package/src/components/form/radio/radio.style.ts +0 -79
- package/src/components/form/radio/radio.tsx +0 -106
- package/src/components/form/select/data.stories.json +0 -452
- package/src/components/form/select/index.ts +0 -1
- package/src/components/form/select/option.tsx +0 -101
- package/src/components/form/select/options.tsx +0 -161
- package/src/components/form/select/select.stories.tsx +0 -369
- package/src/components/form/select/select.style.ts +0 -116
- package/src/components/form/select/select.tsx +0 -312
- package/src/components/form/select/select.types.ts +0 -97
- package/src/components/form/slider/index.ts +0 -1
- package/src/components/form/slider/slider.stories.tsx +0 -40
- package/src/components/form/slider/slider.style.ts +0 -92
- package/src/components/form/slider/slider.tsx +0 -108
- package/src/components/form/switch/index.ts +0 -1
- package/src/components/form/switch/switch.stories.tsx +0 -88
- package/src/components/form/switch/switch.style.ts +0 -137
- package/src/components/form/switch/switch.tsx +0 -177
- package/src/components/form/textarea/index.ts +0 -1
- package/src/components/form/textarea/textarea.stories.tsx +0 -43
- package/src/components/form/textarea/textarea.style.ts +0 -7
- package/src/components/form/textarea/textarea.tsx +0 -76
- package/src/components/icon/icon.stories.tsx +0 -63
- package/src/components/icon/icon.tsx +0 -64
- package/src/components/icon/icons/index.ts +0 -18
- package/src/components/icon/icons/object.tsx +0 -482
- package/src/components/icon/icons/social.tsx +0 -88
- package/src/components/icon/icons/symbol.tsx +0 -776
- package/src/components/icon/index.ts +0 -5
- package/src/components/image/image.stories.tsx +0 -25
- package/src/components/image/image.tsx +0 -7
- package/src/components/image/index.ts +0 -1
- package/src/components/index.ts +0 -17
- package/src/components/infinity-scroll/index.ts +0 -1
- package/src/components/infinity-scroll/infinity-scroll.stories.tsx +0 -118
- package/src/components/infinity-scroll/infinity-scroll.style.ts +0 -30
- package/src/components/infinity-scroll/infinity-scroll.tsx +0 -53
- package/src/components/line/index.ts +0 -1
- package/src/components/line/line.stories.tsx +0 -66
- package/src/components/line/line.style.ts +0 -57
- package/src/components/line/line.tsx +0 -76
- package/src/components/loaders/icons/box-1.tsx +0 -31
- package/src/components/loaders/icons/box-2.tsx +0 -30
- package/src/components/loaders/icons/box-3.tsx +0 -66
- package/src/components/loaders/icons/clock-1.tsx +0 -25
- package/src/components/loaders/icons/clock-2.tsx +0 -58
- package/src/components/loaders/icons/dots-1.tsx +0 -194
- package/src/components/loaders/icons/dots-2.tsx +0 -15
- package/src/components/loaders/icons/dots-3.tsx +0 -38
- package/src/components/loaders/icons/dots-4.tsx +0 -90
- package/src/components/loaders/icons/dots-5.tsx +0 -30
- package/src/components/loaders/icons/dots-6.tsx +0 -72
- package/src/components/loaders/icons/dots-7.tsx +0 -51
- package/src/components/loaders/icons/dots-8.tsx +0 -42
- package/src/components/loaders/icons/dots-9.tsx +0 -27
- package/src/components/loaders/icons/lines-1.tsx +0 -96
- package/src/components/loaders/icons/lines-2.tsx +0 -48
- package/src/components/loaders/icons/pulse-1.tsx +0 -69
- package/src/components/loaders/icons/pulse-2.tsx +0 -69
- package/src/components/loaders/icons/pulse-3.tsx +0 -105
- package/src/components/loaders/icons/pulse-4.tsx +0 -105
- package/src/components/loaders/icons/pulse-5.tsx +0 -56
- package/src/components/loaders/icons/spinner-1.tsx +0 -162
- package/src/components/loaders/icons/spinner-2.tsx +0 -147
- package/src/components/loaders/icons/spinner-3.tsx +0 -35
- package/src/components/loaders/icons/spinner-4.tsx +0 -16
- package/src/components/loaders/index.ts +0 -1
- package/src/components/loaders/simple-loader/index.ts +0 -1
- package/src/components/loaders/simple-loader/simple-loader.stories.tsx +0 -42
- package/src/components/loaders/simple-loader/simple-loader.style.ts +0 -12
- package/src/components/loaders/simple-loader/simple-loader.tsx +0 -99
- package/src/components/modals/action-modal/action-modal.stories.tsx +0 -157
- package/src/components/modals/action-modal/action-modal.style.ts +0 -117
- package/src/components/modals/action-modal/action-modal.tsx +0 -148
- package/src/components/modals/action-modal/index.ts +0 -1
- package/src/components/modals/aside-modal/aside-modal.stories.tsx +0 -81
- package/src/components/modals/aside-modal/aside-modal.style.ts +0 -88
- package/src/components/modals/aside-modal/aside-modal.tsx +0 -64
- package/src/components/modals/aside-modal/index.ts +0 -1
- package/src/components/modals/confirmation-modal/confirmation-modal.stories.tsx +0 -62
- package/src/components/modals/confirmation-modal/confirmation-modal.style.ts +0 -17
- package/src/components/modals/confirmation-modal/confirmation-modal.tsx +0 -43
- package/src/components/modals/confirmation-modal/index.ts +0 -1
- package/src/components/modals/index.ts +0 -6
- package/src/components/modals/menu/index.ts +0 -1
- package/src/components/modals/menu/menu.stories.tsx +0 -79
- package/src/components/modals/menu/menu.style.ts +0 -103
- package/src/components/modals/menu/menu.tsx +0 -186
- package/src/components/modals/modal/backdrop.tsx +0 -70
- package/src/components/modals/modal/index.ts +0 -2
- package/src/components/modals/modal/modal.stories.tsx +0 -328
- package/src/components/modals/modal/modal.style.ts +0 -70
- package/src/components/modals/modal/modal.tsx +0 -106
- package/src/components/modals/portal/index.ts +0 -1
- package/src/components/modals/portal/portal.tsx +0 -21
- package/src/components/ripple/index.ts +0 -1
- package/src/components/ripple/ripple.stories.tsx +0 -38
- package/src/components/ripple/ripple.style.ts +0 -33
- package/src/components/ripple/ripple.tsx +0 -65
- package/src/components/smart-table/index.ts +0 -1
- package/src/components/smart-table/smart-table.column.tsx +0 -63
- package/src/components/smart-table/smart-table.helpers.tsx +0 -59
- package/src/components/smart-table/smart-table.hooks.ts +0 -27
- package/src/components/smart-table/smart-table.row.tsx +0 -29
- package/src/components/smart-table/smart-table.stories.tsx +0 -301
- package/src/components/smart-table/smart-table.style.ts +0 -102
- package/src/components/smart-table/smart-table.tsx +0 -112
- package/src/components/smart-table/smart-table.types.ts +0 -41
- package/src/components/tabs/index.ts +0 -1
- package/src/components/tabs/tabs-container.stories.tsx +0 -159
- package/src/components/tabs/tabs-list.tsx +0 -134
- package/src/components/tabs/tabs.stories.tsx +0 -68
- package/src/components/tabs/tabs.style.ts +0 -137
- package/src/components/tabs/tabs.tsx +0 -117
- package/src/components/tag/index.ts +0 -1
- package/src/components/tag/tag.stories.tsx +0 -48
- package/src/components/tag/tag.style.ts +0 -29
- package/src/components/tag/tag.tsx +0 -34
- package/src/components/tooltips/click-to-copy/click-to-copy.stories.tsx +0 -39
- package/src/components/tooltips/click-to-copy/click-to-copy.tsx +0 -41
- package/src/components/tooltips/click-to-copy/index.ts +0 -1
- package/src/components/tooltips/index.ts +0 -2
- package/src/components/tooltips/tooltip/index.ts +0 -1
- package/src/components/tooltips/tooltip/tooltip.stories.tsx +0 -38
- package/src/components/tooltips/tooltip/tooltip.style.ts +0 -93
- package/src/components/tooltips/tooltip/tooltip.tsx +0 -59
- package/src/components/typography/index.ts +0 -2
- package/src/components/typography/typography.constants.ts +0 -43
- package/src/components/typography/typography.stories.tsx +0 -108
- package/src/components/typography/typography.style.ts +0 -76
- package/src/components/typography/typography.tsx +0 -100
- package/src/contexts/fetch-context/fetch-context.tsx +0 -114
- package/src/contexts/fetch-context/index.ts +0 -1
- package/src/contexts/form-context/form-context.tsx +0 -43
- package/src/contexts/form-context/index.ts +0 -1
- package/src/contexts/index.ts +0 -3
- package/src/contexts/theme-context/index.ts +0 -3
- package/src/contexts/theme-context/theme-context.tsx +0 -158
- package/src/contexts/theme-context/theme.animations.ts +0 -269
- package/src/contexts/theme-context/theme.defaults.ts +0 -209
- package/src/contexts/theme-context/theme.style.ts +0 -78
- package/src/contexts/theme-context/themes.ts +0 -98
- package/src/core/http-client.d.ts +0 -11
- package/src/core/http-client.d.ts.map +0 -1
- package/src/core/http-client.ts +0 -49
- package/src/core/index.d.ts +0 -2
- package/src/core/index.d.ts.map +0 -1
- package/src/core/index.ts +0 -1
- package/src/core/variants/color.ts +0 -9
- package/src/core/variants/index.ts +0 -3
- package/src/core/variants/radius.ts +0 -27
- package/src/core/variants/size.ts +0 -19
- package/src/helpers/format-bytes.ts +0 -11
- package/src/helpers/format-dates.ts +0 -11
- package/src/helpers/get-modal-position-relative-to-screen.ts +0 -86
- package/src/helpers/get-modal-position.ts +0 -211
- package/src/helpers/index.ts +0 -5
- package/src/helpers/text/index.ts +0 -1
- package/src/helpers/text/to-capitalize.ts +0 -17
- package/src/hooks/index.ts +0 -29
- package/src/hooks/use-async.ts +0 -88
- package/src/hooks/use-classnames.ts +0 -13
- package/src/hooks/use-click-outside.ts +0 -32
- package/src/hooks/use-constant.ts +0 -3
- package/src/hooks/use-cookie.ts +0 -124
- package/src/hooks/use-debounce.ts +0 -15
- package/src/hooks/use-dimensions.ts +0 -19
- package/src/hooks/use-dom-container.ts +0 -35
- package/src/hooks/use-event-listener.ts +0 -71
- package/src/hooks/use-file-reader.ts +0 -69
- package/src/hooks/use-geolocation.ts +0 -63
- package/src/hooks/use-hover.ts +0 -17
- package/src/hooks/use-in-view.ts +0 -18
- package/src/hooks/use-input-handlers.ts +0 -49
- package/src/hooks/use-intersection-observer.ts +0 -19
- package/src/hooks/use-media-query.ts +0 -25
- package/src/hooks/use-modal-in-container.ts +0 -85
- package/src/hooks/use-modal-transition.ts +0 -64
- package/src/hooks/use-modal.ts +0 -21
- package/src/hooks/use-mouse-position.ts +0 -64
- package/src/hooks/use-online-status.ts +0 -12
- package/src/hooks/use-render-count.ts +0 -11
- package/src/hooks/use-resize-observer.ts +0 -18
- package/src/hooks/use-safe-dispatch.ts +0 -22
- package/src/hooks/use-scroll.ts +0 -31
- package/src/hooks/use-state-history.ts +0 -22
- package/src/hooks/use-toggle-values.ts +0 -14
- package/src/hooks/use-toggle.ts +0 -11
- package/src/hooks/use-viewport.ts +0 -38
- package/src/index.ts +0 -5
- package/src/layouts/flex/flex.tsx +0 -75
- package/src/layouts/flex/index.ts +0 -1
- package/src/layouts/grid/grid.tsx +0 -86
- package/src/layouts/grid/index.ts +0 -1
- package/src/layouts/index.ts +0 -3
- package/src/layouts/section-layout/index.ts +0 -1
- package/src/layouts/section-layout/section-layout.stories.tsx +0 -55
- package/src/layouts/section-layout/section-layout.style.ts +0 -21
- package/src/layouts/section-layout/section-layout.tsx +0 -46
- package/src/stories/GettingStarted.mdx +0 -62
- package/src/types/generics.ts +0 -68
- package/src/types/index.ts +0 -1
- package/svg/Name=airplane, Category=object.svg +0 -3
- package/svg/Name=arrow-circle, Category=symbol.svg +0 -3
- package/svg/Name=arrow-down, Category=symbol.svg +0 -3
- package/svg/Name=arrow-left, Category=symbol.svg +0 -3
- package/svg/Name=arrow-right, Category=symbol.svg +0 -3
- package/svg/Name=arrow-up, Category=symbol.svg +0 -3
- package/svg/Name=bell, Category=object.svg +0 -3
- package/svg/Name=bicycle, Category=object.svg +0 -3
- package/svg/Name=book-open, Category=object.svg +0 -3
- package/svg/Name=book-solid, Category=object.svg +0 -6
- package/svg/Name=box-shadow, Category=symbol.svg +0 -5
- package/svg/Name=calendar, Category=object.svg +0 -3
- package/svg/Name=camera, Category=object.svg +0 -3
- package/svg/Name=caret-down, Category=symbol.svg +0 -3
- package/svg/Name=caret-left, Category=symbol.svg +0 -3
- package/svg/Name=caret-right, Category=symbol.svg +0 -3
- package/svg/Name=caret-up, Category=symbol.svg +0 -3
- package/svg/Name=checkmark, Category=symbol.svg +0 -3
- package/svg/Name=clean-computer, Category=object.svg +0 -10
- package/svg/Name=codepen, Category=social.svg +0 -3
- package/svg/Name=creative, Category=symbol.svg +0 -5
- package/svg/Name=cross, Category=symbol.svg +0 -4
- package/svg/Name=crossed-flags, Category=object.svg +0 -4
- package/svg/Name=cv, Category=symbol.svg +0 -5
- package/svg/Name=design-ui, Category=symbol.svg +0 -9
- package/svg/Name=document, Category=object.svg +0 -3
- package/svg/Name=door-closed, Category=object.svg +0 -3
- package/svg/Name=door-open, Category=object.svg +0 -3
- package/svg/Name=double-caret-down, Category=symbol.svg +0 -4
- package/svg/Name=double-caret-left, Category=symbol.svg +0 -4
- package/svg/Name=double-caret-righ, Category=symbol.svg +0 -4
- package/svg/Name=double-caret-up, Category=symbol.svg +0 -4
- package/svg/Name=download, Category=symbol.svg +0 -5
- package/svg/Name=dropper, Category=object.svg +0 -5
- package/svg/Name=envelope, Category=object.svg +0 -3
- package/svg/Name=exclamation-close, Category=symbol.svg +0 -4
- package/svg/Name=exclamation-open, Category=symbol.svg +0 -4
- package/svg/Name=external-link, Category=symbol.svg +0 -3
- package/svg/Name=eye, Category=object.svg +0 -4
- package/svg/Name=eye-hidden, Category=object.svg +0 -7
- package/svg/Name=facebook, Category=social.svg +0 -3
- package/svg/Name=form, Category=symbol.svg +0 -8
- package/svg/Name=game-control, Category=object.svg +0 -3
- package/svg/Name=gear, Category=object.svg +0 -3
- package/svg/Name=github, Category=social.svg +0 -3
- package/svg/Name=house, Category=object.svg +0 -3
- package/svg/Name=hyphen, Category=symbol.svg +0 -3
- package/svg/Name=info, Category=symbol.svg +0 -3
- package/svg/Name=instagram, Category=social.svg +0 -3
- package/svg/Name=link, Category=symbol.svg +0 -5
- package/svg/Name=linkedin, Category=social.svg +0 -3
- package/svg/Name=magnifying-glass, Category=object.svg +0 -3
- package/svg/Name=message, Category=symbol.svg +0 -4
- package/svg/Name=moon, Category=object.svg +0 -5
- package/svg/Name=npm, Category=social.svg +0 -3
- package/svg/Name=order-list, Category=symbol.svg +0 -7
- package/svg/Name=pencil, Category=object.svg +0 -3
- package/svg/Name=pin-location, Category=symbol.svg +0 -3
- package/svg/Name=question-mark-close, Category=symbol.svg +0 -3
- package/svg/Name=question-mark-open, Category=symbol.svg +0 -3
- package/svg/Name=share, Category=symbol.svg +0 -5
- package/svg/Name=spinner, Category=symbol.svg +0 -9
- package/svg/Name=star, Category=object.svg +0 -3
- package/svg/Name=star-empty, Category=object.svg +0 -3
- package/svg/Name=sun, Category=object.svg +0 -11
- package/svg/Name=text-shadow, Category=symbol.svg +0 -4
- package/svg/Name=thinking, Category=symbol.svg +0 -3
- package/svg/Name=trash-can, Category=object.svg +0 -4
- package/svg/Name=upload, Category=symbol.svg +0 -5
- package/svg/Name=user, Category=symbol.svg +0 -4
- package/svg/Name=warning, Category=symbol.svg +0 -5
- package/svg/Name=whatsapp, Category=social.svg +0 -3
- package/svgconfig.json +0 -4
- package/tsconfig.json +0 -15
- package/tsup.config.cjs +0 -21
- package/vite.config.ts +0 -14
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
import { Grid } from '../../../layouts';
|
|
2
|
-
import { Button } from '../../buttons';
|
|
3
|
-
import { Line } from '../../line';
|
|
4
|
-
import { Typography } from '../../typography';
|
|
5
|
-
|
|
6
|
-
import { ModalBackdrop } from './backdrop';
|
|
7
|
-
import { Modal as ModalComponent, ModalProps } from './modal';
|
|
8
|
-
|
|
9
|
-
import { PositionContainer } from '@polpo/helpers';
|
|
10
|
-
import { useModal } from '@polpo/hooks';
|
|
11
|
-
|
|
12
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
13
|
-
|
|
14
|
-
const Modal = ({ children, ...props }: ModalProps) => (
|
|
15
|
-
<ModalComponent backdrop='none' {...props} style={{ borderRadius: '1em' }}>
|
|
16
|
-
<Grid style={{ width: '400px', maxWidth: '100%', padding: '1em' }}>
|
|
17
|
-
<Typography variant='header4' color='primary'>
|
|
18
|
-
{children}
|
|
19
|
-
</Typography>
|
|
20
|
-
<Line />
|
|
21
|
-
<Typography>
|
|
22
|
-
Lorem ipsum dolor sit amet, consectetur adipisicing elit. At, commodi dolore, doloremque doloribus esse
|
|
23
|
-
excepturi impedit in, ipsam ipsum iste magni nihil officiis quasi quia quod similique tenetur? Aliquid cum dolor
|
|
24
|
-
incidunt nihil?
|
|
25
|
-
</Typography>
|
|
26
|
-
</Grid>
|
|
27
|
-
</ModalComponent>
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
const meta: Meta<typeof ModalComponent> = {
|
|
31
|
-
title: 'Modals/Modal',
|
|
32
|
-
component: ModalComponent,
|
|
33
|
-
argTypes: {
|
|
34
|
-
animation: { control: { type: 'inline-radio', options: ['none', 'fade-down', 'bounce'] } },
|
|
35
|
-
windowOffset: { control: { type: 'range', min: 0, max: 100 } },
|
|
36
|
-
offset: { control: { type: 'range', min: 0, max: 100 } },
|
|
37
|
-
position: { control: 'inline-radio', options: Object.values(PositionContainer) },
|
|
38
|
-
closeOnClickOutside: { control: 'boolean' },
|
|
39
|
-
opacity: { control: { type: 'range', min: 0, max: 1, step: 0.1 } },
|
|
40
|
-
backdrop: { control: { type: 'inline-radio', options: Object.values(ModalBackdrop) } },
|
|
41
|
-
transitionDuration: { control: false },
|
|
42
|
-
backdropOnClick: { control: false },
|
|
43
|
-
zIndex: { control: false },
|
|
44
|
-
id: { control: false },
|
|
45
|
-
children: { control: false },
|
|
46
|
-
isOpen: { control: false },
|
|
47
|
-
onClose: { control: false },
|
|
48
|
-
className: { control: false },
|
|
49
|
-
style: { control: false },
|
|
50
|
-
rootStyle: { control: false },
|
|
51
|
-
closeAnimationClassName: { control: false },
|
|
52
|
-
containerRef: { control: false },
|
|
53
|
-
modalRef: { control: false },
|
|
54
|
-
},
|
|
55
|
-
args: {
|
|
56
|
-
offset: 20,
|
|
57
|
-
windowOffset: 10,
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export default meta;
|
|
62
|
-
type Story = StoryObj<typeof ModalComponent>;
|
|
63
|
-
|
|
64
|
-
export const AllContainerPositions: Story = {
|
|
65
|
-
argTypes: {
|
|
66
|
-
position: { control: false },
|
|
67
|
-
},
|
|
68
|
-
render: args => {
|
|
69
|
-
const modal1 = useModal<HTMLButtonElement>();
|
|
70
|
-
const modal2 = useModal<HTMLButtonElement>();
|
|
71
|
-
const modal3 = useModal<HTMLButtonElement>();
|
|
72
|
-
const modal4 = useModal<HTMLButtonElement>();
|
|
73
|
-
const modal5 = useModal<HTMLButtonElement>();
|
|
74
|
-
const modal6 = useModal<HTMLButtonElement>();
|
|
75
|
-
const modal7 = useModal<HTMLButtonElement>();
|
|
76
|
-
const modal8 = useModal<HTMLButtonElement>();
|
|
77
|
-
const modal9 = useModal<HTMLButtonElement>();
|
|
78
|
-
const modal10 = useModal<HTMLButtonElement>();
|
|
79
|
-
const modal11 = useModal<HTMLButtonElement>();
|
|
80
|
-
const modal12 = useModal<HTMLButtonElement>();
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<Grid gtc='repeat(3, 1fr)' gap='20px'>
|
|
84
|
-
<Button width='full' ref={modal1.containerRef} onClick={modal1.openModal}>
|
|
85
|
-
top left
|
|
86
|
-
</Button>
|
|
87
|
-
<Modal
|
|
88
|
-
{...args}
|
|
89
|
-
containerRef={modal1.containerRef}
|
|
90
|
-
id='container-modal'
|
|
91
|
-
isOpen={modal1.isOpen}
|
|
92
|
-
onClose={modal1.closeModal}
|
|
93
|
-
position='top left'
|
|
94
|
-
>
|
|
95
|
-
top left
|
|
96
|
-
</Modal>
|
|
97
|
-
<Button width='full' ref={modal2.containerRef} onClick={modal2.openModal}>
|
|
98
|
-
top center
|
|
99
|
-
</Button>
|
|
100
|
-
<Modal
|
|
101
|
-
{...args}
|
|
102
|
-
containerRef={modal2.containerRef}
|
|
103
|
-
id='container-modal'
|
|
104
|
-
isOpen={modal2.isOpen}
|
|
105
|
-
onClose={modal2.closeModal}
|
|
106
|
-
position='top center'
|
|
107
|
-
>
|
|
108
|
-
top center
|
|
109
|
-
</Modal>
|
|
110
|
-
<Button width='full' ref={modal3.containerRef} onClick={modal3.openModal}>
|
|
111
|
-
top right
|
|
112
|
-
</Button>
|
|
113
|
-
<Modal
|
|
114
|
-
{...args}
|
|
115
|
-
containerRef={modal3.containerRef}
|
|
116
|
-
id='container-modal'
|
|
117
|
-
isOpen={modal3.isOpen}
|
|
118
|
-
onClose={modal3.closeModal}
|
|
119
|
-
position='top right'
|
|
120
|
-
>
|
|
121
|
-
top right
|
|
122
|
-
</Modal>
|
|
123
|
-
|
|
124
|
-
<Button width='full' ref={modal4.containerRef} onClick={modal4.openModal}>
|
|
125
|
-
left top
|
|
126
|
-
</Button>
|
|
127
|
-
<Modal
|
|
128
|
-
{...args}
|
|
129
|
-
containerRef={modal4.containerRef}
|
|
130
|
-
id='container-modal'
|
|
131
|
-
isOpen={modal4.isOpen}
|
|
132
|
-
onClose={modal4.closeModal}
|
|
133
|
-
position='left top'
|
|
134
|
-
>
|
|
135
|
-
left top
|
|
136
|
-
</Modal>
|
|
137
|
-
<span />
|
|
138
|
-
<Button width='full' ref={modal5.containerRef} onClick={modal5.openModal}>
|
|
139
|
-
right top
|
|
140
|
-
</Button>
|
|
141
|
-
<Modal
|
|
142
|
-
{...args}
|
|
143
|
-
containerRef={modal5.containerRef}
|
|
144
|
-
id='container-modal'
|
|
145
|
-
isOpen={modal5.isOpen}
|
|
146
|
-
onClose={modal5.closeModal}
|
|
147
|
-
position='right top'
|
|
148
|
-
>
|
|
149
|
-
right top
|
|
150
|
-
</Modal>
|
|
151
|
-
|
|
152
|
-
<Button width='full' ref={modal6.containerRef} onClick={modal6.openModal}>
|
|
153
|
-
left center
|
|
154
|
-
</Button>
|
|
155
|
-
<Modal
|
|
156
|
-
{...args}
|
|
157
|
-
containerRef={modal6.containerRef}
|
|
158
|
-
id='container-modal'
|
|
159
|
-
isOpen={modal6.isOpen}
|
|
160
|
-
onClose={modal6.closeModal}
|
|
161
|
-
position='left center'
|
|
162
|
-
>
|
|
163
|
-
left center
|
|
164
|
-
</Modal>
|
|
165
|
-
<span />
|
|
166
|
-
<Button width='full' ref={modal7.containerRef} onClick={modal7.openModal}>
|
|
167
|
-
right center
|
|
168
|
-
</Button>
|
|
169
|
-
<Modal
|
|
170
|
-
{...args}
|
|
171
|
-
containerRef={modal7.containerRef}
|
|
172
|
-
id='container-modal'
|
|
173
|
-
isOpen={modal7.isOpen}
|
|
174
|
-
onClose={modal7.closeModal}
|
|
175
|
-
position='right center'
|
|
176
|
-
>
|
|
177
|
-
right center
|
|
178
|
-
</Modal>
|
|
179
|
-
|
|
180
|
-
<Button width='full' ref={modal8.containerRef} onClick={modal8.openModal}>
|
|
181
|
-
left bottom
|
|
182
|
-
</Button>
|
|
183
|
-
<Modal
|
|
184
|
-
{...args}
|
|
185
|
-
containerRef={modal8.containerRef}
|
|
186
|
-
id='container-modal'
|
|
187
|
-
isOpen={modal8.isOpen}
|
|
188
|
-
onClose={modal8.closeModal}
|
|
189
|
-
position='left bottom'
|
|
190
|
-
>
|
|
191
|
-
left bottom
|
|
192
|
-
</Modal>
|
|
193
|
-
<span />
|
|
194
|
-
<Button width='full' ref={modal9.containerRef} onClick={modal9.openModal}>
|
|
195
|
-
right bottom
|
|
196
|
-
</Button>
|
|
197
|
-
<Modal
|
|
198
|
-
{...args}
|
|
199
|
-
containerRef={modal9.containerRef}
|
|
200
|
-
id='container-modal'
|
|
201
|
-
isOpen={modal9.isOpen}
|
|
202
|
-
onClose={modal9.closeModal}
|
|
203
|
-
position='right bottom'
|
|
204
|
-
>
|
|
205
|
-
right bottom
|
|
206
|
-
</Modal>
|
|
207
|
-
|
|
208
|
-
<Button width='full' ref={modal10.containerRef} onClick={modal10.openModal}>
|
|
209
|
-
bottom left
|
|
210
|
-
</Button>
|
|
211
|
-
<Modal
|
|
212
|
-
{...args}
|
|
213
|
-
containerRef={modal10.containerRef}
|
|
214
|
-
id='container-modal'
|
|
215
|
-
isOpen={modal10.isOpen}
|
|
216
|
-
onClose={modal10.closeModal}
|
|
217
|
-
position='bottom left'
|
|
218
|
-
>
|
|
219
|
-
bottom left
|
|
220
|
-
</Modal>
|
|
221
|
-
<Button width='full' ref={modal11.containerRef} onClick={modal11.openModal}>
|
|
222
|
-
bottom center
|
|
223
|
-
</Button>
|
|
224
|
-
<Modal
|
|
225
|
-
{...args}
|
|
226
|
-
containerRef={modal11.containerRef}
|
|
227
|
-
id='container-modal'
|
|
228
|
-
isOpen={modal11.isOpen}
|
|
229
|
-
onClose={modal11.closeModal}
|
|
230
|
-
position='bottom center'
|
|
231
|
-
>
|
|
232
|
-
bottom center
|
|
233
|
-
</Modal>
|
|
234
|
-
<Button width='full' ref={modal12.containerRef} onClick={modal12.openModal}>
|
|
235
|
-
bottom right
|
|
236
|
-
</Button>
|
|
237
|
-
<Modal
|
|
238
|
-
{...args}
|
|
239
|
-
containerRef={modal12.containerRef}
|
|
240
|
-
id='container-modal'
|
|
241
|
-
isOpen={modal12.isOpen}
|
|
242
|
-
onClose={modal12.closeModal}
|
|
243
|
-
position='bottom right'
|
|
244
|
-
>
|
|
245
|
-
bottom right
|
|
246
|
-
</Modal>
|
|
247
|
-
</Grid>
|
|
248
|
-
);
|
|
249
|
-
},
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
export const AllScreenPositions: Story = {
|
|
253
|
-
argTypes: {
|
|
254
|
-
position: { control: false },
|
|
255
|
-
},
|
|
256
|
-
render: args => {
|
|
257
|
-
const modal1 = useModal();
|
|
258
|
-
const modal2 = useModal();
|
|
259
|
-
const modal3 = useModal();
|
|
260
|
-
const modal4 = useModal();
|
|
261
|
-
const modal5 = useModal();
|
|
262
|
-
const modal6 = useModal();
|
|
263
|
-
const modal7 = useModal();
|
|
264
|
-
const modal8 = useModal();
|
|
265
|
-
const modal9 = useModal();
|
|
266
|
-
|
|
267
|
-
return (
|
|
268
|
-
<Grid gtc='repeat(3, 1fr)' gap='20px'>
|
|
269
|
-
<Button width='full' onClick={modal1.openModal}>
|
|
270
|
-
top left
|
|
271
|
-
</Button>
|
|
272
|
-
<Modal {...args} id='screen-modal' isOpen={modal1.isOpen} onClose={modal1.closeModal} position='top left'>
|
|
273
|
-
top left
|
|
274
|
-
</Modal>
|
|
275
|
-
<Button width='full' onClick={modal2.openModal}>
|
|
276
|
-
top center
|
|
277
|
-
</Button>
|
|
278
|
-
<Modal {...args} id='screen-modal' isOpen={modal2.isOpen} onClose={modal2.closeModal} position='top center'>
|
|
279
|
-
top center
|
|
280
|
-
</Modal>
|
|
281
|
-
<Button width='full' onClick={modal3.openModal}>
|
|
282
|
-
top right
|
|
283
|
-
</Button>
|
|
284
|
-
<Modal {...args} id='screen-modal' isOpen={modal3.isOpen} onClose={modal3.closeModal} position='top right'>
|
|
285
|
-
top right
|
|
286
|
-
</Modal>
|
|
287
|
-
|
|
288
|
-
<Button width='full' onClick={modal4.openModal}>
|
|
289
|
-
left center
|
|
290
|
-
</Button>
|
|
291
|
-
<Modal {...args} id='screen-modal' isOpen={modal4.isOpen} onClose={modal4.closeModal} position='left center'>
|
|
292
|
-
left center
|
|
293
|
-
</Modal>
|
|
294
|
-
<Button width='full' onClick={modal5.openModal}>
|
|
295
|
-
center
|
|
296
|
-
</Button>
|
|
297
|
-
<Modal {...args} id='screen-modal' isOpen={modal5.isOpen} onClose={modal5.closeModal} position='center'>
|
|
298
|
-
center
|
|
299
|
-
</Modal>
|
|
300
|
-
<Button width='full' onClick={modal6.openModal}>
|
|
301
|
-
right center
|
|
302
|
-
</Button>
|
|
303
|
-
<Modal {...args} id='screen-modal' isOpen={modal6.isOpen} onClose={modal6.closeModal} position='right center'>
|
|
304
|
-
right center
|
|
305
|
-
</Modal>
|
|
306
|
-
|
|
307
|
-
<Button width='full' onClick={modal7.openModal}>
|
|
308
|
-
bottom left
|
|
309
|
-
</Button>
|
|
310
|
-
<Modal {...args} id='screen-modal' isOpen={modal7.isOpen} onClose={modal7.closeModal} position='bottom left'>
|
|
311
|
-
bottom left
|
|
312
|
-
</Modal>
|
|
313
|
-
<Button width='full' onClick={modal8.openModal}>
|
|
314
|
-
bottom center
|
|
315
|
-
</Button>
|
|
316
|
-
<Modal {...args} id='screen-modal' isOpen={modal8.isOpen} onClose={modal8.closeModal} position='bottom center'>
|
|
317
|
-
bottom center
|
|
318
|
-
</Modal>
|
|
319
|
-
<Button width='full' onClick={modal9.openModal}>
|
|
320
|
-
bottom right
|
|
321
|
-
</Button>
|
|
322
|
-
<Modal {...args} id='screen-modal' isOpen={modal9.isOpen} onClose={modal9.closeModal} position='bottom right'>
|
|
323
|
-
bottom right
|
|
324
|
-
</Modal>
|
|
325
|
-
</Grid>
|
|
326
|
-
);
|
|
327
|
-
},
|
|
328
|
-
};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
|
|
3
|
-
export const ModalStyle = styled.section`
|
|
4
|
-
position: fixed;
|
|
5
|
-
z-index: 1001;
|
|
6
|
-
pointer-events: none;
|
|
7
|
-
`;
|
|
8
|
-
|
|
9
|
-
export const ModalContentStyle = styled.section`
|
|
10
|
-
background: ${props => props.theme.colors.background.paper};
|
|
11
|
-
pointer-events: initial;
|
|
12
|
-
|
|
13
|
-
&.animation-fade-down {
|
|
14
|
-
animation: fadeInDown 200ms ease;
|
|
15
|
-
|
|
16
|
-
&.modal-close {
|
|
17
|
-
animation: fadeOutUp 200ms ease;
|
|
18
|
-
transform: translateY(-10px);
|
|
19
|
-
opacity: 0;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
&.animation-bounce {
|
|
24
|
-
animation: bounceIn 500ms ease;
|
|
25
|
-
|
|
26
|
-
&.modal-close {
|
|
27
|
-
animation: bounceOut 500ms ease;
|
|
28
|
-
transform: scale3d(0.3, 0.3, 0.3);
|
|
29
|
-
opacity: 0;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
`;
|
|
33
|
-
|
|
34
|
-
export const BackdropStyle = styled.section`
|
|
35
|
-
position: fixed;
|
|
36
|
-
width: 100%;
|
|
37
|
-
height: 100%;
|
|
38
|
-
top: 0;
|
|
39
|
-
left: 0;
|
|
40
|
-
z-index: 1000;
|
|
41
|
-
animation: backdropOpen 500ms cubic-bezier(0.215, 0.61, 0.355, 1);
|
|
42
|
-
|
|
43
|
-
&.backdrop-close {
|
|
44
|
-
animation: backdropClose 500ms cubic-bezier(0.215, 0.61, 0.355, 1);
|
|
45
|
-
opacity: 0;
|
|
46
|
-
transform: translateY(-10px);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@keyframes backdropOpen {
|
|
50
|
-
from {
|
|
51
|
-
opacity: 0;
|
|
52
|
-
transform: translateY(-10px);
|
|
53
|
-
}
|
|
54
|
-
to {
|
|
55
|
-
opacity: 1;
|
|
56
|
-
transform: translateY(0);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
@keyframes backdropClose {
|
|
61
|
-
from {
|
|
62
|
-
opacity: 1;
|
|
63
|
-
transform: translateY(0);
|
|
64
|
-
}
|
|
65
|
-
to {
|
|
66
|
-
opacity: 0;
|
|
67
|
-
transform: translateY(-10px);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
`;
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import React, { CSSProperties, useMemo, useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import { Portal } from '../portal';
|
|
4
|
-
|
|
5
|
-
import { Backdrop, BackdropProps } from './backdrop';
|
|
6
|
-
import { ModalContentStyle, ModalStyle } from './modal.style';
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
ModalState,
|
|
10
|
-
useClassNames,
|
|
11
|
-
useClickOutside,
|
|
12
|
-
useModalInContainer,
|
|
13
|
-
UseModalInContainerParams,
|
|
14
|
-
useModalTransition,
|
|
15
|
-
UseModalTransitionParams,
|
|
16
|
-
} from '@polpo/hooks';
|
|
17
|
-
|
|
18
|
-
export type ModalProps = Omit<BackdropProps, 'modalState'> &
|
|
19
|
-
UseModalTransitionParams &
|
|
20
|
-
Omit<UseModalInContainerParams, 'modalRef'> & {
|
|
21
|
-
id: string;
|
|
22
|
-
children: React.ReactNode;
|
|
23
|
-
onClose: () => void;
|
|
24
|
-
className?: string;
|
|
25
|
-
style?: React.CSSProperties;
|
|
26
|
-
rootStyle?: CSSProperties;
|
|
27
|
-
animation?: 'none' | 'fade-down' | 'bounce';
|
|
28
|
-
closeAnimationClassName?: string;
|
|
29
|
-
modalRef?: React.RefObject<HTMLElement>;
|
|
30
|
-
closeOnClickOutside?: boolean;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const Modal = ({
|
|
34
|
-
id,
|
|
35
|
-
children,
|
|
36
|
-
isOpen,
|
|
37
|
-
onClose,
|
|
38
|
-
className = '',
|
|
39
|
-
style = {},
|
|
40
|
-
rootStyle = {},
|
|
41
|
-
animation = 'fade-down',
|
|
42
|
-
closeAnimationClassName = 'modal-close',
|
|
43
|
-
modalRef: modalRefProp,
|
|
44
|
-
closeOnClickOutside = true,
|
|
45
|
-
transitionDuration = 300,
|
|
46
|
-
windowOffset = 10,
|
|
47
|
-
offset = 20,
|
|
48
|
-
position,
|
|
49
|
-
containerRef,
|
|
50
|
-
zIndex = 1000,
|
|
51
|
-
...backdropProps
|
|
52
|
-
}: ModalProps) => {
|
|
53
|
-
const uuid = useMemo(() => crypto.randomUUID(), []);
|
|
54
|
-
const modalRef = useRef<HTMLElement>(null);
|
|
55
|
-
const { modalState, isVisible } = useModalTransition({
|
|
56
|
-
transitionDuration,
|
|
57
|
-
isOpen,
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
useModalInContainer({
|
|
61
|
-
modalRef: modalRefProp ?? modalRef,
|
|
62
|
-
containerRef,
|
|
63
|
-
offset,
|
|
64
|
-
windowOffset,
|
|
65
|
-
position,
|
|
66
|
-
isOpen: isVisible,
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
useClickOutside<HTMLElement>(modalRefProp ?? modalRef, () => {
|
|
70
|
-
if (isOpen && closeOnClickOutside) {
|
|
71
|
-
onClose();
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
const modalContentClassName = useClassNames({
|
|
76
|
-
[className]: true,
|
|
77
|
-
[`animation-${animation}`]: Boolean(animation) && animation !== 'none',
|
|
78
|
-
[closeAnimationClassName]: modalState === ModalState.CLOSING || modalState === ModalState.CLOSED,
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
if (!isVisible) {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
<Portal id={`modal-${id}-${uuid}`}>
|
|
87
|
-
<Backdrop {...backdropProps} modalState={modalState} zIndex={zIndex} />
|
|
88
|
-
<ModalStyle
|
|
89
|
-
ref={modalRefProp ?? modalRef}
|
|
90
|
-
style={{
|
|
91
|
-
maxWidth: `calc(100dvw - ${windowOffset * 2}px)`,
|
|
92
|
-
maxHeight: `calc(100dvh - ${windowOffset * 2}px)`,
|
|
93
|
-
...rootStyle,
|
|
94
|
-
zIndex: +zIndex + 1,
|
|
95
|
-
}}
|
|
96
|
-
>
|
|
97
|
-
<ModalContentStyle
|
|
98
|
-
style={{ ...style, animationDuration: `${transitionDuration}ms` }}
|
|
99
|
-
className={modalContentClassName}
|
|
100
|
-
>
|
|
101
|
-
{children}
|
|
102
|
-
</ModalContentStyle>
|
|
103
|
-
</ModalStyle>
|
|
104
|
-
</Portal>
|
|
105
|
-
);
|
|
106
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './portal';
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { forwardRef, ReactNode } from 'react';
|
|
2
|
-
import { createPortal } from 'react-dom';
|
|
3
|
-
|
|
4
|
-
import { useDomContainer } from '@polpo/hooks';
|
|
5
|
-
|
|
6
|
-
type PortalProps = {
|
|
7
|
-
id: string;
|
|
8
|
-
children: ReactNode;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const PortalComponent = ({ children, id }: PortalProps) => {
|
|
12
|
-
const root = useDomContainer(id);
|
|
13
|
-
|
|
14
|
-
if (root === null) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return createPortal(children, root);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const Portal = forwardRef(PortalComponent);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './ripple';
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Ripple } from './ripple';
|
|
2
|
-
|
|
3
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
4
|
-
|
|
5
|
-
const meta: Meta<typeof Ripple> = {
|
|
6
|
-
title: 'Ripple',
|
|
7
|
-
component: Ripple,
|
|
8
|
-
argTypes: {
|
|
9
|
-
color: { control: 'color' },
|
|
10
|
-
duration: { control: { type: 'range', min: 500, max: 5000, step: 100 } },
|
|
11
|
-
timingFunction: { options: ['ease', 'ease-out', 'ease-in', 'ease-in-out', 'cubic-bezier(0.81, -0.52, 0.42, 2.5)'] },
|
|
12
|
-
times: { control: { type: 'range', min: 1, max: 5 } },
|
|
13
|
-
className: { control: false },
|
|
14
|
-
style: { control: false },
|
|
15
|
-
},
|
|
16
|
-
args: {
|
|
17
|
-
color: '#FFFFFF',
|
|
18
|
-
},
|
|
19
|
-
render: args => (
|
|
20
|
-
<section
|
|
21
|
-
style={{
|
|
22
|
-
background: 'linear-gradient(35deg, rgba(230,96,255,1) 0%, rgba(91,170,255,1) 100%)',
|
|
23
|
-
width: '300px',
|
|
24
|
-
height: '300px',
|
|
25
|
-
borderRadius: '10px',
|
|
26
|
-
}}
|
|
27
|
-
>
|
|
28
|
-
<Ripple {...args} />
|
|
29
|
-
</section>
|
|
30
|
-
),
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export default meta;
|
|
34
|
-
type Story = StoryObj<typeof Ripple>;
|
|
35
|
-
|
|
36
|
-
export const Default: Story = {
|
|
37
|
-
args: {},
|
|
38
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
|
|
3
|
-
export const RippleStyle = styled.span`
|
|
4
|
-
position: absolute;
|
|
5
|
-
display: block;
|
|
6
|
-
top: 0;
|
|
7
|
-
left: 0;
|
|
8
|
-
right: 0;
|
|
9
|
-
bottom: 0;
|
|
10
|
-
overflow: hidden;
|
|
11
|
-
border-radius: inherit;
|
|
12
|
-
z-index: 1;
|
|
13
|
-
|
|
14
|
-
.ripple-effect {
|
|
15
|
-
position: absolute;
|
|
16
|
-
transform: translate(-50%, -50%);
|
|
17
|
-
border-radius: 50%;
|
|
18
|
-
width: 0;
|
|
19
|
-
height: 0;
|
|
20
|
-
pointer-events: none;
|
|
21
|
-
animation: ripple-effect infinite;
|
|
22
|
-
opacity: 0.4;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@keyframes ripple-effect {
|
|
26
|
-
to {
|
|
27
|
-
width: 300px;
|
|
28
|
-
height: 300px;
|
|
29
|
-
opacity: 0;
|
|
30
|
-
filter: blur(5px);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
`;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import { RippleStyle } from './ripple.style';
|
|
4
|
-
|
|
5
|
-
type RippleProps = {
|
|
6
|
-
color?: string;
|
|
7
|
-
duration?: number;
|
|
8
|
-
timingFunction?: React.CSSProperties['animationTimingFunction'];
|
|
9
|
-
times?: number;
|
|
10
|
-
className?: string;
|
|
11
|
-
style?: React.CSSProperties;
|
|
12
|
-
zIndex?: React.CSSProperties['zIndex'];
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const Ripple = ({
|
|
16
|
-
color,
|
|
17
|
-
duration = 1000,
|
|
18
|
-
timingFunction = 'ease-out',
|
|
19
|
-
times = 1,
|
|
20
|
-
className = '',
|
|
21
|
-
style = {},
|
|
22
|
-
zIndex = 1,
|
|
23
|
-
}: RippleProps) => {
|
|
24
|
-
const ref = useRef<HTMLSpanElement>(null);
|
|
25
|
-
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
if (!ref.current?.parentElement) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const computedPosition = getComputedStyle(ref.current.parentElement).position;
|
|
32
|
-
|
|
33
|
-
if (!['absolute', 'fixed', 'sticky', 'relative'].includes(computedPosition)) {
|
|
34
|
-
ref.current.parentElement.style.position = 'relative';
|
|
35
|
-
}
|
|
36
|
-
}, []);
|
|
37
|
-
|
|
38
|
-
const handleClick = (e: React.MouseEvent<HTMLSpanElement>) => {
|
|
39
|
-
const { pageX, pageY, currentTarget } = e;
|
|
40
|
-
|
|
41
|
-
const rect = currentTarget.getBoundingClientRect();
|
|
42
|
-
|
|
43
|
-
const x = ((pageX - rect.left) * 100) / rect.width;
|
|
44
|
-
const y = ((pageY - rect.top) * 100) / rect.height;
|
|
45
|
-
|
|
46
|
-
const ripple = document.createElement('span');
|
|
47
|
-
ripple.classList.add('ripple-effect');
|
|
48
|
-
color && (ripple.style.background = color);
|
|
49
|
-
ripple.style.animationDuration = `${duration}ms`;
|
|
50
|
-
ripple.style.animationTimingFunction = timingFunction;
|
|
51
|
-
ripple.style.left = `${x}%`;
|
|
52
|
-
ripple.style.top = `${y}%`;
|
|
53
|
-
|
|
54
|
-
currentTarget.appendChild(ripple);
|
|
55
|
-
|
|
56
|
-
setTimeout(
|
|
57
|
-
() => {
|
|
58
|
-
ripple.remove();
|
|
59
|
-
},
|
|
60
|
-
Math.max(duration, 500) * Math.max(times, 1),
|
|
61
|
-
);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
return <RippleStyle ref={ref} onMouseDown={handleClick} className={className} style={{ ...style, zIndex }} />;
|
|
65
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './smart-table';
|