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

Stylebook: render overview colors in 4 columns #67597

Merged
merged 5 commits into from
Dec 9, 2024

Conversation

matiasbenedetto
Copy link
Contributor

What?

Stylebook: render overview colors in 4 columns

Why?

Closes: #67592

How?

Add a columns prop to ColorExamples component. Add specific styles for color grids with 4 colors per row.

Testing Instructions

  • Navigate to the stylebook.
  • Observe the colors in the overview page, they should be rendered in 4 columns.
  • Navigate to the Colors tab of the style book.
  • Observe the colors, they should be rendered in 2 columns.

Screenshots or screencast

Before After
Screenshot from 2024-12-04 15-28-06 Screenshot from 2024-12-04 15-27-53 Screenshot from 2024-12-04 15-18-06 Screenshot from 2024-12-04 15-17-22

Copy link

github-actions bot commented Dec 4, 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: matiasbenedetto <[email protected]>
Co-authored-by: tellthemachines <[email protected]>
Co-authored-by: jasmussen <[email protected]>

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

Copy link
Contributor

@tellthemachines tellthemachines 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 the PR, code LGTM and works as expected!

if ( ! colors ) {
return null;
}

return (
<Grid columns={ 2 } rowGap={ 8 } columnGap={ 16 }>
<Grid columns={ columns } rowGap={ 8 } columnGap={ 16 }>
{ colors.map( ( color: Color | Gradient ) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we always want it to show 4 cols, regardless of width? This is how it looks on small screens:

Screenshot 2024-12-05 at 1 45 42 pm

If we wanted to make it responsive, we could instead of columns use templateColumns with something like repeat(auto-fill, minmax(150px, 1fr))

It's not too bad as it is though so I don't feel strongly about it.

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to fall back to 2 columns on mobile, 👍 👍

Copy link
Contributor Author

@matiasbenedetto matiasbenedetto Dec 6, 2024

Choose a reason for hiding this comment

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

👍 ok, thanks for the suggestion. I added that in the latest commits. It adds some complexity that I'm not sure it worth but it looks good.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, LGTM!

Copy link
Contributor

@jasmussen jasmussen left a comment

Choose a reason for hiding this comment

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

@tellthemachines left a good code suggestion for how this could wrap on mobile.

Separately, I've a question around why the column widths here are different:
Screenshot 2024-12-05 at 10 53 50

But since that's probably largely irrelevant with #67546 landed, this one is good. Thank you!

if ( ! colors ) {
return null;
}

return (
<Grid columns={ 2 } rowGap={ 8 } columnGap={ 16 }>
<Grid columns={ columns } rowGap={ 8 } columnGap={ 16 }>
{ colors.map( ( color: Color | Gradient ) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to fall back to 2 columns on mobile, 👍 👍

Copy link

github-actions bot commented Dec 6, 2024

Flaky tests detected in 8c711c1.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12206982841
📝 Reported issues:

@matiasbenedetto matiasbenedetto merged commit 0154339 into trunk Dec 9, 2024
61 of 63 checks passed
@matiasbenedetto matiasbenedetto deleted the fix/stylebook-colors-4-columns branch December 9, 2024 13:14
@github-actions github-actions bot added this to the Gutenberg 19.9 milestone Dec 9, 2024
yogeshbhutkar pushed a commit to yogeshbhutkar/gutenberg that referenced this pull request Dec 18, 2024
* render overview colors in 4 columns

* use templateColums instead of colums to enable responsive columns

* use templateColumns instead of columns

* tweak CSS

Co-authored-by: matiasbenedetto <[email protected]>
Co-authored-by: tellthemachines <[email protected]>
Co-authored-by: jasmussen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Style Book [Type] Enhancement A suggestion for improvement.
Projects
Development

Successfully merging this pull request may close these issues.

Stylebook: Style _landing_ page, the colors should be shown in 4 columns
3 participants