Skip to content

Commit ec0ec04

Browse files
committed
Implement menu.
1 parent 7e74ca0 commit ec0ec04

File tree

4 files changed

+74
-1
lines changed

4 files changed

+74
-1
lines changed

css-gradient-based-app-step-1/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"build": "parcel build src/index.html",
1010
"postbuild:not-fully-working": "parcel build 'public/**/*'",
1111
"postbuild": "ncp ./public ./dist --filter '**/*.*'",
12-
"dev": "parcel src/index.html",
12+
"dev": "parcel src/index.html --no-cache",
1313
"start": "pm2 start 'npm run dev' --name app",
1414
"restart": "pm2 restart app",
1515
"stop": "pm2 kill",

css-gradient-based-app-step-1/src/css/main.css

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,43 @@ figcaption {
5353
font-size: 1.3em;
5454
font-weight: bolder;
5555
}
56+
57+
/* menu */
58+
59+
nav {
60+
background: #fff;
61+
}
62+
63+
ul {
64+
display: none;
65+
}
66+
67+
ul.active {
68+
display: block;
69+
position: absolute;
70+
background: #fff;
71+
height: 100%;
72+
width: 50%;
73+
left: 0;
74+
top: 0;
75+
}
76+
77+
ul {
78+
margin-top: 0;
79+
padding-left: 0;
80+
list-style-type: none;
81+
}
82+
83+
ul li a {
84+
color: #000;
85+
text-decoration: none;
86+
text-transform: uppercase;
87+
font-size: .8em;
88+
display: block;
89+
padding: 1.5em 3em;
90+
background-color: rgba(255, 255, 255, .35);
91+
}
92+
93+
ul li a:hover {
94+
background-color: rgba(232, 232, 232, 0.35);
95+
}

css-gradient-based-app-step-1/src/index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717
<figcaption>Max Simko</figcaption>
1818
</figure>
1919
<img src="../public/images/menu.svg" alt="image">
20+
<nav>
21+
<ul>
22+
<li><a href="#">Home</a></li>
23+
<li><a href="#">About me</a></li>
24+
<li><a href="#">Portfolio</a></li>
25+
<li><a href="#">Contacts</a></li>
26+
</ul>
27+
</nav>
2028
</aside>
2129
<main>
2230
<!-- main site content -->

css-gradient-based-app-step-1/src/js/app.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,28 @@ WebFont.load({
99
],
1010
},
1111
});
12+
13+
function $(selector) {
14+
return document.querySelector(selector);
15+
}
16+
17+
function findMenu() {
18+
return $('aside nav ul');
19+
}
20+
21+
function findImg() {
22+
return $('img');
23+
}
24+
25+
function toggleMenu(e) {
26+
const menu = findMenu();
27+
// menu.display = !menu || !menu.display || menu.display !== 'block' ? 'block' : 'none';
28+
menu.classList.toggle('active');
29+
e.preventDefault();
30+
}
31+
32+
function onDomContentLoaded() {
33+
findImg().addEventListener('click', toggleMenu, false);
34+
}
35+
36+
document.addEventListener('DOMContentLoaded', onDomContentLoaded, false);

0 commit comments

Comments
 (0)