Skip to content
Snippets Groups Projects
Commit bfc5a91d authored by Oleksandr Karpovich's avatar Oleksandr Karpovich
Browse files

Update web tutorials and template to conform the latest API changes

parent 6e3efa2e
No related branches found
No related tags found
No related merge requests found
...@@ -3,9 +3,9 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat ...@@ -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 {
......
...@@ -175,19 +175,20 @@ You can find a more detailed overview of the style DSL, as well as additional ex ...@@ -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() { ...@@ -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() { ...@@ -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") }
} }
} }
``` ```
\ No newline at end of file
...@@ -60,9 +60,9 @@ There are more event listeners supported out of a box. We plan to add the docume ...@@ -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") {
......
...@@ -93,13 +93,11 @@ kotlin { ...@@ -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)
......
...@@ -10,15 +10,15 @@ In this tutorial we have a look at how to style the components using the Style D ...@@ -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() { ...@@ -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) { ...@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment