|
2 | 2 | <html lang="en">
|
3 | 3 | <head>
|
4 | 4 | <meta charset="UTF-8">
|
5 |
| - <title>Array Cardio 💪</title> |
| 5 | + <title>Flex Panels 💪</title> |
| 6 | + <link href='https://fonts.googleapis.com/css?family=Amatic+SC' rel='stylesheet' type='text/css'> |
6 | 7 | </head>
|
7 | 8 | <body>
|
8 |
| - <p><em>Psst: have a look at the JavaScript Console</em> 💁</p> |
9 |
| - <script> |
10 |
| - // Get your shorts on - this is an array workout! |
11 |
| - // ## Array Cardio Day 1 |
12 |
| - |
13 |
| - // Some data we can work with |
| 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 | + } |
14 | 23 |
|
15 |
| - const inventors = [ |
16 |
| - { first: 'Albert', last: 'Einstein', year: 1879, passed: 1955 }, |
17 |
| - { first: 'Isaac', last: 'Newton', year: 1643, passed: 1727 }, |
18 |
| - { first: 'Galileo', last: 'Galilei', year: 1564, passed: 1642 }, |
19 |
| - { first: 'Marie', last: 'Curie', year: 1867, passed: 1934 }, |
20 |
| - { first: 'Johannes', last: 'Kepler', year: 1571, passed: 1630 }, |
21 |
| - { first: 'Nicolaus', last: 'Copernicus', year: 1473, passed: 1543 }, |
22 |
| - { first: 'Max', last: 'Planck', year: 1858, passed: 1947 }, |
23 |
| - { first: 'Katherine', last: 'Blodgett', year: 1898, passed: 1979 }, |
24 |
| - { first: 'Ada', last: 'Lovelace', year: 1815, passed: 1852 }, |
25 |
| - { first: 'Sarah E.', last: 'Goode', year: 1855, passed: 1905 }, |
26 |
| - { first: 'Lise', last: 'Meitner', year: 1878, passed: 1968 }, |
27 |
| - { first: 'Hanna', last: 'Hammarström', year: 1829, passed: 1909 } |
28 |
| - ]; |
| 24 | + .panels { |
| 25 | + min-height:100vh; |
| 26 | + overflow: hidden; |
| 27 | + |
| 28 | + display: flex; |
| 29 | + } |
29 | 30 |
|
30 |
| - const people = ['Beck, Glenn', 'Becker, Carl', 'Beckett, Samuel', 'Beddoes, Mick', 'Beecher, Henry', 'Beethoven, Ludwig', 'Begin, Menachem', 'Belloc, Hilaire', 'Bellow, Saul', 'Benchley, Robert', 'Benenson, Peter', 'Ben-Gurion, David', 'Benjamin, Walter', 'Benn, Tony', 'Bennington, Chester', 'Benson, Leana', 'Bent, Silas', 'Bentsen, Lloyd', 'Berger, Ric', 'Bergman, Ingmar', 'Berio, Luciano', 'Berle, Milton', 'Berlin, Irving', 'Berne, Eric', 'Bernhard, Sandra', 'Berra, Yogi', 'Berry, Halle', 'Berry, Wendell', 'Bethea, Erin', 'Bevan, Aneurin', 'Bevel, Ken', 'Biden, Joseph', 'Bierce, Ambrose', 'Biko, Steve', 'Billings, Josh', 'Biondo, Frank', 'Birrell, Augustine', 'Black, Elk', 'Blair, Robert', 'Blair, Tony', 'Blake, William']; |
| 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 | + /* 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 | + |
| 46 | + flex: 1; |
| 47 | + flex-grow: 1; |
| 48 | + justify-content: center; |
| 49 | + align-items: center; |
| 50 | + display: flex; |
| 51 | + flex-direction: column; |
| 52 | + } |
31 | 53 |
|
32 |
| - // Array.prototype.filter() |
33 |
| - // 1. Filter the list of inventors for those who were born in the 1500's |
34 | 54 |
|
35 |
| - // Array.prototype.map() |
36 |
| - // 2. Give us an array of the inventors' first and last names |
| 55 | + .panel1 { background-image:url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500); } |
| 56 | + .panel2 { background-image:url(https://source.unsplash.com/1CD3fd8kHnE/1500x1500); } |
| 57 | + .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); } |
| 58 | + .panel4 { background-image:url(https://source.unsplash.com/ITjiVXcwVng/1500x1500); } |
| 59 | + .panel5 { background-image:url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500); } |
37 | 60 |
|
38 |
| - // Array.prototype.sort() |
39 |
| - // 3. Sort the inventors by birthdate, oldest to youngest |
| 61 | + .panel > * { |
| 62 | + margin:0; |
| 63 | + width: 100%; |
| 64 | + transition:transform 0.5s; |
| 65 | + |
| 66 | + flex: 1 0 auto; |
| 67 | + display: flex; |
| 68 | + justify-content: center; |
| 69 | + align-items: center; |
| 70 | + } |
| 71 | + |
| 72 | + .panel > *:first-child { transform: translateY(-100%); } |
| 73 | + .panel.open-active > *:first-child { transform: translateY(0); } |
| 74 | + .panel > *:last-child { transform: translateY(100%); } |
| 75 | + .panel.open-active > *:last-child { transform: translateY(0); } |
40 | 76 |
|
41 |
| - // Array.prototype.reduce() |
42 |
| - // 4. How many years did all the inventors live? |
| 77 | + .panel p { |
| 78 | + text-transform: uppercase; |
| 79 | + font-family: 'Amatic SC', cursive; |
| 80 | + text-shadow:0 0 4px rgba(0, 0, 0, 0.72), 0 0 14px rgba(0, 0, 0, 0.45); |
| 81 | + font-size: 2em; |
| 82 | + } |
| 83 | + .panel p:nth-child(2) { |
| 84 | + font-size: 4em; |
| 85 | + } |
43 | 86 |
|
44 |
| - // 5. Sort the inventors by years lived |
| 87 | + .panel.open { |
| 88 | + font-size:40px; |
| 89 | + |
| 90 | + flex: 5; |
| 91 | + } |
45 | 92 |
|
46 |
| - // 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name |
47 |
| - // https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris |
| 93 | + .cta { |
| 94 | + color:white; |
| 95 | + text-decoration: none; |
| 96 | + } |
48 | 97 |
|
| 98 | + </style> |
49 | 99 |
|
50 |
| - // 7. sort Exercise |
51 |
| - // Sort the people alphabetically by last name |
52 | 100 |
|
53 |
| - // 8. Reduce Exercise |
54 |
| - // Sum up the instances of each of these |
55 |
| - const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ]; |
| 101 | + <div class="panels"> |
| 102 | + <div class="panel panel1"> |
| 103 | + <p>Hey</p> |
| 104 | + <p>Let's</p> |
| 105 | + <p>Dance</p> |
| 106 | + </div> |
| 107 | + <div class="panel panel2"> |
| 108 | + <p>Give</p> |
| 109 | + <p>Take</p> |
| 110 | + <p>Receive</p> |
| 111 | + </div> |
| 112 | + <div class="panel panel3"> |
| 113 | + <p>Experience</p> |
| 114 | + <p>It</p> |
| 115 | + <p>Today</p> |
| 116 | + </div> |
| 117 | + <div class="panel panel4"> |
| 118 | + <p>Give</p> |
| 119 | + <p>All</p> |
| 120 | + <p>You can</p> |
| 121 | + </div> |
| 122 | + <div class="panel panel5"> |
| 123 | + <p>Life</p> |
| 124 | + <p>In</p> |
| 125 | + <p>Motion</p> |
| 126 | + </div> |
| 127 | + </div> |
56 | 128 |
|
| 129 | + <script> |
| 130 | + const panels = document.querySelectorAll('.panel'); |
| 131 | + |
| 132 | + function toggleOpen() { |
| 133 | + this.classList.toggle('open'); |
| 134 | + } |
| 135 | + |
| 136 | + function toggleActive(e) { |
| 137 | + console.log(e.propertyName); |
| 138 | + if (e.propertyName.includes('flex')) { |
| 139 | + this.classList.toggle('open-active'); |
| 140 | + } |
| 141 | + } |
| 142 | + |
| 143 | + panels.forEach(panel => panel.addEventListener('click', toggleOpen)); |
| 144 | + panels.forEach(panel => panel.addEventListener('transitionend', toggleActive)); |
57 | 145 | </script>
|
| 146 | + |
58 | 147 | </body>
|
59 | 148 | </html>
|
0 commit comments