Skip to content

Commit bb66c05

Browse files
committed
challenge 5 + readme complete
1 parent 9aa6399 commit bb66c05

File tree

7 files changed

+325
-146
lines changed

7 files changed

+325
-146
lines changed

Diff for: exercises/03 - CSS Variables/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ The purpose of this exercise is to gain experience using _CSS3 variables_. These
5353
1. Declare & define a variable as a reference to all of the inputs on the page.
5454
2. Iterate through the _HTML Node Elements_ that the variable is referencing and
5555
attach _event listeners_ to all of them that will call on an _event handler_ whenever
56-
the input value has been changed.
56+
the input value has been changed.
5757
3. Repeat step 2, listening for mouse movements on the inputs instead of value
5858
changes.
5959
4. Define a function that will be used as the _event handler_. This will update

Diff for: exercises/04 - Array Cardio Day 1/README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Exercise 4: Array Cardio
22
Nitish Dayal, Software & Applications Developer - [Contact](http://nitishdayal.me)
3-
Last Commit Date: Dec 10, 2016
3+
Last Commit Date: Dec 12, 2016
44

55
Not really much of a guide necessary for this one. The challenge is pretty
66
well documented as far as what's expected from the developer; use
@@ -10,4 +10,10 @@ the expected values. Easy peasy.
1010
If you're unfamiliar with JavaScript array methods, Mozilla docs are your
1111
friend.
1212

13+
The following built-in Array methods will be utilized to solve this challenge:
14+
- [Array.prototype.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
15+
- [Array.prototype.reduce()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)
16+
- [Array.prototype.sort()][https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Sort]
17+
- [Array.prototype.filter()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Filter)
18+
1319
Woooooooo all done with day 4!

Diff for: exercises/05 - Flex Panel Gallery/README.md

+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Exercise 5: Flex Panel Gallery
2+
Nitish Dayal, Software & Applications Developer - [Contact](http://nitishdayal.me)
3+
Last Commit Date: Dec 12, 2016
4+
5+
We are given a web page with five `div` HTML elements with a class `panels`,
6+
each containing three `p` HTML elements with some text. These five `div` elements
7+
are wrapped inside another `div` element with a class `panel`. Currently, these divs
8+
are stacked vertically and aren't interactive. We want to display these divs vertically
9+
and have only the middle `p` element of each `div` displayed; when a user clicks on a
10+
particular `div` element we want to expand that element and bring the two other `p`
11+
elements back into view. Update the CSS and write the JavaScript code necessary
12+
to bring this interactivity to the page.
13+
14+
Most of this challenge focuses on working with _CSS3 flexible boxes_, or flexbox. If
15+
you're unfamiliar with flexible boxes, here's another free course provided by Wes Bos:
16+
[flexbox.io](http://flexbox.io)
17+
18+
**SIDENOTE:** I broke up the CSS for this challenge into a separate file because that
19+
made it easier to focus on the pieces that I was working with. Organize your code
20+
however you see fit.
21+
22+
23+
## Guide
24+
25+
Flex box layouts consist of a _flex container_ which contain _flex items_.
26+
We'll use the `panels` class as the _flex container_, and the `panel` class as the
27+
_flex items_. By default, _flex items_ are only as wide as they need to be in order
28+
to display their contents, but we want them to take up the entire _flex container_.
29+
Allow the _flex items_ to take up equal space and fill out the _flex container_
30+
by allowing them to **grow**. Given that we want the content of each _flex item_
31+
to be flexible as well, we're going to display the `panel` class as both a _flex item_
32+
**AND** a _flex container_; this means that elements with the `panel` class will adjust
33+
themselves with respect to their _flex container_ (`div` HTML element with class `panels`),
34+
and the contents within those elements (in this case, the three `p` HTML elements) will
35+
adjust themselves with respect to their own _flex container_ (`div` HTML element with
36+
class `panels`).
37+
38+
Horizontally and vertically center the content of the `panel` class, and modify the styling
39+
for any _children_ of the `panel` class (`.panel > *`) so that they are displayed as
40+
_flex items_ and take up 1/3 of their respective _flex container_. Create new style
41+
definitions for the first and last child elements of the `panel` class to push them
42+
off the page and to bring them back in when their parent `panel` is selected, and
43+
update the CSS for the `panel open` class so that the selected `div` will be 5x
44+
larger than the other `div` elements. ~~Holy CSS, Batman!~~
45+
46+
Finally, we'll write some JavaScript code to attach _event listeners_ to each `panels`
47+
element that will fire when an panel is clicked on and call their respective _event
48+
handlers_; one _event handler_ function will adjust the size of the panel, and the
49+
other will be responsible for bringing in the `p` elements that we pushed off earlier.
50+
51+
- CSS
52+
1. Update the styling applied to the `panels` class to display as a _flex container_:
53+
```CSS
54+
.panels {
55+
/* ... */
56+
display: flex;
57+
}
58+
```
59+
2. Update the styling applied to each `panel` so that they equally maximize their
60+
width to fill out the _flex container_:
61+
```CSS
62+
.panel {
63+
/* ... */
64+
flex: 1;
65+
}
66+
```
67+
3. Update the styling applied to the `panel` class so that each panel is also a _flex
68+
container_ and displays its content in _columns_:
69+
```CSS
70+
.panel {
71+
/* ... */
72+
display: flex;
73+
flex-direction: columns;
74+
}
75+
```
76+
4. Update the styling applied to the child elements of the `panel` class so they are
77+
treated as _flex items_ and are center justified:
78+
```CSS
79+
.panel > * {
80+
/* ... */
81+
align-items: center;
82+
display: flex;
83+
flex: 1 0 auto;
84+
justify-content: center;
85+
}
86+
```
87+
5. Create new style definitions for the _first and last child elements_ of the `panel`
88+
class so that the content is pushed off the main page until the panel is selected by the user:
89+
```CSS
90+
.panel > *:first-child {
91+
transform: translateY(-100%);
92+
}
93+
94+
.panel.open-active > *:first-child {
95+
transform: translateY(0);
96+
}
97+
98+
.panel > *:last-child {
99+
transform: translateY(100%);
100+
}
101+
102+
.panel.open-active > *:last-child {
103+
transform: translateY(0);
104+
}
105+
```
106+
6. Update the styling applied to the `panel open` class so that the selected panel takes up
107+
5x the space of the other _flex items_:
108+
```CSS
109+
.panel.open {
110+
/* ... */
111+
flex: 5;
112+
}
113+
```
114+
- JavaScript
115+
1. Declare & define a variable as a reference to _all elements with a class `panels`_.
116+
2. Iterate through the _HTML Node elements_ that the variable is referencing and attach
117+
an _event listener_ for the `click` event to each element, providing the name of a
118+
yet-to-be-defined function as the _event handler_.
119+
3. Repeat step 2, this time attaching an _event listener_ for the `transitionend` event
120+
and providing a different function name for the _event handler_.
121+
4. Define the function for Step 2 to **toggle** the class `open` on the _function context_.
122+
5. Define the function for Step 3 to **toggle** the class `open-active` on the _function
123+
context_ **IF** the event has a property name which includes the word 'flex'.
124+
125+
CHALLENGE 5 === DEMOLISHED

Diff for: exercises/05 - Flex Panel Gallery/flex-panels.css

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
.panels {
2+
display: flex;
3+
min-height: 100vh;
4+
overflow: hidden;
5+
}
6+
7+
.panel {
8+
background: #6B0F9C;
9+
box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.1);
10+
color: white;
11+
display: flex;
12+
text-align: center;
13+
transition: font-size 0.7s cubic-bezier(0.61, -0.19, 0.7, -0.11), flex 0.7s cubic-bezier(0.61, -0.19, 0.7, -0.11), background 0.2s;
14+
font-size: 20px;
15+
flex: 1;
16+
flex-direction: column;
17+
background-size: cover;
18+
background-position: center;
19+
}
20+
21+
.panel > * {
22+
align-items: center;
23+
display: flex;
24+
flex: 1 0 auto;
25+
justify-content: center;
26+
margin: 0;
27+
transition: transform 0.5s;
28+
width: 100%;
29+
}
30+
31+
.panel > *:first-child {
32+
transform: translateY(-100%);
33+
}
34+
35+
.panel.open-active > *:first-child {
36+
transform: translateY(0);
37+
}
38+
39+
.panel > *:last-child {
40+
transform: translateY(100%);
41+
}
42+
43+
.panel.open-active > *:last-child {
44+
transform: translateY(0);
45+
}
46+
47+
.panel p {
48+
font-family: 'Amatic SC', cursive;
49+
font-size: 2em;
50+
text-shadow: 0 0 4px rgba(0, 0, 0, 0.72), 0 0 14px rgba(0, 0, 0, 0.45);
51+
text-transform: uppercase;
52+
}
53+
54+
.panel p:nth-child(2) {
55+
font-size: 4em;
56+
}
57+
58+
.panel.open {
59+
font-size: 40px;
60+
flex: 5;
61+
}

Diff for: exercises/05 - Flex Panel Gallery/index-FINISHED.html

+31-28
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<!DOCTYPE html>
22
<html lang="en">
3+
34
<head>
45
<meta charset="UTF-8">
56
<title>Flex Panels 💪</title>
67
<link href='https://fonts.googleapis.com/css?family=Amatic+SC' rel='stylesheet' type='text/css'>
78
</head>
9+
810
<body>
911
<style>
1012
html {
@@ -95,35 +97,35 @@
9597
</style>
9698

9799

98-
<div class="panels">
99-
<div class="panel panel1">
100-
<p>Hey</p>
101-
<p>Let's</p>
102-
<p>Dance</p>
103-
</div>
104-
<div class="panel panel2">
105-
<p>Give</p>
106-
<p>Take</p>
107-
<p>Receive</p>
108-
</div>
109-
<div class="panel panel3">
110-
<p>Experience</p>
111-
<p>It</p>
112-
<p>Today</p>
113-
</div>
114-
<div class="panel panel4">
115-
<p>Give</p>
116-
<p>All</p>
117-
<p>You can</p>
118-
</div>
119-
<div class="panel panel5">
120-
<p>Life</p>
121-
<p>In</p>
122-
<p>Motion</p>
123-
</div>
100+
<div class="panels">
101+
<div class="panel panel1">
102+
<p>Hey</p>
103+
<p>Let's</p>
104+
<p>Dance</p>
105+
</div>
106+
<div class="panel panel2">
107+
<p>Give</p>
108+
<p>Take</p>
109+
<p>Receive</p>
110+
</div>
111+
<div class="panel panel3">
112+
<p>Experience</p>
113+
<p>It</p>
114+
<p>Today</p>
124115
</div>
116+
<div class="panel panel4">
117+
<p>Give</p>
118+
<p>All</p>
119+
<p>You can</p>
120+
</div>
121+
<div class="panel panel5">
122+
<p>Life</p>
123+
<p>In</p>
124+
<p>Motion</p>
125+
</div>
126+
</div>
125127

126-
<script>
128+
<script>
127129
const panels = document.querySelectorAll('.panel');
128130

129131
function toggleOpen() {
@@ -143,4 +145,5 @@
143145
</script>
144146

145147
</body>
146-
</html>
148+
149+
</html>

0 commit comments

Comments
 (0)