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

Typography Panel: Update typography controls for display in ToolsPanel #35451

Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,13 @@
max-width: 60px;
}
}

.components-tools-panel {
.block-editor-line-height-control {
margin-bottom: 0;

input {
max-width: 100%;
}
}
}
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
### New Feature

- Add an experimental `Navigator` components ([#34904](https://github.com/WordPress/gutenberg/pull/34904)) as a replacement for the previous `Navigation` related components.
- Added `showResetButton` prop to `FontSizePicker` component allowing optional display of the reset button ([35451](https://github.com/WordPress/gutenberg/pull/35451)).

### Bug Fix

Expand Down
9 changes: 9 additions & 0 deletions packages/components/src/font-size-picker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ If onChange is called without any parameter, it should reset the value, attendin
- Type: `function`
- Required: Yes

### showResetButton

If `true`, a reset button will be displayed alongside the predefined and custom
font size fields.

- Type: `Boolean`
- Required: no
- Default: `true`

### value

The current font size value.
Expand Down
25 changes: 14 additions & 11 deletions packages/components/src/font-size-picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function FontSizePicker(
onChange,
value,
withSlider = false,
showResetButton = true,
},
ref
) {
Expand Down Expand Up @@ -143,17 +144,19 @@ function FontSizePicker(
units={ hasUnits ? units : false }
/>
) }
<Button
className="components-color-palette__clear"
disabled={ value === undefined }
onClick={ () => {
onChange( undefined );
} }
isSmall
variant="secondary"
>
{ __( 'Reset' ) }
</Button>
{ showResetButton && (
<Button
className="components-color-palette__clear"
disabled={ value === undefined }
onClick={ () => {
onChange( undefined );
} }
isSmall
variant="secondary"
>
{ __( 'Reset' ) }
</Button>
) }
</div>
{ withSlider && (
<RangeControl
Expand Down
13 changes: 13 additions & 0 deletions packages/components/src/font-size-picker/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,30 @@
align-items: center;
margin-bottom: $grid-unit-30;

// Leave the spacing to the ToolsPanel grid layout.
.components-tools-panel & {
margin-bottom: 0;
}

.components-unit-control-wrapper {
margin-right: $grid-unit-10;

// Remove margin when reset button has been omitted.
&:last-child {
margin-right: 0;
}

.components-input-control__label {
font-weight: 300;
padding-bottom: 0 !important;
margin-bottom: $grid-unit-10 !important;
line-height: 1.4; // Make label line-height consistent between inputs.
}
}

.components-custom-select-control__button {
min-width: 120px;
width: 100%; // Allow the button to stretch when reset button is omitted.
}

// Apply the same height as the isSmall Reset button.
Expand Down Expand Up @@ -46,6 +58,7 @@

// Allow the font-size picker dropdown to grow in width.
.components-font-size-picker__select {
flex: 1;
margin-right: $grid-unit-10;
}

Expand Down