-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { html, render } from 'lit'; | ||
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js'; | ||
|
||
interface Feature { | ||
icon: string; | ||
textBlock: string; | ||
} | ||
|
||
type TemplateArgs = Feature[]; | ||
|
||
const template = (features: TemplateArgs) => { | ||
return html` | ||
${features.map( | ||
(feature) => html` | ||
<article> | ||
<span class="icon fa-gem">${feature.icon}</span> | ||
<div class="content">${unsafeHTML(feature.textBlock)}</div> | ||
</article> | ||
` | ||
)} | ||
`; | ||
}; | ||
|
||
export default function (block: HTMLElement) { | ||
const rows = block.querySelectorAll(':scope > div'); | ||
let features: Feature[] = []; | ||
[...rows].forEach((row) => { | ||
const icon = row.children[0].innerHTML; | ||
const textBlock = row.children[1].innerHTML; | ||
features.push({ icon, textBlock }); | ||
}); | ||
|
||
block.innerHTML = ''; | ||
|
||
block.style.removeProperty('display'); | ||
render(template(features), block); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default function (block: HTMLElement): void; |