Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
c37a00b
remove from exclude list
chad1008 Jan 10, 2023
ee8bbb0
rename js files to js(x), add types.ts
chad1008 Jan 10, 2023
4456a8b
add main component prop types
chad1008 Jan 10, 2023
b99fc35
update `children` to handle `__unsafeHTML` and JSX elements
chad1008 Jan 16, 2023
f9e98d0
fix Button import
chad1008 Jan 11, 2023
75e3b3a
add typing to `useSpokenMessage` and `getDefaultPoliteness`
chad1008 Jan 11, 2023
a49fb49
type the `event` param of `onDismissNotice`
chad1008 Jan 11, 2023
8ab0011
add typing to action mapping arg
chad1008 Jan 11, 2023
bf8f7be
add `secondary` and `link` action variants
chad1008 Jan 11, 2023
ba475ec
add typing to `NoticeList`
chad1008 Jan 12, 2023
1a14810
migrate stories to TypeScript
chad1008 Jan 16, 2023
4a91556
add JSDoc example
chad1008 Jan 17, 2023
163d7b4
add story demonstrating actions
chad1008 Jan 17, 2023
fc7a49d
add story demonstrating JSX children
chad1008 Jan 17, 2023
12022b3
update `Snackbar` to import types from `Notice`
chad1008 Jan 17, 2023
b5fe417
rename test files to `*.tsx`
chad1008 Jan 17, 2023
de29435
unit tests: type `getNoticeWrapper`
chad1008 Jan 18, 2023
5fcc88e
add `children` prop values to unit tests
chad1008 Jan 18, 2023
bdeb877
update CHANGELOG
chad1008 Jan 18, 2023
10347cf
add JSDocs comments to `NoticeListProps`
chad1008 Jan 18, 2023
4380512
README: improve design `dos and donts` section readability
chad1008 Jan 19, 2023
52c2ddc
README: add horizontal rules between do/dont examples
chad1008 Jan 19, 2023
44d5b6d
README: update Props descriptions in README
chad1008 Jan 19, 2023
1437ff1
README: remove outdated screenshots and reference to `default` status
chad1008 Jan 19, 2023
c96c1aa
whitespace fixes
chad1008 Jan 19, 2023
2e1de69
remove `NoticeList` story comment
chad1008 Jan 19, 2023
b9963fd
unit test: update jest mocking
chad1008 Jan 23, 2023
e9751a9
unit tests: update snapshot
chad1008 Jan 23, 2023
508675d
restore JSDoc description for `useSpokenMessage`
chad1008 Jan 24, 2023
d85e2b1
remove `WordPressComponentProps` from typing, not really needed here
chad1008 Jan 24, 2023
1e6a732
add `NoticeList` n storybook as a subcomponent
chad1008 Jan 18, 2023
0385f09
add `NoticeList` JSDoc
chad1008 Jan 24, 2023
0c53a19
remove unneeded `argtypes`
chad1008 Jan 24, 2023
eec9afe
DRY `ComponentStory` type declarations
chad1008 Jan 24, 2023
c82704f
make `NoticeAction` types more specific
chad1008 Jan 24, 2023
8506b33
Update packages/components/src/notice/stories/index.tsx
chad1008 Jan 26, 2023
5ae653c
Update packages/components/src/notice/stories/index.tsx
chad1008 Jan 26, 2023
0342768
`onClick` events typed as `HTMLButtonElement`
chad1008 Jan 26, 2023
3a7dcf1
Update packages/components/src/notice/README.md
chad1008 Jan 27, 2023
7aa87c4
Update packages/components/src/notice/README.md
chad1008 Jan 27, 2023
ff2c6aa
Update packages/components/src/notice/README.md
chad1008 Jan 27, 2023
2cc232c
whitespace
chad1008 Jan 27, 2023
3d1a13b
Pick from new `Button` types
chad1008 Jan 27, 2023
70725f7
default for`NoticeProps[politeness]`
chad1008 Jan 27, 2023
08ef1ff
Revert "default for`NoticeProps[politeness]`"
chad1008 Jan 27, 2023
8bf4159
sync up docs
chad1008 Jan 27, 2023
d43fe8f
improved default for `politeness`
chad1008 Jan 27, 2023
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
Prev Previous commit
Next Next commit
DRY ComponentStory type declarations
  • Loading branch information
chad1008 committed Jan 30, 2023
commit eec9afebe70e2d431dac320c013ec6472cd79a52
15 changes: 6 additions & 9 deletions packages/components/src/notice/stories/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { useState } from '@wordpress/element';
import Notice from '..';
import Button from '../../button';
import NoticeList from '../list';
import type { NoticeProps, NoticeListProps } from '../types';
import type { NoticeListProps } from '../types';

const meta: ComponentMeta< typeof Notice > = {
title: 'Components/Notice',
Expand All @@ -27,26 +27,23 @@ const meta: ComponentMeta< typeof Notice > = {
};
export default meta;

const Template = ( props: NoticeProps ) => {
const Template: ComponentStory< typeof Notice > = ( props ) => {
return <Notice { ...props } />;
};

export const Default: ComponentStory< typeof Notice > = Template.bind( {} );
export const Default = Template.bind( {} );
Default.args = {
children: 'This is a notice.',
};

export const WithCustomSpokenMessage: ComponentStory< typeof Notice > =
Template.bind( {} );
export const WithCustomSpokenMessage = Template.bind( {} );
WithCustomSpokenMessage.args = {
...Default.args,
politeness: 'assertive',
spokenMessage: 'This is a notice with a custom spoken message',
};

export const WithJSXChildren: ComponentStory< typeof Notice > = Template.bind(
{}
);
export const WithJSXChildren = Template.bind( {} );
WithJSXChildren.args = {
...Default.args,
children: (
Expand All @@ -63,7 +60,7 @@ WithJSXChildren.args = {
),
};

export const WithActions: ComponentStory< typeof Notice > = Template.bind( {} );
export const WithActions = Template.bind( {} );
WithActions.args = {
...Default.args,
actions: [
Expand Down