Skip to content

Commit

Permalink
Site screenshot: Add a background color, and overlap the desktop/mobi…
Browse files Browse the repository at this point in the history
…le screenshots on page headers

Fixes #153
  • Loading branch information
ryelle committed Sep 19, 2023
1 parent 120dec3 commit 3a7ca52
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ function inject_background_color( $block_content, $block, $instance ) {
// Remove existing background if there is one.
$style = preg_replace( '/background-color:[^;]+;/', '', $style );
$style .= ';background-color:' . esc_attr( $color );
$style .= ';--wporg-site-screenshot--background-color:' . esc_attr( $color );
$html->set_attribute( 'style', $style );

return $html->get_updated_html();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

.has-feature-color-background & {
flex: 1;
// This value is set if the current page has a custom feature color. Otherwise, use the fallback.
background-color: var(--wporg-site-screenshot--background-color, #f6f6f6);

&:first-child {
flex: 4;
Expand Down Expand Up @@ -63,3 +65,16 @@
aspect-ratio: 375 / 600;
}
}

.wp-block-group.has-feature-color-background > .wp-block-group {
// Scale 20px at 800 wide to 80px at 1200 wide.
gap: clamp(20px, calc(15vw + -100px), 80px);

@media (max-width: 781px) {
gap: 0;

.is-size-mobile {
margin-left: -20%;
}
}
}

0 comments on commit 3a7ca52

Please sign in to comment.