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 'Open CSS' command to the command centre #51718

Merged
merged 2 commits into from
Jun 21, 2023
Merged

Add 'Open CSS' command to the command centre #51718

merged 2 commits into from
Jun 21, 2023

Conversation

dsas
Copy link
Contributor

@dsas dsas commented Jun 20, 2023

What?

Add the 'Open CSS' command to the command centre when in the site-editor

Why?

One of the command centre ideas mentioned in #51502

How?

I've branched from @youknowriad's #51637

Testing Instructions

  1. Open the site editor
  2. Open the command centre, e.g. with ⌘ + k
  3. Type 'CSS'
  4. See the command appear in the list
  5. Choose the command
  6. Watch the 'Additional CSS' screen open.

Post editor

Try it again in the post editor and see that it doesn't appear and you can't use it :)

Without edit_css capabilities

Now try it again but as a user that does have access to the site editor, but doesn't have access to custom CSS.

Add a snippet like this:

add_filter( 'map_meta_cap', 'no_css', 10, 2 );

function no_css( $caps, $cap ) {

	if ( 'edit_css' === $cap ) {
		$caps = array( 'do_not_allow' );
	}

	return $caps;
}

Now try try to run the steps again, you should notice that Open CSS doesn't show up in the command list, just as it doesn't show up in the GS sidebar & three-dot menu

Testing Instructions for Keyboard

As above

Screenshots or screencast

Screen.Capture.on.2023-06-20.at.22-58-24.mp4

dsas added 2 commits June 20, 2023 22:50
The 'Open CSS' command is available inside the site-editor only, and
opens the global styles sidebar going straight to the Additional CSS
screen.
}

Copy link
Contributor

Choose a reason for hiding this comment

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

This is the first time I see this effect. It's a bit weird that this relies on goTo.

I had an idea that I needed elsewhere too to solve this more elegantly: Allow NavigatorProvider to work as a controlled component. I think that's something we'll be needing anyway in the site editor to avoid race conditions when synchronizing the URL to the state. ( cc @ciampo )

(This is not for this PR)

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

This is looking good to me

@youknowriad
Copy link
Contributor

Going to merge it to my PR so we can merge both together.

@youknowriad youknowriad merged commit 2de0919 into WordPress:add/global-styles-commands Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants