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

Notice: Remove knobs in stories #46956

Merged
merged 1 commit into from
Jan 10, 2023
Merged
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
88 changes: 30 additions & 58 deletions packages/components/src/notice/stories/index.js
Original file line number Diff line number Diff line change
@@ -1,74 +1,46 @@
/**
* External dependencies
*/
import { boolean, select, text } from '@storybook/addon-knobs';

/**
* Internal dependencies
*/
import Notice from '../';

// TODO: Add a story involving NoticeList to help people understand
// the difference between onDismiss/onRemove.
Comment on lines +6 to +7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar situation to Snackbar and SnackbarList. In those situations, should we treat these components as part of the same family? In that case, which component is the "main" component?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'd need to evaluate each case based on whether the Foo component can be used independently of the FooList or FooGroup. If it can be used independently, that would be the main component.


export default {
title: 'Components/Notice',
component: Notice,
argTypes: {
isDismissible: { control: 'boolean' },
onDismiss: { control: { type: null } },
onRemove: { control: { type: null } },
politeness: {
control: 'radio',
options: [ 'assertive', 'polite' ],
},
spokenMessage: { control: 'text' },
status: {
control: 'radio',
options: [ 'warning', 'success', 'error', 'info' ],
},
},
parameters: {
knobs: { disable: false },
controls: { expanded: true },
docs: { source: { state: 'open' } },
},
};

export const _default = () => {
const status = select(
'Status',
{
Warning: 'warning',
Success: 'success',
Error: 'error',
Info: 'info',
},
'info'
);
const isDismissible = boolean( 'Is Dismissible', true );

return (
<Notice status={ status } isDismissible={ isDismissible }>
<p>This is a notice.</p>
</Notice>
);
const Template = ( props ) => {
return <Notice { ...props } />;
};

export const withCustomSpokenMessage = () => {
const status = select(
'Status',
{
Warning: 'warning',
Success: 'success',
Error: 'error',
Info: 'info',
},
'info'
);
const isDismissible = boolean( 'Is Dismissible', true );
const politeness = select(
'Politeness',
{
Assertive: 'assertive',
Polite: 'polite',
},
'assertive'
);
const spokenMessage = text(
'Spoken Message',
'This is a notice with a custom spoken message'
);
export const Default = Template.bind( {} );
Default.args = {
children: 'This is a notice.',
};

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