Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global Styles Sidebar: tweak preview box #39978

Merged
merged 3 commits into from
Apr 4, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions packages/edit-site/src/components/global-styles/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ const secondFrame = {
},
};

const normalizedWidth = 250;
const normalizedWidth = 248;
const normalizedHeight = 152;

const normalizedColorSwatchSize = 32;

const StylesPreview = ( { label, isFocused } ) => {
const [ fontWeight ] = useStyle( 'typography.fontWeight' );
Expand Down Expand Up @@ -81,7 +84,7 @@ const StylesPreview = ( { label, isFocused } ) => {
className="edit-site-global-styles-preview__iframe"
head={ <EditorStyles styles={ styles } /> }
style={ {
height: 150 * ratio,
height: normalizedHeight * ratio,
visibility: ! width ? 'hidden' : 'visible',
} }
onMouseEnter={ () => setIsHovered( true ) }
Expand All @@ -91,7 +94,7 @@ const StylesPreview = ( { label, isFocused } ) => {
{ containerResizeListener }
<motion.div
style={ {
height: 150 * ratio,
height: normalizedHeight * ratio,
width: '100%',
background: gradientValue ?? backgroundColor,
cursor: 'pointer',
Expand Down Expand Up @@ -133,10 +136,15 @@ const StylesPreview = ( { label, isFocused } ) => {
<div
key={ slug }
style={ {
height: 30 * ratio,
width: 30 * ratio,
height:
normalizedColorSwatchSize * ratio,
width:
normalizedColorSwatchSize * ratio,
background: color,
borderRadius: 15 * ratio,
borderRadius:
( normalizedColorSwatchSize *
ratio ) /
2,
} }
/>
) ) }
Expand Down