Browse Source

Update web tutorials and template to conform the latest API changes

pull/737/head
Oleksandr Karpovich 3 years ago
parent
commit
bfc5a91d2a
  1. 4
      templates/web-template/build.gradle.kts
  2. 30
      tutorials/Web/Building_UI/README.md
  3. 6
      tutorials/Web/Events_Handling/README.md
  4. 12
      tutorials/Web/Getting_Started/README.md
  5. 21
      tutorials/Web/Style_Dsl/README.md

4
templates/web-template/build.gradle.kts

@ -3,9 +3,9 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat
plugins { plugins {
// __KOTLIN_COMPOSE_VERSION__ // __KOTLIN_COMPOSE_VERSION__
kotlin("multiplatform") version "1.5.0" kotlin("multiplatform") version "1.5.10"
// __LATEST_COMPOSE_RELEASE_VERSION__ // __LATEST_COMPOSE_RELEASE_VERSION__
id("org.jetbrains.compose") version ("0.0.0-web-dev-13") id("org.jetbrains.compose") version ("0.0.0-web-dev-14")
} }
repositories { repositories {

30
tutorials/Web/Building_UI/README.md

@ -175,19 +175,20 @@ You can find a more detailed overview of the style DSL, as well as additional ex
### Runnable example ### Runnable example
```kotlin ```kotlin
import androidx.compose.web.elements.* import androidx.compose.runtime.Composable
import androidx.compose.web.attributes.* import org.jetbrains.compose.web.attributes.*
import androidx.compose.web.css.* import org.jetbrains.compose.web.css.*
import androidx.compose.web.renderComposable import org.jetbrains.compose.web.dom.*
import org.jetbrains.compose.web.renderComposable
fun main() { fun main() {
renderComposable(rootElementId = "root") { renderComposable(rootElementId = "root") {
Div( Div(
attrs = { attrs = {
// specify attributes here // specify attributes here
}, style {
style = { // specify inline style here
// specify inline style here }
} }
) { ) {
Text("A text in <div>") Text("A text in <div>")
@ -196,17 +197,16 @@ fun main() {
Input( Input(
type = InputType.Text, // All InputTypes supported type = InputType.Text, // All InputTypes supported
value = "", // sets the input value value = "", // sets the input value
attrs = {}, attrs = {}
style = {}
) )
Input(attrs = { type(InputType.Text) }) Input(attrs = { type(InputType.Text) })
Text("Arbitrary text") Text("Arbitrary text")
Span( Span({
style = { color("red") } // inline style style { color("red") } // inline style
) { }) {
Text("Red text") Text("Red text")
} }
@ -241,15 +241,15 @@ fun main() {
} }
) { Text("Button") } ) { Text("Button") }
Div( Div({
style = { style {
display(DisplayStyle.Flex) display(DisplayStyle.Flex)
padding(20.px) padding(20.px)
// custom property // custom property
property("font-family", value("Arial, Helvetica, sans-serif")) property("font-family", value("Arial, Helvetica, sans-serif"))
} }
) { Text("Text in Div with inline style") } }) { Text("Text in Div with inline style") }
} }
} }
``` ```

6
tutorials/Web/Events_Handling/README.md

@ -60,9 +60,9 @@ There are more event listeners supported out of a box. We plan to add the docume
```kotlin ```kotlin
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.web.elements.* import org.jetbrains.compose.web.css.*
import androidx.compose.web.attributes.* import org.jetbrains.compose.web.dom.*
import androidx.compose.web.renderComposable import org.jetbrains.compose.web.renderComposable
fun main() { fun main() {
renderComposable(rootElementId = "root") { renderComposable(rootElementId = "root") {

12
tutorials/Web/Getting_Started/README.md

@ -93,13 +93,11 @@ kotlin {
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.web.css.padding import androidx.compose.runtime.Composable
import androidx.compose.web.css.px import org.jetbrains.compose.web.attributes.*
import androidx.compose.web.elements.Button import org.jetbrains.compose.web.css.*
import androidx.compose.web.elements.Div import org.jetbrains.compose.web.dom.*
import androidx.compose.web.elements.Span import org.jetbrains.compose.web.renderComposable
import androidx.compose.web.elements.Text
import androidx.compose.web.renderComposable
fun main() { fun main() {
var count: Int by mutableStateOf(0) var count: Int by mutableStateOf(0)

21
tutorials/Web/Style_Dsl/README.md

@ -10,15 +10,15 @@ In this tutorial we have a look at how to style the components using the Style D
You can declare inline styles via the `style` block of a component You can declare inline styles via the `style` block of a component
``` kotlin ``` kotlin
Div( Div({
style = { style {
display(DisplayStyle.Flex) display(DisplayStyle.Flex)
padding(20.px) padding(20.px)
// custom property (or not supported out of a box) // custom property (or not supported out of a box)
property("font-family", value("Arial, Helvetica, sans-serif")) property("font-family", value("Arial, Helvetica, sans-serif"))
} }
) { /* content goes here */ } }) { /* content goes here */ }
``` ```
In HTML, it will look like this: In HTML, it will look like this:
@ -164,11 +164,10 @@ object MyStyleSheet: StyleSheet() {
### Runnable example ### Runnable example
```kotlin ```kotlin
import androidx.compose.runtime.* import androidx.compose.runtime.Composable
import androidx.compose.web.elements.* import org.jetbrains.compose.web.css.*
import androidx.compose.web.attributes.* import org.jetbrains.compose.web.dom.*
import androidx.compose.web.css.* import org.jetbrains.compose.web.renderComposable
import androidx.compose.web.renderComposable
object AppStylesheet : StyleSheet() { object AppStylesheet : StyleSheet() {
val container by style { // container is a class val container by style { // container is a class
@ -191,15 +190,15 @@ fun Container(content: @Composable () -> Unit) {
fun main() { fun main() {
renderComposable(rootElementId = "root") { renderComposable(rootElementId = "root") {
Div( Div({
style = { style {
display(DisplayStyle.Flex) display(DisplayStyle.Flex)
padding(20.px) padding(20.px)
// custom property (or not supported out of a box) // custom property (or not supported out of a box)
property("font-family", value("Arial, Helvetica, sans-serif")) property("font-family", value("Arial, Helvetica, sans-serif"))
} }
) { /* content goes here */ } }) { /* content goes here */ }
Style(AppStylesheet) Style(AppStylesheet)

Loading…
Cancel
Save