import * as Icons from '@transferwise/icons'; import { Meta, StoryObj } from '@storybook/react-webpack5'; import { fn } from 'storybook/test'; import CircularButton, { CircularButtonProps } from './CircularButton'; import Title from '../title'; import SentimentSurface from '../sentimentSurface'; /** * An IconButton with a text label below it. * * **Design guidance**: wise.design/components/circular-button */ export default { component: CircularButton, title: 'Actions/CircularButton', args: { children: 'Button text', icon: , onClick: fn(), priority: 'primary', type: 'default', disabled: false, }, argTypes: { icon: { options: Object.keys(Icons), mapping: Object.fromEntries( Object.entries(Icons).map(([name, Icon]) => [name, ]), ), }, className: { table: { category: 'Common' } }, onClick: { table: { category: 'Common', type: { summary: 'function' } } }, }, parameters: { docs: { toc: true }, }, } satisfies Meta; type Story = StoryObj; /** Explore all props via the controls panel. */ export const Playground: Story = {}; /** * Priorities set a visual hierarchy amongst the buttons displayed on the * screen to help more important buttons to take precedence over others.
* [Design documentation](https://wise.design/components/circular-button#priority) */ export const Priority: Story = { args: { type: 'default', }, argTypes: { type: { control: 'radio', options: ['default', 'negative'], }, priority: { table: { disable: true } }, disabled: { table: { disable: true } }, icon: { table: { disable: true } }, children: { table: { disable: true } }, onClick: { table: { disable: true } }, }, decorators: [ (Story) => (
), ], render: (args: CircularButtonProps) => ( <> } onClick={fn()}> Primary } onClick={fn()}> Secondary ), }; /** * There are two different types of button – default and negative – designed to emphasise the nature of the action.
* [Design documentation](https://wise.design/components/circular-button#types) */ export const Type: Story = { args: { priority: 'primary', }, argTypes: { priority: { control: 'radio', options: ['primary', 'secondary'], }, type: { table: { disable: true } }, disabled: { table: { disable: true } }, icon: { table: { disable: true } }, children: { table: { disable: true } }, onClick: { table: { disable: true } }, }, decorators: [ (Story) => (
), ], render: (args: CircularButtonProps) => ( <> } onClick={fn()}> Default } onClick={fn()} > Negative ), }; /** * Disabled buttons cannot be interacted with and are visually distinct. */ export const Disabled: Story = { args: { priority: 'primary', type: 'default', }, argTypes: { priority: { control: 'radio', options: ['primary', 'secondary'], }, type: { control: 'radio', options: ['default', 'negative'], }, disabled: { table: { disable: true } }, icon: { table: { disable: true } }, children: { table: { disable: true } }, onClick: { table: { disable: true } }, }, decorators: [ (Story) => (
), ], render: (args: CircularButtonProps) => ( }> Disabled ), }; /** * `CircularButton` is sentiment-aware and will automatically adjust its colours if wrapped inside * the SentimentSurface component.
* [Design documentation](https://wise.design/components/circular-button) */ export const SentimentAwareness: Story = { render: () => { const buttons = [ { priority: 'primary', type: 'default', icon: , label: 'primary', disabled: false, }, { priority: 'secondary', type: 'default', icon: , label: 'secondary', disabled: false, }, { priority: 'primary', type: 'negative', icon: , label: 'neg primary', disabled: false, }, { priority: 'secondary', type: 'negative', icon: , label: 'neg secondary', disabled: false, }, { priority: 'primary', type: 'default', icon: , label: 'disabled', disabled: true, }, ] as const; const sentiments = ['success', 'warning', 'negative', 'neutral', 'proposition'] as const; return (
{/* Rows for each sentiment with base and elevated emphasis */} {sentiments.flatMap((sentiment) => [
{sentiment} (base)
{buttons.map((button) => (
{button.label}
))}
,
{sentiment} (elevated)
{buttons.map((button) => (
{button.label}
))}
, ])}
); }, parameters: { docs: { canvas: { sourceState: 'hidden' }, }, }, };