Skip to content

Commit 2cfda70

Browse files
authored
Merge pull request #67 from adobe/latest-boilerplate
feat: latest boilerplate
2 parents 1a4c87b + b4decba commit 2cfda70

36 files changed

+769
-660
lines changed

blocks/accordion/accordion.css

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
.accordion details {
2-
border: 1px solid var(--dark-color);
2+
border: 1px solid #dadada;
33
}
44

55
/* stylelint-disable-next-line no-descending-specificity */
66
.accordion details + details {
7-
margin-top: 16px;
7+
margin-top: 24px;
8+
}
9+
10+
.accordion details p {
11+
margin-bottom: 0.8em;
812
}
913

1014
.accordion details summary {
1115
position: relative;
1216
padding: 0 16px;
13-
padding-right: 48px;
17+
padding-right: 46px;
1418
cursor: pointer;
1519
list-style: none;
1620
overflow: auto;
@@ -23,21 +27,21 @@
2327

2428
.accordion details summary:focus,
2529
.accordion details summary:hover {
26-
background-color: var(--dark-color);
30+
background-color: var(--light-color);
2731
}
2832

2933
.accordion details summary::-webkit-details-marker {
3034
display: none;
3135
}
3236

3337
.accordion details summary::after {
34-
content: "";
38+
content: '';
3539
position: absolute;
3640
top: 50%;
3741
right: 18px;
3842
transform: translateY(-50%) rotate(135deg);
39-
width: 9px;
40-
height: 9px;
43+
width: 6px;
44+
height: 6px;
4145
border: 2px solid;
4246
border-width: 2px 2px 0 0;
4347
transition: transform 0.2s;
@@ -52,6 +56,6 @@
5256
}
5357

5458
.accordion details[open] .accordion-item-body {
55-
border-top: 1px solid var(--dark-color);
59+
border-top: 1px solid #dadada;
5660
background-color: var(--background-color);
5761
}

blocks/accordion/accordion.js

-10
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,16 @@
44
* https://www.hlx.live/developer/block-collection/accordion
55
*/
66

7-
function hasWrapper(el) {
8-
return !!el.firstElementChild && window.getComputedStyle(el.firstElementChild).display === 'block';
9-
}
10-
117
export default function decorate(block) {
128
[...block.children].forEach((row) => {
139
// decorate accordion item label
1410
const label = row.children[0];
1511
const summary = document.createElement('summary');
1612
summary.className = 'accordion-item-label';
1713
summary.append(...label.childNodes);
18-
if (!hasWrapper(summary)) {
19-
summary.innerHTML = `<p>${summary.innerHTML}</p>`;
20-
}
2114
// decorate accordion item body
2215
const body = row.children[1];
2316
body.className = 'accordion-item-body';
24-
if (!hasWrapper(body)) {
25-
body.innerHTML = `<p>${body.innerHTML}</p>`;
26-
}
2717
// decorate accordion item
2818
const details = document.createElement('details');
2919
details.className = 'accordion-item';

blocks/cards/cards.css

+3-7
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
margin: 0;
44
padding: 0;
55
display: grid;
6-
grid-template-columns: repeat(auto-fill, minmax(278px, 1fr));
7-
grid-gap: 16px;
6+
grid-template-columns: repeat(auto-fill, minmax(257px, 1fr));
7+
grid-gap: 24px;
88
}
99

1010
.cards > ul > li {
11-
border: 1px solid var(--dark-color);
11+
border: 1px solid #dadada;
1212
background-color: var(--background-color);
1313
}
1414

@@ -20,10 +20,6 @@
2020
line-height: 0;
2121
}
2222

23-
.cards .cards-card-body > *:first-child {
24-
margin-top: 0;
25-
}
26-
2723
.cards > ul > li img {
2824
width: 100%;
2925
aspect-ratio: 4 / 3;

blocks/cards/cards.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default function decorate(block) {
1212
});
1313
ul.append(li);
1414
});
15-
ul.querySelectorAll('img').forEach((img) => img.closest('picture').replaceWith(createOptimizedPicture(img.src, img.alt, false, [{ width: '750' }])));
15+
ul.querySelectorAll('picture > img').forEach((img) => img.closest('picture').replaceWith(createOptimizedPicture(img.src, img.alt, false, [{ width: '750' }])));
1616
block.textContent = '';
1717
block.append(ul);
1818
}

blocks/carousel/carousel.css

+39-56
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
justify-content: center;
3030
position: relative;
3131
width: 100%;
32-
min-height: min(40rem, calc(100svh - var(--nav-height)));
32+
min-height: min(50vw, calc(100dvh - var(--header-height)));
3333
}
3434

