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

Try dark toolbar for the write mode #66116

Merged
merged 8 commits into from
Nov 27, 2024

Conversation

dhruvang21
Copy link
Contributor

@dhruvang21 dhruvang21 commented Oct 15, 2024

What?

Solves #66054

Let's try adding an additional affordance to write mode to help you understand what "mode" you're in, writing or design, by leveraging the pre-existing styles for select mode. This way there's a clear visual affordance to indicate the difference in experiences.

Why?

Part of 66054

How?

I’ve applied the conditions for the is-contentonly-mode class, which gets added when the write mode is activated. I also tried to add the SCSS to match the design. While I did my best to ensure the SCSS is correct, I believe it can be further optimized through the review process if necessary.

Testing Instructions

  1. Open a post or page.
  2. Insert a any block or pattern.
  3. Then change the mode to write mode see the toolbar in darkmode.

Screenshots or screencast

Dark-toolbar-mode.mp4

@dhruvang21 dhruvang21 requested a review from ellatrix as a code owner October 15, 2024 08:50
Copy link

github-actions bot commented Oct 15, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: dhruvang21 <[email protected]>
Co-authored-by: richtabor <[email protected]>
Co-authored-by: youknowriad <[email protected]>
Co-authored-by: draganescu <[email protected]>
Co-authored-by: jameskoster <[email protected]>
Co-authored-by: getdave <[email protected]>
Co-authored-by: jasmussen <[email protected]>
Co-authored-by: hanneslsm <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@dhruvang21
Copy link
Contributor Author

dhruvang21 commented Oct 18, 2024

@richtabor can you please review this PR

@youknowriad
Copy link
Contributor

This is working decently well for me. Would love a design review to ensure it's inline what the original ideal.

