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

FontFamilyControl: Deprecate bottom margin #64280

Merged
merged 2 commits into from
Aug 6, 2024
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/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,
},
};
Loading