Skip to content

Commit

Permalink
Try no using blocks for color tab examples
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw committed Oct 11, 2024
1 parent 40f168a commit 729334e
Show file tree
Hide file tree
Showing 7 changed files with 248 additions and 214 deletions.
44 changes: 44 additions & 0 deletions packages/edit-site/src/components/style-book/color-examples.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* External dependencies
*/
import clsx from 'clsx';

/**
* WordPress dependencies
*/
import { __experimentalGrid as Grid } from '@wordpress/components';
import { View } from '@wordpress/primitives';
import {
getColorClassName,
__experimentalGetGradientClass,
} from '@wordpress/block-editor';

/**
* Internal dependencies
*/
import type { Color, Gradient } from './types';

const ColorExamples = ( { colors, type } ): JSX.Element | null => {
if ( ! colors ) {
return null;
}

return (
<Grid columns={ 2 } rowGap={ 8 } columnGap={ 16 }>
{ colors.map( ( color: Color | Gradient ) => {
const className =
type === 'gradients'
? __experimentalGetGradientClass( color.slug )
: getColorClassName( 'background-color', color.slug );
const classes = clsx(
'edit-site-style-book__color-example',
className
);

return <View key={ color.slug } className={ classes } />;
} ) }
</Grid>
);
};

export default ColorExamples;
21 changes: 21 additions & 0 deletions packages/edit-site/src/components/style-book/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,27 @@ export const STYLE_BOOK_IFRAME_STYLES = `
outline: 3px solid transparent;
}
.edit-site-style-book__duotone-example > div:first-child {
display: flex;
aspect-ratio: 16 / 9;
grid-row: span 1;
grid-column: span 2;
}
.edit-site-style-book__duotone-example img {
width: 100%;
height: 100%;
object-fit: cover;
}
.edit-site-style-book__duotone-example > div:not(:first-child) {
height: 20px;
border: 1px solid #ddd;
}
.edit-site-style-book__color-example {
height: 52px;
border: 1px solid #ddd;
}
.edit-site-style-book__examples.is-wide .edit-site-style-book__example {
flex-direction: row;
}
Expand Down
53 changes: 53 additions & 0 deletions packages/edit-site/src/components/style-book/duotone-examples.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* WordPress dependencies
*/
import { __experimentalGrid as Grid } from '@wordpress/components';
import { View } from '@wordpress/primitives';

/**
* Internal dependencies
*/
import type { Duotone } from './types';

const DuotoneExamples = ( { duotones } ): JSX.Element | null => {
if ( ! duotones ) {
return null;
}

return (
<Grid columns={ 2 } rowGap={ 16 } columnGap={ 16 }>
{ duotones.map( ( duotone: Duotone ) => {
return (
<Grid
key={ duotone.slug }
className="edit-site-style-book__duotone-example"
columns={ 2 }
rowGap={ 8 }
columnGap={ 8 }
>
<View>
<img
alt={ `Duotone example: ${ duotone.slug }` }
src="https://s.w.org/images/core/5.3/MtBlanc1.jpg"
style={ {
filter: `url(#wp-duotone-${ duotone.slug })`,
} }
/>
</View>
{ duotone.colors.map( ( color ) => {
return (
<View
key={ color }
className="edit-site-style-book__color-example"
style={ { backgroundColor: color } }
/>
);
} ) }
</Grid>
);
} ) }
</Grid>
);
};

export default DuotoneExamples;
202 changes: 0 additions & 202 deletions packages/edit-site/src/components/style-book/examples.ts

This file was deleted.

Loading

0 comments on commit 729334e

Please sign in to comment.