Skip to content

Commit

Permalink
Add the option prop to show the global style in iframe
Browse files Browse the repository at this point in the history
This would fix the issue added in WordPress#61217, This wanted to remove the color combination in the typography preview shown in the styles editor page
  • Loading branch information
hbhalodia committed May 1, 2024
1 parent 38d0a43 commit fb5c81a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default function PreviewIframe( {
label,
isFocused,
withHoverView,
addGlobalStyles = true,
} ) {
const [ backgroundColor = 'white' ] = useGlobalStyle( 'color.background' );
const [ gradientValue ] = useGlobalStyle( 'color.gradient' );
Expand Down Expand Up @@ -129,7 +130,10 @@ export default function PreviewIframe( {
style={ {
height: normalizedHeight * ratio,
width: '100%',
background: gradientValue ?? backgroundColor,
color: addGlobalStyles ? undefined : '#000',
background: addGlobalStyles
? gradientValue ?? backgroundColor
: '#fff',
cursor: withHoverView ? 'pointer' : undefined,
} }
initial="start"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ function ScreenTypography() {
/>
<div className="edit-site-global-styles-screen">
<VStack spacing={ 7 }>
<TypographyVariations title={ __( 'Presets' ) } />
<TypographyVariations
addGlobalStyles={ false }
title={ __( 'Presets' ) }
/>
{ ! window.__experimentalDisableFontLibrary &&
fontLibraryEnabled && <FontFamilies /> }
<TypographyElements />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ import PreviewIframe from '../preview-iframe';
import Variation from './variation';
import Subtitle from '../subtitle';

export default function TypographyVariations( { title, gap = 2 } ) {
export default function TypographyVariations( {
title,
gap = 2,
addGlobalStyles = false,
} ) {
const typographyVariations = useTypographyVariations();

if ( ! typographyVariations?.length ) {
Expand All @@ -37,6 +41,7 @@ export default function TypographyVariations( { title, gap = 2 } ) {
<Variation key={ index } variation={ variation }>
{ ( isFocused ) => (
<PreviewIframe
addGlobalStyles={ addGlobalStyles }
label={ variation?.title }
isFocused={ isFocused }
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ function SidebarNavigationScreenGlobalStylesContent() {
) }
{ typographyVariations?.length && (
<TypographyVariations
addGlobalStyles
title={ __( 'Typography' ) }
gap={ gap }
/>
Expand Down

0 comments on commit fb5c81a

Please sign in to comment.