@infonomic/uikit 1.5.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/button/button-group.d.ts +1 -1
- package/dist/components/button/button-group.d.ts.map +1 -1
- package/dist/components/button/button-group.js +1 -1
- package/dist/components/button/button.d.ts.map +1 -1
- package/dist/components/button/button.js +1 -1
- package/dist/components/button/control-buttons.d.ts.map +1 -1
- package/dist/components/button/control-buttons.js +3 -3
- package/dist/components/button/copy-button.d.ts.map +1 -1
- package/dist/components/button/copy-button.js +2 -2
- package/dist/components/button/icon-button.d.ts.map +1 -1
- package/dist/components/button/icon-button.js +1 -1
- package/dist/components/button/index.js +17 -1
- package/dist/components/card/card.d.ts.map +1 -1
- package/dist/components/dropdown/dropdown.d.ts +1 -1
- package/dist/components/dropdown/dropdown.d.ts.map +1 -1
- package/dist/components/input/checkbox.d.ts.map +1 -1
- package/dist/components/input/checkbox.js +4 -4
- package/dist/components/input/error-text.d.ts.map +1 -1
- package/dist/components/input/error-text.js +1 -1
- package/dist/components/input/help-text.d.ts.map +1 -1
- package/dist/components/input/help-text.js +1 -1
- package/dist/components/input/input-adornment.d.ts.map +1 -1
- package/dist/components/input/input-adornment.js +1 -1
- package/dist/components/input/input.d.ts.map +1 -1
- package/dist/components/input/input.js +3 -3
- package/dist/components/input/label.d.ts.map +1 -1
- package/dist/components/input/label.js +1 -1
- package/dist/components/input/radio-group.js +1 -1
- package/dist/components/input/select.d.ts +1 -1
- package/dist/components/input/select.d.ts.map +1 -1
- package/dist/components/input/select.js +3 -3
- package/dist/components/input/text-area.d.ts.map +1 -1
- package/dist/components/input/text-area.js +3 -3
- package/dist/components/notifications/alert.d.ts.map +1 -1
- package/dist/components/notifications/alert.js +2 -2
- package/dist/components/notifications/toast.js +4 -4
- package/dist/components/pager/ellipses.d.ts.map +1 -1
- package/dist/components/pager/ellipses.js +1 -1
- package/dist/components/pager/first-button.d.ts.map +1 -1
- package/dist/components/pager/first-button.js +2 -2
- package/dist/components/pager/last-button.d.ts.map +1 -1
- package/dist/components/pager/last-button.js +2 -2
- package/dist/components/pager/next-button.d.ts.map +1 -1
- package/dist/components/pager/next-button.js +2 -2
- package/dist/components/pager/number-button.d.ts.map +1 -1
- package/dist/components/pager/number-button.js +2 -2
- package/dist/components/pager/pagination.d.ts +1 -1
- package/dist/components/pager/pagination.d.ts.map +1 -1
- package/dist/components/pager/pagination.js +5 -5
- package/dist/components/pager/previous-button.d.ts.map +1 -1
- package/dist/components/pager/previous-button.js +2 -2
- package/dist/components/scroll-area/scroll-area.js +1 -1
- package/dist/components/table/table.d.ts.map +1 -1
- package/dist/components/table/table.js +2 -2
- package/dist/components/tabs/tabs.d.ts +1 -1
- package/dist/components/tabs/tabs.d.ts.map +1 -1
- package/dist/components/tabs/tabs.js +1 -1
- package/dist/components/tooltip/tooltip.d.ts.map +1 -1
- package/dist/icons/index.js +1 -17
- package/package.json +9 -5
- package/src/astro.d.ts +43 -0
- package/src/astro.js +2 -2
- package/src/components/@types/shared.ts +24 -0
- package/src/components/accordion/accordion.module.css +60 -0
- package/src/components/accordion/accordion.stories.tsx +117 -0
- package/src/components/accordion/accordion.tsx +105 -0
- package/src/components/animation/fade-in-lift.stories.tsx +81 -0
- package/src/components/animation/fade-in-lift.tsx +42 -0
- package/src/components/avatar/avatar.module.css +54 -0
- package/src/components/avatar/avatar.stories.tsx +28 -0
- package/src/components/avatar/avatar.tsx +19 -0
- package/src/components/button/@types/button.ts +17 -0
- package/src/components/button/button-group.module.css +17 -0
- package/src/components/button/button-group.stories.tsx +45 -0
- package/src/components/button/button-group.tsx +132 -0
- package/src/components/button/button-icon.stories.tsx +145 -0
- package/src/components/button/button-intents.stories.tsx +50 -0
- package/src/components/button/button-variants.stories.tsx +60 -0
- package/src/components/button/button.astro +86 -0
- package/src/components/button/button.module.css +533 -0
- package/src/components/button/button.tsx +81 -0
- package/src/components/button/control-buttons.module.css +144 -0
- package/src/components/button/control-buttons.stories.tsx +60 -0
- package/src/components/button/control-buttons.tsx +137 -0
- package/src/components/button/copy-button.module.css +31 -0
- package/src/components/button/copy-button.stories.tsx +50 -0
- package/src/components/button/copy-button.tsx +92 -0
- package/src/components/button/icon-button.astro +47 -0
- package/src/components/button/icon-button.tsx +44 -0
- package/src/components/button/index.ts +5 -0
- package/src/components/calendar/calendar.module.css +315 -0
- package/src/components/calendar/calendar.stories.tsx +139 -0
- package/src/components/calendar/calendar.tsx +173 -0
- package/src/components/card/card-content.astro +14 -0
- package/src/components/card/card-description.astro +14 -0
- package/src/components/card/card-footer.astro +14 -0
- package/src/components/card/card-header.astro +14 -0
- package/src/components/card/card-title.astro +14 -0
- package/src/components/card/card.astro +41 -0
- package/src/components/card/card.module.css +67 -0
- package/src/components/card/card.stories.tsx +61 -0
- package/src/components/card/card.tsx +86 -0
- package/src/components/container/container.astro +13 -0
- package/src/components/container/container.module.css +28 -0
- package/src/components/container/container.stories.tsx +42 -0
- package/src/components/container/container.tsx +23 -0
- package/src/components/dropdown/dropdown.module.css +131 -0
- package/src/components/dropdown/dropdown.stories.tsx +103 -0
- package/src/components/dropdown/dropdown.tsx +193 -0
- package/src/components/hamburger/hamburger.astro +30 -0
- package/src/components/hamburger/hamburger.tsx +66 -0
- package/src/components/input/@types/checkbox.ts +20 -0
- package/src/components/input/@types/input.ts +20 -0
- package/src/components/input/checkbox-group.tsx +78 -0
- package/src/components/input/checkbox.module.css +267 -0
- package/src/components/input/checkbox.stories.tsx +240 -0
- package/src/components/input/checkbox.tsx +95 -0
- package/src/components/input/error-text.astro +14 -0
- package/src/components/input/error-text.module.css +19 -0
- package/src/components/input/error-text.tsx +18 -0
- package/src/components/input/errors.tsx +37 -0
- package/src/components/input/help-text.astro +13 -0
- package/src/components/input/help-text.module.css +19 -0
- package/src/components/input/help-text.tsx +13 -0
- package/src/components/input/index.tsx +8 -0
- package/src/components/input/input-adornment.astro +26 -0
- package/src/components/input/input-adornment.module.css +18 -0
- package/src/components/input/input-adornment.tsx +36 -0
- package/src/components/input/input.astro +99 -0
- package/src/components/input/input.module.css +310 -0
- package/src/components/input/input.stories.tsx +174 -0
- package/src/components/input/input.tsx +103 -0
- package/src/components/input/label.astro +24 -0
- package/src/components/input/label.module.css +28 -0
- package/src/components/input/label.tsx +25 -0
- package/src/components/input/radio-group.module.css +219 -0
- package/src/components/input/radio-group.stories.tsx +73 -0
- package/src/components/input/radio-group.tsx +67 -0
- package/src/components/input/select.module.css +75 -0
- package/src/components/input/select.stories.tsx +34 -0
- package/src/components/input/select.tsx +115 -0
- package/src/components/input/text-area.module.css +9 -0
- package/src/components/input/text-area.stories.tsx +51 -0
- package/src/components/input/text-area.tsx +81 -0
- package/src/components/input/utils.ts +21 -0
- package/src/components/notifications/@types/alert.ts +12 -0
- package/src/components/notifications/@types/toast.ts +12 -0
- package/src/components/notifications/alert.module.css +114 -0
- package/src/components/notifications/alert.stories.tsx +39 -0
- package/src/components/notifications/alert.tsx +117 -0
- package/src/components/notifications/index.ts +2 -0
- package/src/components/notifications/toast.module.css +237 -0
- package/src/components/notifications/toast.stories.tsx +42 -0
- package/src/components/notifications/toast.tsx +124 -0
- package/src/components/overlay/index.stories.tsx +29 -0
- package/src/components/overlay/index.ts +2 -0
- package/src/components/overlay/overlay.module.css +41 -0
- package/src/components/overlay/overlay.tsx +61 -0
- package/src/components/pager/@types/index.ts +2 -0
- package/src/components/pager/ellipses.tsx +18 -0
- package/src/components/pager/event-pager.tsx +18 -0
- package/src/components/pager/first-button.tsx +53 -0
- package/src/components/pager/hooks/types/usePagination.ts +80 -0
- package/src/components/pager/hooks/usePagination.ts +140 -0
- package/src/components/pager/icons/first.tsx +33 -0
- package/src/components/pager/icons/index.tsx +4 -0
- package/src/components/pager/icons/last.tsx +33 -0
- package/src/components/pager/icons/next.tsx +20 -0
- package/src/components/pager/icons/previous.tsx +20 -0
- package/src/components/pager/index.ts +4 -0
- package/src/components/pager/last-button.tsx +57 -0
- package/src/components/pager/next-button.tsx +55 -0
- package/src/components/pager/number-button.tsx +83 -0
- package/src/components/pager/pagination.module.css +165 -0
- package/src/components/pager/pagination.stories.tsx +190 -0
- package/src/components/pager/pagination.tsx +266 -0
- package/src/components/pager/previous-button.tsx +51 -0
- package/src/components/scroll-area/scroll-area.module.css +80 -0
- package/src/components/scroll-area/scroll-area.stories.tsx +33 -0
- package/src/components/scroll-area/scroll-area.tsx +22 -0
- package/src/components/scroll-to-top/scroll-to-top.tsx +59 -0
- package/src/components/section/section.astro +13 -0
- package/src/components/section/section.module.css +7 -0
- package/src/components/section/section.tsx +23 -0
- package/src/components/shimmer/shimmer.module.css +53 -0
- package/src/components/shimmer/shimmer.stories.tsx +24 -0
- package/src/components/shimmer/shimmer.tsx +70 -0
- package/src/components/table/table.module.css +100 -0
- package/src/components/table/table.stories.tsx +95 -0
- package/src/components/table/table.tsx +165 -0
- package/src/components/tabs/tabs.module.css +64 -0
- package/src/components/tabs/tabs.stories.tsx +47 -0
- package/src/components/tabs/tabs.tsx +75 -0
- package/src/components/timeline/timeline.module.css +87 -0
- package/src/components/timeline/timeline.stories.tsx +50 -0
- package/src/components/timeline/timeline.tsx +177 -0
- package/src/components/tooltip/tooltip.module.css +55 -0
- package/src/components/tooltip/tooltip.stories.tsx +59 -0
- package/src/components/tooltip/tooltip.tsx +51 -0
- package/src/declarations.d.ts +4 -0
- package/src/hooks/use-media-query.ts +20 -0
- package/src/icons/activity-icon.tsx +40 -0
- package/src/icons/calendar-icon.tsx +39 -0
- package/src/icons/check-icon.tsx +33 -0
- package/src/icons/chevron-down-icon.tsx +39 -0
- package/src/icons/chevron-left-double-icon.tsx +58 -0
- package/src/icons/chevron-left-icon.tsx +58 -0
- package/src/icons/chevron-right-double-icon.tsx +58 -0
- package/src/icons/chevron-right-icon.tsx +58 -0
- package/src/icons/chevrons-up-down.tsx +37 -0
- package/src/icons/close-icon.astro +38 -0
- package/src/icons/close-icon.tsx +30 -0
- package/src/icons/copy-icon.tsx +35 -0
- package/src/icons/danger-icon.tsx +18 -0
- package/src/icons/dashboard-icon.tsx +41 -0
- package/src/icons/delete-icon.tsx +34 -0
- package/src/icons/document-icon.tsx +38 -0
- package/src/icons/download-icon.tsx +39 -0
- package/src/icons/edit-icon.tsx +35 -0
- package/src/icons/ellipsis-icon.tsx +38 -0
- package/src/icons/email-icon.tsx +33 -0
- package/src/icons/external-link-icon.tsx +39 -0
- package/src/icons/github-icon.tsx +27 -0
- package/src/icons/globe-icon.tsx +50 -0
- package/src/icons/google-icon.tsx +44 -0
- package/src/icons/gripper-vertical-icon.tsx +43 -0
- package/src/icons/history-icon.tsx +32 -0
- package/src/icons/home-icon.tsx +34 -0
- package/src/icons/icon-element.astro +27 -0
- package/src/icons/icon-element.tsx +32 -0
- package/src/icons/icon-sprite.tsx +18 -0
- package/src/icons/icons.module.css +147 -0
- package/src/icons/index.stories.tsx +25 -0
- package/src/icons/index.ts +39 -0
- package/src/icons/info-icon.tsx +18 -0
- package/src/icons/infonomic-icon.tsx +173 -0
- package/src/icons/light-icon.astro +36 -0
- package/src/icons/light-icon.tsx +29 -0
- package/src/icons/location-pin-icon.tsx +36 -0
- package/src/icons/moon-icon.astro +38 -0
- package/src/icons/moon-icon.tsx +42 -0
- package/src/icons/plus-icon.tsx +34 -0
- package/src/icons/primary-icon.tsx +22 -0
- package/src/icons/refresh-icon.tsx +33 -0
- package/src/icons/return-icon.tsx +36 -0
- package/src/icons/roles-icon.tsx +34 -0
- package/src/icons/search-icon.astro +40 -0
- package/src/icons/search-icon.tsx +29 -0
- package/src/icons/search-menu-icon.tsx +42 -0
- package/src/icons/settings-gear-icon.tsx +36 -0
- package/src/icons/settings-sliders-icon.tsx +43 -0
- package/src/icons/sign-out-icon.tsx +35 -0
- package/src/icons/source/icon-calendar.svg +1 -0
- package/src/icons/source/icon-check.svg +4 -0
- package/src/icons/source/icon-close.svg +3 -0
- package/src/icons/source/icon-coinbase.svg +9 -0
- package/src/icons/source/icon-copy.svg +4 -0
- package/src/icons/source/icon-document.svg +5 -0
- package/src/icons/source/icon-download.svg +4 -0
- package/src/icons/source/icon-edit.svg +6 -0
- package/src/icons/source/icon-eth-purple.svg +15 -0
- package/src/icons/source/icon-etherscan.svg +5 -0
- package/src/icons/source/icon-external-link.svg +4 -0
- package/src/icons/source/icon-globe.svg +7 -0
- package/src/icons/source/icon-gripper-vertical.svg +9 -0
- package/src/icons/source/icon-info.svg +4 -0
- package/src/icons/source/icon-infonomic.svg +43 -0
- package/src/icons/source/icon-ledger.svg +4 -0
- package/src/icons/source/icon-light.svg +3 -0
- package/src/icons/source/icon-location-pin.svg +8 -0
- package/src/icons/source/icon-logout.svg +6 -0
- package/src/icons/source/icon-metamask.svg +32 -0
- package/src/icons/source/icon-moon.svg +3 -0
- package/src/icons/source/icon-plus.svg +4 -0
- package/src/icons/source/icon-refresh.svg +4 -0
- package/src/icons/source/icon-return.svg +4 -0
- package/src/icons/source/icon-search-menu.svg +13 -0
- package/src/icons/source/icon-search.svg +3 -0
- package/src/icons/source/icon-settings-gear.svg +5 -0
- package/src/icons/source/icon-settings.svg +12 -0
- package/src/icons/source/icon-wallet.svg +3 -0
- package/src/icons/source/icon-walletconnect.svg +4 -0
- package/src/icons/source/icon-x.svg +4 -0
- package/src/icons/stopwatch-icon.tsx +39 -0
- package/src/icons/success-icon.tsx +18 -0
- package/src/icons/types/icon.ts +8 -0
- package/src/icons/user-icon.tsx +33 -0
- package/src/icons/users-icon.tsx +35 -0
- package/src/icons/wallet-icon.tsx +29 -0
- package/src/icons/warning-icon.tsx +18 -0
- package/src/icons/x-icon.tsx +33 -0
- package/src/loaders/ellipses.tsx +36 -0
- package/src/loaders/loaders.stories.tsx +46 -0
- package/src/loaders/ring.tsx +33 -0
- package/src/loaders/spinner.tsx +28 -0
- package/src/loaders/types/index.ts +6 -0
- package/src/react.ts +99 -0
- package/src/styles/base/animations.css +143 -0
- package/src/styles/base/base.css +5 -0
- package/src/styles/base/colors.css +163 -0
- package/src/styles/base/colors.stories.tsx +671 -0
- package/src/styles/base/reset.css +464 -0
- package/src/styles/base/typography.css +25 -0
- package/src/styles/base/vars.css +188 -0
- package/src/styles/components/card.css +20 -0
- package/src/styles/components/checkbox.css +55 -0
- package/src/styles/components/components.css +11 -0
- package/src/styles/components/directional-button.css +92 -0
- package/src/styles/components/dropdown.css +19 -0
- package/src/styles/components/fade-in-lift.css +13 -0
- package/src/styles/components/hamburger.css +107 -0
- package/src/styles/components/icon-element.css +4 -0
- package/src/styles/components/list-checkbox.css +60 -0
- package/src/styles/components/loaders.css +196 -0
- package/src/styles/components/popover.css +15 -0
- package/src/styles/components/scroll-to-top.css +89 -0
- package/src/styles/components/toast.css +18 -0
- package/src/styles/styles.css +6 -0
- package/src/styles/theme/autofill.css +58 -0
- package/src/styles/theme/scrollers.css +52 -0
- package/src/styles/theme/theme.css +130 -0
- package/src/styles/theme/theme.stories.tsx +33 -0
- package/src/styles/typography/code.stories.tsx +76 -0
- package/src/styles/typography/default.stories.tsx +51 -0
- package/src/styles/typography/fonts.css +30 -0
- package/src/styles/typography/lists.stories.tsx +50 -0
- package/src/styles/typography/prose.css +404 -0
- package/src/styles/typography/quote.stories.tsx +37 -0
- package/src/styles/typography.css +24 -0
- package/src/styles/utils/scroll-layout-shift.css +9 -0
- package/src/styles/utils/utility-classes.css +1278 -0
- package/src/styles/utils/utils.css +2 -0
- package/src/theme/theme-provider/index.ts +1 -0
- package/src/theme/theme-provider/provider.tsx +44 -0
- package/src/utils/capitalize.ts +6 -0
- package/src/utils/externalLinkProps.ts +6 -0
- package/src/utils/findMatch.ts +7 -0
- package/src/utils/getPortalRoot.ts +3 -0
- package/src/utils/isTouchDevice.ts +11 -0
- package/src/utils/objectsToArray.ts +15 -0
- package/src/utils/objectsToString.ts +5 -0
- package/src/utils/polymorphic.ts +16 -0
- package/src/utils/to-kebab-case.ts +5 -0
- package/src/widgets/datepicker/datepicker.module.css +189 -0
- package/src/widgets/datepicker/datepicker.stories.tsx +25 -0
- package/src/widgets/datepicker/datepicker.tsx +310 -0
- package/src/widgets/drawer/drawer-container.tsx +26 -0
- package/src/widgets/drawer/drawer-content.tsx +26 -0
- package/src/widgets/drawer/drawer-context.tsx +49 -0
- package/src/widgets/drawer/drawer-header.tsx +27 -0
- package/src/widgets/drawer/drawer-top-actions.tsx +27 -0
- package/src/widgets/drawer/drawer-wrapper.tsx +54 -0
- package/src/widgets/drawer/drawer.module.css +116 -0
- package/src/widgets/drawer/drawer.stories.tsx +224 -0
- package/src/widgets/drawer/drawer.tsx +115 -0
- package/src/widgets/drawer/motionDomAnimation.ts +4 -0
- package/src/widgets/drawer/motionDomMax.ts +4 -0
- package/src/widgets/modal/modal-actions.tsx +26 -0
- package/src/widgets/modal/modal-container.tsx +26 -0
- package/src/widgets/modal/modal-content.tsx +26 -0
- package/src/widgets/modal/modal-header.tsx +27 -0
- package/src/widgets/modal/modal-wrapper.tsx +50 -0
- package/src/widgets/modal/modal.module.css +85 -0
- package/src/widgets/modal/modal.stories.tsx +71 -0
- package/src/widgets/modal/modal.tsx +110 -0
- package/src/widgets/modal/motionDomAnimation.ts +4 -0
- package/src/widgets/modal/motionDomMax.ts +4 -0
- package/src/widgets/search/index.ts +1 -0
- package/src/widgets/search/search.stories.tsx +18 -0
- package/src/widgets/search/search.tsx +186 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import cx from 'classnames'
|
|
2
|
+
import type * as React from 'react'
|
|
3
|
+
|
|
4
|
+
import type { Intent, Variant } from './@types/input.js'
|
|
5
|
+
import { ErrorText } from './error-text.js'
|
|
6
|
+
import { HelpText } from './help-text.js'
|
|
7
|
+
import inputStyles from './input.module.css'
|
|
8
|
+
import { Label } from './label.js'
|
|
9
|
+
import styles from './text-area.module.css'
|
|
10
|
+
|
|
11
|
+
export interface TextAreaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
12
|
+
id: string
|
|
13
|
+
name: string
|
|
14
|
+
label: string
|
|
15
|
+
required?: boolean
|
|
16
|
+
variant?: Variant
|
|
17
|
+
intent?: Intent
|
|
18
|
+
rows: number
|
|
19
|
+
placeHolder?: string
|
|
20
|
+
autoComplete?: string
|
|
21
|
+
error?: boolean
|
|
22
|
+
helpText?: string
|
|
23
|
+
errorText?: string
|
|
24
|
+
className?: string
|
|
25
|
+
ref?: React.RefCallback<HTMLTextAreaElement | null> | React.RefObject<HTMLTextAreaElement | null>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const TextArea = function TextArea({
|
|
29
|
+
ref,
|
|
30
|
+
id,
|
|
31
|
+
name,
|
|
32
|
+
label,
|
|
33
|
+
rows = 4,
|
|
34
|
+
required = false,
|
|
35
|
+
variant = 'outlined',
|
|
36
|
+
intent = 'primary',
|
|
37
|
+
placeHolder = '',
|
|
38
|
+
autoComplete = 'off',
|
|
39
|
+
error = false,
|
|
40
|
+
helpText = '',
|
|
41
|
+
errorText = '',
|
|
42
|
+
className,
|
|
43
|
+
...rest
|
|
44
|
+
}: TextAreaProps): React.JSX.Element {
|
|
45
|
+
return (
|
|
46
|
+
<fieldset className={cx('text-area-wrapper', inputStyles.inputWrapper)}>
|
|
47
|
+
<Label id={id} htmlFor={id} required={required} label={label} />
|
|
48
|
+
<textarea
|
|
49
|
+
ref={ref}
|
|
50
|
+
id={id}
|
|
51
|
+
name={name}
|
|
52
|
+
required={required}
|
|
53
|
+
rows={rows}
|
|
54
|
+
autoComplete={autoComplete}
|
|
55
|
+
placeholder={placeHolder}
|
|
56
|
+
aria-labelledby={`label-for-${id}`}
|
|
57
|
+
aria-invalid={error}
|
|
58
|
+
aria-required={required}
|
|
59
|
+
aria-errormessage={errorText}
|
|
60
|
+
aria-describedby={error ? `error-for-${id}` : undefined}
|
|
61
|
+
className={cx(
|
|
62
|
+
'text-area',
|
|
63
|
+
variant,
|
|
64
|
+
intent,
|
|
65
|
+
inputStyles.input,
|
|
66
|
+
inputStyles[variant],
|
|
67
|
+
inputStyles[intent],
|
|
68
|
+
styles['text-area'],
|
|
69
|
+
{ [inputStyles.error]: error },
|
|
70
|
+
className
|
|
71
|
+
)}
|
|
72
|
+
{...rest}
|
|
73
|
+
/>
|
|
74
|
+
{error ? (
|
|
75
|
+
<ErrorText id={`error-for-${id}`} text={errorText ?? helpText} />
|
|
76
|
+
) : (
|
|
77
|
+
helpText?.length > 0 && <HelpText text={helpText} />
|
|
78
|
+
)}
|
|
79
|
+
</fieldset>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ZodType, z } from 'zod'
|
|
2
|
+
|
|
3
|
+
type FormattedErrors = z.inferFormattedError<ZodType<any, any, any>>
|
|
4
|
+
|
|
5
|
+
export function hasErrors(name: string, clientErrors: any, serverErrors: any): boolean {
|
|
6
|
+
return Boolean(serverErrors?.[name as keyof typeof serverErrors] ?? clientErrors[name])
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function getErrorText(
|
|
10
|
+
name: string,
|
|
11
|
+
clientErrors: any,
|
|
12
|
+
serverErrors: any
|
|
13
|
+
): string | undefined {
|
|
14
|
+
const message = clientErrors[name]?.message
|
|
15
|
+
if (message != null) return message
|
|
16
|
+
const error =
|
|
17
|
+
serverErrors != null
|
|
18
|
+
? (serverErrors[name as keyof typeof serverErrors] as FormattedErrors)
|
|
19
|
+
: undefined
|
|
20
|
+
if (error?._errors != null) return error._errors.join(' ')
|
|
21
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
import type { ReactNode } from 'react'
|
|
3
|
+
|
|
4
|
+
// generic types
|
|
5
|
+
import type { Intent as t } from '../../@types/shared.js'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* This file contains the types and prop-types for Button and IconButton component.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// typescript types
|
|
12
|
+
export type Intent = 'primary' | t
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// generic types
|
|
2
|
+
import type { Icons as i, Position as p, Intent as t } from '../../@types/shared.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This file contains the types and prop-types for Toast component.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// typescript types
|
|
9
|
+
export type Intent = 'primary' | t
|
|
10
|
+
export type Position = 'top-right' | p
|
|
11
|
+
export type IconType = 'success' | i
|
|
12
|
+
export type OnOpenChange = (open: boolean) => void
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
@layer infonomic-base, infonomic-utilities, infonomic-theme, infonomic-typography, infonomic-components;
|
|
2
|
+
|
|
3
|
+
@layer infonomic-components {
|
|
4
|
+
.alert {
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: start;
|
|
7
|
+
width: 100%;
|
|
8
|
+
gap: var(--gap-2);
|
|
9
|
+
border-radius: var(--border-radius-md);
|
|
10
|
+
padding: 16px;
|
|
11
|
+
font-family: inherit;
|
|
12
|
+
font-weight: normal;
|
|
13
|
+
transition: all 0.3s ease-in-out;
|
|
14
|
+
border: 1px solid var(--alert-border);
|
|
15
|
+
background-color: var(--alert-background);
|
|
16
|
+
margin-bottom: 1rem;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.alert-with-title {
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
width: 100%;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.icon {
|
|
26
|
+
display: flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
justify-content: center;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.close {
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
padding: 0;
|
|
36
|
+
min-width: 24px;
|
|
37
|
+
min-height: 24px;
|
|
38
|
+
width: 24px;
|
|
39
|
+
height: 24px;
|
|
40
|
+
border-radius: 100%;
|
|
41
|
+
margin-left: auto;
|
|
42
|
+
margin-top: -2px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.close svg {
|
|
46
|
+
fill: white
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.fade {
|
|
50
|
+
opacity: 0;
|
|
51
|
+
transition: opacity 0.4s ease-in-out;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.header {
|
|
55
|
+
display: flex;
|
|
56
|
+
align-items: start;
|
|
57
|
+
width: 100%;
|
|
58
|
+
margin-bottom: var(--spacing-2);
|
|
59
|
+
gap: var(--gap-2);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.title {
|
|
63
|
+
display: flex;
|
|
64
|
+
font-weight: bold;
|
|
65
|
+
font-size: 1.2rem;
|
|
66
|
+
line-height: 1;
|
|
67
|
+
padding-top: 1px;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.content {
|
|
71
|
+
padding-top: 1px;
|
|
72
|
+
font-size: var(--font-size-sm);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.content:first-child {
|
|
76
|
+
margin-top: 0;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/* Intents */
|
|
80
|
+
.primary {
|
|
81
|
+
--alert-border: var(--primary-300);
|
|
82
|
+
--alert-background: oklch(from var(--primary-500) l c h / 0.1);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.secondary {
|
|
86
|
+
--alert-border: var(--secondary-300);
|
|
87
|
+
--alert-background: oklch(from var(--secondary-500) l c h / 0.1);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.noeffect {
|
|
91
|
+
--alert-border: var(--gray-300);
|
|
92
|
+
--alert-background: oklch(from var(--gray-500) l c h / 0.1);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.success {
|
|
96
|
+
--alert-border: var(--green-300);
|
|
97
|
+
--alert-background: oklch(from var(--green-500) l c h / 0.1);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.info {
|
|
101
|
+
--alert-border: var(--blue-300);
|
|
102
|
+
--alert-background: oklch(from var(--blue-500) l c h / 0.1);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.warning {
|
|
106
|
+
--alert-border: var(--yellow-300);
|
|
107
|
+
--alert-background: oklch(from var(--yellow-500) l c h / 0.1);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.danger {
|
|
111
|
+
--alert-border: var(--red-300);
|
|
112
|
+
--alert-background: oklch(from var(--red-500) l c h / 0.1);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Meta } from '@storybook/react-vite'
|
|
2
|
+
import type React from 'react'
|
|
3
|
+
|
|
4
|
+
import { type Intent, intent } from '../@types/shared.js'
|
|
5
|
+
|
|
6
|
+
import { Alert as AlertComponent } from './alert.js'
|
|
7
|
+
|
|
8
|
+
export const Alerts = (): React.JSX.Element => {
|
|
9
|
+
return (
|
|
10
|
+
<div style={{ maxWidth: '600px', margin: '0 auto' }}>
|
|
11
|
+
{intent.map((intent: Intent) => {
|
|
12
|
+
if (intent !== 'noeffect') {
|
|
13
|
+
return (
|
|
14
|
+
<div style={{ marginBottom: '1rem' }} key={intent}>
|
|
15
|
+
<AlertComponent intent={intent}>
|
|
16
|
+
This is a {intent} alert - with some additional text here.
|
|
17
|
+
</AlertComponent>
|
|
18
|
+
</div>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
return null
|
|
22
|
+
})}
|
|
23
|
+
<AlertComponent intent="info" title="This is a title">
|
|
24
|
+
This is an info alert with a title and with some additional text here.
|
|
25
|
+
</AlertComponent>
|
|
26
|
+
</div>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const meta: Meta = {
|
|
31
|
+
/* 👇 The title prop is optional.
|
|
32
|
+
* See https://storybook.js.org/docs/react/configure/overview#configure-story-loading
|
|
33
|
+
* to learn how to generate automatic titles
|
|
34
|
+
*/
|
|
35
|
+
title: 'Components',
|
|
36
|
+
component: Alerts,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default meta
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import cx from 'classnames'
|
|
4
|
+
import type React from 'react'
|
|
5
|
+
import { useEffect, useState } from 'react'
|
|
6
|
+
import { CloseIcon } from '../../icons/close-icon'
|
|
7
|
+
import { DangerIcon } from '../../icons/danger-icon'
|
|
8
|
+
import { InfoIcon } from '../../icons/info-icon'
|
|
9
|
+
import { SuccessIcon } from '../../icons/success-icon'
|
|
10
|
+
import { WarningIcon } from '../../icons/warning-icon'
|
|
11
|
+
import { Button } from '../button/button.js'
|
|
12
|
+
|
|
13
|
+
import type { Intent } from './@types/alert.js'
|
|
14
|
+
|
|
15
|
+
import styles from './alert.module.css'
|
|
16
|
+
|
|
17
|
+
export interface AlertProps {
|
|
18
|
+
intent?: Intent
|
|
19
|
+
icon?: boolean
|
|
20
|
+
close?: boolean
|
|
21
|
+
className?: string
|
|
22
|
+
title?: string
|
|
23
|
+
children: React.ReactNode
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const alertIcons = {
|
|
27
|
+
primary: WarningIcon,
|
|
28
|
+
secondary: InfoIcon,
|
|
29
|
+
success: SuccessIcon,
|
|
30
|
+
info: InfoIcon,
|
|
31
|
+
warning: WarningIcon,
|
|
32
|
+
danger: DangerIcon,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const Alert = function Alert({
|
|
36
|
+
ref,
|
|
37
|
+
intent = 'success',
|
|
38
|
+
icon = true,
|
|
39
|
+
close = true,
|
|
40
|
+
title,
|
|
41
|
+
className,
|
|
42
|
+
children,
|
|
43
|
+
...rest
|
|
44
|
+
}: AlertProps & {
|
|
45
|
+
ref?: React.RefObject<HTMLDivElement>
|
|
46
|
+
}): React.JSX.Element | null {
|
|
47
|
+
const [show, setShow] = useState(true)
|
|
48
|
+
const [fade, setFade] = useState(false)
|
|
49
|
+
|
|
50
|
+
const Icon = alertIcons[intent as keyof typeof alertIcons]
|
|
51
|
+
|
|
52
|
+
const handleOnClose = (): void => {
|
|
53
|
+
setFade(true)
|
|
54
|
+
setTimeout(() => setShow(false), 400) // Match the CSS transition duration
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (!show) {
|
|
59
|
+
// Perform any cleanup if necessary
|
|
60
|
+
}
|
|
61
|
+
}, [show])
|
|
62
|
+
|
|
63
|
+
if (show === false) return null
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<div
|
|
67
|
+
ref={ref}
|
|
68
|
+
className={cx('alert', intent, styles.alert, styles[intent], className, {
|
|
69
|
+
[styles.fade]: fade,
|
|
70
|
+
})}
|
|
71
|
+
{...rest}
|
|
72
|
+
>
|
|
73
|
+
{title != null ? (
|
|
74
|
+
<div className={cx('alert-with-title', styles['alert-with-title'])}>
|
|
75
|
+
<div className={cx(styles.header)}>
|
|
76
|
+
{icon && <Icon className={styles.icon} />}
|
|
77
|
+
<div className={cx(styles.title)}>
|
|
78
|
+
<span>{title}</span>
|
|
79
|
+
</div>
|
|
80
|
+
{close === true && (
|
|
81
|
+
<Button
|
|
82
|
+
intent={intent}
|
|
83
|
+
variant="filled"
|
|
84
|
+
aria-label="Close"
|
|
85
|
+
className={cx(styles.close)}
|
|
86
|
+
type="button"
|
|
87
|
+
onClick={handleOnClose}
|
|
88
|
+
{...rest}
|
|
89
|
+
>
|
|
90
|
+
<CloseIcon height="12px" width="12px" />
|
|
91
|
+
</Button>
|
|
92
|
+
)}
|
|
93
|
+
</div>
|
|
94
|
+
<div className={cx(styles.content)}>{children}</div>
|
|
95
|
+
</div>
|
|
96
|
+
) : (
|
|
97
|
+
<>
|
|
98
|
+
{icon && <Icon className={styles.icon} />}
|
|
99
|
+
<div className={styles.content}>{children}</div>
|
|
100
|
+
{close === true && (
|
|
101
|
+
<Button
|
|
102
|
+
intent={intent}
|
|
103
|
+
variant="filled"
|
|
104
|
+
aria-label="Close"
|
|
105
|
+
className={styles.close}
|
|
106
|
+
type="button"
|
|
107
|
+
onClick={handleOnClose}
|
|
108
|
+
{...rest}
|
|
109
|
+
>
|
|
110
|
+
<CloseIcon height="12px" width="12px" />
|
|
111
|
+
</Button>
|
|
112
|
+
)}
|
|
113
|
+
</>
|
|
114
|
+
)}
|
|
115
|
+
</div>
|
|
116
|
+
)
|
|
117
|
+
}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
@layer infonomic-base, infonomic-utilities, infonomic-theme, infonomic-typography, infonomic-components;
|
|
2
|
+
|
|
3
|
+
@layer infonomic-components {
|
|
4
|
+
/* Positions are relative to the toast viewport which is set
|
|
5
|
+
globally in components/toast.css */
|
|
6
|
+
|
|
7
|
+
.root {
|
|
8
|
+
position: absolute;
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
gap: var(--gap-1);
|
|
12
|
+
padding-top: 12px;
|
|
13
|
+
padding-bottom: 16px;
|
|
14
|
+
background: var(--gray-25);
|
|
15
|
+
border-width: var(--border-width-thin);
|
|
16
|
+
border-color: var(--border-color);
|
|
17
|
+
border-style: var(--border-style-solid);
|
|
18
|
+
border-radius: var(--border-radius-md);
|
|
19
|
+
box-shadow: var(--shadow-sm);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.root:is(:global(.dark) *) {
|
|
23
|
+
background: var(--canvas-800);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.root[data-state="open"] {
|
|
27
|
+
animation: slideInFromBottom 150ms cubic-bezier(0.16, 1, 0.3, 1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.root[data-state="closed"] {
|
|
31
|
+
animation: hide 100ms ease-in;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.root[data-swipe="move"] {
|
|
35
|
+
transform: translateX(var(--radix-toast-swipe-move-x));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.root[data-swipe="cancel"] {
|
|
39
|
+
transform: translateX(0);
|
|
40
|
+
transition: transform 200ms ease-out;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.root.top-right[data-swipe="end"],
|
|
44
|
+
.root.bottom-right[data-swipe="end"] {
|
|
45
|
+
animation: swipeOutToRight 100ms ease-out;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.root.top-left[data-swipe="end"],
|
|
49
|
+
.root.bottom-left[data-swipe="end"] {
|
|
50
|
+
animation: swipeOutToLeft 100ms ease-out;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.header {
|
|
54
|
+
display: flex;
|
|
55
|
+
padding: 0 16px 0 12px;
|
|
56
|
+
align-items: start;
|
|
57
|
+
gap: var(--gap-2);
|
|
58
|
+
justify-content: space-between;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.close {
|
|
62
|
+
display: flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
justify-content: center;
|
|
65
|
+
padding: 0;
|
|
66
|
+
min-width: 24px;
|
|
67
|
+
min-height: 24px;
|
|
68
|
+
width: 24px;
|
|
69
|
+
height: 24px;
|
|
70
|
+
border-radius: 100%;
|
|
71
|
+
margin-left: auto;
|
|
72
|
+
margin-top: -2px;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.close svg {
|
|
76
|
+
fill: white;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
.title {
|
|
81
|
+
display: flex;
|
|
82
|
+
padding: 0 12px 0 8px;
|
|
83
|
+
align-items: start;
|
|
84
|
+
gap: var(--gap-2);
|
|
85
|
+
margin-bottom: 5px;
|
|
86
|
+
font-weight: 500;
|
|
87
|
+
font-size: 15px;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.description {
|
|
91
|
+
margin: 0;
|
|
92
|
+
padding: 0 8px 0 12px;
|
|
93
|
+
font-size: var(--font-size-sm);
|
|
94
|
+
line-height: 1.3;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.action {
|
|
98
|
+
display: flex;
|
|
99
|
+
justify-content: end;
|
|
100
|
+
padding: 0 12px 0 12px;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* Positions are relative to the toast viewport which is set
|
|
104
|
+
globally in components/toast.css */
|
|
105
|
+
|
|
106
|
+
.top-left {
|
|
107
|
+
top: 88px;
|
|
108
|
+
right: 16px;
|
|
109
|
+
left: 16px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.top-right {
|
|
113
|
+
top: 88px;
|
|
114
|
+
right: 16px;
|
|
115
|
+
left: 16px;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.bottom-left {
|
|
119
|
+
bottom: 16px;
|
|
120
|
+
right: 16px;
|
|
121
|
+
left: 16px;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.bottom-right {
|
|
125
|
+
bottom: 16px;
|
|
126
|
+
right: 16px;
|
|
127
|
+
left: 16px;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@media (min-width: 768px) {
|
|
131
|
+
|
|
132
|
+
.root.top-right[data-state="open"],
|
|
133
|
+
.root.bottom-right[data-state="open"] {
|
|
134
|
+
animation: slideInFromRight 150ms cubic-bezier(0.16, 1, 0.3, 1);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.root.top-left[data-state="open"],
|
|
138
|
+
.root.bottom-left[data-state="open"] {
|
|
139
|
+
animation: slideInFromLeft 150ms cubic-bezier(0.16, 1, 0.3, 1);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.bottom-right {
|
|
143
|
+
bottom: 16px;
|
|
144
|
+
right: 16px;
|
|
145
|
+
left: auto;
|
|
146
|
+
width: 100%;
|
|
147
|
+
max-width: 390px;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.bottom-left {
|
|
151
|
+
bottom: 16px;
|
|
152
|
+
left: 16px;
|
|
153
|
+
right: auto;
|
|
154
|
+
width: 100%;
|
|
155
|
+
max-width: 390px;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.top-left {
|
|
159
|
+
top: 88px;
|
|
160
|
+
left: 16px;
|
|
161
|
+
right: auto;
|
|
162
|
+
bottom: auto;
|
|
163
|
+
width: 100%;
|
|
164
|
+
max-width: 390px;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.top-right {
|
|
168
|
+
top: 88px;
|
|
169
|
+
right: 16px;
|
|
170
|
+
bottom: auto;
|
|
171
|
+
left: auto;
|
|
172
|
+
width: 100%;
|
|
173
|
+
max-width: 390px;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
@keyframes slideInFromRight {
|
|
179
|
+
from {
|
|
180
|
+
transform: translateX(calc(100% + var(--viewport-padding)));
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
to {
|
|
184
|
+
transform: translateX(0);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
@keyframes slideInFromLeft {
|
|
189
|
+
from {
|
|
190
|
+
transform: translateX(calc(-100% - var(--viewport-padding)));
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
to {
|
|
194
|
+
transform: translateX(0);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
@keyframes slideInFromBottom {
|
|
199
|
+
from {
|
|
200
|
+
transform: translateY(calc(100% + var(--viewport-padding)));
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
to {
|
|
204
|
+
transform: translateY(0);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
@keyframes swipeOutToRight {
|
|
209
|
+
from {
|
|
210
|
+
transform: translateX(var(--radix-toast-swipe-end-x));
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
to {
|
|
214
|
+
transform: translateX(calc(100% + var(--viewport-padding)));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
@keyframes swipeOutToLeft {
|
|
219
|
+
from {
|
|
220
|
+
transform: translateX(var(--radix-toast-swipe-end-x));
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
to {
|
|
224
|
+
transform: translateX(calc(-100% - var(--viewport-padding)));
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
@keyframes hide {
|
|
229
|
+
from {
|
|
230
|
+
opacity: 1;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
to {
|
|
234
|
+
opacity: 0;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2
|
+
|
|
3
|
+
import type { Meta } from '@storybook/react-vite'
|
|
4
|
+
import React from 'react'
|
|
5
|
+
|
|
6
|
+
import { Button } from '../button/button.js'
|
|
7
|
+
|
|
8
|
+
import { Toast as ToastComponent } from './toast.js'
|
|
9
|
+
|
|
10
|
+
export const Toast = (): React.JSX.Element => {
|
|
11
|
+
const [toast, setToast] = React.useState(false)
|
|
12
|
+
|
|
13
|
+
const handleOpenToastClick = (): void => {
|
|
14
|
+
setToast(!toast)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div className="mb-6 max-w-[600px]">
|
|
19
|
+
<Button onClick={handleOpenToastClick}>Open Toast</Button>
|
|
20
|
+
<ToastComponent
|
|
21
|
+
title="Note"
|
|
22
|
+
iconType="success"
|
|
23
|
+
intent="success"
|
|
24
|
+
position="bottom-right"
|
|
25
|
+
message="This is a test Toast modal that should appear when the button is clicked."
|
|
26
|
+
open={toast}
|
|
27
|
+
onOpenChange={setToast}
|
|
28
|
+
/>
|
|
29
|
+
</div>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const meta: Meta<typeof Toast> = {
|
|
34
|
+
/* 👇 The title prop is optional.
|
|
35
|
+
* See https://storybook.js.org/docs/react/configure/overview#configure-story-loading
|
|
36
|
+
* to learn how to generate automatic titles
|
|
37
|
+
*/
|
|
38
|
+
title: 'Components/Toast',
|
|
39
|
+
component: ToastComponent,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default meta
|