File tree Expand file tree Collapse file tree 3 files changed +37
-30
lines changed Expand file tree Collapse file tree 3 files changed +37
-30
lines changed Original file line number Diff line number Diff line change 55 < title > custom-element demo</ title >
66 </ head >
77 < body >
8- < custom-element > </ custom-element >
8+ < blink-text > Hello World </ blink-text >
99
1010 < script type ="module ">
1111 // import 'https://unpkg.com/@github/custom-element-boilerplate@latest/dist/custom-element.js'
12- import '../src/custom -element.ts'
12+ import '../src/blink-text -element.ts'
1313 </ script >
1414 </ body >
1515</ html >
Original file line number Diff line number Diff line change 1+ class BlinkTextElement extends HTMLElement {
2+ #renderRoot = this . attachShadow ( { mode : 'open' } )
3+
4+ connectedCallback ( ) : void {
5+ this . #renderRoot. innerHTML = `
6+ <style>
7+ :host {
8+ animation: 1s linear blink infinite;
9+ }
10+ @keyframes blink {
11+ from {
12+ opacity: 0
13+ }
14+ to {
15+ opacity: 1
16+ }
17+ }
18+ </style>
19+ <slot></slot>
20+ `
21+ }
22+ }
23+
24+ declare global {
25+ interface Window {
26+ BlinkTextElement : typeof BlinkTextElement
27+ }
28+ }
29+
30+ export default BlinkTextElement
31+
32+ if ( ! window . customElements . get ( 'blink-text' ) ) {
33+ window . BlinkTextElement = BlinkTextElement
34+ window . customElements . define ( 'blink-text' , BlinkTextElement )
35+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments