11import kotlinx.browser.document
2+ import react.*
3+ import emotion.react.css
4+ import react.dom.render
5+ import csstype.Position
6+ import csstype.px
7+ import react.dom.html.ReactHTML.h1
8+ import react.dom.html.ReactHTML.h3
9+ import react.dom.html.ReactHTML.div
10+ import react.dom.html.ReactHTML.p
11+ import react.dom.html.ReactHTML.img
12+ import kotlinx.serialization.Serializable
13+ import react.dom.client.createRoot
14+
15+ data class Video (
16+ val id : Int ,
17+ val title : String ,
18+ val speaker : String ,
19+ val videoUrl : String ,
20+ )
21+
22+ val unwatchedVideos = listOf (
23+ Video (1 , " Opening Keynote" , " Andrey Breslav" , " https://youtu.be/PsaFVLr8t4E" ),
24+ Video (2 , " Dissecting the stdlib" , " Huyen Tue Dao" , " https://youtu.be/Fzt_9I733Yg" ),
25+ Video (3 , " Kotlin and Spring Boot" , " Nicolas Frankel" , " https://youtu.be/pSiZVAeReeg" )
26+ )
27+
28+ val watchedVideos = listOf (
29+ Video (4 , " Creating Internal DSLs in Kotlin" , " Venkat Subramaniam" , " https://youtu.be/JzTeAM8N1-o" )
30+ )
231
332fun main () {
4- document.bgColor = " red"
33+ val container = document.getElementById(" root" ) ? : error(" Couldn't find root container!" )
34+
35+ createRoot(container).render(Fragment .create {
36+ h1 {
37+ + " Hello, React+Kotlin/JS!"
38+ }
39+ div {
40+ h3 {
41+ + " Videos to watch"
42+ }
43+ for (video in unwatchedVideos) {
44+ p {
45+ + " ${video.speaker} : ${video.title} "
46+ }
47+ }
48+
49+ h3 {
50+ + " Videos watched"
51+ }
52+ for (video in watchedVideos) {
53+ p {
54+ + " ${video.speaker} : ${video.title} "
55+ }
56+ }
57+ }
58+ div {
59+ css {
60+ position = Position .absolute
61+ top = 10 .px
62+ right = 10 .px
63+ }
64+ h3 {
65+ + " John Doe: Building and breaking things"
66+ }
67+ img {
68+ src = " https://via.placeholder.com/640x360.png?text=Video+Player+Placeholder"
69+ }
70+ }
71+ })
572}
0 commit comments