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 5
5
< title > custom-element demo</ title >
6
6
</ head >
7
7
< body >
8
- < custom-element > </ custom-element >
8
+ < blink-text > Hello World </ blink-text >
9
9
10
10
< script type ="module ">
11
11
// 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'
13
13
</ script >
14
14
</ body >
15
15
</ 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