File tree Expand file tree Collapse file tree 3 files changed +66
-14
lines changed Expand file tree Collapse file tree 3 files changed +66
-14
lines changed Original file line number Diff line number Diff line change 88 "preview" : " vite preview"
99 },
1010 "dependencies" : {
11+ "@zero-dependency/dom" : " ^0.10.0" ,
1112 "fireworks-js" : " workspace:*"
1213 },
1314 "devDependencies" : {
Original file line number Diff line number Diff line change 11import { Fireworks } from 'fireworks-js'
2+ import { el } from '@zero-dependency/dom'
23import './style.css'
34
45const app = document . querySelector < HTMLDivElement > ( '#app' ) !
56const fireworks = new Fireworks ( app )
67
7- const button = document . createElement ( 'button' )
8- button . textContent = 'Start'
9- button . style . position = 'absolute'
10- button . style . zIndex = '999'
11- button . addEventListener ( 'click' , ( ) => {
12- fireworks . start ( )
13- stopFireworks ( fireworks )
8+ const start = el (
9+ 'button' ,
10+ {
11+ onclick : ( ) => {
12+ fireworks . start ( )
13+ }
14+ } ,
15+ 'Start'
16+ )
17+
18+ const stop = el (
19+ 'button' ,
20+ {
21+ onclick : ( ) => {
22+ fireworks . waitStop ( )
23+ }
24+ } ,
25+ 'Stop'
26+ )
27+
28+ const launch = el (
29+ 'button' ,
30+ {
31+ onclick : ( ) => {
32+ fireworks . launch ( Number ( fires . value ) )
33+ }
34+ } ,
35+ 'Launch'
36+ )
37+
38+ const fires = el ( 'input' , {
39+ value : '1' ,
40+ type : 'number' ,
41+ placeholder : 'count' ,
42+ style : {
43+ width : '2rem'
44+ }
1445} )
1546
16- document . body . appendChild ( button )
47+ const buttons = el (
48+ 'div' ,
49+ {
50+ style : {
51+ position : 'absolute' ,
52+ display : 'flex' ,
53+ gap : '4px'
54+ }
55+ } ,
56+ start ,
57+ stop ,
58+ launch ,
59+ fires
60+ )
1761
18- async function stopFireworks ( fireworks : Fireworks ) {
19- console . time ( )
20- await new Promise ( ( resolve ) => setTimeout ( resolve , 2000 ) )
21- await fireworks . waitStop ( )
22- console . timeEnd ( )
23- }
62+ document . body . appendChild ( buttons )
You can’t perform that action at this time.
0 commit comments