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

Components: FontSizePicker: Adjust Select Button sizing #19479

Merged
merged 3 commits into from
Jan 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Components: FontSizePicker: Adjust Select Button sizing
This update enhances `CustomSelectControl` to accept props to modify it's
internal `Button` component (`Object`). Since `FontSizePicker` uses
`CustomSelectControl`, this update allows us to specify the `isSmall`
property for the `Button`. By doing so, it fixes the alignment of the Select
with the other form control elements.
  • Loading branch information
Jon Q authored and youknowriad committed Jan 29, 2020
commit 6a30654c92661e45091a2018ed5d028d0d012a68
6 changes: 6 additions & 0 deletions packages/components/src/custom-select-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ Function called with the control's internal state changes. The `selectedItem` pr
- Type: `Function`
- Required: No

#### selectButtonProps
Copy link
Member

Choose a reason for hiding this comment

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

I think this could just be called isSmall directly.


Props to pass to the internally rendered `Button` component.
- Type: `Object`
- Required: No

#### value

Can be used to externally control the value of the control, like in the `MyControlledCustomSelectControl` example above.
Expand Down
5 changes: 4 additions & 1 deletion packages/components/src/custom-select-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default function CustomSelectControl( {
label,
options: items,
onChange: onSelectedItemChange,
selectButtonProps = {},
value: _selectedItem,
} ) {
const {
Expand All @@ -73,6 +74,7 @@ export default function CustomSelectControl( {
selectedItem: _selectedItem,
stateReducer,
} );

const menuProps = getMenuProps( {
className: 'components-custom-select-control__menu',
} );
Expand All @@ -99,10 +101,11 @@ export default function CustomSelectControl( {
</label>
<Button
{ ...getToggleButtonProps( {
...selectButtonProps,
// This is needed because some speech recognition software don't support `aria-labelledby`.
'aria-label': label,
'aria-labelledby': undefined,
className: 'components-custom-select-control__button',
className: classnames( 'components-custom-select-control__button', selectButtonProps.className ),
} ) }
>
{ itemToString( selectedItem ) }
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/font-size-picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export default function FontSizePicker( {
<div className="components-font-size-picker__controls">
{ fontSizes.length > 0 && (
<CustomSelectControl
selectButtonProps={ { isSmall: true } }
className={ 'components-font-size-picker__select' }
label={ __( 'Preset Size' ) }
options={ options }
Expand Down