gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Add "selected" styling to active elements in the design selector.

Open juanfra opened this issue 1 year ago • 11 comments

What problem does this address?

While working on TT5, I noticed no visual indication of the design chosen for templates. It would be nice to know at a first glance which design is active.

https://github.com/user-attachments/assets/36163b7c-6a96-4851-b3c7-4836e9ff8a34

To reproduce:

  1. Download Twenty Twenty-Five, or use a theme that comes with different designs for some templates.
  2. Locate that template in the site editor.
  3. Change the design, and see that there's no indication.

What is your proposed solution?

We could leverage what we already have. The :focus style for that same element already has a visual hint (border with the admin accent color). We know with the data-active-item which element is active.

The other option, which can also be in line with the design patterns we already have in place, could be replicating what we have for the "selected" state in the "Templates" page of the site editor.

https://github.com/user-attachments/assets/5b42ea7f-6ed3-4d63-9e8a-7e7dd9314d8d

juanfra avatar Sep 06 '24 16:09 juanfra

CC: @scruffian @MaggieCabrera , I think you may have worked on the inspector control. Thank you for looking.

jasmussen avatar Sep 09 '24 07:09 jasmussen

@juanfra @jasmussen I'll look into this and create a PR for the same. Also, I feel like the design of "selected" state in the "Templates" page of the site editor can be used here as well, just without the checkbox.

patil-vipul avatar Sep 25 '24 11:09 patil-vipul

Hey folks! Coming back to this issue after a first round of review on #65917 and wanted to add a clarification to this suggestion:

We know with the data-active-item which element is active

That is true! Although we won't be able to rely on the "active" item to style the "selected" item — there's a difference between the two:

  • active, in this context, refers specifically to the active composite item, ie. the item in the composite widget that has keyboard focus when the composite widget is being interacted with
  • selected is the selected pattern. Active and selected do not always coincide — ie. a user may select a pattern, and then navigate the list again using arrow keys, thus changing the active item without updating the selected item. Having said that, we should make sure that, when a new item gets selected, we update the active item to be the same as the selected item.

This scenario is similar to what happens in https://github.com/WordPress/gutenberg/blob/8a7df39e11758aade23c586b435830a5d35aa5f2/packages/dataviews/src/dataviews-layouts/list/index.tsx

I'm leaving this clarification because folks who are not knowledgeable about how composite widgets and the Composite component work may get confused.

ciampo avatar Oct 08 '24 09:10 ciampo

Thanks for the clarification Marco! Indeed, the suggestion is to add styling over the "selected" element.

That is true! Although we won't be able to rely on the "active" item to style the "selected" item

Definitely! I referenced the data-active-item to show that we have some data available, but we agree that the style should be applied to the "selected" element.

juanfra avatar Oct 08 '24 10:10 juanfra

Hi @ciampo , @juanfra

Thanks for all the details and explanations that you have shared.

Now it is more clear regarding the scenario that we need to handle. So I will look into these points in details and work on some alternative solutions.

Just clarifying that, we need the selected pattern styling along with this, right?

Regards, Benazeer

benazeer-ben avatar Oct 09 '24 10:10 benazeer-ben

Thanks @benazeer-ben

Just clarifying that, we need the selected pattern styling along with this, right?

We need to highlight which design is selected, right.

juanfra avatar Oct 09 '24 15:10 juanfra

Hi @ciampo

I have updated the code as per your feedbacks and committed. So please have a look on that and share your thoughts on this.

I have also added separate explanations for each feedback that you have provided.

So now, we are highlighting which design is selected.

Regard, Benazeer.

benazeer-ben avatar Oct 10 '24 07:10 benazeer-ben

@WordPress/gutenberg-design , could you advise on the styles for the selected design (pattern) ? I have a draft proposal in https://github.com/WordPress/gutenberg/pull/66185 but it definitely needs some design feedback

ciampo avatar Oct 18 '24 08:10 ciampo

Can we use the same active state as is designed for style variations here?

Image

jasmussen avatar Oct 18 '24 08:10 jasmussen

Got it — so the standard "primary color" (blueberry) outline for focused items, and a black outline for selected.

https://github.com/user-attachments/assets/330d88bf-378f-459e-9f3f-0959c5377b9b

Focus styles and hover styles should override selected styles.

ciampo avatar Oct 18 '24 13:10 ciampo

Yes. We can evolve the treatment if need be, for the moment the main point is they should be the same.

jasmussen avatar Oct 18 '24 13:10 jasmussen