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

FontSizePicker: Make control take up full width #44559

Merged
merged 2 commits into from
Sep 29, 2022
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
4 changes: 4 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Enhancements

- `FontSizePicker`: Updated to take up full width of its parent and have a 40px Reset button when `size` is `__unstable-large` ((44559)[https://github.com/WordPress/gutenberg/pull/44559]).

### Bug Fix

- `Popover`: fix limitShift logic by adding iframe offset correctly [#42950](https://github.com/WordPress/gutenberg/pull/42950)).
Expand Down
8 changes: 3 additions & 5 deletions packages/components/src/font-size-picker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,7 @@ const UnforwardedFontSizePicker = (
{ ! withSlider &&
! disableCustomFontSizes &&
showCustomValueControl && (
<Flex
justify="space-between"
className="components-font-size-picker__custom-size-control"
>
<Flex className="components-font-size-picker__custom-size-control">
<FlexItem isBlock>
<UnitControl
label={ __( 'Custom' ) }
Expand Down Expand Up @@ -303,14 +300,15 @@ const UnforwardedFontSizePicker = (
/>
</FlexItem>
{ withReset && (
<FlexItem isBlock>
<FlexItem>
<ResetButton
disabled={ value === undefined }
onClick={ () => {
onChange?.( undefined );
} }
isSmall
variant="secondary"
size={ size }
>
{ __( 'Reset' ) }
</ResetButton>
Expand Down
12 changes: 6 additions & 6 deletions packages/components/src/font-size-picker/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import BaseControl from '../base-control';
import Button from '../button';
import { space } from '../ui/utils/space';
import { COLORS } from '../utils';
import type { FontSizePickerProps } from './types';

export const Container = styled.fieldset`
border: 0;
Expand All @@ -26,19 +27,18 @@ export const HeaderHint = styled.span`
margin-left: ${ space( 1 ) };
`;

// 280px is the sidebar width.
// TODO: Remove this, @wordpress/components shouldn't care what a "sidebar" is.
export const Controls = styled.div< {
__nextHasNoMarginBottom: boolean;
} >`
max-width: calc( 280px - ${ space( 4 ) } * 2 );

${ ( props ) =>
! props.__nextHasNoMarginBottom && `margin-bottom: ${ space( 6 ) };` }
`;

export const ResetButton = styled( Button )`
export const ResetButton = styled( Button )< {
size: FontSizePickerProps[ 'size' ];
} >`
&&& {
height: 30px;
height: ${ ( props ) =>
props.size === '__unstable-large' ? '40px' : '30px' };
}
`;