Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 146 additions & 0 deletions blocks/hero-trends/hero-trends.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
/* Hero Trends Block */

.hero-trends {
background-color: rgba(139, 254, 248, 0.5); /* Light cyan/turquoise background */
padding: 40px 24px;
}

.hero-trends-container {
max-width: 1248px;
margin: 0 auto;
display: grid;
grid-template-columns: 1fr;
gap: 40px;
align-items: center;
}

/* Content Column */
.hero-trends-content {
display: flex;
flex-direction: column;
gap: 24px;
}

/* Byline */
.hero-trends-byline {
font-family: var(--body-font-family);
font-size: 14.4px;
line-height: 18.72px;
letter-spacing: 0.144px;
text-transform: uppercase;
color: rgba(0, 0, 0, 0.6);
margin: 0;
}

/* Headline */
.hero-trends-headline {
font-family: var(--heading-font-family);
font-size: 60px;
line-height: 1.04;
letter-spacing: -0.904px;
color: var(--text-color);
margin: 0;
font-weight: var(--heading-font-weight);
}

.hero-trends-headline-line {
display: block;
}

/* Description */
.hero-trends-description {
font-family: var(--body-font-family);
font-size: 24px;
line-height: 1.6;
color: var(--text-color);
margin: 0;
max-width: 575px;
}

/* CTA Text */
.hero-trends-cta-text {
font-family: var(--body-font-family);
font-size: 16px;
line-height: 1.6;
color: rgba(0, 0, 0, 0.6);
margin: 0;
max-width: 545px;
}

/* Button */
.hero-trends-button-wrapper {
margin-top: 8px;
}

.hero-trends-button {
display: inline-block;
padding: var(--button-padding);
border-radius: var(--button-border-radius);
background-color: var(--dark-color);
color: var(--text-color-inverse);
text-decoration: none;
font-family: var(--body-font-family);
font-size: 16px;
line-height: 1.2;
box-shadow: 4px 4px 0px 0px rgba(244, 254, 139, 0.5);
border: 2px solid var(--dark-color);
transition: var(--button-transition);
}

.hero-trends-button:hover {
background-color: #333;
box-shadow: 7px 7px 0px 0px rgba(244, 254, 139, 0.5);
}

/* Image Column */
.hero-trends-image {
width: 100%;
max-width: 576px;
margin: 0 auto;
}

.hero-trends-image picture,
.hero-trends-image img {
width: 100%;
height: auto;
border-radius: 20px;
display: block;
object-fit: cover;
aspect-ratio: 576 / 884;
}

/* Desktop Layout (2 columns) */
@media (width >= 900px) {
.hero-trends {
padding: 64px 32px;
}

.hero-trends-container {
grid-template-columns: 1fr 576px;
gap: 64px;
}

.hero-trends-headline {
font-size: 90.4px;
line-height: 1.04;
}

.hero-trends-description {
font-size: 32px;
}

.hero-trends-image {
margin: 0;
}
}

/* Tablet adjustments */
@media (width >= 600px) and (width < 900px) {
.hero-trends-headline {
font-size: 72px;
}

.hero-trends-description {
font-size: 28px;
}
}
108 changes: 108 additions & 0 deletions blocks/hero-trends/hero-trends.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/**
* Hero Trends Block
* Displays a hero section with byline, large stacked headline, description, CTA text, button, and image
*
* Expected structure:
* Row 1: Byline (small text, e.g., "by Taylor Brooks")
* Row 2: Main headline (large text, can be multi-line, e.g., "Trends\nthat\nturn\nheads")
* Row 3: Description text (paragraph)
* Row 4: CTA text (secondary paragraph)
* Row 5: Button link
* Row 6: Image
*/

export default function decorate(block) {
const rows = Array.from(block.children);

// Extract content from rows
const byline = rows[0]?.textContent.trim() || '';
const headline = rows[1]?.textContent.trim() || '';
const description = rows[2]?.textContent.trim() || '';
const ctaText = rows[3]?.textContent.trim() || '';
const buttonElement = rows[4]?.querySelector('a');
const imageElement = rows[5]?.querySelector('picture') || rows[5]?.querySelector('img');

// Clear the block
block.innerHTML = '';

// Create container
const container = document.createElement('div');
container.className = 'hero-trends-container';

// Create content column
const contentColumn = document.createElement('div');
contentColumn.className = 'hero-trends-content';

// Add byline
if (byline) {
const bylineElement = document.createElement('p');
bylineElement.className = 'hero-trends-byline';
bylineElement.textContent = byline;
contentColumn.appendChild(bylineElement);
}

// Add headline (split on newlines and create separate lines)
if (headline) {
const headlineContainer = document.createElement('h1');
headlineContainer.className = 'hero-trends-headline';

// Split headline by newlines and create separate lines
const lines = headline.split('\n').map(line => line.trim()).filter(line => line);
lines.forEach((line, index) => {
const lineElement = document.createElement('span');
lineElement.className = 'hero-trends-headline-line';
lineElement.textContent = line;
headlineContainer.appendChild(lineElement);

// Add line break between lines (except after last)
if (index < lines.length - 1) {
headlineContainer.appendChild(document.createElement('br'));
}
});

contentColumn.appendChild(headlineContainer);
}

// Add description
if (description) {
const descriptionElement = document.createElement('p');
descriptionElement.className = 'hero-trends-description';
descriptionElement.textContent = description;
contentColumn.appendChild(descriptionElement);
}

// Add CTA text
if (ctaText) {
const ctaElement = document.createElement('p');
ctaElement.className = 'hero-trends-cta-text';
ctaElement.textContent = ctaText;
contentColumn.appendChild(ctaElement);
}

// Add button
if (buttonElement) {
const buttonWrapper = document.createElement('div');
buttonWrapper.className = 'hero-trends-button-wrapper';

const button = buttonElement.cloneNode(true);
button.className = 'hero-trends-button button';
buttonWrapper.appendChild(button);

contentColumn.appendChild(buttonWrapper);
}

container.appendChild(contentColumn);

// Create image column
if (imageElement) {
const imageColumn = document.createElement('div');
imageColumn.className = 'hero-trends-image';

const clonedImage = imageElement.cloneNode(true);
imageColumn.appendChild(clonedImage);

container.appendChild(imageColumn);
}

block.appendChild(container);
}
10 changes: 5 additions & 5 deletions styles/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -229,22 +229,22 @@ button {
line-height: 1.2;
text-align: center;
text-decoration: none;
background-color: transparent;
color: var(--text-color);
background-color: var(--dark-color);
color: var(--text-color-inverse);
cursor: pointer;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
box-shadow: var(--button-box-shadow);
box-shadow: none;
transition: var(--button-transition);
}

a.button:hover,
a.button:focus,
button:hover,
button:focus {
background-color: var(--button-background-hover);
box-shadow: var(--button-box-shadow-hover);
background-color: #333;
box-shadow: none;
cursor: pointer;
}

Expand Down
Loading