diff --git a/src/components/Checkbox/Checkbox.styles.ts b/src/components/Checkbox/Checkbox.styles.ts index 13b77731..6ffb6bc2 100644 --- a/src/components/Checkbox/Checkbox.styles.ts +++ b/src/components/Checkbox/Checkbox.styles.ts @@ -19,6 +19,7 @@ export const defaultConfig = { flexDirection: 'column', alignItems: 'flex-start', gap: '$space-component-gap-xSmall', + w: 'max-content', minWidth: '$size-3xSmall', minHeight: '$size-3xSmall', color: '$color-content-primary', diff --git a/src/components/Dialog/AdditionalElementWrapper.tsx b/src/components/Dialog/AdditionalElementWrapper.tsx new file mode 100644 index 00000000..dfb03ec0 --- /dev/null +++ b/src/components/Dialog/AdditionalElementWrapper.tsx @@ -0,0 +1,38 @@ +import { FC, isValidElement, PropsWithChildren } from 'react'; + +import { checkIfChildrenIsCustomComponent } from './utils'; + +import { tet } from '@/tetrisly'; + +type AdditionalElementWrapperProps = PropsWithChildren; + +export const AdditionalElementWrapper: FC = ({ + children, +}) => { + const isCustomComponent = + isValidElement(children) && checkIfChildrenIsCustomComponent(children); + + return isCustomComponent ? ( + + {children} + + ) : ( + <> + + {children} + + + + ); +}; diff --git a/src/components/Dialog/AllComponents.tsx b/src/components/Dialog/AllComponents.tsx new file mode 100644 index 00000000..9946dc3d --- /dev/null +++ b/src/components/Dialog/AllComponents.tsx @@ -0,0 +1,10 @@ +import * as components from '../../index'; + +const allComponents = Array.from(Object.values(components)); +const allComponentsProps = await Promise.all( + allComponents.map( + (component) => import(`../${component}.props.ts/${component}Props`), + ), +); + +export { allComponents, allComponentsProps }; diff --git a/src/components/Dialog/Dialog.props.ts b/src/components/Dialog/Dialog.props.ts new file mode 100644 index 00000000..d26ddb0c --- /dev/null +++ b/src/components/Dialog/Dialog.props.ts @@ -0,0 +1,19 @@ +import { ReactNode } from 'react'; + +import { DialogConfig } from './Dialog.styles'; +import { DialogFooter, DialogIntent, DialogSize } from './types'; + +import type { Action } from '@/types'; + +export type DialogProps = { + actions?: Action[]; + children?: ReactNode; + content?: string; + custom?: DialogConfig; + docsPresentation?: boolean; + footer?: DialogFooter; + onCloseClick?: (e: React.MouseEvent) => void; + intent?: DialogIntent; + size?: DialogSize; + title?: string; +}; diff --git a/src/components/Dialog/Dialog.stories.tsx b/src/components/Dialog/Dialog.stories.tsx new file mode 100644 index 00000000..ec2a5ff7 --- /dev/null +++ b/src/components/Dialog/Dialog.stories.tsx @@ -0,0 +1,211 @@ +import { action } from '@storybook/addon-actions'; +import { Meta, StoryObj } from '@storybook/react'; + +import { Dialog } from './Dialog'; +import { customStyleForDocs } from './Dialog.styles'; +import { Button } from '../Button'; +import { Checkbox } from '../Checkbox'; +import { Dimmer } from '../Dimmer'; + +import { DialogDocs } from '@/docs-components/DialogDocs'; +import { TetDocs } from '@/docs-components/TetDocs'; +import { tet } from '@/tetrisly'; + +const meta = { + title: 'Dialog', + component: Dialog, + tags: ['autodocs'], + argTypes: { + docsPresentation: { + table: { + disable: true, + }, + }, + }, + args: { + title: 'Title', + actions: [ + { + label: 'Primary action', + onClick: action('onClick'), + }, + { + label: 'Secondary action', + onClick: action('onClick'), + }, + ], + onCloseClick: action('onCloseClick'), + }, + parameters: { + docs: { + description: { + component: + 'A temporary, focused window that overlays the main content. Often used to prompt user input or present important information that requires interaction, such as confirmation or error messages.', + }, + page: () => ( + + + + ), + }, + }, +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +export const Default: Story = { + args: { + title: 'title', + content: 'content', + onCloseClick: () => {}, + footer: 'steps', + actions: [{ label: 'first action' }, { label: 'second action' }], + size: 'small', + custom: customStyleForDocs, + }, +}; + +export const Decision: Story = { + render: () => ( + + + + + ), +}; + +export const Confirmation: Story = { + render: () => ( + + + + + ), +}; + +export const Steps: Story = { + render: () => ( + + + + + ), +}; + +export const Destructive: Story = { + render: () => ( + + + + + ), +}; + +export const NestedComponentInsideFooter: Story = { + args: { + title: 'title', + content: 'content', + onCloseClick: () => {}, + footer: 'decision', + actions: [{ label: 'first action' }, { label: 'second action' }], + size: 'medium', + custom: customStyleForDocs, + children: , + }, +}; + +export const NestedButtonInsideFooter: Story = { + args: { + title: 'title', + content: 'content', + onCloseClick: () => {}, + footer: 'decision', + actions: [{ label: 'first action' }, { label: 'second action' }], + size: 'medium', + custom: customStyleForDocs, + children: