Skip to content

Commit

Permalink
FontSizePicker: Hard deprecate bottom margin (#58702)
Browse files Browse the repository at this point in the history
* FontSizePicker: Hard deprecate bottom margin

* Remove usages in app

* Update changelog

* Update changelog for block-editor package

Co-authored-by: mirka <[email protected]>
Co-authored-by: ciampo <[email protected]>
  • Loading branch information
3 people authored Feb 6, 2024
1 parent 7705c03 commit 2078ac4
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 157 deletions.
2 changes: 2 additions & 0 deletions packages/block-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- `FontSizePicker`: Remove deprecated `__nextHasNoMarginBottom` prop and promote to default behavior ([#58702](https://github.com/WordPress/gutenberg/pull/58702)).

## 12.18.0 (2024-01-24)

- Deprecated `__experimentalRecursionProvider` and `__experimentalUseHasRecursion` in favor of their new stable counterparts `RecursionProvider` and `useHasRecursion`.
Expand Down
9 changes: 0 additions & 9 deletions packages/block-editor/src/components/font-sizes/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const MyFontSizePicker = () => {

return (
<FontSizePicker
__nextHasNoMarginBottom
value={ fontSize }
fallbackFontSize={ fallbackFontSize }
onChange={ ( newFontSize ) => {
Expand Down Expand Up @@ -80,11 +79,3 @@ If `true`, the UI will contain a slider, instead of a numeric text input field.
- Type: `Boolean`
- Required: no
- Default: `false`

### __nextHasNoMarginBottom

Start opting into the new margin-free styles that will become the default in a future version, currently scheduled to be WordPress 6.4. (The prop can be safely removed once this happens.)

- Type: `Boolean`
- Required: no
- Default: `false`
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ export default function TypographyPanel( {
withReset={ false }
withSlider
size="__unstable-large"
__nextHasNoMarginBottom
/>
</ToolsPanelItem>
) }
Expand Down
1 change: 0 additions & 1 deletion packages/block-editor/src/hooks/font-size.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ export function FontSizeEdit( props ) {
withReset={ false }
withSlider
size="__unstable-large"
__nextHasNoMarginBottom
/>
);
}
Expand Down
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Breaking Changes

- `FontSizePicker`: Remove deprecated `__nextHasNoMarginBottom` prop and promote to default behavior ([#58702](https://github.com/WordPress/gutenberg/pull/58702)).
- `GradientPicker`: Remove deprecated `__nextHasNoMargin` prop and promote to default behavior ([#58701](https://github.com/WordPress/gutenberg/pull/58701)).
- `CustomGradientPicker`: Remove deprecated `__nextHasNoMargin` prop and promote to default behavior ([#58699](https://github.com/WordPress/gutenberg/pull/58699)).
- `AnglePickerControl`: Remove deprecated `__nextHasNoMarginBottom` prop and promote to default behavior ([#58700](https://github.com/WordPress/gutenberg/pull/58700)).
Expand Down
8 changes: 0 additions & 8 deletions packages/components/src/font-size-picker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const MyFontSizePicker = () => {

return (
<FontSizePicker
__nextHasNoMarginBottom
fontSizes={ fontSizes }
value={ fontSize }
fallbackFontSize={ fallbackFontSize }
Expand Down Expand Up @@ -113,10 +112,3 @@ If `true`, a slider will be displayed alongside the input field when a custom fo

- Required: no
- Default: `false`

### `__nextHasNoMarginBottom`: `boolean`

Start opting into the new margin-free styles that will become the default in a future version, currently scheduled to be WordPress 6.4. (The prop can be safely removed once this happens.)

- Required: no
- Default: `false`
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,10 @@ import { T_SHIRT_ABBREVIATIONS, T_SHIRT_NAMES } from './constants';
import type { FontSizePickerToggleGroupProps } from './types';

const FontSizePickerToggleGroup = ( props: FontSizePickerToggleGroupProps ) => {
const {
fontSizes,
value,
__nextHasNoMarginBottom,
__next40pxDefaultSize,
size,
onChange,
} = props;
const { fontSizes, value, __next40pxDefaultSize, size, onChange } = props;
return (
<ToggleGroupControl
__nextHasNoMarginBottom={ __nextHasNoMarginBottom }
__nextHasNoMarginBottom
__next40pxDefaultSize={ __next40pxDefaultSize }
label={ __( 'Font size' ) }
hideLabelFromVision
Expand Down
24 changes: 3 additions & 21 deletions packages/components/src/font-size-picker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type { ForwardedRef } from 'react';
/**
* WordPress dependencies
*/
import deprecated from '@wordpress/deprecated';
import { __ } from '@wordpress/i18n';
import { settings } from '@wordpress/icons';
import { useState, useMemo, forwardRef } from '@wordpress/element';
Expand All @@ -31,7 +30,6 @@ import {
HeaderHint,
HeaderLabel,
HeaderToggle,
Controls,
} from './styles';
import { Spacer } from '../spacer';
import FontSizePickerSelect from './font-size-picker-select';
Expand All @@ -43,8 +41,6 @@ const UnforwardedFontSizePicker = (
ref: ForwardedRef< any >
) => {
const {
/** Start opting into the new margin-free styles that will become the default in a future version. */
__nextHasNoMarginBottom = false,
__next40pxDefaultSize = false,
fallbackFontSize,
fontSizes = [],
Expand All @@ -57,14 +53,6 @@ const UnforwardedFontSizePicker = (
withReset = true,
} = props;

if ( ! __nextHasNoMarginBottom ) {
deprecated( 'Bottom margin styles for wp.components.FontSizePicker', {
since: '6.1',
version: '6.4',
hint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version.',
} );
}

const units = useCustomUnits( {
availableUnits: unitsProp || [ 'px', 'em', 'rem' ],
} );
Expand Down Expand Up @@ -159,10 +147,7 @@ const UnforwardedFontSizePicker = (
) }
</Header>
</Spacer>
<Controls
className="components-font-size-picker__controls"
__nextHasNoMarginBottom={ __nextHasNoMarginBottom }
>
<div>
{ !! fontSizes.length &&
shouldUseSelectControl &&
! showCustomValueControl && (
Expand Down Expand Up @@ -196,7 +181,6 @@ const UnforwardedFontSizePicker = (
<FontSizePickerToggleGroup
fontSizes={ fontSizes }
value={ value }
__nextHasNoMarginBottom={ __nextHasNoMarginBottom }
__next40pxDefaultSize={ __next40pxDefaultSize }
size={ size }
onChange={ ( newValue ) => {
Expand Down Expand Up @@ -243,9 +227,7 @@ const UnforwardedFontSizePicker = (
<FlexItem isBlock>
<Spacer marginX={ 2 } marginBottom={ 0 }>
<RangeControl
__nextHasNoMarginBottom={
__nextHasNoMarginBottom
}
__nextHasNoMarginBottom
__next40pxDefaultSize={
__next40pxDefaultSize
}
Expand Down Expand Up @@ -297,7 +279,7 @@ const UnforwardedFontSizePicker = (
) }
</Flex>
) }
</Controls>
</div>
</Container>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ const TwoFontSizePickersWithState: StoryFn< typeof FontSizePicker > = ( {
export const Default: StoryFn< typeof FontSizePicker > =
FontSizePickerWithState.bind( {} );
Default.args = {
__nextHasNoMarginBottom: true,
disableCustomFontSizes: false,
fontSizes: [
{
Expand Down
7 changes: 0 additions & 7 deletions packages/components/src/font-size-picker/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,3 @@ export const HeaderLabel = styled( BaseControl.VisualLabel )`
export const HeaderHint = styled.span`
color: ${ COLORS.gray[ 700 ] };
`;

export const Controls = styled.div< {
__nextHasNoMarginBottom: boolean;
} >`
${ ( props ) =>
! props.__nextHasNoMarginBottom && `margin-bottom: ${ space( 6 ) };` }
`;
Loading

0 comments on commit 2078ac4

Please sign in to comment.