generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created a Dave component with green title and red subtitle.
- Loading branch information
1 parent
b59e8bc
commit 1ff16ad
Showing
2 changed files
with
25 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.dave strong { | ||
color: green; | ||
font-size: 2rem; | ||
font-weight: bold; | ||
border-bottom: 2px solid green; | ||
} | ||
|
||
.dave i { | ||
color: red; | ||
font-size: 1.5rem; | ||
font-style: italic; | ||
} |
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,13 @@ | ||
export default function decorate(block) { | ||
const quoteDiv = block.querySelector('div:last-of-type'); | ||
const dave = document.createElement('dave'); | ||
dave.innerHTML = `<strong>${quoteDiv.innerHTML}</strong>`; | ||
quoteDiv.replaceWith(dave); | ||
|
||
const authorDiv = block.querySelector('div:nth-child(2)'); | ||
if (authorDiv) { | ||
const author = document.createElement('p'); | ||
author.innerHTML = `<i>${authorDiv.innerHTML}</i>`; | ||
authorDiv.replaceWith(author); | ||
} | ||
} |