Skip to content

Commit 21f1048

Browse files
committed
Finished overall website
1 parent 15bcf93 commit 21f1048

File tree

5 files changed

+93
-17
lines changed

5 files changed

+93
-17
lines changed

starter/07-Omnifood-Desktop/css/general.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ html {
5757
/* Percentage of user's browser font-size setting */
5858
font-size: 62.5%;
5959
overflow-x: hidden;
60+
61+
scroll-behavior: smooth;
6062
}
6163

6264
body {

starter/07-Omnifood-Desktop/css/queries.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,10 @@ wtf is em? em is the root font size and rem is the current font size
128128
}
129129

130130
/* MOBILE NAVIGATION */
131+
131132
.btn-mobile-nav {
132133
display: block;
134+
z-index: 1000;
133135
}
134136

135137
.main-nav {
@@ -308,3 +310,5 @@ wtf is em? em is the root font size and rem is the current font size
308310
2 / 4 / 8 / 12 / 16 / 24 / 32 / 48 / 64 / 80 / 96 / 128
309311
310312
*/
313+
314+
/* 09 Omnifood Project, 139 lecture is incomplete */

starter/07-Omnifood-Desktop/css/style.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,24 @@
7575
display: none;
7676
}
7777

78+
/* STICKY NAVIGATION */
79+
.sticky .header {
80+
position: fixed;
81+
top: 0;
82+
bottom: 0;
83+
width: 100%;
84+
height: 8rem;
85+
padding-top: 0;
86+
padding-bottom: 0;
87+
background-color: rgba(255, 255, 255, 0.97);
88+
z-index: 100;
89+
box-shadow: 0 1.2rem 3.2rem rgba(0, 0, 0, 0.03);
90+
}
91+
92+
.sticky .section-hero {
93+
margin-top: 9.6rem;
94+
}
95+
7896
/**************************/
7997
/* HERO SECTION */
8098
/**************************/

starter/07-Omnifood-Desktop/index.html

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.esm.js"
1818
></script>
1919

20+
<script defer src="js/script.js"></script>
21+
2022
<title>Omnifood</title>
2123
</head>
2224
<body>
@@ -26,11 +28,13 @@
2628
</a>
2729
<nav class="main-nav">
2830
<ul class="main-nav-list">
29-
<li><a class="main-nav-link" href="#">How it works</a></li>
30-
<li><a class="main-nav-link" href="#">Meals</a></li>
31-
<li><a class="main-nav-link" href="#">Testimonials</a></li>
32-
<li><a class="main-nav-link" href="#">Pricing</a></li>
33-
<li><a class="main-nav-link nav-cta" href="#">Try for free</a></li>
31+
<li><a class="main-nav-link" href="#how">How it works</a></li>
32+
<li><a class="main-nav-link" href="#sample-meals">Meals</a></li>
33+
<li>
34+
<a class="main-nav-link" href="#sect-testimonials">Testimonials</a>
35+
</li>
36+
<li><a class="main-nav-link" href="#pricing">Pricing</a></li>
37+
<li><a class="main-nav-link nav-cta" href="#cta">Try for free</a></li>
3438
</ul>
3539
</nav>
3640

@@ -41,7 +45,7 @@
4145
</header>
4246

4347
<main>
44-
<section class="section-hero">
48+
<section class="section-hero" id="hero">
4549
<div class="hero">
4650
<div class="hero-text-box">
4751
<h1 class="heading-primary">
@@ -52,10 +56,10 @@ <h1 class="heading-primary">
5256
eat healthy again. Tailored to your personal tastes and
5357
nutritional needs.
5458
</p>
55-
<a href="#" class="btn btn--full margin-right-sm"
59+
<a href="#cta" class="btn btn--full margin-right-sm"
5660
>Start eating well</a
5761
>
58-
<a href="#" class="btn btn--outline">Learn more &darr;</a>
62+
<a href="#how" class="btn btn--outline">Learn more &darr;</a>
5963
<div class="delivered-meals">
6064
<div class="delivered-imgs">
6165
<img src="img/customers/customer-1.jpg" alt="Customer photo" />
@@ -80,7 +84,7 @@ <h1 class="heading-primary">
8084
</div>
8185
</section>
8286

83-
<section class="section-featured">
87+
<section class="section-featured" id="feature">
8488
<div class="container">
8589
<h2 class="heading-featured-in">As featured in</h2>
8690
<div class="logos">
@@ -99,7 +103,7 @@ <h2 class="heading-featured-in">As featured in</h2>
99103
</div>
100104
</section>
101105

