Skip to content

Commit 39f67bd

Browse files
author
Nikos Katsikanis
committed
update to full width
1 parent c8a29a7 commit 39f67bd

File tree

3 files changed

+44
-17
lines changed

3 files changed

+44
-17
lines changed

css/common.css

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ body {
2323
padding: 0;
2424
height: 100vh;
2525
transition:
26-
background-color 0.5s,
27-
color 0.5s;
26+
background-color 0.5s,
27+
color 0.5s;
2828
}
2929

3030
main {
@@ -65,3 +65,25 @@ a {
6565
margin: 0;
6666
font-weight: normal;
6767
}
68+
69+
/* -------------------------------------------------
70+
* Utility: Full-bleed breakout (safe “50vw” method)
71+
* Use to make an element span the full viewport
72+
* even inside padded / max-width containers.
73+
* Example: <section class="u-breakout u-breakout--clip">…</section>
74+
* ------------------------------------------------- */
75+
.u-breakout {
76+
position: relative;
77+
left: 50%;
78+
right: 50%;
79+
margin-left: -50vw;
80+
margin-right: -50vw;
81+
width: 100vw;
82+
max-width: 100vw;
83+
display: block;
84+
}
85+
86+
/* Optional: hide any overflow to avoid stray scrollbars */
87+
.u-breakout--clip {
88+
overflow: hidden;
89+
}

js/components/fullscreen-hero.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// File: js/components/hero.js
1+
// File: js/components/fullscreen-hero.js
22
// Repository: https://github.com/quantuminformation/vanillajs-patterns
33

44
/**
@@ -93,13 +93,15 @@ export default (hostComponent) => {
9393
margin-bottom: 1.5rem;
9494
}
9595
</style>
96-
<div class="hero-container">
97-
<div class="hero-overlay"></div>
98-
<div class="hero-content">
99-
<h1 class="hero-header">${header}</h1>
100-
<p class="hero-text">${text}</p>
101-
<a href="${buttonLink}" class="button transparent squarify">${buttonText}</a>
96+
<section class="u-breakout u-breakout--clip">
97+
<div class="hero-container">
98+
<div class="hero-overlay"></div>
99+
<div class="hero-content">
100+
<h1 class="hero-header">${header}</h1>
101+
<p class="hero-text">${text}</p>
102+
<a href="${buttonLink}" class="button transparent squarify">${buttonText}</a>
103+
</div>
102104
</div>
103-
</div>
105+
</section>
104106
`;
105107
};

js/components/narrow-hero.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// Updated narrow-hero component to maintain padding and a fixed height
1+
// File: js/components/narrow-hero.js
2+
// Repository: https://github.com/quantuminformation/vanillajs-patterns
23

34
export default (hostComponent) => {
45
const { header = "Default Header", text = "" } = hostComponent.dataset;
@@ -45,13 +46,15 @@ export default (hostComponent) => {
4546
}
4647
</style>
4748
48-
<section class="narrow-hero">
49-
<div class="narrow-hero-overlay">
50-
<div class="narrow-hero-content">
51-
<h1>${header}</h1>
52-
<p>${text}</p>
49+
<section class="u-breakout u-breakout--clip">
50+
<section class="narrow-hero">
51+
<div class="narrow-hero-overlay">
52+
<div class="narrow-hero-content">
53+
<h1>${header}</h1>
54+
<p>${text}</p>
55+
</div>
5356
</div>
54-
</div>
57+
</section>
5558
</section>
5659
`;
5760
};

0 commit comments

Comments
 (0)