1
Fork 0

Add hero and sidebar mockup

This commit is contained in:
Jake Howard 2024-08-13 23:05:02 +01:00
parent f207a67a96
commit 0dc69763bc
Signed by: jake
GPG key ID: 57AFB45680EDD477
3 changed files with 156 additions and 4 deletions

View file

@ -0,0 +1,46 @@
<html>
<head>
<link rel="stylesheet" href="./index.scss" />
</head>
<body>
<div class="hero" id="hero">
<div class="details-wrapper" id="details">
<div class="details">
<small>Breadcrumb</small>
<h1>Title</h1>
<p>Details</p>
</div>
</div>
</div>
<main>
<div class="spacer"></div>
<div class="content-wrapper">
<p>Content</p>
<img src="https://placehold.co/2000x200" />
<img src="https://placehold.co/2000x200" class="inset" />
<img src="https://placehold.co/2000x200" class="bleed" />
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
<p>Content</p>
</div>
<div class="sidebar">
<div class="sidebar-inner">
<p>Sidebar</p>
</div>
</div>
</main>
<script async src="../hero/index.js" type="module"></script>
</body>
</html>

104
src/hero-sidebar/index.scss Normal file
View file

@ -0,0 +1,104 @@
@import "normalize.css";
body,
html {
height: 100%;
font-size: 18px;
}
$content-width: 85ch;
$content-padding: 16px;
$bleed-ratio: 0.2;
$details-bg: black;
$details-padding: $content-padding;
.hero {
height: 50vh;
background-color: red;
display: flex;
align-items: flex-end;
justify-content: center;
.details-wrapper {
background-color: transparentize($details-bg, 0.6);
color: white;
line-height: 1;
width: calc(100% - ($details-padding * 2));
padding: 0 $details-padding;
transition-duration: 0.15s;
transition-property: background-color, width;
&.stuck {
position: fixed;
top: 0;
background-color: transparentize($details-bg, 0.1);
width: $content-width;
}
}
.details {
width: $content-width;
max-width: 100%;
margin: 1rem auto;
h1 {
margin: 0;
margin-bottom: 0.75rem;
margin-top: 0.5rem;
font-size: 3.5rem;
}
p {
margin: 0;
}
}
}
main {
display: flex;
}
.spacer {
flex-grow: 1;
flex-shrink: 10;
flex-basis: 200px;
}
.content-wrapper {
display: grid;
width: $content-width * (1 + $bleed-ratio);
grid-template-columns:
1fr
$content-width
1fr;
& > * {
grid-column: 2;
width: 100%;
}
.bleed {
grid-column: 1 / -1;
max-width: 100vw;
margin-left: auto;
margin-right: auto;
}
.inset {
max-width: calc($content-width * (1 - $bleed-ratio));
margin-left: auto;
margin-right: auto;
}
}
.sidebar {
flex-grow: 1;
flex-shrink: 10;
flex-basis: 200px;
.sidebar-inner {
position: sticky;
top: 0;
}
}

View file

@ -51,9 +51,11 @@ window.addEventListener("load", function () {
handleDetailsStick(hero); handleDetailsStick(hero);
window.addEventListener("resize", handleScrollIndicator); if (SCROLL_INDICATOR) {
window.addEventListener("scroll", handleScrollIndicator); window.addEventListener("resize", handleScrollIndicator);
window.addEventListener("scroll", handleScrollIndicator);
// Initialize the indicator // Initialize the indicator
handleScrollIndicator(); handleScrollIndicator();
}
}); });