Skip to content

Commit ec6a9f6

Browse files
committed
Update cards block
1 parent cb725b8 commit ec6a9f6

File tree

6 files changed

+205
-87
lines changed

6 files changed

+205
-87
lines changed

blocks/cards/cards.css

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/* default cards css */
2+
.cards > ul {
3+
display: grid;
4+
grid-template-columns: 1fr;
5+
grid-auto-rows: auto;
6+
grid-gap: 12px;
7+
list-style: none;
8+
margin: 0;
9+
padding: 0;
10+
width: 100%;
11+
}
12+
.cards > ul > li {
13+
border: 1px solid #dadada;
14+
background-color: var(--background-color);
15+
}
16+
17+
.cards .cards-card-body {
18+
margin: 16px;
19+
}
20+
21+
.cards .cards-card-image {
22+
line-height: 0;
23+
}
24+
25+
.cards > ul > li img {
26+
width: 100%;
27+
aspect-ratio: 4 / 3;
28+
object-fit: cover;
29+
}
30+
31+
@media (width >= 900px) {
32+
.cards > ul {
33+
grid-template-columns: repeat(auto-fit, minmax(23%, 1fr));
34+
grid-auto-rows: 1fr;
35+
}
36+
}
37+
38+
/* end of default cards css */
39+
40+
/* cards - links */
41+
.cards.links > ul {
42+
grid-gap: 20px;
43+
}
44+
45+
.cards.links li {
46+
position: relative;
47+
border: none;
48+
border-radius: 20px;
49+
overflow: hidden;
50+
box-shadow: rgba(0, 0, 0, 0.08) 0px 6px 16px, rgba(0, 0, 0, 0.12) 0px 3px 6px;
51+
transition: 0.5s ease-in-out;
52+
transform-style: preserve-3d;
53+
}
54+
55+
.cards.links li:hover {
56+
transform: scale(1.015);
57+
box-shadow: rgba(0, 0, 0, 0.15) 0px 6px 32px, rgba(0, 0, 0, 0.35) 0px 3px 12px;
58+
}
59+
60+
.cards.links > ul > li img {
61+
max-height: 375px;
62+
transition: 0.5s ease-in-out;
63+
transform-style: preserve-3d;
64+
}
65+
66+
.cards.links li:hover img {
67+
transform: scale(1.015);
68+
box-shadow: rgba(0, 0, 0, 0.15) 0px 6px 32px, rgba(0, 0, 0, 0.35) 0px 3px 12px;
69+
}
70+
71+
.cards.links .cards-card-body {
72+
position: absolute;
73+
top: 50%;
74+
left: 50%;
75+
transform: translate(-50%, -50%);
76+
color: #fff;
77+
text-align: center;
78+
width: max-content;
79+
max-width: 400px;
80+
margin: 0;
81+
padding: 16px;
82+
}
83+
84+
.cards.links .cards-card-body h2 {
85+
margin: 0;
86+
line-height: 1;
87+
}
88+
89+
.cards.links .cards-card-body p {
90+
margin: 0;
91+
}

blocks/cards/cards.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { createOptimizedPicture } from '../../scripts/aem.js';
2+
3+
export default function decorate(block) {
4+
/* change to ul, li */
5+
const ul = document.createElement('ul');
6+
[...block.children].forEach((row) => {
7+
const li = document.createElement('li');
8+
while (row.firstElementChild) li.append(row.firstElementChild);
9+
[...li.children].forEach((div) => {
10+
if (div.children.length === 1 && div.querySelector('picture')) div.className = 'cards-card-image';
11+
else div.className = 'cards-card-body';
12+
});
13+
14+
/* wrap each card with link */
15+
const existingLink = li.querySelector('a');
16+
if (existingLink?.href) {
17+
const { href } = existingLink;
18+
const wrapperLink = document.createElement('a');
19+
wrapperLink.href = href;
20+
21+
// Move all children of li into the wrapperLink
22+
while (li.firstChild) {
23+
wrapperLink.appendChild(li.firstChild);
24+
}
25+
26+
existingLink.parentElement.remove();
27+
li.appendChild(wrapperLink);
28+
}
29+
30+
ul.append(li);
31+
});
32+
ul.querySelectorAll('picture > img').forEach((img) => img.closest('picture').replaceWith(createOptimizedPicture(img.src, img.alt, false, [{ width: '750' }])));
33+
block.textContent = '';
34+
block.append(ul);
35+
}

