1- import { Router , mount , router , unmount } from 'redom'
2- import type { RedomComponent , RedomEl } from 'redom'
3- import { Counter } from './Counter.js'
4-
5- class H1 implements RedomComponent {
6- public el : RedomEl
7-
8- constructor ( ) {
9- ; < span this = "el" > hello</ span >
10- }
11- }
12-
13- class H2 implements RedomComponent {
14- public el : RedomEl
15-
16- constructor ( ) {
17- ; < span this = "el" > world</ span >
18- }
19- }
20-
21- class Heading {
22- public el : Router
23-
24- constructor ( ) {
25- this . el = router ( 'p.heading' , {
26- h1 : H1 ,
27- h2 : H2
28- } )
29-
30- this . el . update ( 'h1' )
31- }
32- }
33-
34- const list = Array . from ( { length : 5 } , ( ) => Math . random ( ) )
1+ import { mount , unmount } from 'redom-jsx'
2+ import type { RedomComponent , RedomEl } from 'redom-jsx'
3+ import { Counter } from './Counter.jsx'
354
365export class App implements RedomComponent {
37- public el : RedomEl
38- public counter : RedomComponent
39- public button : HTMLElement
40- public router : Router
41- public toggle = true
6+ el : RedomEl
427
43- constructor ( ) {
44- this . render ( )
45- }
8+ private counter : RedomComponent
9+ private button : HTMLElement
4610
47- private render ( ) : void {
48- ; < div this = "el" >
11+ constructor ( ) {
12+ // prettier-ignore
13+ < div this = "el" >
4914 < Counter
5015 this = "counter"
5116 initialValue = { - 10 }
@@ -60,30 +25,7 @@ export class App implements RedomComponent {
6025 }
6126 } }
6227 >
63- mount/unmount counter
64- </ button >
65- < p >
66- Lorem ipsum dolor, sit amet consectetur adipisicing elit. Illum enim
67- veniam id consequatur, dolor recusandae minima dolore ab eius sunt quo
68- totam quasi nam? Cum voluptate et id porro odit!
69- </ p >
70- { list . map ( ( value ) => (
71- < p > { value } </ p >
72- ) ) }
73- < a
74- href = "https://google.com"
75- target = "_blank"
76- >
77- This is link
78- </ a >
79- < Heading this = "router" />
80- < button
81- onclick = { ( ) => {
82- this . toggle = ! this . toggle
83- this . router . el . update ! ( this . toggle ? 'h1' : 'h2' )
84- } }
85- >
86- toggle
28+ Toggle
8729 </ button >
8830 </ div >
8931 }
0 commit comments