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

Button: Add opt-in prop for next 40px default size #50254

Merged
merged 3 commits into from
May 9, 2023
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
1 change: 1 addition & 0 deletions packages/base-styles/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ $grid-unit-80: 8 * $grid-unit; // 64px

$icon-size: 24px;
$button-size: 36px;
$button-size-next-default-40px: 40px; // transitionary variable for next default button size
$button-size-small: 24px;
$header-height: 60px;
$panel-header-height: $grid-unit-60;
Expand Down
14 changes: 6 additions & 8 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@

## Unreleased

### Enhancements

- Change the default color scheme to use the new WP Blueberry color. See PR description for instructions on how to restore the previous color scheme when using in a non-WordPress context ([#50193](https://github.com/WordPress/gutenberg/pull/50193)).
- `CheckboxControl`, `CustomGradientPicker`, `FormToggle`, : Refactor and correct the focus style for consistency ([#50127](https://github.com/WordPress/gutenberg/pull/50127)).
- `Button`, update spacing values in `has-text has-icon` buttons. ([#50277](https://github.com/WordPress/gutenberg/pull/50277)).
- `Button`, remove custom padding applied to `tertiary` variant. ([#50276](https://github.com/WordPress/gutenberg/pull/50276)).
- `Modal`: Correct padding for title less confirm variant. ([#50283](https://github.com/WordPress/gutenberg/pull/50283)).

### Breaking Changes

- `onDragStart` in `<Draggable>` is now a synchronous function to allow setting additional data for `event.dataTransfer` ([#49673](https://github.com/WordPress/gutenberg/pull/49673)).
Expand All @@ -34,7 +26,13 @@

- `FormTokenField`, `ComboboxControl`: Add `__next40pxDefaultSize` prop to opt into the new 40px default size, superseding the `__next36pxDefaultSize` prop ([#50261](https://github.com/WordPress/gutenberg/pull/50261)).
- `Modal`: Add css class to children container ([#50099](https://github.com/WordPress/gutenberg/pull/50099)).
- `Button`: Add `__next40pxDefaultSize` prop to opt into the new 40px default size ([#50254](https://github.com/WordPress/gutenberg/pull/50254)).
- `PaletteEdit`: Allow custom popover configuration ([#49975](https://github.com/WordPress/gutenberg/pull/49975)).
- Change the default color scheme to use the new WP Blueberry color. See PR description for instructions on how to restore the previous color scheme when using in a non-WordPress context ([#50193](https://github.com/WordPress/gutenberg/pull/50193)).
- `CheckboxControl`, `CustomGradientPicker`, `FormToggle`, : Refactor and correct the focus style for consistency ([#50127](https://github.com/WordPress/gutenberg/pull/50127)).
- `Button`, update spacing values in `has-text has-icon` buttons. ([#50277](https://github.com/WordPress/gutenberg/pull/50277)).
- `Button`, remove custom padding applied to `tertiary` variant. ([#50276](https://github.com/WordPress/gutenberg/pull/50276)).
- `Modal`: Correct padding for title less confirm variant. ([#50283](https://github.com/WordPress/gutenberg/pull/50283)).

## 23.9.0 (2023-04-26)

Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export function UnforwardedButton(
ref: ForwardedRef< any >
) {
const {
__next40pxDefaultSize,
isSmall,
isPressed,
isBusy,
Expand Down Expand Up @@ -115,6 +116,7 @@ export function UnforwardedButton(
children?.[ 0 ]?.props?.className !== 'components-tooltip' );

const classes = classnames( 'components-button', className, {
'is-next-40px-default-size': __next40pxDefaultSize,
'is-secondary': variant === 'secondary',
'is-primary': variant === 'primary',
'is-small': isSmall,
Expand Down
8 changes: 8 additions & 0 deletions packages/components/src/button/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
border-radius: $radius-block-ui;
color: $components-color-foreground;

&.is-next-40px-default-size {
height: $button-size-next-default-40px;
}

&[aria-expanded="true"],
&:hover {
color: $components-color-accent;
Expand Down Expand Up @@ -285,6 +289,10 @@
min-width: $button-size;
justify-content: center;

&.is-next-40px-default-size {
min-width: $button-size-next-default-40px;
}

.dashicon {
display: inline-block;
flex: 0 0 auto;
Expand Down
7 changes: 7 additions & 0 deletions packages/components/src/button/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ export type ButtonAsButtonProps = BaseButtonProps & _ButtonProps;
export type ButtonAsAnchorProps = BaseButtonProps & AnchorProps;

type BaseButtonProps = {
/**
* Start opting into the larger default height that will become the
* default size in a future version.
*
* @default false
*/
__next40pxDefaultSize?: boolean;
/**
* The button's children.
*/
Expand Down