Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add link to options-general.php in the site title description #31122

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/block-library/src/site-title/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,33 @@
* WordPress dependencies
*/
import { mapMarker as icon } from '@wordpress/icons';
import { createInterpolateElement } from '@wordpress/element';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import metadata from './block.json';
import edit from './edit';
import AccessibleSteps from './util/accessible-steps';

const { name } = metadata;
export { metadata, name };

export const settings = {
description: createInterpolateElement(
__(
'Displays and allows editing the name of the site. The site title usually appears in the browser title bar, in search results, and more. Also available in <path/>.'
),
{
path: (
<AccessibleSteps
elements={ [ __( 'Settings' ), __( 'General' ) ] }
link="options-general.php"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll want to avoid a hardcoded link here since some clients need to be able to override this link. Other places have used a slot/fill pattern, but we may need a new generic filter for links added in block settings.

Added a screencap of feedback to save folks a click, from #30926

Screen Shot 2021-05-10 at 9 11 15 AM

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for sharing! So we need a way for clients to be able to override internal links. Maybe something for a [Type] Discussion issue?

How do you suggest we go from here?

Copy link
Contributor

@gwwar gwwar May 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For next steps maybe something like:

  1. Audit to see if any other hardcoded links are currently present in block settings
  2. Open up an exploration PR(s) to explore the customization hook we're adding, with a few links to test it out (anything that the audit uncovered + site title + home link block).

If you're interested in the general problem, I think we can reuse this PR and update the summary + title. If not, I was intending to follow up on this, and I'd be happy to ping folks when a mechanism is available. Just let me know :D

/>
),
}
),
icon,
edit,
};
46 changes: 46 additions & 0 deletions packages/block-library/src/site-title/util/accessible-steps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';

/**
* External dependencies
*/
import { isEmpty } from 'lodash';

const PathSeparator = () => (
<>
&nbsp;
<span
aria-label={
// translators: accessibility text for describing steps with the > character
__( 'and then' )
}
>
{ '>' }
</span>{ ' ' }
</>
);

export default function AccessibleSteps( { elements, link } ) {
if ( isEmpty( elements ) ) {
return null;
}

const Wrapper = ( { children } ) =>
isEmpty( link ) ? <>{ children }</> : <a href={ link }>{ children }</a>;

return (
<Wrapper>
<b>
{ elements.reduce( ( acc, curr ) => (
<>
{ acc }
<PathSeparator />
{ curr }
</>
) ) }
</b>
</Wrapper>
);
}