-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.mock.html
227 lines (206 loc) · 5.99 KB
/
index.mock.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Shoppy Cart</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
border: 1px solid red;
}
body {
min-height: 100vh;
display: flex;
justify-content: center;
}
#app {
max-width: 1000px;
}
header {
height: 100px;
display: flex;
justify-content: center;
align-items: center;
}
main {
padding: 20px 0;
display: grid;
height: calc(100% - 100px);
grid-template-columns: 1fr 150px;
grid-gap: 60px;
}
.catalog {
margin-left: 80px;
}
.catalog__product-list {
list-style-type: none;
}
.sidebar {
margin-right: 20px;
}
.cart-preview {
display: flex;
flex-direction: column;
justify-content: center;
position: sticky;
text-align: center;
top: 20px;
height: 80px;
}
.product {
display: grid;
grid-template-columns: 3fr 1fr 1fr;
}
.product__name {
grid-row: 1 / 2;
padding: 5px;
}
.product__description {
order: 1;
padding: 5px;
}
.product__price {
grid-row: 1 / 3;
padding: 5px;
text-align: center;
}
.modal {
align-items: center;
background: #fff;
display: flex;
height: 100vh;
justify-content: center;
left: 0;
position: fixed;
top: 0;
width: 100vw;
z-index: 10;
}
.cart {
display: flex;
flex-direction: column;
justify-content: space-between;
margin-top: -10%;
min-height: 50%;
min-width: 50%;
}
.cart__headline {
text-align: center;
}
.cart__table {
align-self: center;
text-align: left;
min-height: 25%;
min-width: 90%;
}
.cart__table th, .cart__table td {
padding: 5px;
}
.hidden {
display: none;
}
</style>
</head>
<body>
<div id="app">
<header>
<h1>Things You Can Buy With Money</h1>
</header>
<main>
<section class="catalog">
<ul class="catalog__product-list">
<li>
<article class="product">
<h2 class="product__name">Product name</h2>
<p class="product__description">Description, it could be as long as a short paragraph, maybe even a long paragraph, can anyone know for sure how long the description will be???</p>
<p class="product__price">$6.66</p>
<button class="product__button">Add to cart</button>
</article>
</li>
<li>
<article class="product">
<h2 class="product__name">Product name</h2>
<p class="product__description">Description, it could be as long as a short paragraph, maybe even a long paragraph, can anyone know for sure how long the description will be???</p>
<p class="product__price">$6.66</p>
<button class="product__button">Add to cart</button>
</article>
</li>
<li>
<article class="product">
<h2 class="product__name">Product name</h2>
<p class="product__description">Description, it could be as long as a short paragraph, maybe even a long paragraph, can anyone know for sure how long the description will be???</p>
<p class="product__price">$6.66</p>
<button class="product__button">Add to cart</button>
</article>
</li>
<li>
<article class="product">
<h2 class="product__name">Product name</h2>
<p class="product__description">Description, it could be as long as a short paragraph, maybe even a long paragraph, can anyone know for sure how long the description will be???</p>
<p class="product__price">$6.66</p>
<button class="product__button">Add to cart</button>
</article>
</li>
<li>
<article class="product">
<h2 class="product__name">Product type</h2>
<p class="product__description">Description, it could be as long as a short paragraph, maybe even a long paragraph, can anyone know for sure how long the description will be???</p>
<p class="product__price">$6.66</p>
<button class="product__button">Add to cart</button>
</article>
</li>
</ul>
</section>
<aside class="sidebar">
<div class="cart-preview">
<button class="js-view-cart">View cart</button>
<p>(# items)</p>
</div>
</aside>
</main>
<div class="modal hidden">
<div class="cart">
<h2 class="cart__headline">Your Cart</h2>
<table class="cart__table">
<thead>
<tr>
<th>Item</th>
<th>Price</th>
<th>Qty</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Dark</td>
<td>$1.50</td>
<td>3</td>
<td><button>remove</button></td>
</tr>
</tbody>
</table>
<p>Total: $X.XX</p>
<div>
<button>Clear</button>
<button class="js-close-cart">Close</button>
</div>
</div>
</div>
</div>
<script>
// const app = document.querySelector('#app');
const modal = document.querySelector('.modal');
const viewCart = document.querySelector('.js-view-cart');
const closeCart = document.querySelector('.js-close-cart');
viewCart.addEventListener('click', () => modal.classList.remove('hidden'));
closeCart.addEventListener('click', () => modal.classList.add('hidden'));
document.body.addEventListener('keydown', e => {
if (e.keyCode === 27) modal.classList.add('hidden');
});
</script>
</body>
</html>