From 4d333f343ed36282c026a1b0776bda2c33109b8a Mon Sep 17 00:00:00 2001 From: Lena Morita Date: Tue, 23 Apr 2024 21:02:16 +0900 Subject: [PATCH 1/2] FontSizerPicker: Improve docs for default units --- packages/components/src/font-size-picker/README.md | 1 + packages/components/src/font-size-picker/index.tsx | 6 ++++-- .../components/src/font-size-picker/stories/index.story.tsx | 1 - packages/components/src/font-size-picker/types.ts | 2 ++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/components/src/font-size-picker/README.md b/packages/components/src/font-size-picker/README.md index 3baf0527d9313..2a342d3de9114 100644 --- a/packages/components/src/font-size-picker/README.md +++ b/packages/components/src/font-size-picker/README.md @@ -92,6 +92,7 @@ Size of the control. Available units for custom font size selection. - Required: No +- Default: `[ 'px', 'em', 'rem' ]` ### `value`: `number | string` diff --git a/packages/components/src/font-size-picker/index.tsx b/packages/components/src/font-size-picker/index.tsx index 3c626cced1569..6a18660adfda1 100644 --- a/packages/components/src/font-size-picker/index.tsx +++ b/packages/components/src/font-size-picker/index.tsx @@ -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 > @@ -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; diff --git a/packages/components/src/font-size-picker/stories/index.story.tsx b/packages/components/src/font-size-picker/stories/index.story.tsx index 6ea47742ba783..eec8f5173d965 100644 --- a/packages/components/src/font-size-picker/stories/index.story.tsx +++ b/packages/components/src/font-size-picker/stories/index.story.tsx @@ -84,7 +84,6 @@ Default.args = { size: 26, }, ], - units: [ 'px', 'em', 'rem' ], value: 16, withSlider: false, }; diff --git a/packages/components/src/font-size-picker/types.ts b/packages/components/src/font-size-picker/types.ts index 2e90728808373..6b4ed4b7ee75a 100644 --- a/packages/components/src/font-size-picker/types.ts +++ b/packages/components/src/font-size-picker/types.ts @@ -28,6 +28,8 @@ export type FontSizePickerProps = { ) => void; /** * Available units for custom font size selection. + * + * @default `[ 'px', 'em', 'rem' ]` */ units?: string[]; /** From 4dd9f0c8438eff6d7dbb873f4767d6868079e66e Mon Sep 17 00:00:00 2001 From: Lena Morita Date: Tue, 23 Apr 2024 21:13:44 +0900 Subject: [PATCH 2/2] Add changelog --- packages/components/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index 0df9c6c9df842..88a8c1c35b0c1 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -10,6 +10,10 @@ - `SlotFill`: fixed missing `getServerSnapshot` parameter in slot map ([#60943](https://github.com/WordPress/gutenberg/pull/60943)). +### Internal + +- `FontSizerPicker`: Improve docs for default units ([#60996](https://github.com/WordPress/gutenberg/pull/60996)). + ## 27.4.0 (2024-04-19) ### Deprecation