Browse Source

Introduce web-integration-widgets and rename web-integration to web-integration-core

web-integration-widgets is without tests so far
pull/690/head
Shagen Ogandzhanian 4 years ago
parent
commit
4dd4390ecd
  1. 0
      web/integration-core/build.gradle.kts
  2. 0
      web/integration-core/src/jsMain/kotlin/androidx/compose/web/sample/CodeSnippetSamples.kt
  3. 0
      web/integration-core/src/jsMain/kotlin/androidx/compose/web/sample/HighlightJs.kt
  4. 0
      web/integration-core/src/jsMain/kotlin/androidx/compose/web/sample/Sample.kt
  5. 0
      web/integration-core/src/jsMain/kotlin/androidx/compose/web/sample/tests/Common.kt
  6. 0
      web/integration-core/src/jsMain/kotlin/androidx/compose/web/sample/tests/InputsTests.kt
  7. 0
      web/integration-core/src/jsMain/kotlin/androidx/compose/web/sample/tests/TestCases1.kt
  8. 0
      web/integration-core/src/jsMain/resources/hljs.css
  9. 2
      web/integration-core/src/jsMain/resources/index.html
  10. 0
      web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/InputsTests.kt
  11. 0
      web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/IntegrationTests.kt
  12. 0
      web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/BaseIntegrationTests.kt
  13. 0
      web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/ServerLauncher.kt
  14. 0
      web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/StaticServerSetupExtension.kt
  15. 0
      web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/WithChromeDriver.kt
  16. 43
      web/integration-widgets/build.gradle.kts
  17. 131
      web/integration-widgets/src/commonMain/kotlin/App.kt
  18. 33
      web/integration-widgets/src/jsMain/kotlin/androidx/compose/web/with-web/demo.kt
  19. 49
      web/integration-widgets/src/jsMain/resources/index.html
  20. 49
      web/integration-widgets/src/jsMain/resources/styles.css
  21. 25
      web/integration-widgets/src/jvmMain/kotlin/demo.kt
  22. 6
      web/settings.gradle.kts

0
web/integration/build.gradle.kts → web/integration-core/build.gradle.kts

0
web/integration/src/jsMain/kotlin/androidx/compose/web/sample/CodeSnippetSamples.kt → web/integration-core/src/jsMain/kotlin/androidx/compose/web/sample/CodeSnippetSamples.kt

0
web/integration/src/jsMain/kotlin/androidx/compose/web/sample/HighlightJs.kt → web/integration-core/src/jsMain/kotlin/androidx/compose/web/sample/HighlightJs.kt

0
web/integration/src/jsMain/kotlin/androidx/compose/web/sample/Sample.kt → web/integration-core/src/jsMain/kotlin/androidx/compose/web/sample/Sample.kt

0
web/integration/src/jsMain/kotlin/androidx/compose/web/sample/tests/Common.kt → web/integration-core/src/jsMain/kotlin/androidx/compose/web/sample/tests/Common.kt

0
web/integration/src/jsMain/kotlin/androidx/compose/web/sample/tests/InputsTests.kt → web/integration-core/src/jsMain/kotlin/androidx/compose/web/sample/tests/InputsTests.kt

0
web/integration/src/jsMain/kotlin/androidx/compose/web/sample/tests/TestCases1.kt → web/integration-core/src/jsMain/kotlin/androidx/compose/web/sample/tests/TestCases1.kt

0
web/integration/src/jsMain/resources/hljs.css → web/integration-core/src/jsMain/resources/hljs.css

2
web/integration/src/jsMain/resources/index.html → web/integration-core/src/jsMain/resources/index.html

@ -7,5 +7,5 @@
</head>
<body>
</body>
<script src="web-integration.js"></script>
<script src="web-integration-core.js"></script>
</html>

0
web/integration/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/InputsTests.kt → web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/InputsTests.kt

0
web/integration/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/IntegrationTests.kt → web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/IntegrationTests.kt

0
web/integration/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/BaseIntegrationTests.kt → web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/BaseIntegrationTests.kt

0
web/integration/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/ServerLauncher.kt → web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/ServerLauncher.kt

0
web/integration/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/StaticServerSetupExtension.kt → web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/StaticServerSetupExtension.kt

0
web/integration/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/WithChromeDriver.kt → web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration/common/WithChromeDriver.kt

43
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"))
}
}
}
}

131
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()
}

33
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()
}
}

49
web/integration-widgets/src/jsMain/resources/index.html

@ -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.
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>compose-browser-with-web-demo</title>
<link type="text/css" rel="stylesheet" href="styles.css">
</head>
<body>
<h1>with web demo</h1>
<div id="container">
<div id = "rootParent">
<div id="root"></div>
</div>
<div id= "raw">
<div>
<span>
Alfred Sisley
</span>
<span>
3 minutes ago
</span>
<div class="row">
<div class="box-a box"></div>
<div class="box-b box"></div>
</div>
</div>
</div>
</div>
<script src="with-web-demo.js">
</script>
</body>
</html>

49
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;
}

25
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()
}
}

6
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")

Loading…
Cancel
Save