Skip to content

Commit

Permalink
Don't apply the background and text colors to typography previews
Browse files Browse the repository at this point in the history
  • Loading branch information
scruffian committed Jun 5, 2024
1 parent 06198d1 commit b1267b3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
17 changes: 11 additions & 6 deletions packages/edit-site/src/components/global-styles/preview-iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default function PreviewIframe( {
label,
isFocused,
withHoverView,
previewStyles,
} ) {
const [ backgroundColor = 'white' ] = useGlobalStyle( 'color.background' );
const [ gradientValue ] = useGlobalStyle( 'color.gradient' );
Expand Down Expand Up @@ -109,6 +110,15 @@ export default function PreviewIframe( {
}, [ styles ] );
const isReady = !! width;

const calculatedStyles = {
height: normalizedHeight * ratio,
width: '100%',
background: gradientValue ?? backgroundColor,
cursor: withHoverView ? 'pointer' : undefined,
// Override these styles with the previewStyles prop.
...previewStyles,
};

return (
<>
<div style={ { position: 'relative' } }>
Expand All @@ -126,12 +136,7 @@ export default function PreviewIframe( {
>
<EditorStyles styles={ editorStyles } />
<motion.div
style={ {
height: normalizedHeight * ratio,
width: '100%',
background: gradientValue ?? backgroundColor,
cursor: withHoverView ? 'pointer' : undefined,
} }
style={ calculatedStyles }
initial="start"
animate={
( isHovered || isFocused ) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export default function TypographyVariations( { title, gap = 2 } ) {
<PreviewIframe
label={ variation?.title }
isFocused={ isFocused }
previewStyles={ {
background: '#ffffff',
color: '#000000',
} }
>
{ ( { ratio, key } ) => (
<HStack
Expand Down

0 comments on commit b1267b3

Please sign in to comment.