diff --git a/web/integration/build.gradle.kts b/web/integration-core/build.gradle.kts similarity index 100% rename from web/integration/build.gradle.kts rename to web/integration-core/build.gradle.kts diff --git a/web/integration/src/jsMain/kotlin/androidx/compose/web/sample/CodeSnippetSamples.kt b/web/integration-core/src/jsMain/kotlin/androidx/compose/web/sample/CodeSnippetSamples.kt similarity index 100% rename from web/integration/src/jsMain/kotlin/androidx/compose/web/sample/CodeSnippetSamples.kt rename to web/integration-core/src/jsMain/kotlin/androidx/compose/web/sample/CodeSnippetSamples.kt diff --git a/web/integration/src/jsMain/kotlin/androidx/compose/web/sample/HighlightJs.kt b/web/integration-core/src/jsMain/kotlin/androidx/compose/web/sample/HighlightJs.kt similarity index 100% rename from web/integration/src/jsMain/kotlin/androidx/compose/web/sample/HighlightJs.kt rename to web/integration-core/src/jsMain/kotlin/androidx/compose/web/sample/HighlightJs.kt diff --git a/web/integration/src/jsMain/kotlin/androidx/compose/web/sample/Sample.kt b/web/integration-core/src/jsMain/kotlin/androidx/compose/web/sample/Sample.kt similarity index 100% rename from web/integration/src/jsMain/kotlin/androidx/compose/web/sample/Sample.kt rename to web/integration-core/src/jsMain/kotlin/androidx/compose/web/sample/Sample.kt diff --git a/web/integration/src/jsMain/kotlin/androidx/compose/web/sample/tests/Common.kt b/web/integration-core/src/jsMain/kotlin/androidx/compose/web/sample/tests/Common.kt similarity index 100% rename from web/integration/src/jsMain/kotlin/androidx/compose/web/sample/tests/Common.kt rename to web/integration-core/src/jsMain/kotlin/androidx/compose/web/sample/tests/Common.kt diff --git a/web/integration/src/jsMain/kotlin/androidx/compose/web/sample/tests/InputsTests.kt b/web/integration-core/src/jsMain/kotlin/androidx/compose/web/sample/tests/InputsTests.kt similarity index 100% rename from web/integration/src/jsMain/kotlin/androidx/compose/web/sample/tests/InputsTests.kt rename to web/integration-core/src/jsMain/kotlin/androidx/compose/web/sample/tests/InputsTests.kt diff --git a/web/integration/src/jsMain/kotlin/androidx/compose/web/sample/tests/TestCases1.kt b/web/integration-core/src/jsMain/kotlin/androidx/compose/web/sample/tests/TestCases1.kt similarity index 100% rename from web/integration/src/jsMain/kotlin/androidx/compose/web/sample/tests/TestCases1.kt rename to web/integration-core/src/jsMain/kotlin/androidx/compose/web/sample/tests/TestCases1.kt diff --git a/web/integration/src/jsMain/resources/hljs.css b/web/integration-core/src/jsMain/resources/hljs.css similarity index 100% rename from web/integration/src/jsMain/resources/hljs.css rename to web/integration-core/src/jsMain/resources/hljs.css diff --git a/web/integration/src/jsMain/resources/index.html b/web/integration-core/src/jsMain/resources/index.html similarity index 79% rename from web/integration/src/jsMain/resources/index.html rename to web/integration-core/src/jsMain/resources/index.html index 77ef68f965..cc52ab7d00 100644 --- a/web/integration/src/jsMain/resources/index.html +++ b/web/integration-core/src/jsMain/resources/index.html @@ -7,5 +7,5 @@ - + diff --git a/web/integration/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/InputsTests.kt b/web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/InputsTests.kt similarity index 100% rename from web/integration/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/InputsTests.kt rename to web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/InputsTests.kt diff --git a/web/integration/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/IntegrationTests.kt b/web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/IntegrationTests.kt similarity index 100% rename from web/integration/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/IntegrationTests.kt rename to web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/IntegrationTests.kt diff --git a/web/integration/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/BaseIntegrationTests.kt b/web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/BaseIntegrationTests.kt similarity index 100% rename from web/integration/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/BaseIntegrationTests.kt rename to web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/BaseIntegrationTests.kt diff --git a/web/integration/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/ServerLauncher.kt b/web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/ServerLauncher.kt similarity index 100% rename from web/integration/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/ServerLauncher.kt rename to web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/ServerLauncher.kt diff --git a/web/integration/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/StaticServerSetupExtension.kt b/web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/StaticServerSetupExtension.kt similarity index 100% rename from web/integration/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/StaticServerSetupExtension.kt rename to web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/StaticServerSetupExtension.kt diff --git a/web/integration/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/WithChromeDriver.kt b/web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/WithChromeDriver.kt similarity index 100% rename from web/integration/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/WithChromeDriver.kt rename to web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/WithChromeDriver.kt diff --git a/web/integration-widgets/build.gradle.kts b/web/integration-widgets/build.gradle.kts new file mode 100644 index 0000000000..769854db4f --- /dev/null +++ b/web/integration-widgets/build.gradle.kts @@ -0,0 +1,43 @@ +plugins { + id("kotlin-multiplatform") + id("org.jetbrains.compose") +} + + +kotlin { + js(IR) { + browser() { + testTask { + testLogging.showStandardStreams = true + useKarma { + useChromeHeadless() + useFirefox() + } + } + } + binaries.executable() + } + + sourceSets { + val commonMain by getting { + dependencies { + implementation(compose.runtime) + implementation(project(":web-core")) + implementation(kotlin("stdlib-common")) + } + } + + val jsMain by getting { + dependencies { + implementation(kotlin("stdlib-js")) + implementation(npm("highlight.js", "10.7.2")) + } + } + + val jsTest by getting { + dependencies { + implementation(kotlin("test-js")) + } + } + } +} diff --git a/web/integration-widgets/src/commonMain/kotlin/App.kt b/web/integration-widgets/src/commonMain/kotlin/App.kt new file mode 100644 index 0000000000..5c4e545978 --- /dev/null +++ b/web/integration-widgets/src/commonMain/kotlin/App.kt @@ -0,0 +1,131 @@ +package org.jetbrainsc.compose.common.demo + +import androidx.compose.runtime.Composable +import org.jetbrains.compose.common.foundation.layout.Box +import org.jetbrains.compose.common.ui.Modifier +import org.jetbrains.compose.common.ui.size +import org.jetbrains.compose.common.ui.background +import org.jetbrains.compose.common.ui.padding +import org.jetbrains.compose.common.ui.unit.dp +import org.jetbrains.compose.common.core.graphics.Color +import org.jetbrains.compose.common.foundation.layout.Row +import org.jetbrains.compose.common.foundation.layout.Column +import org.jetbrains.compose.common.foundation.layout.Arrangement +import org.jetbrains.compose.common.ui.Alignment +import org.jetbrains.compose.common.foundation.border +import org.jetbrains.compose.common.material.Text +import org.jetbrains.compose.common.ui.unit.em +import org.jetbrains.compose.common.material.Slider +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import org.jetbrains.compose.common.material.Button +import org.jetbrains.compose.common.foundation.layout.width +import org.jetbrains.compose.common.foundation.clickable +import org.jetbrains.compose.common.ui.draw.clip +import jetbrains.compose.common.shapes.CircleShape + +object LayoutSamples { + @Composable + fun TwoTexts() { + Text("Alfred Sisley") + Text("3 minutes ago") + } + + @Composable + fun TwoTextsInColumn() { + val defaultFontSize = 0.79f + val fontSize = remember { mutableStateOf(defaultFontSize) } + val subtitleColor = remember { mutableStateOf(Color(0, 0, 200)) } + Column { + Text("Alfred Sisley") + Text( + "3 minutes ago", + color = subtitleColor.value, + size = fontSize.value.em, + modifier = Modifier.clickable { + subtitleColor.value = Color.Yellow + } + ) + Slider( + fontSize.value, + onValueChange = { value -> + fontSize.value = value + }, + valueRange = 0.1f..1.2f, + steps = 80, + modifier = Modifier.width(200.dp) + ) + Button( + onClick = { + fontSize.value = defaultFontSize + } + ) { + Text("reset view") + } + } + } + + @Composable + fun TwoTextsInRow() { + Text("Alfred Sisley") + Text("3 minutes ago") + } + + @Composable + fun Layouts() { + val horizontalArrangements = listOf(Arrangement.Start, Arrangement.End) + val verticalAlignments = listOf(Alignment.Top, Alignment.CenterVertically, Alignment.Bottom) + Column() { + horizontalArrangements.forEach { horizontalArrangement -> + verticalAlignments.forEach { verticalAlignment -> + Row( + modifier = Modifier + .size(150.dp) + .padding(4.dp) + .border(1.dp, Color(0, 0, 200)) + .background(Color.Yellow), + horizontalArrangement = horizontalArrangement, + verticalAlignment = verticalAlignment + ) { + Box(Modifier.size(50.dp).background(Color.Red)) { } + Box(Modifier.size(30.dp).background(Color.Blue)) { } + } + } + } + } + } + + @Composable + fun LayoutsClipped() { + val horizontalArrangements = listOf(Arrangement.Start, Arrangement.End) + val verticalAlignments = listOf(Alignment.Top, Alignment.CenterVertically, Alignment.Bottom) + Column() { + horizontalArrangements.forEach { horizontalArrangement -> + verticalAlignments.forEach { verticalAlignment -> + Row( + modifier = Modifier + .size(150.dp) + .padding(4.dp) + .border(1.dp, Color(0, 0, 200)) + .background(Color.Yellow), + horizontalArrangement = horizontalArrangement, + verticalAlignment = verticalAlignment + ) { + Box(Modifier.size(50.dp).background(Color.Red)) { } + Box( + Modifier + .clip(CircleShape) + .size(30.dp) + .background(Color.Blue) + ) { } + } + } + } + } + } +} + +@Composable +fun App() { + LayoutSamples.TwoTextsInColumn() +} \ No newline at end of file diff --git a/web/integration-widgets/src/jsMain/kotlin/androidx/compose/web/with-web/demo.kt b/web/integration-widgets/src/jsMain/kotlin/androidx/compose/web/with-web/demo.kt new file mode 100644 index 0000000000..f595431042 --- /dev/null +++ b/web/integration-widgets/src/jsMain/kotlin/androidx/compose/web/with-web/demo.kt @@ -0,0 +1,33 @@ +/* + * Copyright 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrainsc.compose.common.demo + +import androidx.compose.web.renderComposable +import kotlinx.browser.document +import org.w3c.dom.HTMLElement +import androidx.compose.web.css.Style +import org.jetbrains.compose.web.ui.Styles + +fun main() { + val root = document.getElementById("root") as HTMLElement + + renderComposable( + root = root + ) { + Style(Styles) + App() + } +} \ No newline at end of file diff --git a/web/integration-widgets/src/jsMain/resources/index.html b/web/integration-widgets/src/jsMain/resources/index.html new file mode 100644 index 0000000000..12b4fd3a64 --- /dev/null +++ b/web/integration-widgets/src/jsMain/resources/index.html @@ -0,0 +1,49 @@ + + + + + + + compose-browser-with-web-demo + + + +

with web demo

+ +
+
+
+
+
+
+ + Alfred Sisley + + + 3 minutes ago + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/web/integration-widgets/src/jsMain/resources/styles.css b/web/integration-widgets/src/jsMain/resources/styles.css new file mode 100644 index 0000000000..34f25b7f43 --- /dev/null +++ b/web/integration-widgets/src/jsMain/resources/styles.css @@ -0,0 +1,49 @@ +/* + * Copyright 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#container { + display: flex; +} + +#rootParent { + background: lemonchiffon; + flex: 1 1 0px; +} + +#raw { + background: powderblue; + flex: 1 1 0px; +} + +.row { + width: 150px; + height: 150px; + background: yellow; + display: flex; + align-items: end; +} + +.box-a { + background: red; + width: 50px; + height: 50px; +} + +.box-b { + background: blue; + width: 30px; + height: 30px; +} \ No newline at end of file diff --git a/web/integration-widgets/src/jvmMain/kotlin/demo.kt b/web/integration-widgets/src/jvmMain/kotlin/demo.kt new file mode 100644 index 0000000000..be31c2c1f7 --- /dev/null +++ b/web/integration-widgets/src/jvmMain/kotlin/demo.kt @@ -0,0 +1,25 @@ +/* + * Copyright 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrainsc.compose.common.demo + +import androidx.compose.desktop.Window +import androidx.compose.ui.unit.IntSize + +fun main() { + Window(title = "Demo", size = IntSize(800, 800)) { + App() + } +} \ No newline at end of file diff --git a/web/settings.gradle.kts b/web/settings.gradle.kts index 05511b99e3..395a114be4 100644 --- a/web/settings.gradle.kts +++ b/web/settings.gradle.kts @@ -20,7 +20,9 @@ pluginManagement { } include("web-core") -include("web-integration") +include("web-integration-core") +include("web-integration-widgets") project(":web-core").projectDir = file("$rootDir/core") -project(":web-integration").projectDir = file("$rootDir/integration") +project(":web-integration-core").projectDir = file("$rootDir/integration-core") +project(":web-integration-widgets").projectDir = file("$rootDir/integration-widgets")