From 049b09d2cea4b3b55ae82ecb249bd37faf4fb76a Mon Sep 17 00:00:00 2001 From: Matias Ventura Date: Wed, 5 Oct 2022 13:35:57 +0200 Subject: [PATCH] Modify Frame animation of styles grid (#39717) Rework animation of color array and hover state. It constructs a backdrop with a blurred out color palette from the json. --- .../src/components/global-styles/preview.js | 137 ++++++++++-------- .../global-styles/screen-style-variations.js | 3 +- 2 files changed, 81 insertions(+), 59 deletions(-) diff --git a/packages/edit-site/src/components/global-styles/preview.js b/packages/edit-site/src/components/global-styles/preview.js index 0fd3e578cfaa0e..66735b2a7b44aa 100644 --- a/packages/edit-site/src/components/global-styles/preview.js +++ b/packages/edit-site/src/components/global-styles/preview.js @@ -21,23 +21,32 @@ import { useGlobalStylesOutput } from './use-global-styles-output'; const firstFrame = { start: { + scale: 1, opacity: 1, - display: 'block', }, hover: { + scale: 0, opacity: 0, - display: 'none', + }, +}; + +const midFrame = { + hover: { + opacity: 1, + }, + start: { + opacity: 0.5, }, }; const secondFrame = { hover: { + scale: 1, opacity: 1, - display: 'block', }, start: { + scale: 0, opacity: 0, - display: 'none', }, }; @@ -46,7 +55,7 @@ const normalizedHeight = 152; const normalizedColorSwatchSize = 32; -const StylesPreview = ( { label, isFocused } ) => { +const StylesPreview = ( { label, isFocused, withHoverView } ) => { const [ fontWeight ] = useStyle( 'typography.fontWeight' ); const [ fontFamily = 'serif' ] = useStyle( 'typography.fontFamily' ); const [ headingFontFamily = fontFamily ] = useStyle( @@ -57,7 +66,6 @@ const StylesPreview = ( { label, isFocused } ) => { ); const [ textColor = 'black' ] = useStyle( 'color.text' ); const [ headingColor = textColor ] = useStyle( 'elements.h1.color.text' ); - const [ linkColor = 'blue' ] = useStyle( 'elements.link.color.text' ); const [ backgroundColor = 'white' ] = useStyle( 'color.background' ); const [ gradientValue ] = useStyle( 'color.gradient' ); const [ styles ] = useGlobalStylesOutput(); @@ -116,7 +124,7 @@ const StylesPreview = ( { label, isFocused } ) => { } } initial="start" animate={ - ( isHovered || isFocused ) && ! disableMotion + ( isHovered || isFocused ) && ! disableMotion && label ? 'hover' : 'start' } @@ -136,41 +144,90 @@ const StylesPreview = ( { label, isFocused } ) => { overflow: 'hidden', } } > -
Aa -
+ - { highlightedColors.map( ( { slug, color } ) => ( + { highlightedColors.map( + ( { slug, color }, index ) => ( + + ) + ) } + + + + + + { paletteColors + .slice( 0, 4 ) + .map( ( { color }, index ) => (
) ) } - { { label && (
{ label }
) } - -
- Aa -
-
- Aa -
-
- { paletteColors && ( - - { paletteColors - .slice( 0, 4 ) - .map( ( { color }, index ) => ( -
- ) ) } - - ) } diff --git a/packages/edit-site/src/components/global-styles/screen-style-variations.js b/packages/edit-site/src/components/global-styles/screen-style-variations.js index 1ea9301aee5eca..39f7b7a1fd9ded 100644 --- a/packages/edit-site/src/components/global-styles/screen-style-variations.js +++ b/packages/edit-site/src/components/global-styles/screen-style-variations.js @@ -87,6 +87,7 @@ function Variation( { variation } ) {
@@ -125,7 +126,7 @@ function ScreenStyleVariations() { back="/" title={ __( 'Browse styles' ) } description={ __( - 'Choose a different style combination for the theme styles' + 'Choose a variation to change the look of the site.' ) } />