diff --git a/.storybook/preview.js b/.storybook/preview.js index 4305b6bebe269..fef17237e88a9 100644 --- a/.storybook/preview.js +++ b/.storybook/preview.js @@ -10,4 +10,9 @@ export const parameters = { disable: true, expanded: true, }, + docs: { + source: { + excludeDecorators: true, + }, + }, }; diff --git a/change/@fluentui-react-button-2b550638-96d1-40ea-9b3f-94bd0ecc1d89.json b/change/@fluentui-react-button-2b550638-96d1-40ea-9b3f-94bd0ecc1d89.json new file mode 100644 index 0000000000000..f55f555937b04 --- /dev/null +++ b/change/@fluentui-react-button-2b550638-96d1-40ea-9b3f-94bd0ecc1d89.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "Button docs", + "packageName": "@fluentui/react-button", + "email": "peter@draxler.ml", + "dependentChangeType": "none" +} diff --git a/packages/react-button/.storybook/preview.js b/packages/react-button/.storybook/preview.js index b52409294c330..75f5ad3840b32 100644 --- a/packages/react-button/.storybook/preview.js +++ b/packages/react-button/.storybook/preview.js @@ -1,3 +1,4 @@ import * as rootPreview from '../../../.storybook/preview'; export const decorators = [...rootPreview.decorators]; +export const parameters = { ...rootPreview.parameters }; diff --git a/packages/react-button/src/Button.stories.tsx b/packages/react-button/src/Button.stories.tsx deleted file mode 100644 index d1c6754cf9e7d..0000000000000 --- a/packages/react-button/src/Button.stories.tsx +++ /dev/null @@ -1,118 +0,0 @@ -import * as React from 'react'; -import { Button, ButtonProps } from './Button'; -import { Playground } from './Playground.stories'; -import { PlaygroundProps } from './Playground.types.stories'; -import { buttonBaseProps } from './buttonBaseProps.stories'; - -// TODO: this is here while waiting for react-icons to merge -const SVGIcon = () => ( - - - - - -); - -export const Default = () => ; - -// -// Anatomy & Layout -// - -export const TextOnly = () => ; -export const TextOnlyLong = () => ; - -export const IconWithText = () => ( - <> - - - -); - -export const IconOnly = () => - - - - - -); - -export const Primary = () => ; - -// -// States -// -export const Disabled = () => ( - <> - - - -); - -const buttonProps: PlaygroundProps['sections'] = [ - { sectionName: 'Button props', propList: buttonBaseProps }, -]; - -export const ButtonPlayground = () => ( - - ; + +export const Emphasis = () => ( + <> + + + + + + +); +Emphasis.parameters = { + docs: { + description: { + story: + '- `primary` button is used for the most important action on the page or in a view\n' + + '- `default` button is used for subordinate actions\n' + + '- `outline` has no background styling and is emphasized through the styling of its content and borders\n' + + '- `transparent` has no background or border styling and is just emphasized through its content styling\n' + + '- `subtle` button blends into its background and becomes less emphasized\n', + }, + }, +}; + +export const ButtonWithIcon = () => ( + <> + + + + + + + + + + + +); +BlockButton.parameters = { + docs: { + description: { + story: 'A button can fill the width of its container.', + }, + }, +}; + +export const DisabledButton = () => { + const groupStyles: React.CSSProperties = { display: 'flex', flexWrap: 'wrap', gap: '0.5em' }; + + return ( + <> +
+ + + +
+
+ + + +
+ + ); +}; +DisabledButton.parameters = { + docs: { + description: { + story: `A button can be \`disabled\` or \`disabledFocusable\`. + \`disabledFocusable\` is used in scenarios where it is important to keep a consistent tab order + for screen reader and keyboard users. The primary example of this pattern is when + the disabled button is in a menu or a commandbar and is seldom used for standalone buttons.`, + }, + }, +}; + +export const ButtonWithLongText = () => ( + <> + + + +); +ButtonWithLongText.parameters = { + docs: { + description: { + story: 'Text truncates after it hits the max width theme token value.', + }, + }, +}; + +export default { + title: 'Components/Button', + component: Button, + parameters: { + docs: { + description: { + component: [descriptionMd, bestPracticesMd].join('\n'), + }, + }, + }, + decorators: [ + Story => ( +
+ +
+ ), + ], +} as Meta; diff --git a/packages/react-button/src/components/Button/Button.tsx b/packages/react-button/src/components/Button/Button.tsx index d71f9f2921ee3..157d95f9d99f5 100644 --- a/packages/react-button/src/components/Button/Button.tsx +++ b/packages/react-button/src/components/Button/Button.tsx @@ -5,8 +5,7 @@ import { renderButton } from './renderButton'; import { useButtonStyles } from './useButtonStyles'; /** - * Define a styled Button, using the `useButton` hook. - * {@docCategory Button} + * Buttons give people a way to trigger an action. */ export const Button: React.FunctionComponent> = React.forwardRef< HTMLElement, @@ -18,5 +17,4 @@ export const Button: React.FunctionComponent