From cd07f4f3e47a227f4a71fba9bfd3768327e6bdb4 Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Mon, 14 Oct 2024 13:29:04 +0200 Subject: [PATCH] Improve PostURL terminology and accessibility (#63669) * Improve PostURL terminology and accessibility. * Restore createInterpolateElement after rebase. * Remove value truncation after PR 64053. * Replace term URL with Permalink. * Reduce post url intro text top margin. Co-authored-by: afercia Co-authored-by: joedolson Co-authored-by: richtabor Co-authored-by: annezazu Co-authored-by: t-hamano --- .../editor/src/components/post-url/index.js | 122 ++++++++++-------- .../editor/src/components/post-url/panel.js | 90 ++++++++----- .../editor/src/components/post-url/style.scss | 24 +++- 3 files changed, 145 insertions(+), 91 deletions(-) diff --git a/packages/editor/src/components/post-url/index.js b/packages/editor/src/components/post-url/index.js index 8d072fa2eeb5d2..c7dc5712dcac4a 100644 --- a/packages/editor/src/components/post-url/index.js +++ b/packages/editor/src/components/post-url/index.js @@ -17,7 +17,7 @@ import { import { store as noticesStore } from '@wordpress/notices'; import { copySmall } from '@wordpress/icons'; import { store as coreStore } from '@wordpress/core-data'; -import { useCopyToClipboard } from '@wordpress/compose'; +import { useCopyToClipboard, useInstanceId } from '@wordpress/compose'; /** * Internal dependencies @@ -70,25 +70,29 @@ export default function PostURL( { onClose } ) { const { createNotice } = useDispatch( noticesStore ); const [ forceEmptyField, setForceEmptyField ] = useState( false ); const copyButtonRef = useCopyToClipboard( permalink, () => { - createNotice( 'info', __( 'Copied URL to clipboard.' ), { + createNotice( 'info', __( 'Copied Permalink to clipboard.' ), { isDismissible: true, type: 'snackbar', } ); } ); + const postUrlSlugDescriptionId = + 'editor-post-url__slug-descriotion-' + useInstanceId( PostURL ); + return (
{ isEditable && ( -
+

{ createInterpolateElement( __( - 'Customize the last part of the URL. Learn more.' + 'Customize the last part of the Permalink. Learn more.' ), { + span: , a: ( +

) }
{ isEditable && ( - - / - - } - suffix={ - - ); } + +function FrontPageLink() { + const { postLink } = useSelect( ( select ) => { + const { getCurrentPost } = select( editorStore ); + return { + postLink: getCurrentPost()?.link, + }; + }, [] ); + + return ( + + { postLink } + + ); +} diff --git a/packages/editor/src/components/post-url/style.scss b/packages/editor/src/components/post-url/style.scss index c815f89682cb2d..f8a70f5fdf760b 100644 --- a/packages/editor/src/components/post-url/style.scss +++ b/packages/editor/src/components/post-url/style.scss @@ -9,14 +9,19 @@ } /* rtl:begin:ignore */ -.editor-post-url__link { +.editor-post-url__link, +.editor-post-url__front-page-link { direction: ltr; word-break: break-word; - margin-top: $grid-unit-05; - color: $gray-700; } /* rtl:end:ignore */ +.editor-post-url__front-page-link { + // Match padding on tertiary buttons for alignment. + padding: $grid-unit-15 * 0.5 0 $grid-unit-15 * 0.5 $grid-unit-15; +} + + .editor-post-url__link-slug { font-weight: 600; } @@ -30,3 +35,16 @@ .editor-post-url__panel-toggle { word-break: break-word; } + +.editor-post-url__intro { + margin: 0; +} + +.editor-post-url__permalink { + margin-top: $grid-unit-10; + margin-bottom: 0; + + &-visual-label { + display: block; + } +}