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
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,21 @@ import {
*/
import type { Color, Gradient } from './types';

const ColorExamples = ( { colors, type } ): JSX.Element | null => {
const ColorExamples = ( { colors, type, columns = 2 } ): JSX.Element | null => {
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!

const className =
type === 'gradients'
? __experimentalGetGradientClass( color.slug )
: getColorClassName( 'background-color', color.slug );
const classes = clsx(
'edit-site-style-book__color-example',
`edit-site-style-book__color-example__${ columns }-col`,
className
);

Expand Down
4 changes: 4 additions & 0 deletions packages/edit-site/src/components/style-book/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ export const STYLE_BOOK_IFRAME_STYLES = `
border: 1px solid #ddd;
}

.edit-site-style-book__color-example__4-col {
height: 32px;
}

.edit-site-style-book__examples.is-wide .edit-site-style-book__example {
flex-direction: row;
}
Expand Down
6 changes: 5 additions & 1 deletion packages/edit-site/src/components/style-book/examples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ function getOverviewBlockExamples(
title: __( 'Colors' ),
category: 'overview',
content: (
<ColorExamples colors={ themePalette.colors } type={ colors } />
<ColorExamples
colors={ themePalette.colors }
type={ colors }
columns={ 4 }
/>
),
};

Expand Down
Loading