Skip to content

Commit 7b923ee

Browse files
committed
implemented the flex panel gallery
1 parent 0e4e274 commit 7b923ee

File tree

3 files changed

+114
-3
lines changed

3 files changed

+114
-3
lines changed

01 - JavaScript Drum Kit/index-START.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@
8282
const keys = document.querySelectorAll('.key');
8383
keys.forEach(key => key.addEventListener('transitionend', removeTranstion));
8484
window.addEventListener('keydown', playSound);
85-
8685
</script>
8786

8887

04 - Array Cardio Day 1/index-START.html

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,112 @@
3333

3434
// Array.prototype.filter()
3535
// 1. Filter the list of inventors for those who were born in the 1500's
36+
// filter will return 2 out of 10
37+
var fifteen = inventors.filter(function(investor) {
38+
if (investor.year >= 1500 && investor.year < 1599) {
39+
return true;// keep it
40+
}
41+
});
42+
43+
// using the reduce to implement filter
44+
// var fifteen = inventors.reduce(function(acc, investor) {
45+
// if (investor.year >= 1500 && investor.year < 1599) {
46+
// acc.push(inventor);
47+
// }
48+
49+
// return acc;
50+
// }, []);
51+
52+
53+
console.log(fifteen);
3654

3755
// Array.prototype.map()
3856
// 2. Give us an array of the inventors' first and last names
57+
// map return the amount of array you give it
58+
var fullNames = inventors.map(function(investor) {
59+
return investor.first + ' ' + investor.last;
60+
});
61+
62+
console.log(fullNames);
3963

4064
// Array.prototype.sort()
4165
// 3. Sort the inventors by birthdate, oldest to youngest
66+
// two items, return 1, or 1-
67+
68+
var ordered = inventors.sort(function(firstPerson, secondPerson) {
69+
if (firstPerson.year > secondPerson.year) {
70+
return 1;
71+
} else {
72+
return -1;
73+
}
74+
});
75+
76+
// Simple way to implement
77+
//var ordered = inventors.sort((a, b) => a.year > b.year ? 1 : -1);
78+
79+
console.table(ordered);
4280

4381
// Array.prototype.reduce()
4482
// 4. How many years did all the inventors live?
4583

84+
var totalYears = inventors.reduce(function(total, investor) {
85+
return total + (investor.passed - investor.year);
86+
}, 0);
87+
console.log(totalYears);
88+
4689
// 5. Sort the inventors by years lived
4790

91+
var oldest = inventors.sort(function(a, b) {
92+
var lastGuy = a.passed - a.year;
93+
var nextGuy = b.passed - b.year;
94+
95+
if (lastGuy > nextGuy) {
96+
return -1;
97+
} else {
98+
return 1;
99+
}
100+
});
101+
102+
console.table(oldest);
103+
48104
// 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name
49105
// https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris
106+
// var category = document.querySelector('.mw-category');
107+
// var links = Array.from(category.querySelectorAll('a'));
108+
109+
// //
110+
// var de = links.map(function(link) {
111+
// return link.textContent;
112+
// }).filter(function(streetName) {
113+
// return streetName.includes('de');
114+
// });
50115

51116

52117
// 7. sort Exercise
53118
// Sort the people alphabetically by last name
119+
var alpha = people.sort(function(lastOne, nextOne) {
120+
var [aFirst, aLast] = lastOne.split(', ');
121+
var [bFirst, bLast] = nextOne.split(', ');
122+
return aLast > bLast ? 1 : -1
123+
});
124+
125+
126+
127+
console.log(alpha);
54128

55129
// 8. Reduce Exercise
56130
// Sum up the instances of each of these
57131
const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ];
132+
var transportation = data.reduce(function(obj, item) {
133+
if (!obj[item]) {
134+
obj[item] = 0;
135+
}
136+
137+
obj[item]++;
138+
return obj;
139+
}, {});
140+
141+
console.log(transportation);
58142

59143
</script>
60144
</body>

05 - Flex Panel Gallery/index-START.html

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
.panels {
2525
min-height:100vh;
2626
overflow: hidden;
27+
display: flex;
2728
}
2829

2930
.panel {
@@ -41,6 +42,12 @@
4142
font-size: 20px;
4243
background-size:cover;
4344
background-position:center;
45+
flex: 1;
46+
justify-content: center;
47+
align-items:center;
48+
display:flex;;
49+
flex-direction: column;
50+
/* display evently*/
4451
}
4552

4653

@@ -54,8 +61,17 @@
5461
margin:0;
5562
width: 100%;
5663
transition:transform 0.5s;
64+
flex: 1 0 auto;
65+
display: flex;
66+
justify-content: center;
67+
align-content: center;
5768
}
5869

70+
.panel > *:first-child {transform: translateY(-100%);}
71+
.panel.open-active > *:first-child {transform: translateY(0);}
72+
.panel > *:last-child {transform: translateY(100%);}
73+
.panel.open-active > *:last-child {transform: translateY(0);}
74+
5975
.panel p {
6076
text-transform: uppercase;
6177
font-family: 'Amatic SC', cursive;
@@ -68,6 +84,8 @@
6884

6985
.panel.open {
7086
font-size:40px;
87+
flex:5;
88+
7189
}
7290

7391
.cta {
@@ -107,10 +125,20 @@
107125
</div>
108126

109127
<script>
128+
var panels = document.querySelectorAll('.panel');
129+
function toggleOpen() {
130+
this.classList.toggle('open');
131+
}
132+
133+
function toggleActive(e) {
134+
if (e.propertyName.includes('flex')) {
135+
this.classList.toggle('open-active');
136+
}
137+
}
110138

139+
panels.forEach(panel => panel.addEventListener('click', toggleOpen));
140+
panels.forEach(panel => panel.addEventListener('transitionend', toggleActive));
111141
</script>
112142

113-
114-
115143
</body>
116144
</html>

0 commit comments

Comments
 (0)