Skip to content

Commit 35d21de

Browse files
author
Dovydas Ceilutka
committed
Solved exercise wesbos#5
1 parent 3ea31a5 commit 35d21de

File tree

2 files changed

+149
-0
lines changed

2 files changed

+149
-0
lines changed

05 - Flex Panel Gallery/app.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
(function init() {
2+
const toggleOpen = function toggleOpen() {
3+
this.classList.toggle('open');
4+
};
5+
const toggleActive = function toggleActive(e) {
6+
if (e.propertyName.includes('flex')) {
7+
this.classList.toggle('open-active');
8+
}
9+
};
10+
const panels = document.querySelectorAll('.panel');
11+
panels.forEach(panel => panel.addEventListener('click', toggleOpen));
12+
panels.forEach(panel => panel.addEventListener('transitionend', toggleActive));
13+
}());

05 - Flex Panel Gallery/index.html

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Flex Panels 💪</title>
6+
<link href='https://fonts.googleapis.com/css?family=Amatic+SC' rel='stylesheet' type='text/css'>
7+
</head>
8+
<body>
9+
<style>
10+
html {
11+
box-sizing: border-box;
12+
background:#ffc600;
13+
font-family:'helvetica neue';
14+
font-size: 20px;
15+
font-weight: 200;
16+
}
17+
body {
18+
margin: 0;
19+
}
20+
*, *:before, *:after {
21+
box-sizing: inherit;
22+
}
23+
24+
.panels {
25+
min-height:100vh;
26+
overflow: hidden;
27+
display: flex;
28+
}
29+
30+
.panel {
31+
background:#6B0F9C;
32+
box-shadow:inset 0 0 0 5px rgba(255,255,255,0.1);
33+
color:white;
34+
text-align: center;
35+
align-items:center;
36+
/* Safari transitionend event.propertyName === flex */
37+
/* Chrome + FF transitionend event.propertyName === flex-grow */
38+
transition:
39+
font-size 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11),
40+
flex 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11),
41+
background 0.2s;
42+
font-size: 20px;
43+
background-size:cover;
44+
background-position:center;
45+
flex: 1;
46+
display: flex;
47+
justify-content: center;
48+
align-items: center;
49+
flex-direction: column;
50+
}
51+
52+
53+
.panel1 { background-image:url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500); }
54+
.panel2 { background-image:url(https://source.unsplash.com/1CD3fd8kHnE/1500x1500); }
55+
.panel3 { background-image:url(https://images.unsplash.com/photo-1465188162913-8fb5709d6d57?ixlib=rb-0.3.5&q=80&fm=jpg&crop=faces&cs=tinysrgb&w=1500&h=1500&fit=crop&s=967e8a713a4e395260793fc8c802901d); }
56+
.panel4 { background-image:url(https://source.unsplash.com/ITjiVXcwVng/1500x1500); }
57+
.panel5 { background-image:url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500); }
58+
59+
.panel > * {
60+
margin:0;
61+
width: 100%;
62+
transition:transform 0.5s;
63+
flex: 1 0 auto;
64+
display: flex;
65+
justify-content: center;
66+
align-items: center;
67+
}
68+
69+
.panel > *:first-child {
70+
transform: translateY(-100%);
71+
}
72+
73+
.panel.open-active > *:first-child {
74+
transform: translateY(0);
75+
}
76+
77+
.panel > *:last-child {
78+
transform: translateY(100%);
79+
}
80+
81+
.panel.open-active > *:last-child {
82+
transform: translateY(0);
83+
}
84+
85+
.panel p {
86+
text-transform: uppercase;
87+
font-family: 'Amatic SC', cursive;
88+
text-shadow:0 0 4px rgba(0, 0, 0, 0.72), 0 0 14px rgba(0, 0, 0, 0.45);
89+
font-size: 2em;
90+
}
91+
.panel p:nth-child(2) {
92+
font-size: 4em;
93+
}
94+
95+
.panel.open {
96+
font-size:40px;
97+
flex: 5;
98+
}
99+
100+
</style>
101+
102+
103+
<div class="panels">
104+
<div class="panel panel1">
105+
<p>Hey</p>
106+
<p>Let's</p>
107+
<p>Dance</p>
108+
</div>
109+
<div class="panel panel2">
110+
<p>Give</p>
111+
<p>Take</p>
112+
<p>Receive</p>
113+
</div>
114+
<div class="panel panel3">
115+
<p>Experience</p>
116+
<p>It</p>
117+
<p>Today</p>
118+
</div>
119+
<div class="panel panel4">
120+
<p>Give</p>
121+
<p>All</p>
122+
<p>You can</p>
123+
</div>
124+
<div class="panel panel5">
125+
<p>Life</p>
126+
<p>In</p>
127+
<p>Motion</p>
128+
</div>
129+
</div>
130+
131+
<script src="./app.js"></script>
132+
133+
134+
135+
</body>
136+
</html>

0 commit comments

Comments
 (0)