35-
.carousel .carousel-slide:has(.carousel-slide-content[data-align="center"]) {
35+
.carousel .carousel-slide:has(.carousel-slide-content[data-align='center']) {
3636
align-items: center;
3737
}
3838

39-
.carousel .carousel-slide:has(.carousel-slide-content[data-align="right"]) {
39+
.carousel .carousel-slide:has(.carousel-slide-content[data-align='right']) {
4040
align-items: flex-end;
4141
}
4242

@@ -53,54 +53,46 @@
5353

5454
.carousel .carousel-slide .carousel-slide-content {
5555
z-index: 1;
56-
padding: 1rem;
57-
margin: 1.5rem 3rem;
56+
margin: 68px;
57+
padding: 16px;
5858
color: white;
59-
background-color: rgba(0 0 0 / 50%);
59+
background-color: rgba(19 19 19 / 75%);
6060
position: relative;
6161
width: var(--slide-content-width, auto);
6262
}
6363

6464
.carousel .carousel-slide-indicators {
6565
display: flex;
66+
flex-wrap: wrap;
6667
justify-content: center;
67-
gap: 0.5rem;
68+
gap: 6px 12px;
69+
padding: 12px;
70+
background-color: var(--light-color);
71+
line-height: 0;
6872
}
6973

7074
.carousel .carousel-slide-indicator button {
71-
width: 1rem;
72-
height: 1rem;
75+
width: 24px;
76+
height: 24px;
77+
margin: 0;
7378
padding: 0;
74-
border-radius: 1rem;
75-
background-color: rgba(0 0 0 / 25%);
79+
border-radius: 50%;
80+
background-color: #dadada;
81+
transition: background-color 0.2s;
7682
}
7783

7884
.carousel .carousel-slide-indicator button:disabled,
7985
.carousel .carousel-slide-indicator button:hover,
8086
.carousel .carousel-slide-indicator button:focus-visible {
81-
background-color: rgba(0 0 0 / 80%);
82-
}
83-
84-
.carousel .carousel-slide-indicator span,
85-
.carousel .carousel-navigation-buttons span {
86-
border: 0;
87-
clip: rect(0 0 0 0);
88-
clip-path: inset(50%);
89-
height: 1px;
90-
margin: -1px;
91-
overflow: hidden;
92-
padding: 0;
93-
position: absolute;
94-
width: 1px;
95-
white-space: nowrap;
87+
background-color: var(--text-color);
9688
}
9789

9890
.carousel .carousel-navigation-buttons {
9991
position: absolute;
10092
top: 50%;
10193
transform: translateY(-50%);
102-
left: 0.5rem;
103-
right: 0.5rem;
94+
left: 12px;
95+
right: 12px;
10496
display: flex;
10597
align-items: center;
10698
justify-content: space-between;
@@ -109,62 +101,53 @@
109101

110102
/* stylelint-disable-next-line no-descending-specificity */
111103
.carousel .carousel-navigation-buttons button {
112-
border-radius: 8px;
104+
position: relative;
105+
width: 44px;
106+
height: 44px;
113107
margin: 0;
108+
border-radius: 50%;
114109
padding: 0;
115-
width: 2rem;
116-
height: 2rem;
117-
position: relative;
118-
background-color: rgba(0 0 0 / 25%);
110+
background-color: rgba(19 19 19 / 25%);
111+
transition: background-color 0.2s;
119112
}
120113

121114
.carousel .carousel-navigation-buttons button:hover,
122115
.carousel .carousel-navigation-buttons button:focus-visible {
123-
background-color: rgba(0 0 0 / 80%);
116+
background-color: rgba(19 19 19 / 75%);
124117
}
125118

126119
.carousel .carousel-navigation-buttons button::after {
127120
display: block;
128-
content: "";
129-
border: 3px white solid;
121+
content: '';
122+
border: 2px solid;
130123
border-bottom: 0;
131124
border-left: 0;
132-
height: 0.75rem;
133-
width: 0.75rem;
125+
height: 12px;
126+
width: 12px;
134127
position: absolute;
135128
top: 50%;
136-
left: calc(50% + 3px);
129+
left: calc(50% + 2px);
137130
transform: translate(-50%, -50%) rotate(-135deg);
138131
}
139132

140133
.carousel .carousel-navigation-buttons button.slide-next::after {
141-
transform: translate(-50%, -50%) rotate(45deg);
142-
left: calc(50% - 3px);
134+
transform: translate(-50%, -50%) rotate(45deg);
135+
left: calc(50% - 2px);
143136
}
144137

145138
@media (width >= 600px) {
146139
.carousel .carousel-navigation-buttons {
147-
left: 1rem;
148-
right: 1rem;
149-
}
150-
151-
.carousel .carousel-navigation-buttons button {
152-
width: 3rem;
153-
height: 3rem;
154-
}
155-
156-
.carousel .carousel-navigation-buttons button::after {
157-
width: 1rem;
158-
height: 1rem;
140+
left: 24px;
141+
right: 24px;
159142
}
160143

161144
.carousel .carousel-slide .carousel-slide-content {
162-
--slide-content-width: 50%;
145+
--slide-content-width: calc((100% - 184px) / 2);
163146

164-
margin: 2.5rem 5rem;
147+
margin: 92px;
165148
}
166149

167-
.carousel .carousel-slide .carousel-slide-content[data-align="justify"] {
150+
.carousel .carousel-slide .carousel-slide-content[data-align='justify'] {
168151
--slide-content-width: auto;
169152
}
170153
}

blocks/carousel/carousel.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export default async function decorate(block) {
135135
const indicator = document.createElement('li');
136136
indicator.classList.add('carousel-slide-indicator');
137137
indicator.dataset.targetSlide = idx;
138-
indicator.innerHTML = `<button type="button"><span>${placeholders.showSlide || 'Show Slide'} ${idx + 1} ${placeholders.of || 'of'} ${rows.length}</span></button>`;
138+
indicator.innerHTML = `<button type="button" aria-label="${placeholders.showSlide || 'Show Slide'} ${idx + 1} ${placeholders.of || 'of'} ${rows.length}"></button>`;
139139
slideIndicators.append(indicator);
140140
}
141141
row.remove();

blocks/columns/columns.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
.columns > div {
2424
align-items: center;
2525
flex-direction: unset;
26-
gap: 32px;
26+
gap: 24px;
2727
}
2828

2929
.columns > div > div {

blocks/footer/footer.css

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
footer {
2-
padding: 2rem;
32
background-color: var(--light-color);
4-
font-size: var(--body-font-size-s);
3+
font-size: var(--body-font-size-xs);
54
}
65

7-
footer .footer {
8-
max-width: 1200px;
6+
footer .footer > div {
97
margin: auto;
8+
max-width: 1200px;
9+
padding: 40px 24px 24px;
1010
}
1111

1212
footer .footer p {
1313
margin: 0;
1414
}
15+
16+
@media (width >= 900px) {
17+
footer .footer > div {
18+
padding: 40px 32px 24px;
19+
}
20+
}

blocks/footer/footer.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ import { loadFragment } from '../fragment/fragment.js';
66
* @param {Element} block The footer block element
77
*/
88
export default async function decorate(block) {
9+
// load footer as fragment
910
const footerMeta = getMetadata('footer');
10-
block.textContent = '';
11-
12-
// load footer fragment
13-
const footerPath = footerMeta.footer || '/footer';
11+
const footerPath = footerMeta ? new URL(footerMeta, window.location).pathname : '/footer';
1412
const fragment = await loadFragment(footerPath);
1513

1614
// decorate footer DOM
15+
block.textContent = '';
1716
const footer = document.createElement('div');
1817
while (fragment.firstElementChild) footer.append(fragment.firstElementChild);
1918

blocks/form/form-fields.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ function createLabel(fd) {
2424
label.id = generateFieldId(fd, '-label');
2525
label.textContent = fd.Label || fd.Name;
2626
label.setAttribute('for', fd.Id);
27+
if (fd.Mandatory.toLowerCase() === 'true' || fd.Mandatory.toLowerCase() === 'x') {
28+
label.dataset.required = true;
29+
}
2730
return label;
2831
}
2932

@@ -103,7 +106,7 @@ const createSelect = async (fd) => {
103106

104107
const fieldWrapper = createFieldWrapper(fd);
105108
fieldWrapper.append(select);
106-
fieldWrapper.append(createLabel(fd));
109+
fieldWrapper.prepend(createLabel(fd));
107110

108111
return { field: select, fieldWrapper };
109112
};
@@ -133,7 +136,7 @@ const createTextArea = (fd) => {
133136
const label = createLabel(fd);
134137
field.setAttribute('aria-labelledby', label.id);
135138
fieldWrapper.append(field);
136-
fieldWrapper.append(label);
139+
fieldWrapper.prepend(label);
137140

138141
return { field, fieldWrapper };
139142
};
@@ -147,7 +150,11 @@ const createInput = (fd) => {
147150
const label = createLabel(fd);
148151
field.setAttribute('aria-labelledby', label.id);
149152
fieldWrapper.append(field);
150-
fieldWrapper.append(label);
153+
if (fd.Type === 'radio' || fd.Type === 'checkbox') {
154+
fieldWrapper.append(label);
155+
} else {
156+
fieldWrapper.prepend(label);
157+
}
151158

152159
return { field, fieldWrapper };
153160
};

0 commit comments

Comments
 (0)