From cca1f55f048f027df49f0c08e757e73f73a54193 Mon Sep 17 00:00:00 2001 From: Seth Miller Date: Mon, 15 Apr 2024 04:41:53 -0400 Subject: [PATCH 01/35] Combobox: Add links to related components (#60726) Co-authored-by: flexseth Co-authored-by: Mamaduka --- packages/components/src/combobox-control/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/components/src/combobox-control/README.md b/packages/components/src/combobox-control/README.md index 9b64076be32402..b84e01b7d6a077 100644 --- a/packages/components/src/combobox-control/README.md +++ b/packages/components/src/combobox-control/README.md @@ -110,8 +110,8 @@ Custom renderer invoked for each option in the suggestion list. The render prop ## Related components -- Like this component, but without a search input, the `CustomSelectControl` component. +- Like this component, but without a search input, the [`CustomSelectControl`](https://developer.wordpress.org/block-editor/reference-guides/components/custom-select-control/) component. -- To select one option from a set, when you want to show all the available options at once, use the `Radio` component. -- To select one or more items from a set, use the `CheckboxControl` component. -- To toggle a single setting on or off, use the `ToggleControl` component. +- To select one option from a set, when you want to show all the available options at once, use the [`RadioControl`](https://developer.wordpress.org/block-editor/reference-guides/components/radio-control/) component. +- To select one or more items from a set, use the [`CheckboxControl`](https://developer.wordpress.org/block-editor/reference-guides/components/checkbox-control/) component. +- To toggle a single setting on or off, use the [`ToggleControl`](https://developer.wordpress.org/block-editor/reference-guides/components/toggle-control/) component. From d9a6429054e8bf0fa930c921472b4c3109ed2012 Mon Sep 17 00:00:00 2001 From: Sunil Prajapati <61308756+sunil25393@users.noreply.github.com> Date: Mon, 15 Apr 2024 18:59:27 +0530 Subject: [PATCH 02/35] Add loading state on image upload in featured image, Site logo and Cover blocks (#59519) Co-authored-by: sunil25393 Co-authored-by: Mamaduka Co-authored-by: t-hamano Co-authored-by: annezazu --- packages/block-library/src/cover/editor.scss | 15 +++- .../src/post-featured-image/edit.js | 66 ++++++++++----- .../src/post-featured-image/editor.scss | 17 ++++ packages/block-library/src/site-logo/edit.js | 82 +++++++++++-------- .../block-library/src/site-logo/editor.scss | 21 ++++- 5 files changed, 139 insertions(+), 62 deletions(-) diff --git a/packages/block-library/src/cover/editor.scss b/packages/block-library/src/cover/editor.scss index 4e2a07ffe8e4ee..6aa10657ec6f2e 100644 --- a/packages/block-library/src/cover/editor.scss +++ b/packages/block-library/src/cover/editor.scss @@ -30,9 +30,18 @@ } // Applied while media is being uploaded - &.is-transient::before { - background-color: #fff; - opacity: 0.3; + &.is-transient { + position: relative; + + &::before { + background-color: #fff; + content: ""; + height: 100%; + opacity: 0.3; + position: absolute; + width: 100%; + z-index: 1; + } } // Shown while media is being uploaded diff --git a/packages/block-library/src/post-featured-image/edit.js b/packages/block-library/src/post-featured-image/edit.js index d1d03c0d4b52a1..25133a2babcfc0 100644 --- a/packages/block-library/src/post-featured-image/edit.js +++ b/packages/block-library/src/post-featured-image/edit.js @@ -6,6 +6,7 @@ import classnames from 'classnames'; /** * WordPress dependencies */ +import { isBlobURL } from '@wordpress/blob'; import { useEntityProp, store as coreStore } from '@wordpress/core-data'; import { useSelect, useDispatch } from '@wordpress/data'; import { @@ -14,6 +15,7 @@ import { PanelBody, Placeholder, Button, + Spinner, TextControl, } from '@wordpress/components'; import { @@ -27,7 +29,7 @@ import { __experimentalGetShadowClassesAndStyles as getShadowClassesAndStyles, useBlockEditingMode, } from '@wordpress/block-editor'; -import { useMemo } from '@wordpress/element'; +import { useMemo, useEffect, useState } from '@wordpress/element'; import { __, sprintf } from '@wordpress/i18n'; import { upload } from '@wordpress/icons'; import { store as noticesStore } from '@wordpress/notices'; @@ -70,6 +72,7 @@ export default function PostFeaturedImageEdit( { linkTarget, useFirstImageFromPost, } = attributes; + const [ temporaryURL, setTemporaryURL ] = useState(); const [ storedFeaturedImage, setFeaturedImage ] = useEntityProp( 'postType', @@ -144,6 +147,9 @@ export default function PostFeaturedImageEdit( { const blockProps = useBlockProps( { style: { width, height, aspectRatio }, + className: classnames( { + 'is-transient': temporaryURL, + } ), } ); const borderProps = useBorderProps( attributes ); const shadowProps = getShadowClassesAndStyles( attributes ); @@ -173,11 +179,23 @@ export default function PostFeaturedImageEdit( { if ( value?.id ) { setFeaturedImage( value.id ); } + + if ( value?.url && isBlobURL( value.url ) ) { + setTemporaryURL( value.url ); + } }; + // Reset temporary url when media is available. + useEffect( () => { + if ( mediaUrl && temporaryURL ) { + setTemporaryURL(); + } + }, [ mediaUrl, temporaryURL ] ); + const { createErrorNotice } = useDispatch( noticesStore ); const onUploadError = ( message ) => { createErrorNotice( message, { type: 'snackbar' } ); + setTemporaryURL(); }; const controls = blockEditingMode === 'default' && ( @@ -241,7 +259,7 @@ export default function PostFeaturedImageEdit( { /** * A Post Featured Image block should not have image replacement * or upload options in the following cases: - * - Is placed in a Query Loop. This is a consious decision to + * - Is placed in a Query Loop. This is a conscious decision to * prevent content editing of different posts in Query Loop, and * this could change in the future. * - Is in a context where it does not have a postId (for example @@ -289,7 +307,7 @@ export default function PostFeaturedImageEdit( { * - It has no image assigned yet * Then display the placeholder with the image upload option. */ - if ( ! featuredImage ) { + if ( ! featuredImage && ! temporaryURL ) { image = ( - ); + image = + ! media && ! temporaryURL ? ( + placeholder() + ) : ( + <> + { + { temporaryURL && } + + ); } /** @@ -343,7 +365,7 @@ export default function PostFeaturedImageEdit( { */ return ( <> - { controls } + { ! temporaryURL && controls } { !! media && ! isDescendentOfQueryLoop && ( { const settings = select( blockEditorStore ).getSettings(); const siteEntities = select( coreStore ).getEntityRecord( @@ -113,17 +111,20 @@ const SiteLogo = ( { } const img = ( - { { - setNaturalSize( { - naturalWidth: event.target.naturalWidth, - naturalHeight: event.target.naturalHeight, - } ); - } } - /> + <> + { { + setNaturalSize( { + naturalWidth: event.target.naturalWidth, + naturalHeight: event.target.naturalHeight, + } ); + } } + /> + { isBlobURL( logoUrl ) && } + ); let imgWrapper = img; @@ -434,6 +435,7 @@ export default function LogoEdit( { }; }, [] ); const { getSettings } = useSelect( blockEditorStore ); + const [ temporaryURL, setTemporaryURL ] = useState(); const { editEntityRecord } = useDispatch( coreStore ); @@ -480,6 +482,7 @@ export default function LogoEdit( { if ( ! media.id && media.url ) { // This is a temporary blob image. + setTemporaryURL( media.url ); setLogo( undefined ); return; } @@ -495,6 +498,7 @@ export default function LogoEdit( { const { createErrorNotice } = useDispatch( noticesStore ); const onUploadError = ( message ) => { createErrorNotice( message, { type: 'snackbar' } ); + setTemporaryURL(); }; const onFilesDrop = ( filesList ) => { @@ -503,6 +507,7 @@ export default function LogoEdit( { filesList, onFileChange( [ image ] ) { if ( isBlobURL( image?.url ) ) { + setTemporaryURL( image.url ); return; } onInitialSelectLogo( image ); @@ -517,7 +522,7 @@ export default function LogoEdit( { onError: onUploadError, onRemoveLogo, }; - const controls = canUserEdit && logoUrl && ( + const controls = canUserEdit && logoUrl && ! temporaryURL && ( @@ -528,22 +533,32 @@ export default function LogoEdit( { if ( isLoading ) { logoImage = ; } - if ( !! logoUrl ) { + + // Reset temporary url when logoUrl is available. + useEffect( () => { + if ( logoUrl && temporaryURL ) { + setTemporaryURL(); + } + }, [ logoUrl, temporaryURL ] ); + + if ( !! logoUrl || !! temporaryURL ) { logoImage = ( - + <> + + ); } const placeholder = ( content ) => { @@ -568,6 +583,7 @@ export default function LogoEdit( { const classes = classnames( className, { 'is-default-size': ! width, + 'is-transient': temporaryURL, } ); const blockProps = useBlockProps( { className: classes } ); @@ -631,8 +647,8 @@ export default function LogoEdit( {
{ controls } { mediaInspectorPanel } - { !! logoUrl && logoImage } - { ! logoUrl && ! canUserEdit && ( + { ( !! logoUrl || !! temporaryURL ) && logoImage } + { ! temporaryURL && ! logoUrl && ! canUserEdit && ( { !! isLoading && ( @@ -641,7 +657,7 @@ export default function LogoEdit( { ) } ) } - { ! logoUrl && canUserEdit && ( + { ! temporaryURL && ! logoUrl && canUserEdit && ( Date: Mon, 15 Apr 2024 09:44:03 -0400 Subject: [PATCH 03/35] Fix external link indicator in Link Control (#60439) * Add display inline * target the new span rather than the svg * use clip Co-authored-by: richtabor Co-authored-by: jasmussen Co-authored-by: t-hamano Co-authored-by: jeryj --- .../src/components/link-control/style.scss | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/block-editor/src/components/link-control/style.scss b/packages/block-editor/src/components/link-control/style.scss index e635dcf90632f0..91428274a99140 100644 --- a/packages/block-editor/src/components/link-control/style.scss +++ b/packages/block-editor/src/components/link-control/style.scss @@ -249,6 +249,7 @@ $block-editor-link-control-number-of-actions: 1; border-radius: $radius-block-ui; line-height: 1.1; + &:focus { box-shadow: none; } @@ -268,8 +269,15 @@ $block-editor-link-control-number-of-actions: 1; font-weight: normal; } - svg { - display: none; // specifically requested to be removed visually as well. + .components-external-link__icon { + position: absolute; + width: 1px; + height: 1px; + padding: 0; + margin: -1px; + overflow: hidden; + clip: rect(0, 0, 0, 0); // specifically requested to be removed visually as well. + border: 0; } } } From 2cebea7f2858287c800e79f50de7fcd5c4b7990c Mon Sep 17 00:00:00 2001 From: Lena Morita Date: Tue, 16 Apr 2024 01:31:13 +0900 Subject: [PATCH 04/35] DimensionControl: Fix story config (#60703) Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: tyxla --- .../src/dimension-control/stories/index.story.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/components/src/dimension-control/stories/index.story.tsx b/packages/components/src/dimension-control/stories/index.story.tsx index 0698125c446ca7..1220be3d4eea1f 100644 --- a/packages/components/src/dimension-control/stories/index.story.tsx +++ b/packages/components/src/dimension-control/stories/index.story.tsx @@ -29,10 +29,10 @@ export default { mobile, }, }, - parameters: { - controls: { expanded: true }, - docs: { canvas: { sourceState: 'shown' } }, - }, + }, + parameters: { + controls: { expanded: true }, + docs: { canvas: { sourceState: 'shown' } }, }, } as Meta< typeof DimensionControl >; From b06dbb940239d4e90afe5b1a34d0097b6e7e7b1d Mon Sep 17 00:00:00 2001 From: Lena Morita Date: Tue, 16 Apr 2024 01:34:54 +0900 Subject: [PATCH 05/35] Navigation: Soft deprecate component (#59182) * Navigation: Soft deprecate component * Set up redirect * Add deprecation notice in Storybook * Add changelog Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: tyxla --- packages/components/CHANGELOG.md | 4 ++++ packages/components/src/navigation/README.md | 4 ++++ packages/components/src/navigation/back-button/index.tsx | 3 +++ packages/components/src/navigation/group/index.tsx | 3 +++ packages/components/src/navigation/index.tsx | 2 ++ packages/components/src/navigation/item/index.tsx | 3 +++ packages/components/src/navigation/menu/index.tsx | 3 +++ .../components/src/navigation/stories/index.story.tsx | 8 +++++++- storybook/manager-head.html | 9 +++++++++ 9 files changed, 38 insertions(+), 1 deletion(-) diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index 48827c815c5854..e2f363bbca8f66 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Deprecation + +- `Navigation`: Soft deprecate component ([#59182](https://github.com/WordPress/gutenberg/pull/59182)). + ### Enhancements - `ExternalLink`: Use unicode arrow instead of svg icon ([#60255](https://github.com/WordPress/gutenberg/pull/60255)). diff --git a/packages/components/src/navigation/README.md b/packages/components/src/navigation/README.md index 3a1fa992611b62..b294eb78331eef 100644 --- a/packages/components/src/navigation/README.md +++ b/packages/components/src/navigation/README.md @@ -1,5 +1,9 @@ # Navigation +
+This component is deprecated. Consider using `Navigator` instead. +
+
This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.
diff --git a/packages/components/src/navigation/back-button/index.tsx b/packages/components/src/navigation/back-button/index.tsx index 182faa8773726d..f1fb79ae40d484 100644 --- a/packages/components/src/navigation/back-button/index.tsx +++ b/packages/components/src/navigation/back-button/index.tsx @@ -64,6 +64,9 @@ function UnforwardedNavigationBackButton( ); } +/** + * @deprecated Use `Navigator` instead. + */ export const NavigationBackButton = forwardRef( UnforwardedNavigationBackButton ); diff --git a/packages/components/src/navigation/group/index.tsx b/packages/components/src/navigation/group/index.tsx index cd91fb97365d26..60febcf7644569 100644 --- a/packages/components/src/navigation/group/index.tsx +++ b/packages/components/src/navigation/group/index.tsx @@ -19,6 +19,9 @@ import type { NavigationGroupProps } from '../types'; let uniqueId = 0; +/** + * @deprecated Use `Navigator` instead. + */ export function NavigationGroup( { children, className, diff --git a/packages/components/src/navigation/index.tsx b/packages/components/src/navigation/index.tsx index dfc1b26cb33ad0..9ccd4f46e5f182 100644 --- a/packages/components/src/navigation/index.tsx +++ b/packages/components/src/navigation/index.tsx @@ -28,6 +28,8 @@ const noop = () => {}; /** * Render a navigation list with optional groupings and hierarchy. * + * @deprecated Use `Navigator` instead. + * * ```jsx * import { * __experimentalNavigation as Navigation, diff --git a/packages/components/src/navigation/item/index.tsx b/packages/components/src/navigation/item/index.tsx index 2fd1aebefcbbac..d234ed1a549b59 100644 --- a/packages/components/src/navigation/item/index.tsx +++ b/packages/components/src/navigation/item/index.tsx @@ -22,6 +22,9 @@ import type { NavigationItemProps } from '../types'; const noop = () => {}; +/** + * @deprecated Use `Navigator` instead. + */ export function NavigationItem( props: NavigationItemProps ) { const { badge, diff --git a/packages/components/src/navigation/menu/index.tsx b/packages/components/src/navigation/menu/index.tsx index b001bd0fa0f3d8..8fcddf3faddb9e 100644 --- a/packages/components/src/navigation/menu/index.tsx +++ b/packages/components/src/navigation/menu/index.tsx @@ -23,6 +23,9 @@ import { MenuUI } from '../styles/navigation-styles'; import type { NavigationMenuProps } from '../types'; +/** + * @deprecated Use `Navigator` instead. + */ export function NavigationMenu( props: NavigationMenuProps ) { const { backButtonLabel, diff --git a/packages/components/src/navigation/stories/index.story.tsx b/packages/components/src/navigation/stories/index.story.tsx index e0a3f1e1397576..2f09ace29f16e5 100644 --- a/packages/components/src/navigation/stories/index.story.tsx +++ b/packages/components/src/navigation/stories/index.story.tsx @@ -19,8 +19,14 @@ import { MoreExamplesStory } from './utils/more-examples'; import { HideIfEmptyStory } from './utils/hide-if-empty'; import './style.css'; +/** + * Render a navigation list with optional groupings and hierarchy. + * + * This component is deprecated. Consider using `Navigator` instead. + */ const meta: Meta< typeof Navigation > = { - title: 'Components (Experimental)/Navigation', + title: 'Components (Deprecated)/Navigation', + id: 'components-navigation', component: Navigation, subcomponents: { // @ts-expect-error - See https://github.com/storybookjs/storybook/issues/23170 diff --git a/storybook/manager-head.html b/storybook/manager-head.html index 21ee902c02a36d..629f06bf98edf9 100644 --- a/storybook/manager-head.html +++ b/storybook/manager-head.html @@ -1,10 +1,19 @@