Skip to content
Merged
Show file tree
Hide file tree
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
118 changes: 54 additions & 64 deletions packages/ui/src/button/stories/index.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,12 @@ export const Neutral: Story = {
},
};

/**
* Destructive buttons should be used for high-stakes, irreversible actions.
*/
export const Destructive: Story = {
export const NeutralOutline: Story = {
...Default,
args: {
...Default.args,
children: 'Permanently delete',
tone: 'destructive',
tone: 'neutral',
variant: 'outline',
},
};

Expand All @@ -95,64 +92,57 @@ export const AllTonesAndVariants: Story = {
<div></div>
<div style={ { textAlign: 'center' } }>Resting</div>
<div style={ { textAlign: 'center' } }>Disabled</div>
{ ( [ 'brand', 'neutral', 'destructive' ] as const ).map(
( tone ) => (
<Fragment key={ tone }>
{ (
[
'solid',
'outline',
'minimal',
'unstyled',
] as const
).map( ( variant ) => (
<Fragment key={ variant }>
<div
style={ {
paddingInlineEnd: '1rem',
display: 'flex',
alignItems: 'center',
} }
>
{ variant }, { tone }
</div>
<div
style={ {
padding: '0.5rem 1rem',
display: 'flex',
alignItems: 'center',
} }
>
<Button
{ ...args }
tone={ tone }
variant={ variant }
/>
</div>
<div
style={ {
padding: '0.5rem 1rem',
display: 'flex',
alignItems: 'center',
} }
>
<Button
{ ...args }
tone={ tone }
variant={ variant }
// Disabling because this lint rule was meant for the
// `@wordpress/components` Button, but is being applied here.
// TODO: rework the lint rule so that it checks the package
// where the Button comes from.
// eslint-disable-next-line no-restricted-syntax
disabled
/>
</div>
</Fragment>
) ) }
</Fragment>
)
) }
{ ( [ 'brand', 'neutral' ] as const ).map( ( tone ) => (
<Fragment key={ tone }>
{ (
[ 'solid', 'outline', 'minimal', 'unstyled' ] as const
).map( ( variant ) => (
<Fragment key={ variant }>
<div
style={ {
paddingInlineEnd: '1rem',
display: 'flex',
alignItems: 'center',
} }
>
{ variant }, { tone }
</div>
<div
style={ {
padding: '0.5rem 1rem',
display: 'flex',
alignItems: 'center',
} }
>
<Button
{ ...args }
tone={ tone }
variant={ variant }
/>
</div>
<div
style={ {
padding: '0.5rem 1rem',
display: 'flex',
alignItems: 'center',
} }
>
<Button
{ ...args }
tone={ tone }
variant={ variant }
// Disabling because this lint rule was meant for the
// `@wordpress/components` Button, but is being applied here.
// TODO: rework the lint rule so that it checks the package
// where the Button comes from.
// eslint-disable-next-line no-restricted-syntax
disabled
/>
</div>
</Fragment>
) ) }
</Fragment>
) ) }
</div>
),
};
Expand Down
33 changes: 0 additions & 33 deletions packages/ui/src/button/style.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -185,39 +185,6 @@
}
}

.is-destructive {
&.is-solid {
--wp-ui-button-background-color: var(--wpds-color-bg-interactive-error-strong);
--wp-ui-button-background-color-active: var(--wpds-color-bg-interactive-error-strong-active);
--wp-ui-button-background-color-disabled: var(--wpds-color-bg-interactive-error-strong-disabled);
--wp-ui-button-foreground-color: var(--wpds-color-fg-interactive-error-strong);
--wp-ui-button-foreground-color-active: var(--wpds-color-fg-interactive-error-strong-active);
--wp-ui-button-foreground-color-disabled: var(--wpds-color-fg-interactive-error-strong-disabled);
}

/* Outline and minimal buttons use the same foreground color */
&.is-outline,
&.is-minimal {
--wp-ui-button-foreground-color: var(--wpds-color-fg-interactive-error);
--wp-ui-button-foreground-color-active: var(--wpds-color-fg-interactive-error-active);
--wp-ui-button-foreground-color-disabled: var(--wpds-color-fg-interactive-error-disabled);
}

&.is-outline {
--wp-ui-button-background-color: var(--wpds-color-bg-interactive-error);
--wp-ui-button-background-color-active: var(--wpds-color-bg-interactive-error-active);
--wp-ui-button-background-color-disabled: var(--wpds-color-bg-interactive-error-disabled);
--wp-ui-button-border-color: var(--wpds-color-stroke-interactive-error);
--wp-ui-button-border-color-active: var(--wpds-color-stroke-interactive-error-active);
}

&.is-minimal {
--wp-ui-button-background-color: var(--wpds-color-bg-interactive-error-weak);
--wp-ui-button-background-color-active: var(--wpds-color-bg-interactive-error-weak-active);
--wp-ui-button-background-color-disabled: var(--wpds-color-bg-interactive-error-weak-disabled);
}
}

.is-unstyled {
border: none;
background: none;
Expand Down
6 changes: 3 additions & 3 deletions packages/ui/src/button/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ export interface ButtonProps
variant?: 'solid' | 'outline' | 'minimal' | 'unstyled';

/**
* The tone of the button:
* The tone of the button, describing a semantic color intent:
*
* - `'brand': for the most prominent actions, using the brand colors.
* - `'neutral'` for less prominent actions.
* - `'destructive'`: for high-stakes, irreversible actions.
*
* @default "brand"
*/
tone?: 'brand' | 'neutral' | 'destructive';
tone?: 'brand' | 'neutral';

/**
* The size of the button.
Expand Down
Loading