Skip to content

Commit

Permalink
FontSizePicker: Add help prop for additional guidance
Browse files Browse the repository at this point in the history
  • Loading branch information
SainathPoojary committed Jan 10, 2025
1 parent 51e0697 commit 7becc77
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/components/src/font-size-picker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const UnforwardedFontSizePicker = (
withSlider = false,
withReset = true,
label = 'Size',
help,
} = props;

const units = useCustomUnits( {
Expand Down Expand Up @@ -132,8 +133,19 @@ const UnforwardedFontSizePicker = (
size,
} );

let helpLabel;
if ( help ) {
if ( typeof help === 'function' ) {
if ( value !== undefined ) {
helpLabel = help( value );
}
} else {
helpLabel = help;
}
}

return (
<BaseControl>
<BaseControl help={ helpLabel }>
<Container ref={ ref } className="components-font-size-picker">
<VisuallyHidden as="legend">
{ __( 'Font size' ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const meta: Meta< typeof FontSizePicker > = {
component: FontSizePicker,
argTypes: {
value: { control: false },
help: { control: 'text' },
},
parameters: {
actions: { argTypesRegex: '^on.*' },
Expand Down

0 comments on commit 7becc77

Please sign in to comment.