View my-message.mjs
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
export default function MyMessage({ html, state }) { | |
const { attrs } = state | |
const { message='' } = attrs | |
return html` | |
<h1>${ message }</h1> | |
<script type="module"> | |
class MyMessage extends HTMLElement { | |
constructor() { | |
super() |
View as-slots.html
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title></title> | |
</head> | |
<body> | |
<begin-heading> | |
<h2 slot="header"></h2> |
View index.html
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title></title> | |
</head> | |
<body> | |
<template id="my-p-template"> | |
<p> |
View my-message.mjs
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
export default function MyMessage({ html, state }) { | |
const { attrs } = state | |
const { message='' } = attrs | |
return html` | |
<h1>${ message }</h1> | |
<script type="module"> | |
class MyMessage extends HTMLElement { | |
constructor() { | |
super() |
View text-input.mjs
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
export default function InputText({ html, state, utils={} }) { | |
const { attrs={} } = state | |
const { | |
description='', | |
label='', | |
name='', | |
pattern='', | |
placeholder='', | |
value='', | |
min='', |
View custom-element.mjs
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
export default class CustomElement extends HTMLElement { | |
constructor() { | |
super() | |
const templateName = `${this.tagName.toLowerCase()}-template` | |
const template = document.getElementById(templateName) | |
if (template) { | |
this.template = template | |
} | |
else { | |
this.template = document.createElement('template') |
View element-base.mjs
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
export default class ElementBase extends HTMLElement { | |
constructor() { | |
super() | |
const name = this.tagName.toLowerCase() | |
const template = document.getElementById(`${name}-template`) | |
if (template) { | |
this.replaceChildren(template.content.cloneNode(true)) | |
} | |
} | |
} |
View multiple-single-file-web-components.html
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title></title> | |
</head> | |
<body> | |
<template id="a"> | |
<style> | |
slot { |
View single-file-web-component.html
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Single File Web Component</title> | |
</head> | |
<body> | |
<template id=single-file> | |
<style> | |
h1 { |
View main-page.js
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
// Function name would be the page name | |
export async function Main(html, data) { | |
return html`<my-custom-element todos="${data.todos}"></my-custom-element>` | |
} |
NewerOlder