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,117 +0,0 @@
|
|
|
1
|
-
import { styled } from 'styled-components';
|
|
2
|
-
|
|
3
|
-
import { Modal } from '../modal';
|
|
4
|
-
|
|
5
|
-
export const ModalStyle = styled(Modal)`
|
|
6
|
-
background: transparent;
|
|
7
|
-
|
|
8
|
-
.modal-content {
|
|
9
|
-
&.shake-animation {
|
|
10
|
-
animation: headShake 600ms linear;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
`;
|
|
14
|
-
|
|
15
|
-
export const ActionModalStyle = styled.section`
|
|
16
|
-
position: relative;
|
|
17
|
-
|
|
18
|
-
.action-modal-body {
|
|
19
|
-
box-shadow: 0 0 10px -5px;
|
|
20
|
-
border-radius: 10px;
|
|
21
|
-
overflow: hidden;
|
|
22
|
-
display: grid;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.action-modal-content {
|
|
26
|
-
background: ${props => props.theme.colors.background.main};
|
|
27
|
-
padding: 3em 4em 2em;
|
|
28
|
-
display: grid;
|
|
29
|
-
gap: 1em;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
&.no-padding .action-modal-content {
|
|
33
|
-
padding: 2em 0 0;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
&:has(.action-modal-icon) .action-modal-content {
|
|
37
|
-
padding-top: 4em;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
&.back-card {
|
|
41
|
-
&::before {
|
|
42
|
-
content: '';
|
|
43
|
-
position: absolute;
|
|
44
|
-
width: 90%;
|
|
45
|
-
height: 100%;
|
|
46
|
-
top: 8px;
|
|
47
|
-
left: 50%;
|
|
48
|
-
transform: translate(-50%);
|
|
49
|
-
z-index: -1;
|
|
50
|
-
background: ${props => props.theme.colors.primary.main};
|
|
51
|
-
border-radius: 10px;
|
|
52
|
-
display: block;
|
|
53
|
-
transition: top 300ms cubic-bezier(0.81, -0.52, 0.42, 2.5);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.action-modal-icon {
|
|
58
|
-
position: absolute;
|
|
59
|
-
top: 0;
|
|
60
|
-
left: 50%;
|
|
61
|
-
transform: translate(-50%, -50%);
|
|
62
|
-
background: ${props => props.theme.colors.primary.main};
|
|
63
|
-
color: ${props => props.theme.colors.primary.contrast};
|
|
64
|
-
padding: 0;
|
|
65
|
-
border-radius: 50%;
|
|
66
|
-
width: 2em;
|
|
67
|
-
height: 2em;
|
|
68
|
-
display: grid;
|
|
69
|
-
place-content: center;
|
|
70
|
-
transition: box-shadow 300ms cubic-bezier(0.81, -0.52, 0.42, 2.5);
|
|
71
|
-
z-index: 1;
|
|
72
|
-
box-shadow:
|
|
73
|
-
0 0 0 0 ${props => props.theme.colors.primary.main}88,
|
|
74
|
-
0 0 0 0 ${props => props.theme.colors.primary.main}66,
|
|
75
|
-
0 0 0 0 ${props => props.theme.colors.primary.main}44,
|
|
76
|
-
0 0 0 0 ${props => props.theme.colors.primary.main}22;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.close-modal-button {
|
|
80
|
-
width: 1em;
|
|
81
|
-
height: 1em;
|
|
82
|
-
border-radius: 50%;
|
|
83
|
-
cursor: pointer;
|
|
84
|
-
background: ${props => props.theme.colors.background.main};
|
|
85
|
-
position: absolute;
|
|
86
|
-
top: 10px;
|
|
87
|
-
right: 5px;
|
|
88
|
-
font-size: ${props => props.theme.constants.typography.header3.fontSize};
|
|
89
|
-
opacity: 0;
|
|
90
|
-
transition: opacity 300ms ease;
|
|
91
|
-
z-index: 1;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
&.line-on-top {
|
|
95
|
-
.action-modal-content {
|
|
96
|
-
border-top: 5px solid ${props => props.theme.colors.primary.main};
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
&:hover {
|
|
101
|
-
.action-modal-icon {
|
|
102
|
-
box-shadow:
|
|
103
|
-
0 0 0 7px ${props => props.theme.colors.primary.main}88,
|
|
104
|
-
0 0 0 14px ${props => props.theme.colors.primary.main}66,
|
|
105
|
-
0 0 0 21px ${props => props.theme.colors.primary.main}44,
|
|
106
|
-
0 0 0 28px ${props => props.theme.colors.primary.main}22;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
.close-modal-button {
|
|
110
|
-
opacity: 1;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
&::before {
|
|
114
|
-
top: 15px;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
`;
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { createContext, useCallback, useContext, useRef, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { Button, ButtonProps } from '../../buttons';
|
|
4
|
-
import { Icon, IconNameT } from '../../icon';
|
|
5
|
-
import { Typography } from '../../typography';
|
|
6
|
-
import { ModalProps } from '../modal';
|
|
7
|
-
|
|
8
|
-
import { ModalStyle, ActionModalStyle } from './action-modal.style';
|
|
9
|
-
|
|
10
|
-
import { PositionContainer } from '@polpo/helpers';
|
|
11
|
-
import { useClassNames } from '@polpo/hooks';
|
|
12
|
-
|
|
13
|
-
type ActionModalContextType = {
|
|
14
|
-
onClose: () => void;
|
|
15
|
-
isActionInProgress: boolean;
|
|
16
|
-
setIsActionInProgress: (isActionInProgress: boolean) => void;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const ActionModalContext = createContext<ActionModalContextType | null>(null);
|
|
20
|
-
|
|
21
|
-
const useActionModalContext = () => {
|
|
22
|
-
const context = useContext(ActionModalContext);
|
|
23
|
-
|
|
24
|
-
if (!context) {
|
|
25
|
-
throw new Error('useActionModalContext must be used within a ActionModal');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return context;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export type ActionModalProps = Omit<
|
|
32
|
-
ModalProps,
|
|
33
|
-
'id' | 'animation' | 'closeAnimationClassName' | 'position' | 'rootStyle' | 'className' | 'style'
|
|
34
|
-
> & {
|
|
35
|
-
actionRequired?: boolean;
|
|
36
|
-
icon?: IconNameT;
|
|
37
|
-
noCloseButton?: boolean;
|
|
38
|
-
lineOnTop?: boolean;
|
|
39
|
-
backCard?: boolean;
|
|
40
|
-
noPadding?: boolean;
|
|
41
|
-
className?: string;
|
|
42
|
-
style?: React.CSSProperties;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const ActionModal = ({
|
|
46
|
-
children,
|
|
47
|
-
isOpen,
|
|
48
|
-
onClose,
|
|
49
|
-
actionRequired,
|
|
50
|
-
icon,
|
|
51
|
-
noCloseButton,
|
|
52
|
-
lineOnTop = false,
|
|
53
|
-
backCard = false,
|
|
54
|
-
noPadding = false,
|
|
55
|
-
className = '',
|
|
56
|
-
style = {},
|
|
57
|
-
...modalProps
|
|
58
|
-
}: ActionModalProps) => {
|
|
59
|
-
const [isActionInProgress, setIsActionInProgress] = useState(false);
|
|
60
|
-
const ref = useRef<HTMLElement>(null);
|
|
61
|
-
|
|
62
|
-
const remainAction = useCallback(() => {
|
|
63
|
-
ref.current?.classList.add('shake-animation');
|
|
64
|
-
setTimeout(() => {
|
|
65
|
-
ref.current?.classList.remove('shake-animation');
|
|
66
|
-
}, 500);
|
|
67
|
-
}, []);
|
|
68
|
-
|
|
69
|
-
const actionModalClassName = useClassNames({
|
|
70
|
-
'back-card': backCard,
|
|
71
|
-
'line-on-top': lineOnTop,
|
|
72
|
-
'no-padding': noPadding,
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
return (
|
|
76
|
-
<ActionModalContext.Provider value={{ onClose, isActionInProgress, setIsActionInProgress }}>
|
|
77
|
-
<ModalStyle
|
|
78
|
-
id='action-modal'
|
|
79
|
-
animation='bounce'
|
|
80
|
-
opacity={0.8}
|
|
81
|
-
isOpen={isOpen}
|
|
82
|
-
onClose={onClose}
|
|
83
|
-
{...modalProps}
|
|
84
|
-
backdropOnClick={actionRequired ? remainAction : onClose}
|
|
85
|
-
position={PositionContainer.CENTER}
|
|
86
|
-
>
|
|
87
|
-
<section ref={ref} className='modal-content'>
|
|
88
|
-
<ActionModalStyle className={actionModalClassName}>
|
|
89
|
-
{!noCloseButton && !actionRequired && (
|
|
90
|
-
<section className='close-modal-button' onClick={() => onClose()}>
|
|
91
|
-
<Icon name='cross' inCircle scale={2} />
|
|
92
|
-
</section>
|
|
93
|
-
)}
|
|
94
|
-
{icon ? (
|
|
95
|
-
<Typography variant='header4' className='action-modal-icon'>
|
|
96
|
-
<Icon name={icon} />
|
|
97
|
-
</Typography>
|
|
98
|
-
) : null}
|
|
99
|
-
<section className='action-modal-body'>
|
|
100
|
-
<section className={`action-modal-content ${className}`} style={style}>
|
|
101
|
-
{children}
|
|
102
|
-
</section>
|
|
103
|
-
</section>
|
|
104
|
-
</ActionModalStyle>
|
|
105
|
-
</section>
|
|
106
|
-
</ModalStyle>
|
|
107
|
-
</ActionModalContext.Provider>
|
|
108
|
-
);
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
type ActionButtonProps = Omit<ButtonProps, 'onClick'> & {
|
|
112
|
-
onClick: (() => Promise<void>) | (() => void);
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const ActionButton = ({ onClick, children, isLoading: manualIsLoading, ...buttonProps }: ActionButtonProps) => {
|
|
116
|
-
const { onClose, isActionInProgress, setIsActionInProgress } = useActionModalContext();
|
|
117
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
118
|
-
|
|
119
|
-
const handleAction = useCallback(() => {
|
|
120
|
-
setIsLoading(true);
|
|
121
|
-
setIsActionInProgress(true);
|
|
122
|
-
const result = onClick();
|
|
123
|
-
|
|
124
|
-
if (result instanceof Promise) {
|
|
125
|
-
result.then(() => {
|
|
126
|
-
onClose();
|
|
127
|
-
setIsLoading(false);
|
|
128
|
-
setIsActionInProgress(false);
|
|
129
|
-
});
|
|
130
|
-
} else {
|
|
131
|
-
onClose();
|
|
132
|
-
setIsLoading(false);
|
|
133
|
-
setIsActionInProgress(false);
|
|
134
|
-
}
|
|
135
|
-
}, [onClick, onClose, setIsActionInProgress]);
|
|
136
|
-
|
|
137
|
-
if (!isLoading && isActionInProgress) {
|
|
138
|
-
return null;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return (
|
|
142
|
-
<Button {...buttonProps} onClick={handleAction} isLoading={manualIsLoading || isLoading}>
|
|
143
|
-
{children}
|
|
144
|
-
</Button>
|
|
145
|
-
);
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
ActionModal.ActionButton = ActionButton;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './action-modal';
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { Button } from '../../buttons';
|
|
4
|
-
import { Image } from '../../image';
|
|
5
|
-
import { Typography } from '../../typography';
|
|
6
|
-
|
|
7
|
-
import { AsideModal } from './aside-modal';
|
|
8
|
-
|
|
9
|
-
import { PositionContainer } from '@polpo/helpers';
|
|
10
|
-
|
|
11
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
12
|
-
|
|
13
|
-
const meta: Meta<typeof AsideModal> = {
|
|
14
|
-
title: 'Modals/AsideModal',
|
|
15
|
-
component: AsideModal,
|
|
16
|
-
argTypes: {
|
|
17
|
-
position: {
|
|
18
|
-
control: 'inline-radio',
|
|
19
|
-
options: [PositionContainer.TOP, PositionContainer.LEFT, PositionContainer.RIGHT, PositionContainer.BOTTOM],
|
|
20
|
-
},
|
|
21
|
-
children: { control: 'text' },
|
|
22
|
-
size: { control: { type: 'range', min: 100, max: 500, step: 10 } },
|
|
23
|
-
className: { control: false },
|
|
24
|
-
style: { control: false },
|
|
25
|
-
},
|
|
26
|
-
decorators: [
|
|
27
|
-
(Story, { args }) => {
|
|
28
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<>
|
|
32
|
-
<Button onClick={() => setIsOpen(true)}>Open modal</Button>
|
|
33
|
-
<Story args={{ ...args, isOpen, onClose: () => setIsOpen(false) }} />
|
|
34
|
-
</>
|
|
35
|
-
);
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export default meta;
|
|
41
|
-
type Story = StoryObj<typeof AsideModal>;
|
|
42
|
-
|
|
43
|
-
export const Aside: Story = {
|
|
44
|
-
argTypes: {
|
|
45
|
-
children: { control: false },
|
|
46
|
-
},
|
|
47
|
-
args: {
|
|
48
|
-
size: 500,
|
|
49
|
-
},
|
|
50
|
-
render: args => {
|
|
51
|
-
return (
|
|
52
|
-
<AsideModal {...args}>
|
|
53
|
-
<Typography variant='header4'>Aside modal</Typography>
|
|
54
|
-
<Typography>
|
|
55
|
-
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam amet at cupiditate dolorum eaque eligendi
|
|
56
|
-
error est fugit harum illo incidunt ipsum itaque labore nulla quaerat quam recusandae repellat sequi
|
|
57
|
-
similique, sit unde vel veniam? Aliquam dicta ipsum voluptates voluptatum.
|
|
58
|
-
</Typography>
|
|
59
|
-
<Image src='https://picsum.photos/500/300' />
|
|
60
|
-
<Typography>
|
|
61
|
-
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Doloremque illum quas recusandae? Adipisci alias
|
|
62
|
-
corporis, cumque doloribus ducimus ea enim, et hic id non nulla quae quis sed temporibus vero.
|
|
63
|
-
</Typography>
|
|
64
|
-
<Typography>
|
|
65
|
-
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolor doloribus error excepturi minima quae, quia
|
|
66
|
-
quod voluptatem? Consectetur, enim exercitationem hic illo iusto obcaecati odio?
|
|
67
|
-
</Typography>
|
|
68
|
-
<Typography>
|
|
69
|
-
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio ducimus necessitatibus officiis optio
|
|
70
|
-
quaerat qui, reiciendis tempora totam ut veniam. At blanditiis cupiditate dolor dolorum ipsum laboriosam natus
|
|
71
|
-
quisquam quo soluta ut? Accusamus aspernatur at beatae neque nisi possimus rerum!
|
|
72
|
-
</Typography>
|
|
73
|
-
<Typography>
|
|
74
|
-
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus asperiores aspernatur at debitis delectus
|
|
75
|
-
error excepturi fuga, harum in laboriosam laudantium minus, neque omnis, optio praesentium quidem recusandae
|
|
76
|
-
reiciendis reprehenderit rerum sunt voluptatem.
|
|
77
|
-
</Typography>
|
|
78
|
-
</AsideModal>
|
|
79
|
-
);
|
|
80
|
-
},
|
|
81
|
-
};
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
|
|
3
|
-
import { Modal } from '../modal';
|
|
4
|
-
|
|
5
|
-
export const AsideModalStyle = styled(Modal)`
|
|
6
|
-
color: ${props => props.theme.colors.text.main};
|
|
7
|
-
overflow: auto;
|
|
8
|
-
height: 100%;
|
|
9
|
-
|
|
10
|
-
.aside-modal-content {
|
|
11
|
-
padding: 2em;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.close-modal-button {
|
|
15
|
-
border-radius: 50%;
|
|
16
|
-
cursor: pointer;
|
|
17
|
-
display: grid;
|
|
18
|
-
place-content: center;
|
|
19
|
-
background: ${props => props.theme.colors.background.main};
|
|
20
|
-
border: 4px solid ${props => props.theme.colors.primary.main};
|
|
21
|
-
position: absolute;
|
|
22
|
-
padding: 0.5em;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
&.left {
|
|
26
|
-
border-right: 4px solid ${props => props.theme.colors.primary.main};
|
|
27
|
-
animation: slideIn-left 300ms ease;
|
|
28
|
-
|
|
29
|
-
&.modal-close {
|
|
30
|
-
animation: slideOut-left 300ms ease;
|
|
31
|
-
transform: translateX(-100%);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.close-modal-button {
|
|
35
|
-
top: 2em;
|
|
36
|
-
left: 100%;
|
|
37
|
-
transform: translate(calc(-50% + 2px));
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
&.right {
|
|
42
|
-
border-left: 4px solid ${props => props.theme.colors.primary.main};
|
|
43
|
-
animation: slideIn-right 300ms ease;
|
|
44
|
-
|
|
45
|
-
&.modal-close {
|
|
46
|
-
animation: slideOut-right 300ms ease;
|
|
47
|
-
transform: translateX(100%);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.close-modal-button {
|
|
51
|
-
top: 2em;
|
|
52
|
-
right: 100%;
|
|
53
|
-
transform: translate(calc(50% - 2px));
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
&.top {
|
|
58
|
-
border-bottom: 4px solid ${props => props.theme.colors.primary.main};
|
|
59
|
-
animation: slideIn-top 300ms ease;
|
|
60
|
-
|
|
61
|
-
&.modal-close {
|
|
62
|
-
animation: slideOut-top 300ms ease;
|
|
63
|
-
transform: translateY(-100%);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.close-modal-button {
|
|
67
|
-
bottom: 0;
|
|
68
|
-
right: 2em;
|
|
69
|
-
transform: translate(0, calc(50% - 2px));
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
&.bottom {
|
|
74
|
-
border-top: 4px solid ${props => props.theme.colors.primary.main};
|
|
75
|
-
animation: slideIn-bottom 300ms ease;
|
|
76
|
-
|
|
77
|
-
&.modal-close {
|
|
78
|
-
animation: slideOut-bottom 300ms ease;
|
|
79
|
-
transform: translateY(100%);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.close-modal-button {
|
|
83
|
-
top: 0;
|
|
84
|
-
right: 2em;
|
|
85
|
-
transform: translate(0, calc(-50% + 2px));
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
`;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { CSSProperties, useMemo } from 'react';
|
|
2
|
-
|
|
3
|
-
import { Icon } from '../../icon';
|
|
4
|
-
import { ModalProps } from '../modal';
|
|
5
|
-
|
|
6
|
-
import { AsideModalStyle } from './aside-modal.style';
|
|
7
|
-
|
|
8
|
-
import { PositionContainer } from '@polpo/helpers';
|
|
9
|
-
|
|
10
|
-
type AsideModalProps = Omit<
|
|
11
|
-
ModalProps,
|
|
12
|
-
'id' | 'animation' | 'closeAnimationClassName' | 'position' | 'rootStyle' | 'className' | 'style'
|
|
13
|
-
> & {
|
|
14
|
-
position?:
|
|
15
|
-
| `${PositionContainer.TOP}`
|
|
16
|
-
| `${PositionContainer.LEFT}`
|
|
17
|
-
| `${PositionContainer.RIGHT}`
|
|
18
|
-
| `${PositionContainer.BOTTOM}`;
|
|
19
|
-
size?: number | `${number}px` | `${number}em`;
|
|
20
|
-
className?: string;
|
|
21
|
-
style?: React.CSSProperties;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const AsideModal = ({
|
|
25
|
-
children,
|
|
26
|
-
isOpen,
|
|
27
|
-
onClose,
|
|
28
|
-
position = PositionContainer.LEFT,
|
|
29
|
-
size,
|
|
30
|
-
className = '',
|
|
31
|
-
...modalProps
|
|
32
|
-
}: AsideModalProps) => {
|
|
33
|
-
const modalRootStyles = useMemo<CSSProperties>(() => {
|
|
34
|
-
const computedSize = {
|
|
35
|
-
[PositionContainer.TOP]: { height: size, width: '100%' },
|
|
36
|
-
[PositionContainer.LEFT]: { height: '100%', width: size },
|
|
37
|
-
[PositionContainer.RIGHT]: { height: '100%', width: size },
|
|
38
|
-
[PositionContainer.BOTTOM]: { height: size, width: '100%' },
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
return computedSize[position];
|
|
42
|
-
}, [position, size]);
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<AsideModalStyle
|
|
46
|
-
id='aside'
|
|
47
|
-
isOpen={isOpen}
|
|
48
|
-
onClose={onClose}
|
|
49
|
-
opacity={0.6}
|
|
50
|
-
windowOffset={0}
|
|
51
|
-
animation='none'
|
|
52
|
-
className={`${className} ${position}`}
|
|
53
|
-
rootStyle={modalRootStyles}
|
|
54
|
-
backdropOnClick={onClose}
|
|
55
|
-
position={position}
|
|
56
|
-
{...modalProps}
|
|
57
|
-
>
|
|
58
|
-
<span className='close-modal-button' onClick={onClose}>
|
|
59
|
-
<Icon name='cross' />
|
|
60
|
-
</span>
|
|
61
|
-
<section className='aside-modal-content'>{children}</section>
|
|
62
|
-
</AsideModalStyle>
|
|
63
|
-
);
|
|
64
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './aside-modal';
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Button } from '../../buttons';
|
|
2
|
-
import ActionModalStory from '../action-modal/action-modal.stories';
|
|
3
|
-
|
|
4
|
-
import { ConfirmationModal } from './confirmation-modal';
|
|
5
|
-
|
|
6
|
-
import { useModal } from '@polpo/hooks';
|
|
7
|
-
|
|
8
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
9
|
-
|
|
10
|
-
const meta: Meta<typeof ConfirmationModal> = {
|
|
11
|
-
title: 'Modals/ConfirmationModal',
|
|
12
|
-
component: ConfirmationModal,
|
|
13
|
-
argTypes: {
|
|
14
|
-
...ActionModalStory.argTypes,
|
|
15
|
-
title: { control: 'text' },
|
|
16
|
-
onAccept: { control: false },
|
|
17
|
-
onReject: { control: false },
|
|
18
|
-
acceptText: { control: 'text' },
|
|
19
|
-
rejectText: { control: 'text' },
|
|
20
|
-
isLoading: { control: 'boolean' },
|
|
21
|
-
},
|
|
22
|
-
args: {
|
|
23
|
-
title: 'Are you sure?',
|
|
24
|
-
acceptText: 'Accept',
|
|
25
|
-
rejectText: 'Reject',
|
|
26
|
-
children: 'Are you sure want to execute an action?',
|
|
27
|
-
},
|
|
28
|
-
decorators: [
|
|
29
|
-
(Story, { args }) => {
|
|
30
|
-
const { isOpen, openModal, closeModal } = useModal();
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<>
|
|
34
|
-
<Button onClick={openModal}>Open modal</Button>
|
|
35
|
-
<Story
|
|
36
|
-
args={{
|
|
37
|
-
...args,
|
|
38
|
-
isOpen,
|
|
39
|
-
onClose: closeModal,
|
|
40
|
-
onAccept: () =>
|
|
41
|
-
new Promise(resolve => {
|
|
42
|
-
setTimeout(resolve, 1000);
|
|
43
|
-
}),
|
|
44
|
-
|
|
45
|
-
onReject: () =>
|
|
46
|
-
new Promise(resolve => {
|
|
47
|
-
setTimeout(resolve, 1000);
|
|
48
|
-
}),
|
|
49
|
-
}}
|
|
50
|
-
/>
|
|
51
|
-
</>
|
|
52
|
-
);
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export default meta;
|
|
58
|
-
type Story = StoryObj<typeof ConfirmationModal>;
|
|
59
|
-
|
|
60
|
-
export const Default: Story = {
|
|
61
|
-
args: {},
|
|
62
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { styled } from 'styled-components';
|
|
2
|
-
|
|
3
|
-
export const ConfirmationModalStyle = styled.section`
|
|
4
|
-
display: grid;
|
|
5
|
-
max-width: 450px;
|
|
6
|
-
gap: 1em;
|
|
7
|
-
place-content: center;
|
|
8
|
-
justify-items: center;
|
|
9
|
-
text-align: center;
|
|
10
|
-
|
|
11
|
-
.confirmation-modal-actions {
|
|
12
|
-
display: grid;
|
|
13
|
-
grid-auto-flow: column;
|
|
14
|
-
justify-content: center;
|
|
15
|
-
gap: 1em;
|
|
16
|
-
}
|
|
17
|
-
`;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Typography } from '../../typography';
|
|
2
|
-
import { ActionModal, ActionModalProps } from '../action-modal';
|
|
3
|
-
|
|
4
|
-
import { ConfirmationModalStyle } from './confirmation-modal.style';
|
|
5
|
-
|
|
6
|
-
type ConfirmationModalProps = ActionModalProps & {
|
|
7
|
-
title: string;
|
|
8
|
-
onAccept: (() => Promise<void>) | (() => void);
|
|
9
|
-
onReject?: (() => Promise<void>) | (() => void);
|
|
10
|
-
acceptText: string;
|
|
11
|
-
rejectText: string;
|
|
12
|
-
isLoading?: boolean;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const ConfirmationModal = ({
|
|
16
|
-
title,
|
|
17
|
-
onAccept,
|
|
18
|
-
onReject = () => null,
|
|
19
|
-
acceptText,
|
|
20
|
-
rejectText,
|
|
21
|
-
children,
|
|
22
|
-
isLoading,
|
|
23
|
-
...actionModalProps
|
|
24
|
-
}: ConfirmationModalProps) => {
|
|
25
|
-
return (
|
|
26
|
-
<ActionModal {...actionModalProps} backCard>
|
|
27
|
-
<ConfirmationModalStyle>
|
|
28
|
-
<Typography variant='header4'>{title}</Typography>
|
|
29
|
-
<section>{children}</section>
|
|
30
|
-
<section className='confirmation-modal-actions'>
|
|
31
|
-
{!isLoading && (
|
|
32
|
-
<ActionModal.ActionButton variant='ghost' onClick={onReject}>
|
|
33
|
-
{rejectText}
|
|
34
|
-
</ActionModal.ActionButton>
|
|
35
|
-
)}
|
|
36
|
-
<ActionModal.ActionButton isLoading={isLoading} onClick={onAccept}>
|
|
37
|
-
{acceptText}
|
|
38
|
-
</ActionModal.ActionButton>
|
|
39
|
-
</section>
|
|
40
|
-
</ConfirmationModalStyle>
|
|
41
|
-
</ActionModal>
|
|
42
|
-
);
|
|
43
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './confirmation-modal';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './menu';
|