102-
<section class="section-how">
106+
<section class="section-how" id="how">
103107
<div class="container">
104108
<span class="subheading">How it works</span>
105109
<h2 class="heading-secondary">
@@ -168,7 +172,7 @@ <h3 class="heading-tertiary">Receive meals at convenient time</h3>
168172
</div>
169173
</section>
170174

171-
<section class="section-meals">
175+
<section class="section-meals" id="sample-meals">
172176
<div class="container center-text">
173177
<span class="subheading">Sample Meals</span>
174178
<h2 class="heading-secondary">
@@ -288,7 +292,7 @@ <h3 class="heading-tertiary">Works with any diet:</h3>
288292
</div>
289293
</section>
290294

291-
<section class="section-testimonials">
295+
<section class="section-testimonials" id="sect-testimonials">
292296
<div class="testimonials-container">
293297
<span class="subheading">Testimonials</span>
294298
<h2 class="heading-secondary">Once you try it, you can't go back</h2>
@@ -425,7 +429,7 @@ <h2 class="heading-secondary">Once you try it, you can't go back</h2>
425429
</div>
426430
</section>
427431

428-
<section class="section-pricing">
432+
<section class="section-pricing" id="pricing">
429433
<div class="container">
430434
<span class="subheading">Pricing</span>
431435
<h2 class="heading-secondary">
@@ -541,7 +545,7 @@ <h2 class="heading-secondary">
541545
</div>
542546
</section>
543547

544-
<section class="section-cta">
548+
<section class="section-cta" id="cta">
545549
<div class="container">
546550
<div class="cta">
547551
<div class="cta-text-box">
@@ -624,7 +628,8 @@ <h2 class="heading-secondary">Get your first meal for free!</h2>
624628
</ul>
625629

626630
<p class="copyright">
627-
Copyright &copy; 2027 by Omnifood, Inc. All rights reserved.
631+
Copyright &copy; <span class="year">2027</span> by Omnifood, Inc.
632+
All rights reserved.
628633
</p>
629634
</div>
630635
<div class="address-col">

starter/07-Omnifood-Desktop/js/script.js

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,54 @@
11
///////////////////////////////////////////////////////////
2+
console.log("Hello World!");
3+
4+
const myName = "Gillian Gavino";
5+
const h1 = document.querySelector(".heading-primary");
6+
7+
// h1.addEventListener("click", function () {
8+
// h1.textContent = myName;
9+
// h1.style.backgroundColor = "red";
10+
// h1.style.padding = "5rem";
11+
// });
12+
13+
///////////////////////////////////////////////////////////
14+
// Set current year
15+
const yearEl = document.querySelector(".year");
16+
const currentYear = new Date().getFullYear();
17+
yearEl.textContent = currentYear;
18+
19+
///////////////////////////////////////////////////////////
20+
// Make mobile navigation work
21+
const btnNav = document.querySelector(".btn-mobile-nav");
22+
const headerEl = document.querySelector(".header");
23+
24+
btnNav.addEventListener("click", function () {
25+
headerEl.classList.toggle("nav-open");
26+
});
27+
28+
///////////////////////////////////////////////////////////
29+
// Making nav sticky
30+
const sectionHeroEl = document.querySelector(".section-hero");
31+
const bodyEl = document.querySelector("body");
32+
33+
const obs = new IntersectionObserver(
34+
function (entries) {
35+
const ent = entries[0];
36+
37+
if (!ent.isIntersecting) bodyEl.classList.add("sticky");
38+
39+
if (ent.isIntersecting) bodyEl.classList.remove("sticky");
40+
},
41+
{
42+
root: null,
43+
threshold: 0,
44+
rootMargin: "-80px",
45+
}
46+
);
47+
obs.observe(sectionHeroEl);
48+
249
// Fixing flexbox gap property missing in some Safari versions
350
function checkFlexGap() {
4-
var flex = document.createElement("div");
51+
const flex = document.createElement("div");
552
flex.style.display = "flex";
653
flex.style.flexDirection = "column";
754
flex.style.rowGap = "1px";
@@ -10,7 +57,7 @@ function checkFlexGap() {
1057
flex.appendChild(document.createElement("div"));
1158

1259
document.body.appendChild(flex);
13-
var isSupported = flex.scrollHeight === 1;
60+
const isSupported = flex.scrollHeight === 1;
1461
flex.parentNode.removeChild(flex);
1562
console.log(isSupported);
1663

0 commit comments

Comments
 (0)