Skip to content

Commit

Permalink
prep build 08/07
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Aug 7, 2024
2 parents f3fd088 + c384bb6 commit a2d8733
Show file tree
Hide file tree
Showing 67 changed files with 838 additions and 378 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ module.exports = {
'SearchControl',
'TextControl',
'TextareaControl',
'ToggleControl',
'ToggleGroupControl',
'TreeSelect',
].map( ( componentName ) => ( {
Expand Down
3 changes: 3 additions & 0 deletions backport-changelog/6.7/7137.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/7137

* https://github.com/WordPress/gutenberg/pull/64192
2 changes: 1 addition & 1 deletion docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ An individual item within a list. ([Source](https://github.com/WordPress/gutenbe
- **Category:** text
- **Parent:** core/list
- **Allowed Blocks:** core/list
- **Supports:** color (background, gradients, link, text), interactivity (clientNavigation), spacing (margin, padding), splitting, typography (fontSize, lineHeight), ~~className~~
- **Supports:** anchor, color (background, gradients, link, text), interactivity (clientNavigation), spacing (margin, padding), splitting, typography (fontSize, lineHeight), ~~className~~
- **Attributes:** content, placeholder

## Login/out
Expand Down
2 changes: 1 addition & 1 deletion docs/reference-guides/data/data-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Namespace: `core`.

### Dynamically generated selectors
## Dynamically generated selectors

There are a number of user-friendly selectors that are wrappers of the more generic `getEntityRecord` and `getEntityRecords` that can be used to retrieve information for the various entities.

Expand Down
11 changes: 11 additions & 0 deletions lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -2383,6 +2383,17 @@ protected static function compute_style_properties( $styles, $settings = array()

// Processes background styles.
if ( 'background' === $value_path[0] && isset( $styles['background'] ) ) {
/*
* For user-uploaded images at the block level, assign defaults.
* Matches defaults applied in the editor and in block supports: background.php.
*/
if ( static::ROOT_BLOCK_SELECTOR !== $selector && ! empty( $styles['background']['backgroundImage']['id'] ) ) {
$styles['background']['backgroundSize'] = $styles['background']['backgroundSize'] ?? 'cover';
// If the background size is set to `contain` and no position is set, set the position to `center`.
if ( 'contain' === $styles['background']['backgroundSize'] && empty( $styles['background']['backgroundPosition'] ) ) {
$styles['background']['backgroundPosition'] = 'center';
}
}
$background_styles = gutenberg_style_engine_get_styles( array( 'background' => $styles['background'] ) );
$value = $background_styles['declarations'][ $css_property ] ?? $value;
}
Expand Down
9 changes: 9 additions & 0 deletions packages/block-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

## Unreleased

### Breaking Changes

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

### 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,
},
};
127 changes: 66 additions & 61 deletions packages/block-editor/src/components/global-styles/background-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,12 @@ function BackgroundImageControls( {
return;
}

const sizeValue = style?.background?.backgroundSize;
const positionValue = style?.background?.backgroundPosition;
const sizeValue =
style?.background?.backgroundSize ||
inheritedValue?.background?.backgroundSize;
const positionValue =
style?.background?.backgroundPosition ||
inheritedValue?.background?.backgroundPosition;

onChange(
setImmutably( style, [ 'background' ], {
Expand All @@ -334,6 +338,7 @@ function BackgroundImageControls( {
! positionValue && ( 'auto' === sizeValue || ! sizeValue )
? '50% 0'
: positionValue,
backgroundSize: sizeValue,
} )
);
};
Expand Down Expand Up @@ -448,6 +453,9 @@ function BackgroundSizeControls( {
const imageValue =
style?.background?.backgroundImage?.url ||
inheritedValue?.background?.backgroundImage?.url;
const isUploadedImage =
style?.background?.backgroundImage?.id ||
inheritedValue?.background?.backgroundImage?.id;
const positionValue =
style?.background?.backgroundPosition ||
inheritedValue?.background?.backgroundPosition;
Expand All @@ -456,19 +464,15 @@ function BackgroundSizeControls( {
inheritedValue?.background?.backgroundAttachment;

/*
* An `undefined` value is replaced with any supplied
* default control value for the toggle group control.
* An empty string is treated as `auto` - this allows a user
* to select "Size" and then enter a custom value, with an
* empty value being treated as `auto`.
* Set default values for uploaded images.
* The default values are passed by the consumer.
* Block-level controls may have different defaults to root-level controls.
* A falsy value is treated by default as `auto` (Tile).
*/
const currentValueForToggle =
( sizeValue !== undefined &&
sizeValue !== 'cover' &&
sizeValue !== 'contain' ) ||
sizeValue === ''
? 'auto'
: sizeValue || defaultValues?.backgroundSize;
! sizeValue && isUploadedImage
? defaultValues?.backgroundSize
: sizeValue || 'auto';

/*
* If the current value is `cover` and the repeat value is `undefined`, then
Expand Down Expand Up @@ -720,55 +724,56 @@ export default function BackgroundPanel( {
}
) }
>
{ shouldShowBackgroundImageControls ? (
<BackgroundControlsPanel
label={ title }
filename={ title }
url={ getResolvedThemeFilePath( url, themeFileURIs ) }
onToggle={ setIsDropDownOpen }
hasImageValue={ hasImageValue }
>
<VStack spacing={ 3 } className="single-column">
<BackgroundImageControls
onChange={ onChange }
style={ value }
inheritedValue={ inheritedValue }
themeFileURIs={ themeFileURIs }
displayInPanel
onRemoveImage={ () => {
setIsDropDownOpen( false );
resetBackground();
} }
/>
<BackgroundSizeControls
onChange={ onChange }
panelId={ panelId }
style={ value }
defaultValues={ defaultValues }
inheritedValue={ inheritedValue }
themeFileURIs={ themeFileURIs }
/>
</VStack>
</BackgroundControlsPanel>
) : (
<BackgroundImageControls
onChange={ onChange }
style={ value }
inheritedValue={ inheritedValue }
themeFileURIs={ themeFileURIs }
/>
) }
<ToolsPanelItem
hasValue={ () => hasImageValue }
label={ __( 'Image' ) }
onDeselect={ resetBackground }
isShownByDefault={ defaultControls.backgroundImage }
panelId={ panelId }
>
{ shouldShowBackgroundImageControls ? (
<BackgroundControlsPanel
label={ title }
filename={ title }
url={ getResolvedThemeFilePath(
url,
themeFileURIs
) }
onToggle={ setIsDropDownOpen }
hasImageValue={ hasImageValue }
>
<VStack spacing={ 3 } className="single-column">
<BackgroundImageControls
onChange={ onChange }
style={ value }
inheritedValue={ inheritedValue }
themeFileURIs={ themeFileURIs }
displayInPanel
onRemoveImage={ () => {
setIsDropDownOpen( false );
resetBackground();
} }
/>
<BackgroundSizeControls
onChange={ onChange }
panelId={ panelId }
style={ value }
defaultValues={ defaultValues }
inheritedValue={ inheritedValue }
themeFileURIs={ themeFileURIs }
/>
</VStack>
</BackgroundControlsPanel>
) : (
<BackgroundImageControls
onChange={ onChange }
style={ value }
inheritedValue={ inheritedValue }
themeFileURIs={ themeFileURIs }
/>
) }
</ToolsPanelItem>
</div>

{ /* Dummy ToolsPanel items, so we can control what's in the dropdown popover */ }
<ToolsPanelItem
hasValue={ () => hasImageValue }
label={ __( 'Image' ) }
onDeselect={ resetBackground }
isShownByDefault={ defaultControls.backgroundImage }
panelId={ panelId }
className="block-editor-global-styles-background-panel__hidden-tools-panel-item"
/>
</Wrapper>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default function ImageSettingsPanel( {
panelId={ panelId }
>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Expand on click' ) }
checked={ lightboxChecked }
onChange={ onChangeLightbox }
Expand Down
6 changes: 0 additions & 6 deletions packages/block-editor/src/components/global-styles/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,6 @@
}
}

.block-editor-global-styles-background-panel__hidden-tools-panel-item {
height: 0;
width: 0;
position: absolute;
}

// Push control panel into the background when the media modal is open.
.modal-open .block-editor-global-styles-background-panel__popover {
z-index: z-index(".block-editor-global-styles-background-panel__popover");
Expand Down
Loading

0 comments on commit a2d8733

Please sign in to comment.