-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Global Styles: Create a style preview component (#59498)
* refactor previews into smaller components rafctor to three frames * rename the highlighted colors component * rename preview to preview-styles for consistency * rename the wrapper component * move animation frames to a separate file * cast children to an array * remove animation frames * Update packages/edit-site/src/components/global-styles/highlighted-colors.js Co-authored-by: Ramon <ramonjd@users.noreply.github.com> --------- Co-authored-by: Ramon <ramonjd@users.noreply.github.com> Co-authored-by: scruffian <scruffian@git.wordpress.org> Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
- Loading branch information
1 parent
735ef36
commit 5c84e9f
Showing
7 changed files
with
408 additions
and
505 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
packages/edit-site/src/components/global-styles/highlighted-colors.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __unstableMotion as motion } from '@wordpress/components'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { useStylesPreviewColors } from './hooks'; | ||
|
||
export default function HighlightedColors( { | ||
normalizedColorSwatchSize, | ||
ratio, | ||
} ) { | ||
const { highlightedColors } = useStylesPreviewColors(); | ||
const scaledSwatchSize = normalizedColorSwatchSize * ratio; | ||
return highlightedColors.map( ( { slug, color }, index ) => ( | ||
<motion.div | ||
key={ slug } | ||
style={ { | ||
height: scaledSwatchSize, | ||
width: scaledSwatchSize, | ||
background: color, | ||
borderRadius: scaledSwatchSize / 2, | ||
} } | ||
animate={ { | ||
scale: 1, | ||
opacity: 1, | ||
} } | ||
initial={ { | ||
scale: 0.1, | ||
opacity: 0, | ||
} } | ||
transition={ { | ||
delay: index === 1 ? 0.2 : 0.1, | ||
} } | ||
/> | ||
) ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.