Skip to content

Commit

Permalink
prep build 10/27
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Oct 27, 2024
2 parents 3fb0070 + bf84ac6 commit 4138488
Show file tree
Hide file tree
Showing 15 changed files with 86 additions and 33 deletions.
5 changes: 5 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

### Deprecations

- `BorderBoxControl`: Deprecate 36px default size ([#65752](https://github.com/WordPress/gutenberg/pull/65752)).
- `BorderControl`: Deprecate 36px default size ([#65755](https://github.com/WordPress/gutenberg/pull/65755)).

### Bug Fixes

- `ColorPalette`: prevent overflow of custom color button background ([#66152](https://github.com/WordPress/gutenberg/pull/66152)).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const MyBorderBoxControl = () => {

return (
<BorderBoxControl
__next40pxDefaultSize
colors={ colors }
label={ __( 'Borders' ) }
onChange={ onChange }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ const UnconnectedBorderBoxControl = (
*
* return (
* <BorderBoxControl
* __next40pxDefaultSize
* colors={ colors }
* label={ __( 'Borders' ) }
* onChange={ onChange }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import type { WordPressComponentProps } from '../../context';
import { useContextSystem } from '../../context';
import { useCx } from '../../utils/hooks/use-cx';
import { maybeWarnDeprecated36pxSize } from '../../utils/deprecated-36px-size';

import type { Border } from '../../border-control/types';
import type { Borders, BorderSide, BorderBoxControlProps } from '../types';
Expand All @@ -39,6 +40,12 @@ export function useBorderBoxControl(
...otherProps
} = useContextSystem( props, 'BorderBoxControl' );

maybeWarnDeprecated36pxSize( {
componentName: 'BorderBoxControl',
__next40pxDefaultSize,
size,
} );

const computedSize =
size === 'default' && __next40pxDefaultSize ? '__unstable-large' : size;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ Default.args = {
colors,
label: 'Borders',
enableStyle: true,
__next40pxDefaultSize: true,
};
1 change: 1 addition & 0 deletions packages/components/src/border-box-control/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const props = {
props.value = newValue;
} ),
value: undefined,
__next40pxDefaultSize: true,
};

const toggleLabelRegex = /Border color( and style)* picker/;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const MyBorderControl = () => {

return (
<BorderControl
__next40pxDefaultSize
colors={ colors }
label={ __( 'Border' ) }
onChange={ setBorder }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ const UnconnectedBorderControl = (
*
* return (
* <BorderControl
* __next40pxDefaultSize
* colors={ colors }
* label={ __( 'Border' ) }
* onChange={ onChange }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { parseQuantityAndUnitFromRawValue } from '../../unit-control/utils';
import type { WordPressComponentProps } from '../../context';
import { useContextSystem } from '../../context';
import { useCx } from '../../utils/hooks/use-cx';

import type { Border, BorderControlProps } from '../types';
import { maybeWarnDeprecated36pxSize } from '../../utils/deprecated-36px-size';

// If either width or color are defined, the border is considered valid
// and a border style can be set as well.
Expand Down Expand Up @@ -41,6 +41,12 @@ export function useBorderControl(
...otherProps
} = useContextSystem( props, 'BorderControl' );

maybeWarnDeprecated36pxSize( {
componentName: 'BorderControl',
__next40pxDefaultSize,
size,
} );

const computedSize =
size === 'default' && __next40pxDefaultSize ? '__unstable-large' : size;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export const Default = Template.bind( {} );
Default.args = {
colors,
label: 'Border',
__next40pxDefaultSize: true,
enableAlpha: true,
enableStyle: true,
shouldSanitizeBorder: true,
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/border-control/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function createProps( customProps ) {
props.value = newValue;
} ),
value: defaultBorder,
__next40pxDefaultSize: true,
...customProps,
};
return props;
Expand Down
24 changes: 24 additions & 0 deletions packages/components/src/utils/deprecated-36px-size.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* WordPress dependencies
*/
import deprecated from '@wordpress/deprecated';

export function maybeWarnDeprecated36pxSize( {
componentName,
__next40pxDefaultSize,
size,
}: {
componentName: string;
__next40pxDefaultSize: boolean | undefined;
size: string;
} ) {
if ( __next40pxDefaultSize || size !== 'default' ) {
return;
}

deprecated( `36px default size for wp.components.${ componentName }`, {
since: '6.8',
version: '7.1',
hint: 'Set the `__next40pxDefaultSize` prop to true to start opting into the new default size, which will become the default in a future version.',
} );
}
15 changes: 9 additions & 6 deletions packages/edit-site/src/components/style-book/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ export const STYLE_BOOK_CATEGORIES: StyleBookCategory[] = [
},
];

// Forming a "block formatting context" to prevent margin collapsing.
// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context
const ROOT_CONTAINER = `
.is-root-container {
display: flow-root;
}
`;
// The content area of the Style Book is rendered within an iframe so that global styles
// are applied to elements within the entire content area. To support elements that are
// not part of the block previews, such as headings and layout for the block previews,
Expand All @@ -151,17 +158,13 @@ export const STYLE_BOOK_CATEGORIES: StyleBookCategory[] = [
// applied to the `button` element, targeted via `.edit-site-style-book__example`.
// This is to ensure that browser default styles for buttons are not applied to the previews.
export const STYLE_BOOK_IFRAME_STYLES = `
// Forming a "block formatting context" to prevent margin collapsing.
// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context
.is-root-container {
display: flow-root;
}
body {
position: relative;
padding: 32px !important;
}
${ ROOT_CONTAINER }
.edit-site-style-book__examples {
max-width: 1200px;
margin: 0 auto;
Expand Down
4 changes: 2 additions & 2 deletions packages/editor/src/components/entities-saved-states/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ export function EntitiesSavedStatesExtensible( {
_n(
'There is <strong>%d site change</strong> waiting to be saved.',
'There are <strong>%d site changes</strong> waiting to be saved.',
sortedPartitionedSavables.length
dirtyEntityRecords.length
),
sortedPartitionedSavables.length
dirtyEntityRecords.length
),
{ strong: <strong /> }
)
Expand Down
48 changes: 24 additions & 24 deletions packages/editor/src/components/visual-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
privateApis as blockEditorPrivateApis,
__experimentalUseResizeCanvas as useResizeCanvas,
} from '@wordpress/block-editor';
import { useEffect, useRef, useMemo } from '@wordpress/element';
import { useEffect, useRef, useMemo, useState } from '@wordpress/element';
import { useSelect } from '@wordpress/data';
import { parse } from '@wordpress/blocks';
import { store as coreStore } from '@wordpress/core-data';
Expand Down Expand Up @@ -106,7 +106,10 @@ function VisualEditor( {
contentRef,
className,
} ) {
const [ resizeObserver, sizes ] = useResizeObserver();
const [ contentHeight, setContentHeight ] = useState( '' );
const effectContentHeight = useResizeObserver( ( [ entry ] ) => {
setContentHeight( entry.borderBoxSize[ 0 ].blockSize );
} );
const isMobileViewport = useViewportMatch( 'small', '<' );
const {
renderingMode,
Expand Down Expand Up @@ -323,21 +326,6 @@ function VisualEditor( {
.is-root-container.alignfull { max-width: none; margin-left: auto; margin-right: auto;}
.is-root-container.alignfull:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: none;}`;

const localRef = useRef();
const typewriterRef = useTypewriter();
contentRef = useMergeRefs( [
localRef,
contentRef,
renderingMode === 'post-only' ? typewriterRef : null,
useFlashEditableBlocks( {
isEnabled: renderingMode === 'template-locked',
} ),
useSelectNearestEditableBlock( {
isEnabled: renderingMode === 'template-locked',
} ),
useZoomOutModeExit(),
] );

const forceFullHeight = postType === NAVIGATION_POST_TYPE;
const enableResizing =
[
Expand Down Expand Up @@ -368,6 +356,24 @@ function VisualEditor( {
];
}, [ styles, enableResizing ] );

const localRef = useRef();
const typewriterRef = useTypewriter();
contentRef = useMergeRefs( [
localRef,
contentRef,
renderingMode === 'post-only' ? typewriterRef : null,
useFlashEditableBlocks( {
isEnabled: renderingMode === 'template-locked',
} ),
useSelectNearestEditableBlock( {
isEnabled: renderingMode === 'template-locked',
} ),
useZoomOutModeExit(),
// Avoid resize listeners when not needed, these will trigger
// unnecessary re-renders when animating the iframe width.
enableResizing ? effectContentHeight : null,
] );

return (
<div
className={ clsx(
Expand All @@ -385,7 +391,7 @@ function VisualEditor( {
<ResizableEditor
enableResizing={ enableResizing }
height={
sizes.height && ! forceFullHeight ? sizes.height : '100%'
contentHeight && ! forceFullHeight ? contentHeight : '100%'
}
>
<BlockCanvas
Expand Down Expand Up @@ -479,12 +485,6 @@ function VisualEditor( {
/>
) }
</RecursionProvider>
{
// Avoid resize listeners when not needed,
// these will trigger unnecessary re-renders
// when animating the iframe width.
enableResizing && resizeObserver
}
</BlockCanvas>
</ResizableEditor>
</div>
Expand Down

0 comments on commit 4138488

Please sign in to comment.