Skip to content

Commit

Permalink
Merge branch 'trunk' into block-editor-40px-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla authored Aug 19, 2024
2 parents 90a5063 + 2862f2d commit 1d55dae
Show file tree
Hide file tree
Showing 28 changed files with 192 additions and 103 deletions.
18 changes: 9 additions & 9 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,11 @@ module.exports = {
'FontFamilyControl',
'FontSizePicker',
'FormTokenField',
'InputControl',
'LineHeightControl',
'NumberControl',
'RangeControl',
'TextControl',
'ToggleGroupControl',
].map( ( componentName ) => ( {
// Falsy `__next40pxDefaultSize` without a non-default `size` prop.
Expand All @@ -339,15 +341,13 @@ module.exports = {
'FormFileUpload should have the `__next40pxDefaultSize` prop to opt-in to the new default size.',
},
// Temporary rules until all existing components have the `__next40pxDefaultSize` prop.
...[ 'SelectControl', 'TextControl' ].map(
( componentName ) => ( {
// Not strict. Allows pre-existing __next40pxDefaultSize={ false } usage until they are all manually updated.
selector: `JSXOpeningElement[name.name="${ componentName }"]:not(:has(JSXAttribute[name.name="__next40pxDefaultSize"])):not(:has(JSXAttribute[name.name="size"]))`,
message:
componentName +
' should have the `__next40pxDefaultSize` prop to opt-in to the new default size.',
} )
),
...[ 'SelectControl' ].map( ( componentName ) => ( {
// Not strict. Allows pre-existing __next40pxDefaultSize={ false } usage until they are all manually updated.
selector: `JSXOpeningElement[name.name="${ componentName }"]:not(:has(JSXAttribute[name.name="__next40pxDefaultSize"])):not(:has(JSXAttribute[name.name="size"]))`,
message:
componentName +
' should have the `__next40pxDefaultSize` prop to opt-in to the new default size.',
} ) ),
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ function NonDefaultControls( { format, onChange } ) {
/>
{ isCustom && (
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Custom format' ) }
hideLabelFromVision
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,14 @@ const ImageURLInputUI = ( {
checked={ linkTarget === '_blank' }
/>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Link rel' ) }
value={ rel ?? '' }
onChange={ onSetLinkRel }
/>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Link CSS class' ) }
value={ linkClass || '' }
Expand Down
24 changes: 21 additions & 3 deletions packages/block-editor/src/components/use-block-drop-zone/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ export default function useBlockDropZone( {
getAllowedBlocks,
isDragging,
isGroupable,
getSettings,
isZoomOutMode,
} = unlock( useSelect( blockEditorStore ) );
const {
showInsertionPoint,
Expand Down Expand Up @@ -343,6 +345,7 @@ export default function useBlockDropZone( {
const targetBlockName = getBlockNamesByClientId( [
targetRootClientId,
] )[ 0 ];

const draggedBlockNames = getBlockNamesByClientId(
getDraggedBlockClientIds()
);
Expand All @@ -352,10 +355,23 @@ export default function useBlockDropZone( {
draggedBlockNames,
targetBlockName
);

if ( ! isBlockDroppingAllowed ) {
return;
}

const { sectionRootClientId } = unlock( getSettings() );

// In Zoom Out mode, if the target is not the section root provided by settings then
// do not allow dropping as the drop target is not within the root (that which is
// treated as "the content" by Zoom Out Mode).
if (
isZoomOutMode() &&
sectionRootClientId !== targetRootClientId
) {
return;
}

const blocks = getBlocks( targetRootClientId );

// The block list is empty, don't show the insertion point but still allow dropping.
Expand Down Expand Up @@ -470,6 +486,7 @@ export default function useBlockDropZone( {
} );
},
[
isDragging,
getAllowedBlocks,
targetRootClientId,
getBlockNamesByClientId,
Expand All @@ -481,13 +498,14 @@ export default function useBlockDropZone( {
parentBlockClientId,
getBlockIndex,
registry,
showInsertionPoint,
isDragging,
startDragging,
showInsertionPoint,
canInsertBlockType,
isGroupable,
getBlockVariations,
getGroupingBlockName,
isGroupable,
getSettings,
isZoomOutMode,
]
),
200
Expand Down
3 changes: 1 addition & 2 deletions packages/block-library/src/button/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,7 @@ function ButtonEdit( props ) {
<InspectorControls group="advanced">
{ isLinkTag && (
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Link rel' ) }
value={ rel || '' }
Expand Down
3 changes: 1 addition & 2 deletions packages/block-library/src/form-input/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ function InputFieldBlock( { attributes, setAttributes, className } ) {
) }
<InspectorControls group="advanced">
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
autoComplete="off"
label={ __( 'Name' ) }
Expand Down
6 changes: 2 additions & 4 deletions packages/block-library/src/form/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ const Edit = ( { attributes, setAttributes, clientId } ) => {
{ submissionMethod !== 'email' && (
<InspectorControls group="advanced">
<SelectControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Method' ) }
options={ [
Expand All @@ -147,8 +146,7 @@ const Edit = ( { attributes, setAttributes, clientId } ) => {
) }
/>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
autoComplete="off"
label={ __( 'Form action' ) }
Expand Down
40 changes: 33 additions & 7 deletions packages/block-library/src/gallery/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,44 @@ figure.wp-block-gallery.has-nested-images {
width: auto;
}

// Position caption and scrim at the bottom.
&:has(figcaption)::before,
figcaption {
background: linear-gradient(0deg, rgba($color: $black, $alpha: 0.7) 0, rgba($color: $black, $alpha: 0.3) 70%, transparent);
position: absolute;
bottom: 0;
right: 0;
left: 0;
max-height: 100%;
}

// Create a background blur layer.
&:has(figcaption)::before {
content: "";
height: 100%;
max-height: 40%;

// Blur the background under the gradient scrim.
backdrop-filter: blur(3px);

// Crop the caption so the blur is only on the edge.
mask-image: linear-gradient(0deg, $black 20%, transparent 100%);
}

// Place the caption at the bottom.
figcaption {
color: $white;
text-shadow: 0 0 1.5px $black;
font-size: $default-font-size;
left: 0;
margin-bottom: 0;
max-height: 60%;
margin: 0;
overflow: auto;
padding: 0 8px 8px;
position: absolute;
padding: 1em;
text-align: center;
width: 100%;
box-sizing: border-box;
@include custom-scrollbars-on-hover(transparent, rgba($white, 0.8));

// Dark gradient scrim.
background: linear-gradient(0deg, rgba($color: $black, $alpha: 0.4) 0%, transparent 100%);

img {
display: inline;
}
Expand All @@ -85,6 +107,10 @@ figure.wp-block-gallery.has-nested-images {
margin: 0;
padding: 10px 10px 9px;
position: relative;
text-shadow: none;
}
&::before {
content: none;
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions packages/block-library/src/image/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -690,8 +690,7 @@ export default function Image( {
) }
renderContent={ () => (
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
className="wp-block-image__toolbar_content_textarea"
__nextHasNoMarginBottom
label={ __( 'Title attribute' ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ export default function NavigationMenuNameControl() {

return (
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Menu name' ) }
value={ title }
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/post-comment/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ export default function Edit( { attributes: { commentId }, setAttributes } ) {
) }
>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
value={ commentId }
onChange={ ( val ) =>
Expand All @@ -44,6 +43,7 @@ export default function Edit( { attributes: { commentId }, setAttributes } ) {
/>

<Button
__next40pxDefaultSize
variant="primary"
onClick={ () => {
setAttributes( { commentId: commentIdInput } );
Expand Down
3 changes: 1 addition & 2 deletions packages/block-library/src/post-featured-image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,7 @@ export default function PostFeaturedImageEdit( {
checked={ linkTarget === '_blank' }
/>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Link rel' ) }
value={ rel }
Expand Down
3 changes: 1 addition & 2 deletions packages/block-library/src/post-terms/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ export default function PostTermsEdit( {
</BlockControls>
<InspectorControls group="advanced">
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
autoComplete="off"
label={ __( 'Separator' ) }
Expand Down
3 changes: 1 addition & 2 deletions packages/block-library/src/post-title/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ export default function PostTitleEdit( {
checked={ linkTarget === '_blank' }
/>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Link rel' ) }
value={ rel }
Expand Down
6 changes: 2 additions & 4 deletions packages/block-library/src/social-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ const SocialLinkEdit = ( {
<PanelBody title={ __( 'Settings' ) }>
<PanelRow>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Text' ) }
help={ __(
Expand All @@ -157,8 +156,7 @@ const SocialLinkEdit = ( {
</InspectorControls>
<InspectorControls group="advanced">
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Link rel' ) }
value={ rel || '' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ export function TemplatePartAdvancedControls( {
{ isEntityAvailable && (
<>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Title' ) }
value={ title }
Expand All @@ -85,8 +84,7 @@ export function TemplatePartAdvancedControls( {
/>

<SelectControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Area' ) }
labelPosition="top"
Expand Down
9 changes: 3 additions & 6 deletions packages/block-library/src/video/tracks-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ function SingleTrackEditor( { track, onChange, onClose, onRemove } ) {
</span>
<Grid columns={ 2 } gap={ 4 }>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
/* eslint-disable jsx-a11y/no-autofocus */
autoFocus
Expand All @@ -116,8 +115,7 @@ function SingleTrackEditor( { track, onChange, onClose, onRemove } ) {
help={ __( 'Title of track' ) }
/>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
onChange={ ( newSrcLang ) =>
onChange( {
Expand All @@ -132,8 +130,7 @@ function SingleTrackEditor( { track, onChange, onClose, onRemove } ) {
</Grid>
<VStack spacing="8">
<SelectControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
className="block-library-video-tracks-editor__single-track-editor-kind-select"
options={ KIND_OPTIONS }
Expand Down
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@

### Bug Fixes

- `RangeControl`: disable reset button when the current value is equal to the reset value ([#64579](https://github.com/WordPress/gutenberg/pull/64579)).
- `RangeControl`: tweak mark and label absolute positioning ([#64487](https://github.com/WordPress/gutenberg/pull/64487)).

### Internal
Expand Down
Loading

0 comments on commit 1d55dae

Please sign in to comment.