-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22552 from joaonunomota/subtitle-of-prop
Blocks: Add support for `of` prop to `Subtitle`
- Loading branch information
Showing
9 changed files
with
249 additions
and
19 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
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,104 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import React from 'react'; | ||
import { Subtitle } from './Subtitle'; | ||
import * as DefaultButtonStories from '../examples/Button.stories'; | ||
import * as ButtonStoriesWithMetaSubtitleAsBoth from '../examples/ButtonWithMetaSubtitleAsBoth.stories'; | ||
import * as ButtonStoriesWithMetaSubtitleAsComponentSubtitle from '../examples/ButtonWithMetaSubtitleAsComponentSubtitle.stories'; | ||
import * as ButtonStoriesWithMetaSubtitleAsDocsSubtitle from '../examples/ButtonWithMetaSubtitleAsDocsSubtitle.stories'; | ||
|
||
const meta: Meta<typeof Subtitle> = { | ||
component: Subtitle, | ||
parameters: { | ||
controls: { | ||
include: [], | ||
hideNoControlsWarning: true, | ||
}, | ||
// workaround for https://github.com/storybookjs/storybook/issues/20505 | ||
docs: { source: { type: 'code' } }, | ||
attached: false, | ||
docsStyles: true, | ||
}, | ||
}; | ||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const OfCSFFileAsBoth: Story = { | ||
args: { | ||
of: ButtonStoriesWithMetaSubtitleAsBoth, | ||
}, | ||
parameters: { | ||
relativeCsfPaths: ['../examples/ButtonWithMetaSubtitleAsBoth.stories'], | ||
}, | ||
}; | ||
export const OfCSFFileAsComponentSubtitle: Story = { | ||
name: 'Of CSF File As parameters.componentSubtitle', | ||
args: { | ||
of: ButtonStoriesWithMetaSubtitleAsComponentSubtitle, | ||
}, | ||
parameters: { | ||
relativeCsfPaths: ['../examples/ButtonWithMetaSubtitleAsComponentSubtitle.stories'], | ||
}, | ||
}; | ||
export const OfCSFFileAsDocsSubtitle: Story = { | ||
name: 'Of CSF File As parameters.docs.subtitle', | ||
args: { | ||
of: ButtonStoriesWithMetaSubtitleAsDocsSubtitle, | ||
}, | ||
parameters: { | ||
relativeCsfPaths: ['../examples/ButtonWithMetaSubtitleAsDocsSubtitle.stories'], | ||
}, | ||
}; | ||
export const OfMetaAsBoth: Story = { | ||
args: { | ||
of: ButtonStoriesWithMetaSubtitleAsBoth.default, | ||
}, | ||
parameters: { | ||
relativeCsfPaths: ['../examples/ButtonWithMetaSubtitleAsBoth.stories'], | ||
}, | ||
}; | ||
export const OfMetaAsComponentSubtitle: Story = { | ||
name: 'Of Meta As parameters.componentSubtitle', | ||
args: { | ||
of: ButtonStoriesWithMetaSubtitleAsComponentSubtitle.default, | ||
}, | ||
parameters: { | ||
relativeCsfPaths: ['../examples/ButtonWithMetaSubtitleAsComponentSubtitle.stories'], | ||
}, | ||
}; | ||
export const OfMetaAsDocsSubtitle: Story = { | ||
name: 'Of Meta As parameters.docs.subtitle', | ||
args: { | ||
of: ButtonStoriesWithMetaSubtitleAsDocsSubtitle.default, | ||
}, | ||
parameters: { | ||
relativeCsfPaths: ['../examples/ButtonWithMetaSubtitleAsDocsSubtitle.stories'], | ||
}, | ||
}; | ||
export const DefaultAttached: Story = { | ||
parameters: { relativeCsfPaths: ['../examples/Button.stories'], attached: true }, | ||
}; | ||
export const OfUndefinedAttached: Story = { | ||
args: { | ||
// @ts-expect-error this is supposed to be undefined | ||
// eslint-disable-next-line import/namespace | ||
of: DefaultButtonStories.NotDefined, | ||
}, | ||
parameters: { | ||
chromatic: { disableSnapshot: true }, | ||
relativeCsfPaths: ['../examples/Button.stories'], | ||
attached: true, | ||
}, | ||
decorators: [(s) => (window?.navigator.userAgent.match(/StorybookTestRunner/) ? <div /> : s())], | ||
}; | ||
export const OfStringMetaAttached: Story = { | ||
name: 'Of "meta" Attached', | ||
args: { | ||
of: 'meta', | ||
}, | ||
parameters: { relativeCsfPaths: ['../examples/Button.stories'], attached: true }, | ||
}; | ||
export const Children: Story = { | ||
parameters: { relativeCsfPaths: ['../examples/Button.stories'], attached: true }, | ||
render: () => <Subtitle>This subtitle is a string passed as a children</Subtitle>, | ||
}; |
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
29 changes: 29 additions & 0 deletions
29
code/ui/blocks/src/examples/ButtonWithMetaSubtitleAsBoth.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,29 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { Button } from './Button'; | ||
|
||
const meta = { | ||
title: 'examples/Button with Meta Subtitle in Both', | ||
component: Button, | ||
argTypes: { | ||
backgroundColor: { control: 'color' }, | ||
}, | ||
parameters: { | ||
// Stop *this* story from being stacked in Chromatic | ||
theme: 'default', | ||
// this is to test the deprecated features of the Subtitle block | ||
componentSubtitle: 'This subtitle is set in parameters.componentSubtitle', | ||
docs: { | ||
subtitle: 'This subtitle is set in parameters.docs.subtitle', | ||
}, | ||
}, | ||
} satisfies Meta<typeof Button>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const WithMetaSubtitleAsBoth: Story = { | ||
args: { | ||
primary: true, | ||
label: 'Button', | ||
}, | ||
}; |
26 changes: 26 additions & 0 deletions
26
code/ui/blocks/src/examples/ButtonWithMetaSubtitleAsComponentSubtitle.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,26 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { Button } from './Button'; | ||
|
||
const meta = { | ||
title: 'examples/Button with Meta Subtitle in componentSubtitle', | ||
component: Button, | ||
argTypes: { | ||
backgroundColor: { control: 'color' }, | ||
}, | ||
parameters: { | ||
// Stop *this* story from being stacked in Chromatic | ||
theme: 'default', | ||
// this is to test the deprecated features of the Subtitle block | ||
componentSubtitle: 'This subtitle is set in parameters.componentSubtitle', | ||
}, | ||
} satisfies Meta<typeof Button>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const WithMetaSubtitleInComponentSubtitle: Story = { | ||
args: { | ||
primary: true, | ||
label: 'Button', | ||
}, | ||
}; |
27 changes: 27 additions & 0 deletions
27
code/ui/blocks/src/examples/ButtonWithMetaSubtitleAsDocsSubtitle.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,27 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { Button } from './Button'; | ||
|
||
const meta = { | ||
title: 'examples/Button with Meta Subtitle in docs.subtitle', | ||
component: Button, | ||
argTypes: { | ||
backgroundColor: { control: 'color' }, | ||
}, | ||
parameters: { | ||
// Stop *this* story from being stacked in Chromatic | ||
theme: 'default', | ||
docs: { | ||
subtitle: 'This subtitle is set in parameters.docs.subtitle', | ||
}, | ||
}, | ||
} satisfies Meta<typeof Button>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const WithMetaSubtitleInDocsSubtitle: Story = { | ||
args: { | ||
primary: true, | ||
label: 'Button', | ||
}, | ||
}; |
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