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

FontSizerPicker: Improve docs for default units #60996

Merged
merged 3 commits into from
Apr 23, 2024
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
3 changes: 3 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@

- `DropZone`: Avoid a media query on mount [#60546](https://github.com/WordPress/gutenberg/pull/60546)).
- `ComboboxControl`: Simplify string normalization ([#60893](https://github.com/WordPress/gutenberg/pull/60893)).

### Internal

- `FontSizerPicker`: Improve docs for default units ([#60996](https://github.com/WordPress/gutenberg/pull/60996)).

## 27.4.0 (2024-04-19)

### Deprecation
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/font-size-picker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ Size of the control.
Available units for custom font size selection.

- Required: No
- Default: `[ 'px', 'em', 'rem' ]`

### `value`: `number | string`

Expand Down
6 changes: 4 additions & 2 deletions packages/components/src/font-size-picker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import FontSizePickerSelect from './font-size-picker-select';
import FontSizePickerToggleGroup from './font-size-picker-toggle-group';
import { T_SHIRT_NAMES } from './constants';

const DEFAULT_UNITS = [ 'px', 'em', 'rem' ];

const UnforwardedFontSizePicker = (
props: FontSizePickerProps,
ref: ForwardedRef< any >
Expand All @@ -47,14 +49,14 @@ const UnforwardedFontSizePicker = (
disableCustomFontSizes = false,
onChange,
size = 'default',
units: unitsProp,
units: unitsProp = DEFAULT_UNITS,
value,
withSlider = false,
withReset = true,
} = props;

const units = useCustomUnits( {
availableUnits: unitsProp || [ 'px', 'em', 'rem' ],
availableUnits: unitsProp,
} );

const shouldUseSelectControl = fontSizes.length > 5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ Default.args = {
size: 26,
},
],
units: [ 'px', 'em', 'rem' ],
Copy link
Member Author

Choose a reason for hiding this comment

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

Removing from the story args to make it clearer what the default is.

value: 16,
withSlider: false,
};
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/font-size-picker/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export type FontSizePickerProps = {
) => void;
/**
* Available units for custom font size selection.
*
* @default `[ 'px', 'em', 'rem' ]`
*/
units?: string[];
/**
Expand Down
Loading