blocks/do-demos/do-demos.css

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -321,84 +321,3 @@
321321
grid-template-columns: 1fr;
322322
}
323323
}
324-
325-
/* grid-4 */
326-
.cards.grid-4 > ul {
327-
display: grid;
328-
grid-template-columns: 1fr 1fr 1fr 1fr;
329-
}
330-
331-
/* grid-3 */
332-
.cards.grid-3 > ul {
333-
display: grid;
334-
grid-template-columns: 1fr 1fr 1fr;
335-
grid-gap: 24px 30px;
336-
}
337-
338-
/* grid-2 */
339-
.cards.grid-2 > ul {
340-
display: grid;
341-
grid-template-columns: 1fr 1fr;
342-
grid-gap: 24px 30px;
343-
}
344-
345-
/* Modal Container */
346-
.modal {
347-
display: none;
348-
position: fixed;
349-
z-index: 1;
350-
left: 0;
351-
top: 0;
352-
width: 100%;
353-
height: 100%;
354-
overflow: auto;
355-
background-color: rgba(0 0 0 / 65%);
356-
}
357-
358-
.modal-content {
359-
background-color: #fefefe;
360-
margin: 10% auto;
361-
padding: 2rem;
362-
border: 1px solid #888;
363-
width: 80%;
364-
max-width: 750px;
365-
border-radius: 15px;
366-
box-shadow: 0 5px 15px rgba(0 0 0 / 50%);
367-
}
368-
369-
@media (width <= 768px) {
370-
.modal-content {
371-
margin-top: 100px;
372-
}
373-
}
374-
375-
.modal-header {
376-
display: flex;
377-
justify-content: space-between;
378-
position: relative;
379-
margin-bottom: 20px;
380-
}
381-
382-
.close {
383-
color: #aaa;
384-
font-size: 40px;
385-
font-weight: bold;
386-
position: absolute;
387-
right: -15px;
388-
top: -30px;
389-
line-height: normal;
390-
}
391-
392-
.close:hover,
393-
.close:focus {
394-
color: black;
395-
text-decoration: none;
396-
cursor: pointer;
397-
}
398-
399-
400-
#demo-notes-content {
401-
font-size: 16px;
402-
line-height: 1.5;
403-
color: #333;
404-
}

blocks/header/header.css

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,18 @@ header nav[aria-expanded="true"] .nav-hamburger-icon::after {
144144
/* brand */
145145
header .nav-brand {
146146
grid-area: brand;
147-
flex-basis: 128px;
148147
font-size: var(--heading-font-size-s);
149148
font-weight: 700;
150149
line-height: 1;
151150
}
152151

152+
header .nav-brand .icon {
153+
width: unset;
154+
height: unset;
155+
}
156+
153157
header nav .nav-brand img {
154-
width: 150px;
158+
width: 100px;
155159
height: auto;
156160
}
157161

icons/adobe-logo.svg

Lines changed: 11 additions & 0 deletions
Loading

styles/styles.css

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,6 @@ main .section {
200200
padding: 32px 16px;
201201
}
202202

203-
main .section:not(.nav-container) {
204-
margin-bottom: 2rem;
205-
}
206-
207203
main .main-wrapper .section:not(:first-of-type) {
208204
border-radius: 10px;
209205
box-shadow: 0 4px 20px rgba(0 0 0 / 10%);
@@ -227,3 +223,65 @@ main .section.light,
227223
main .section.highlight {
228224
background-color: var(--light-color);
229225
}
226+
227+
/* other */
228+
229+
/* Modal Container */
230+
.modal {
231+
display: none;
232+
position: fixed;
233+
z-index: 1;
234+
left: 0;
235+
top: 0;
236+
width: 100%;
237+
height: 100%;
238+
overflow: auto;
239+
background-color: rgba(0 0 0 / 65%);
240+
}
241+
242+
.modal-content {
243+
background-color: #fefefe;
244+
margin: 10% auto;
245+
padding: 2rem;
246+
border: 1px solid #888;
247+
width: 80%;
248+
max-width: 750px;
249+
border-radius: 15px;
250+
box-shadow: 0 5px 15px rgba(0 0 0 / 50%);
251+
}
252+
253+
@media (width <= 768px) {
254+
.modal-content {
255+
margin-top: 100px;
256+
}
257+
}
258+
259+
.modal-header {
260+
display: flex;
261+
justify-content: space-between;
262+
position: relative;
263+
margin-bottom: 20px;
264+
}
265+
266+
.close {
267+
color: #aaa;
268+
font-size: 40px;
269+
font-weight: bold;
270+
position: absolute;
271+
right: -15px;
272+
top: -30px;
273+
line-height: normal;
274+
}
275+
276+
.close:hover,
277+
.close:focus {
278+
color: black;
279+
text-decoration: none;
280+
cursor: pointer;
281+
}
282+
283+
#demo-notes-content {
284+
font-size: 16px;
285+
line-height: 1.5;
286+
color: #333;
287+
}

0 commit comments

Comments
 (0)