-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nikos Katsikanis
committed
Oct 26, 2024
1 parent
61c4421
commit dac89ce
Showing
9 changed files
with
164 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
export default (hostComponent) => { | ||
// Extract data attributes | ||
const imageUrl = hostComponent.getAttribute('data-image-url') || 'https://picsum.photos/1600/900'; | ||
const overlayColor = hostComponent.getAttribute('data-overlay-color') || 'rgba(0, 0, 0, 0.5)'; | ||
const header = hostComponent.getAttribute('data-header') || 'Welcome'; | ||
const text = hostComponent.getAttribute('data-text') || 'Your default hero text here.'; | ||
const buttonText = hostComponent.getAttribute('data-button-text') || 'Learn More'; | ||
const buttonLink = hostComponent.getAttribute('data-button-link') || '#'; | ||
|
||
// Inject HTML | ||
hostComponent.innerHTML = ` | ||
<style> | ||
.hero-container { | ||
position: relative; | ||
width: 100%; | ||
height: 100vh; | ||
background-image: url('${imageUrl}'); | ||
background-size: cover; | ||
background-position: center; | ||
background-attachment: fixed; | ||
} | ||
.hero-overlay { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
background-color: ${overlayColor}; | ||
} | ||
.hero-content { | ||
position: relative; | ||
max-width: 800px; | ||
margin: 0 auto; | ||
padding: 5rem 1rem; | ||
color: white; | ||
text-align: left; | ||
} | ||
.hero-header { | ||
font-size: 2.5rem; | ||
font-weight: bold; | ||
margin-bottom: 1rem; | ||
} | ||
.hero-text { | ||
font-size: 1.125rem; | ||
margin-bottom: 1.5rem; | ||
} | ||
.hero-button { | ||
display: inline-block; | ||
padding: 0.75rem 1.5rem; | ||
border: 2px solid white; | ||
color: white; | ||
text-decoration: none; | ||
font-weight: bold; | ||
border-radius: 5px; | ||
transition: background-color 0.3s, color 0.3s; | ||
} | ||
.hero-button:hover { | ||
background-color: white; | ||
color: #1a202c; | ||
} | ||
</style> | ||
<div class="hero-container"> | ||
<div class="hero-overlay"></div> | ||
<div class="hero-content"> | ||
<h1 class="hero-header">${header}</h1> | ||
<p class="hero-text">${text}</p> | ||
<a href="${buttonLink}" class="hero-button">${buttonText}</a> | ||
</div> | ||
</div> | ||
`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Updated narrow-hero component to maintain padding and a fixed height | ||
|
||
export default (hostComponent) => { | ||
const { header = "Default Header", text = "" } = hostComponent.dataset; | ||
|
||
const render = () => { | ||
hostComponent.innerHTML = ` | ||
<style> | ||
.narrow-hero { | ||
position: relative; | ||
width: 100%; | ||
height: 250px; | ||
background: url('https://picsum.photos/1600/900') center/cover no-repeat; | ||
} | ||
.narrow-hero-overlay { | ||
position: absolute; | ||
inset: 0; | ||
/* | ||
background-color: rgba(255, 255, 255, 0.7); | ||
*/ | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
padding: 1rem; | ||
} | ||
.narrow-hero-content { | ||
text-align: center; | ||
max-width: 600px; | ||
margin: auto; | ||
padding: 20px; | ||
background: rgba(255, 255, 255, 0.7); | ||
} | ||
.narrow-hero h1 { | ||
font-size: 2rem; | ||
margin: 0; | ||
color: #333; | ||
} | ||
.narrow-hero p { | ||
font-size: 1rem; | ||
color: #555; | ||
} | ||
</style> | ||
<section class="narrow-hero"> | ||
<div class="narrow-hero-overlay"> | ||
<div class="narrow-hero-content"> | ||
<h1>${header}</h1> | ||
<p>${text}</p> | ||
</div> | ||
</div> | ||
</section> | ||
`; | ||
}; | ||
|
||
render(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export default (hostComponent) => { | ||
// Define HTML structure with data attributes directly in the template | ||
const indexHTML = ` | ||
<div data-component="fullscreen-hero" | ||
data-image-url="https://picsum.photos/1600/900" | ||
data-overlay-color="rgba(0, 0, 0, 0.5)" | ||
data-header="Herzlich willkommen" | ||
data-text="Mit unserer umfassenden Kenntnis des aktuellen Markts..." | ||
data-button-text="Mehr dazu" | ||
data-button-link="/kontakt"> | ||
</div> | ||
<div data-component="narrow-hero" | ||
data-header="Narrow hero"> | ||
</div> | ||
`; | ||
|
||
// Apply HTML to the hostComponent | ||
hostComponent.innerHTML = indexHTML; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters