Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate content stories to tsx format #294

Merged
merged 8 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 0 additions & 47 deletions src/components/content/ContentArea/ContentArea.stories.mdx

This file was deleted.

55 changes: 55 additions & 0 deletions src/components/content/ContentArea/ContentArea.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {
Controls,
Description,
Primary,
Stories,
Subheading,
Title,
} from '@storybook/addon-docs'
import { Meta, StoryObj } from '@storybook/react'
import { Theme } from '../../../../.storybook/components'
import { ContentArea } from './ContentArea'

const meta = {
component: ContentArea,
args: {
children: 'Multiple blocks',
},
argTypes: {
children: {
options: ['Multiple blocks', 'One block'],
mapping: {
'Multiple blocks': (
<>
<div className="bg-neutral-200">Block A</div>
<div className="bg-neutral-100">Block B</div>
<div className="bg-neutral-200">Block C</div>
</>
),
'One block': <div className="bg-neutral-200">Block A</div>,
},
control: { type: 'select' },
},
},
parameters: {
docs: {
page: () => (
<>
<Title />
<Description />
<Primary />
<Subheading>Props</Subheading>
<Controls />
<Theme component="content" items={['area']} />
<Stories />
</>
),
},
},
} satisfies Meta<typeof ContentArea>

export default meta

type Story = StoryObj<typeof ContentArea>

export const Default: Story = {}
3 changes: 3 additions & 0 deletions src/components/content/ContentArea/ContentArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export type ContentAreaProps = ClassNameProps & {
children?: ReactNode
}

/**
* This component makes sure that there is enough space between multiple sections and actions on a page.
*/
export function ContentArea({ className, children }: ContentAreaProps) {
const { content } = useTheme()
return (
Expand Down
128 changes: 0 additions & 128 deletions src/components/content/ContentMessage/ContentMessage.stories.mdx

This file was deleted.

82 changes: 82 additions & 0 deletions src/components/content/ContentMessage/ContentMessage.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import IconInfo from '@aboutbits/react-material-icons/dist/IconInfo'
import IconWarning from '@aboutbits/react-material-icons/dist/IconWarning'
import IconError from '@aboutbits/react-material-icons/dist/IconError'
import {
Controls,
Description,
Primary,
Stories,
Subheading,
Title,
} from '@storybook/addon-docs'
import { Meta, StoryObj } from '@storybook/react'
import { Theme } from '../../../../.storybook/components'
import { Tone } from '../../types'
import { ContentMessage } from './ContentMessage'

const meta = {
component: ContentMessage,
args: {
title: 'No items',
text: 'No data available for this view',
icon: IconInfo,
},
argTypes: {
icon: {
options: ['None', 'Info', 'Warning', 'Error'],
mapping: {
None: undefined,
Info: IconInfo,
Warning: IconWarning,
Error: IconError,
},
control: { type: 'select' },
},
tone: {
options: Object.values(Tone),
control: { type: 'select' },
},
},
parameters: {
docs: {
page: () => (
<>
<Title />
<Description />
<Subheading>Subcomponents</Subheading>
It is composed of the following components, which can also be used
separately for custom purposes:
<ul>
<li>ContentMessageContainer</li>
<li>ContentMessageIcon</li>
<li>ContentMessageTitle</li>
<li>ContentMessageText</li>
</ul>
<Primary />
<Subheading>Props</Subheading>
<Controls />
<Theme component="content" items={['message']} />
<Stories />
</>
),
},
},
} satisfies Meta<typeof ContentMessage>

export default meta

type Story = StoryObj<typeof ContentMessage>

export const Default: Story = {}

export const Tones: Story = {
render: (args) => (
<div className="flex flex-row gap-2">
<ContentMessage {...args} tone={Tone.Primary} title="Primary" />
<ContentMessage {...args} tone={Tone.Informative} title="Informative" />
<ContentMessage {...args} tone={Tone.Success} title="Success" />
<ContentMessage {...args} tone={Tone.Warning} title="Warning" />
<ContentMessage {...args} tone={Tone.Critical} title="Critical" />
</div>
),
}
5 changes: 5 additions & 0 deletions src/components/content/ContentMessage/ContentMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ export type ContentMessageProps = ClassNameProps &
iconProps?: Partial<ContentMessageIconProps>
}

/**
*
* This component renders a message with icon in the given tone. It can
* be used to create a warning or error message inside a section.
*/
export function ContentMessage({
className,
icon,
Expand Down
Loading