Skip to content

Commit a649951

Browse files
authored
Merge pull request #6 from dustinleer/completed
Adds scripts and style files, completes exercise
2 parents 88f0e20 + 22f2f57 commit a649951

File tree

3 files changed

+148
-107
lines changed

3 files changed

+148
-107
lines changed
+33-107
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,40 @@
11
<!DOCTYPE html>
22
<html lang="en">
33
<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'>
4+
<meta charset="UTF-8">
5+
<title>Flex Panels 💪</title>
6+
<link rel="stylesheet" href="style.css">
7+
<link href='https://fonts.googleapis.com/css?family=Amatic+SC' rel='stylesheet' type='text/css'>
78
</head>
89
<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-
18-
body {
19-
margin: 0;
20-
}
21-
22-
*, *:before, *:after {
23-
box-sizing: inherit;
24-
}
25-
26-
.panels {
27-
min-height: 100vh;
28-
overflow: hidden;
29-
}
30-
31-
.panel {
32-
background: #6B0F9C;
33-
box-shadow: inset 0 0 0 5px rgba(255,255,255,0.1);
34-
color: white;
35-
text-align: center;
36-
align-items: center;
37-
/* Safari transitionend event.propertyName === flex */
38-
/* Chrome + FF transitionend event.propertyName === flex-grow */
39-
transition:
40-
font-size 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11),
41-
flex 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11),
42-
background 0.2s;
43-
font-size: 20px;
44-
background-size: cover;
45-
background-position: center;
46-
}
47-
48-
.panel1 { background-image:url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500); }
49-
.panel2 { background-image:url(https://source.unsplash.com/rFKUFzjPYiQ/1500x1500); }
50-
.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); }
51-
.panel4 { background-image:url(https://source.unsplash.com/ITjiVXcwVng/1500x1500); }
52-
.panel5 { background-image:url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500); }
53-
54-
/* Flex Children */
55-
.panel > * {
56-
margin: 0;
57-
width: 100%;
58-
transition: transform 0.5s;
59-
}
60-
61-
.panel p {
62-
text-transform: uppercase;
63-
font-family: 'Amatic SC', cursive;
64-
text-shadow: 0 0 4px rgba(0, 0, 0, 0.72), 0 0 14px rgba(0, 0, 0, 0.45);
65-
font-size: 2em;
66-
}
67-
68-
.panel p:nth-child(2) {
69-
font-size: 4em;
70-
}
71-
72-
.panel.open {
73-
font-size: 40px;
74-
}
75-
76-
</style>
77-
78-
79-
<div class="panels">
80-
<div class="panel panel1">
81-
<p>Hey</p>
82-
<p>Let's</p>
83-
<p>Dance</p>
84-
</div>
85-
<div class="panel panel2">
86-
<p>Give</p>
87-
<p>Take</p>
88-
<p>Receive</p>
89-
</div>
90-
<div class="panel panel3">
91-
<p>Experience</p>
92-
<p>It</p>
93-
<p>Today</p>
94-
</div>
95-
<div class="panel panel4">
96-
<p>Give</p>
97-
<p>All</p>
98-
<p>You can</p>
99-
</div>
100-
<div class="panel panel5">
101-
<p>Life</p>
102-
<p>In</p>
103-
<p>Motion</p>
104-
</div>
105-
</div>
106-
107-
<script>
108-
109-
</script>
110-
111-
112-
10+
<div class="panels">
11+
<div class="panel panel1">
12+
<p>Hey</p>
13+
<p>Let's</p>
14+
<p>Dance</p>
15+
</div>
16+
<div class="panel panel2">
17+
<p>Give</p>
18+
<p>Take</p>
19+
<p>Receive</p>
20+
</div>
21+
<div class="panel panel3">
22+
<p>Experience</p>
23+
<p>It</p>
24+
<p>Today</p>
25+
</div>
26+
<div class="panel panel4">
27+
<p>Give</p>
28+
<p>All</p>
29+
<p>You can</p>
30+
</div>
31+
<div class="panel panel5">
32+
<p>Life</p>
33+
<p>In</p>
34+
<p>Motion</p>
35+
</div>
36+
</div>
37+
38+
<script type="text/javascript" src="scripts.js"></script>
11339
</body>
11440
</html>

05 - Flex Panel Gallery/scripts.js

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

05 - Flex Panel Gallery/style.css

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
html {
2+
box-sizing: border-box;
3+
background: #ffc600;
4+
font-family: 'helvetica neue';
5+
font-size: 20px;
6+
font-weight: 200;
7+
}
8+
9+
body {
10+
margin: 0;
11+
}
12+
13+
*, *:before, *:after {
14+
box-sizing: inherit;
15+
}
16+
17+
.panels {
18+
min-height: 100vh;
19+
overflow: hidden;
20+
display: flex;
21+
}
22+
23+
.panel {
24+
background: #6B0F9C;
25+
box-shadow: inset 0 0 0 5px rgba(255,255,255,0.1);
26+
color: white;
27+
text-align: center;
28+
align-items: center;
29+
/* Safari transitionend event.propertyName === flex */
30+
/* Chrome + FF transitionend event.propertyName === flex-grow */
31+
transition:
32+
font-size 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11),
33+
flex 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11),
34+
background 0.2s;
35+
font-size: 20px;
36+
background-size: cover;
37+
background-position: center;
38+
flex: 1;
39+
justify-content: center;
40+
align-items: center;
41+
display: flex;
42+
flex-direction: column;
43+
}
44+
45+
.panel1 {
46+
background-image:url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500);
47+
}
48+
.panel2 {
49+
background-image:url(https://source.unsplash.com/rFKUFzjPYiQ/1500x1500);
50+
}
51+
.panel3 {
52+
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);
53+
}
54+
.panel4 {
55+
background-image:url(https://source.unsplash.com/ITjiVXcwVng/1500x1500);
56+
}
57+
.panel5 {
58+
background-image:url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500);
59+
}
60+
61+
/* Flex Children */
62+
.panel > * {
63+
margin: 0;
64+
width: 100%;
65+
transition: transform 0.5s;
66+
flex: 1 0 auto;
67+
display: flex;
68+
justify-content: center;
69+
align-items: center;
70+
}
71+
72+
.panel > *:first-child {
73+
transform: translateY(-100%);
74+
}
75+
76+
.panel > *:last-child {
77+
transform: translateY(100%);
78+
}
79+
80+
.panel.open-active > *:first-child,
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+
92+
.panel p:nth-child(2) {
93+
font-size: 4em;
94+
}
95+
96+
.panel.open {
97+
flex: 5;
98+
font-size: 40px;
99+
}

0 commit comments

Comments
 (0)