Skip to content

Commit

Permalink
FontFamilyControl: Deprecate bottom margin (#64280)
Browse files Browse the repository at this point in the history
* FontFamilyControl: Deprecate bottom margin

* Add changelog

Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
  • Loading branch information
3 people authored Aug 6, 2024
1 parent a52b951 commit 8b5cdba
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/block-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Enhancements

- `FontFamilyControl`: Add `__nextHasNoMarginBottom` prop for opting into the new margin-free styles ([#64280](https://github.com/WordPress/gutenberg/pull/64280)).

## 13.4.0 (2024-07-24)

## 13.3.0 (2024-07-10)
Expand Down
8 changes: 8 additions & 0 deletions packages/block-editor/src/components/font-family/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const MyFontFamilyControl = () => {
onChange={ ( newFontFamily ) => {
setFontFamily( newFontFamily );
} }
__nextHasNoMarginBottom
/>
);
};
Expand Down Expand Up @@ -69,3 +70,10 @@ The current font family value.
- Default: ''

The rest of the props are passed down to the underlying `<SelectControl />` instance.

#### `__nextHasNoMarginBottom`

- **Type:** `boolean`
- **Default:** `false`

Start opting into the new margin-free styles that will become the default in a future version.
16 changes: 16 additions & 0 deletions packages/block-editor/src/components/font-family/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* WordPress dependencies
*/
import { SelectControl } from '@wordpress/components';
import deprecated from '@wordpress/deprecated';
import { __ } from '@wordpress/i18n';

/**
Expand All @@ -10,6 +11,8 @@ import { __ } from '@wordpress/i18n';
import { useSettings } from '../use-settings';

export default function FontFamilyControl( {
/** Start opting into the new margin-free styles that will become the default in a future version. */
__nextHasNoMarginBottom = false,
value = '',
onChange,
fontFamilies,
Expand All @@ -33,8 +36,21 @@ export default function FontFamilyControl( {
};
} ),
];

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

return (
<SelectControl
__nextHasNoMarginBottom={ __nextHasNoMarginBottom }
label={ __( 'Font' ) }
options={ options }
value={ value }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* WordPress dependencies
*/
import { useState } from '@wordpress/element';

/**
* Internal dependencies
*/
import FontFamilyControl from '..';

export default {
component: FontFamilyControl,
title: 'BlockEditor/FontFamilyControl',
};

export const Default = {
render: function Template( props ) {
const [ value, setValue ] = useState();
return (
<FontFamilyControl
onChange={ setValue }
value={ value }
{ ...props }
/>
);
},
args: {
fontFamilies: [
{
fontFace: [
{
fontFamily: 'Inter',
fontStretch: 'normal',
fontStyle: 'normal',
fontWeight: '200 900',
src: [
'file:./assets/fonts/inter/Inter-VariableFont_slnt,wght.ttf',
],
},
],
fontFamily: '"Inter", sans-serif',
name: 'Inter',
slug: 'inter',
},
{
fontFamily:
'-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif',
name: 'System Font',
slug: 'system-font',
},
],
__nextHasNoMarginBottom: true,
},
};

0 comments on commit 8b5cdba

Please sign in to comment.