@@ -167,11 +171,13 @@ export function PrivateBlockToolbar( {
// Shifts the toolbar to make room for the parent block selector.
const classes = clsx( 'block-editor-block-contextual-toolbar', {
'has-parent': showParentSelector,
'is-dark-toolbar': ! isDefaultEditingMode && ! hasFixedToolbar,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd avoid words that dictate the appearance (dark) as we may need to re-evaluate the design when we introduce light/dark modes down the road.

Copy link
Contributor

Choose a reason for hiding this comment

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

So how you would name this. See my previous comment here #66116 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

We could use inverted or alt (as in alternative)?

Copy link
Contributor

Choose a reason for hiding this comment

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

@dhruvang21 I think this line causes the issues in my video - isDefaultEditingMode applies to indivudual blocks which can be locked or in partially synced patterns so we can end up with the dark toolbar in default mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@draganescu, you’re absolutely right; this condition isn’t complete as it fails for blocks with unique states—like those that are locked, reusable, or partially synced in patterns—where each block’s mode can differ within the editor.

For now, I think we could add this condition: getBlockEditingMode(parentClientId) === 'contentOnly', which directly targets the parent block’s mode. However, a better approach might be to retrieve the editor mode in a way similar to how it’s done for zoom-out activation.

Let me know your thoughts!

@jameskoster
Copy link
Contributor

I haven't been very close to this work so take my feedback with a grain of salt, but I don't know that I'd equate a different toolbar color to a different mode. I'd be tempted to try something with the canvas... maybe in design mode you see the artboard and resize handles:

Screenshot 2024-10-24 at 14 01 59

In terms of the execution I don't love the style overrides; they generally lead to maintenance headaches down the road.

Toggled buttons are looking a bit odd and don't meet contrast requirements:

Screenshot 2024-10-24 at 13 51 38

Menus and popovers remain light, is this intentional?

Screenshot 2024-10-24 at 13 52 06

In an ideal world this would be handled more sustainably, IE at the component level via theming.

@jasmussen
Copy link
Contributor

I would echo Jay's note. There are some good ideas, good intents. But compent and admin-level theming is increasingly on the radar, which will afford a systematic approach to more easily test and tune this in a way that does not risk adding technical debt. I would circle back to this once we're a bit further. But thank you for the contribution, the instinct, and the work!

@jasmussen
Copy link
Contributor

jasmussen commented Oct 24, 2024

My above comment aside, 66054 makes a good case for why a dark toolbar as outlined can make sense even before theming. If this passes a good code review, no blockers from my end.

@jameskoster
Copy link
Contributor

I certainly agree it's worth trying something to help indicate the active mode. I'm not 100% sold on using the toolbar to do that because it's not always visible, and because 'top toolbar' exists. That said I would also not block :)

@richtabor
Copy link
Member

Pushed a few slight color changes.

CleanShot 2024-10-25 at 11 53 02

Copy link
Contributor

@getdave getdave left a comment

Choose a reason for hiding this comment

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

Thanks for this PR.

Screenshot 2024-10-25 at 10 56 39

For me when the toolbar is over a black background it provides a poor experience. I suspect this might be a problem for a11y as well.

I think we need to have some kind of outline on the toolbar to ensure it stands out on darker background.

@jasmussen
Copy link
Contributor

Related, though not for this PR: #66455.

@richtabor
Copy link
Member

I think we need to have some kind of outline on the toolbar to ensure it stands out on darker background.

Good call, updated:

CleanShot 2024-10-25 at 15 11 31

@jameskoster
Copy link
Contributor

We also need to fix the contrast on toggled buttons.

@jameskoster
Copy link
Contributor

Spotted another issue. Select a template part in the page editor and hover the name; it disappears:

Screenshot 2024-10-31 at 09 34 47

Copy link
Contributor

@draganescu draganescu left a comment

Choose a reason for hiding this comment

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

There is a bug in the implementation which keeps the light toolbar around after switching modes, plus the style leaks to all nstances of content only whereas we only want this for the write mode

dark-toolbar-leaks.mp4

@dhruvang21
Copy link
Contributor Author

Hello @draganescu,

Could you please share the steps to recreate the issue you showed in the video? I wasn’t able to reproduce it when testing in the Gutenberg PR reviewer.

@draganescu
Copy link
Contributor

Hi @dhruvang21 sorry for the delay, and thanks for your patience too!

To repro the issues I encountered:

  • add a page
  • add some patterns
  • go to the inspector > Page > Template
  • Select template name
  • Select show template
  • Notice that now we can select the content block
  • in write mode the content block has a white toolbar

also

  • in a template
  • have some template parts
  • notice the template parts have a dark toolbar in design mode

I think the problem is we don't target the mode but the "locking" and the issue is to use the dark toolbar in write mode only, eg. when the blocks are locked in content only keep the white toolbar,

This PR also needs a rebase now as the write/design mode have been moved to an experiment. Hope this helps!

@youknowriad youknowriad force-pushed the try/dark-toolbar-mode branch from 10d338c to 3fb856b Compare November 27, 2024 07:57
@youknowriad
Copy link
Contributor

I fixed the issue raised by @oandregal above and addressed some feedback. I think this is ready to go.

I don't love it personally but I'm ok shipping and trying it.

@youknowriad youknowriad enabled auto-merge (squash) November 27, 2024 07:58
@youknowriad youknowriad merged commit 0f6ab5d into WordPress:trunk Nov 27, 2024
62 checks passed
@github-actions github-actions bot added this to the Gutenberg 19.8 milestone Nov 27, 2024
michalczaplinski pushed a commit that referenced this pull request Dec 5, 2024
Co-authored-by: dhruvang21 <[email protected]>
Co-authored-by: richtabor <[email protected]>
Co-authored-by: youknowriad <[email protected]>
Co-authored-by: draganescu <[email protected]>
Co-authored-by: jameskoster <[email protected]>
Co-authored-by: getdave <[email protected]>
Co-authored-by: jasmussen <[email protected]>
Co-authored-by: hanneslsm <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Write mode Needs Design Feedback Needs general design feedback. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use the previous "select mode" dark toolbar style for Write mode
7 participants