-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs(web-react): Introduce new Stories for Button, Modal and Pill
- Loading branch information
Showing
18 changed files
with
514 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ const config: StorybookViteConfig = { | |
|
||
docs: { | ||
autodocs: true, | ||
defaultName: 'Overview', | ||
}, | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
packages/web-react/src/components/Button/Button.stories.ts
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
packages/web-react/src/components/Button/Button.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react'; | ||
import { Markdown } from '@storybook/blocks'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { Button } from './Button'; | ||
import { args, argTypes } from './stories/args'; | ||
import ReadMe from './README.md?raw'; | ||
|
||
const meta: Meta<typeof Button> = { | ||
title: 'Components/Button', | ||
component: Button, | ||
parameters: { | ||
docs: { | ||
page: () => <Markdown>{ReadMe}</Markdown>, | ||
}, | ||
}, | ||
argTypes: { | ||
...argTypes, | ||
type: { | ||
control: 'select', | ||
options: ['button', 'submit', 'reset'], | ||
}, | ||
}, | ||
args: { | ||
...args, | ||
type: 'button', | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof Button>; | ||
|
||
export const Playground: Story = { | ||
name: 'Button', | ||
}; |
36 changes: 18 additions & 18 deletions
36
packages/web-react/src/components/Button/ButtonLink.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
import { ComponentMeta } from '@storybook/react'; | ||
import argTypes from './demo/argTypes'; | ||
import ButtonLink from './ButtonLink'; | ||
import React from 'react'; | ||
import { Markdown } from '@storybook/blocks'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
export default { | ||
import { ButtonLink } from './ButtonLink'; | ||
import { args, argTypes } from './stories/args'; | ||
import ReadMe from './README.md?raw'; | ||
|
||
const meta: Meta<typeof ButtonLink> = { | ||
title: 'Components/ButtonLink', | ||
component: ButtonLink, | ||
parameters: { | ||
docs: { | ||
description: { | ||
component: 'ButtonLinks allow users to take actions.', | ||
}, | ||
}, | ||
}, | ||
argTypes: { | ||
...argTypes, | ||
href: { | ||
control: { | ||
type: 'text', | ||
}, | ||
defaultValue: '#', | ||
page: () => <Markdown>{ReadMe}</Markdown>, | ||
}, | ||
}, | ||
} as ComponentMeta<typeof ButtonLink>; | ||
argTypes, | ||
args, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof ButtonLink>; | ||
|
||
export { default as ButtonLink } from './demo/ButtonLink'; | ||
export const Playground: Story = { | ||
name: 'ButtonLink', | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React from 'react'; | ||
import { ActionColors, EmotionColors, Sizes } from '../../../constants'; | ||
import { Icon } from '../../Icon'; | ||
|
||
export const argTypes = { | ||
children: { | ||
control: 'text', | ||
description: | ||
'This is the place for the content of the button. In the real code you can pass in any JSX. ' + | ||
'In this demo you can set any text you want, or use one of the predefined texts: `<Icon />` ' + | ||
'(to see how it looks with an Icon) or `<Icon /> Text` (to see how it looks with an Icon ' + | ||
'and text). Please note the predefined texts in this demo are not customizable and have ' + | ||
'to be written exactly as shown.', | ||
mapping: { | ||
'<Icon />': <Icon name="profile" />, | ||
'<Icon /> Text': ( | ||
<> | ||
<Icon name="profile" UNSAFE_className="mr-400" /> Text | ||
</> | ||
), | ||
}, | ||
}, | ||
color: { | ||
control: 'select', | ||
options: [...Object.values(ActionColors), ...Object.values(EmotionColors)], | ||
table: { | ||
defaultValue: { summary: ActionColors.PRIMARY }, | ||
}, | ||
}, | ||
isBlock: { | ||
control: 'boolean', | ||
}, | ||
isDisabled: { | ||
control: 'boolean', | ||
}, | ||
isLoading: { | ||
control: 'boolean', | ||
}, | ||
isSquare: { | ||
control: 'boolean', | ||
}, | ||
size: { | ||
control: 'select', | ||
options: [...Object.values(Sizes)], | ||
}, | ||
}; | ||
|
||
export const args = { | ||
children: 'Click me', | ||
color: ActionColors.PRIMARY, | ||
isBlock: false, | ||
isDisabled: false, | ||
isLoading: false, | ||
isSquare: false, | ||
size: Sizes.MEDIUM, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,78 @@ | ||
import { ComponentMeta } from '@storybook/react'; | ||
import Modal from './Modal'; | ||
import React, { useState } from 'react'; | ||
import { Markdown } from '@storybook/blocks'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
export default { | ||
import { SpiritModalProps } from '../../types'; | ||
import { Button } from '../Button'; | ||
import ReadMe from './README.md?raw'; | ||
import { Modal, ModalHeader, ModalDialog, ModalBody, ModalFooter } from '.'; | ||
|
||
const meta: Meta<typeof Modal> = { | ||
title: 'Components/Modal', | ||
component: Modal, | ||
parameters: { | ||
docs: { | ||
description: { | ||
component: 'Add dialogs to your site for lightboxes, user notifications, or completely custom content.', | ||
page: () => <Markdown>{ReadMe}</Markdown>, | ||
}, | ||
}, | ||
argTypes: { | ||
id: { | ||
control: 'text', | ||
}, | ||
isOpen: { | ||
control: 'boolean', | ||
table: { | ||
defaultValue: { summary: false }, | ||
}, | ||
}, | ||
onClose: { | ||
control: 'function', | ||
}, | ||
}, | ||
args: { | ||
id: 'modal', | ||
isOpen: false, | ||
}, | ||
} as ComponentMeta<typeof Modal>; | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof Modal>; | ||
|
||
const ModalWithHooks = (args: SpiritModalProps) => { | ||
const [isModalOpen, setModalOpen] = useState(false); | ||
|
||
const toggleModal = () => setModalOpen(!isModalOpen); | ||
|
||
const handleClose = () => { | ||
setModalOpen(false); | ||
}; | ||
|
||
const { isOpen } = args; | ||
|
||
return ( | ||
<> | ||
<Button onClick={toggleModal} aria-expanded={isOpen || isModalOpen}> | ||
Open Modal | ||
</Button> | ||
<Modal {...args} isOpen={isOpen || isModalOpen} onClose={handleClose}> | ||
<ModalDialog preferredHeightOnMobile="500px"> | ||
<ModalHeader>Modal Header</ModalHeader> | ||
<ModalBody>Body</ModalBody> | ||
<ModalFooter> | ||
<Button color="primary" onClick={handleClose}> | ||
Confirm | ||
</Button> | ||
<Button color="tertiary" onClick={handleClose}> | ||
Cancel | ||
</Button> | ||
</ModalFooter> | ||
</ModalDialog> | ||
</Modal> | ||
</> | ||
); | ||
}; | ||
|
||
export { default as Modal } from './demo/Modal'; | ||
export const Playground: Story = { | ||
name: 'Modal', | ||
render: (args) => <ModalWithHooks {...args} />, | ||
}; |
Oops, something went wrong.