Skip to content

Commit

Permalink
Updated no-socket usages
Browse files Browse the repository at this point in the history
  • Loading branch information
smilefx committed Nov 4, 2024
1 parent 45bf15e commit 5ea4b76
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
6 changes: 6 additions & 0 deletions bgw-gui/src/commonMain/kotlin/PropData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ enum class Action {
DRAG_DROP,
}

@Serializable
class JsonData(
var container : String = "bgw-root",
var props : PropData
)

@Serializable
class PropData(
var data: Data? = null
Expand Down
11 changes: 8 additions & 3 deletions bgw-gui/src/jsMain/kotlin/tools/aqua/bgw/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import ComponentViewData
import Data
import DialogData
import ID
import JsonData
import PropData
import SceneData
import VisualData
Expand Down Expand Up @@ -55,11 +56,15 @@ fun main() {
}
} else {
document.addEventListener("BGW_MSG", {
val cont = document.getElementById("bgw-root")
val event = it as CustomEvent
val data = event.detail
val jsonData = jsonMapper.decodeFromString<JsonData>(data.toString())
val receivedData = jsonData.props.data
val containerId = jsonData.container

val cont = document.getElementById(containerId)
if (cont != null) {
container = cont as HTMLElement
val data = (it as CustomEvent).detail
val receivedData = jsonMapper.decodeFromString<PropData>(data.toString()).data
handleReceivedData(receivedData!!)
}
})
Expand Down
16 changes: 8 additions & 8 deletions bgw-gui/src/jsMain/kotlin/tools/aqua/bgw/elements/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ val App = FC<AppProps> { props ->
}
}

"#bgw-root-container" {
".bgw-root-container" {
width = 100.pct
height = 100.pct
position = Position.absolute
Expand All @@ -54,13 +54,13 @@ val App = FC<AppProps> { props ->
containerType = ContainerType.size
}

"#bgw-root *" {
".bgw-root *" {
transformOrigin = TransformOrigin(GeometryPosition.center, GeometryPosition.center)
}

// BLUE
"@container bgwContainer (min-aspect-ratio: ${props.data.width}/${props.data.height}) and (orientation: landscape)" {
"#bgw-root" {
".bgw-root" {
fontSize = (100.0 / props.data.height).cqh
width = 100.cqw
height = 100.cqh
Expand All @@ -81,7 +81,7 @@ val App = FC<AppProps> { props ->

// RED
"@container bgwContainer (max-aspect-ratio: ${props.data.width}/${props.data.height}) and (orientation: landscape)" {
"#bgw-root" {
".bgw-root" {
fontSize = (100.0 / props.data.width).cqw
width = 100.cqw
height = 100.cqh
Expand All @@ -102,7 +102,7 @@ val App = FC<AppProps> { props ->

// GREEN
"@container bgwContainer (min-aspect-ratio: ${props.data.width}/${props.data.height}) and (orientation: portrait)" {
"#bgw-root" {
".bgw-root" {
fontSize = (100.0 / props.data.height).cqh
width = 100.cqw
height = 100.cqh
Expand All @@ -123,7 +123,7 @@ val App = FC<AppProps> { props ->

// YELLOW
"@container bgwContainer (max-aspect-ratio: ${props.data.width}/${props.data.height}) and (orientation: portrait)" {
"#bgw-root" {
".bgw-root" {
fontSize = (100.0 / props.data.width).cqw
width = 100.cqw
height = 100.cqh
Expand All @@ -142,7 +142,7 @@ val App = FC<AppProps> { props ->
}
}

"#bgw-root" {
".bgw-root" {
backgroundColor = rgb(0, 0, 0, 1.0)
color = rgb(0, 0, 0)
margin = 0.px
Expand Down Expand Up @@ -292,7 +292,7 @@ val App = FC<AppProps> { props ->
transform = translatex(12.em)
}

"#bgw-root" {
".bgw-root" {
width = 100.pct
height = 100.pct
position = Position.absolute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ val internalChannel: Channel = Channel("/internal").apply {
fun HTML.index() {
body {
div {
id = "bgw-root-container"
classes = setOf("bgw-root-container")
div {
classes = setOf("bgw-root")
id = "bgw-root"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import org.gradle.api.tasks.Copy
import org.gradle.api.tasks.JavaExec
import org.gradle.api.tasks.bundling.Jar
import org.gradle.kotlin.dsl.*
import org.jetbrains.dokka.DokkaConfiguration
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
Expand All @@ -28,6 +29,7 @@ plugins {
application
`maven-publish`
id("io.gitlab.arturbosch.detekt")
id("org.jetbrains.dokka")
}

val useSockets: String? = project.findProperty("useSockets")?.toString()
Expand Down

0 comments on commit 5ea4b76

Please sign in to comment.