Skip to content

Commit

Permalink
Add Dev Kotlin version and update versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
terrakok committed Oct 13, 2021
1 parent eb28edd commit 766e8d2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ buildscript {
gradlePluginPortal()
google()
mavenCentral()
${if (projectInfo.kotlinVersion == KotlinVersion.EAP) "maven(\"https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/\")" else NAN}
${if (projectInfo.kotlinVersion == KotlinVersion.Dev) "maven(\"https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/\")" else NAN}
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${projectInfo.kotlinVersion.versionName}")
Expand All @@ -31,7 +31,7 @@ allprojects {
repositories {
google()
mavenCentral()
${if (projectInfo.kotlinVersion == KotlinVersion.EAP) "maven(\"https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/\")" else NAN}
${if (projectInfo.kotlinVersion == KotlinVersion.Dev) "maven(\"https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/\")" else NAN}
}
}
""".trimIndent().deleteNans()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jetbrains.webwiz.models

enum class KotlinVersion(val versionName: String) {
Stable("1.5.30"),
EAP("1.6.0-M1-329")
Stable("1.5.31"),
EAP("1.6.0-RC"),
Dev("1.6.20-dev-967")
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,29 @@ import org.jetbrains.compose.web.css.*
import org.jetbrains.compose.web.css.selectors.CSSSelector
import org.jetbrains.compose.web.css.selectors.descendant
import org.jetbrains.compose.web.css.selectors.selector
import org.jetbrains.webwiz.style.AppStylesheet
import org.jetbrains.compose.web.dom.Form
import org.jetbrains.compose.web.dom.Input
import org.jetbrains.compose.web.dom.Label
import org.jetbrains.compose.web.dom.Text
import org.jetbrains.webwiz.models.KotlinVersion
import org.jetbrains.compose.web.dom.*
import org.jetbrains.webwiz.style.AppStylesheet

private object SwitcherVariables {
val labelWidth by variable<CSSpxValue>()
val labelPadding by variable<CSSpxValue>()
}

@Composable
fun KotlinVersionSwitcher(versions: Array<KotlinVersion>, state: Map<KotlinVersion, Boolean>, onSelect: (KotlinVersion) -> Unit) {
fun KotlinVersionSwitcher(state: KotlinVersion, onSelect: (KotlinVersion) -> Unit) {
Form(attrs = {
classes(KotlinSwitcherStylesheet.boxed)
}) {
versions.forEach { version ->
KotlinVersion.values().forEach { version ->
Input(type = InputType.Radio, attrs = {
name("code-snippet")
value("snippet$version")
id("snippet$version")
checked(state[version]!!)
checked(version == state)
onClick { onSelect(version) }
})
Label(forId = "snippet$version") { Text("${version.name}") }
Expand All @@ -38,13 +41,6 @@ fun KotlinVersionSwitcher(versions: Array<KotlinVersion>, state: Map<KotlinVersi
object KotlinSwitcherStylesheet : StyleSheet(AppStylesheet) {
val boxed by style {

media(mediaMaxWidth(202.px)) {
self style {
SwitcherVariables.labelWidth(36.px)
SwitcherVariables.labelPadding(5.px)
}
}

backgroundColor(Color("rgb(244,244,244)"))

descendant(self, CSSSelector.Type("label")) style {
Expand Down
22 changes: 2 additions & 20 deletions src/jsMain/kotlin/org/jetbrains/webwiz/content/WizardSection.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ private val defaultProject = ProjectInfo(

internal val projectInfoState = mutableStateOf(defaultProject)

val switcherState = mutableStateOf(mapOf(KotlinVersion.EAP to false, KotlinVersion.Stable to true))

@Composable
@OptIn(ExperimentalComposeWebWidgetsApi::class)
fun WizardSection(callback: (projectInfo: ProjectInfo) -> Unit) = Section({
Expand Down Expand Up @@ -100,25 +98,9 @@ fun WizardSection(callback: (projectInfo: ProjectInfo) -> Unit) = Section({
Text("Kotlin version")
}

Div({ classes(WtOffsets.kotlinSwitcherStyle) }) {
KotlinVersionSwitcher(
KotlinVersion.values(),
switcherState.value
)
{
Div {
KotlinVersionSwitcher(projectInfoState.value.kotlinVersion) {
projectInfoState.value = projectInfoState.value.copy(kotlinVersion = it)
switcherState.value = mapOf(
KotlinVersion.EAP to (
when (it) {
KotlinVersion.EAP -> !switcherState.value[KotlinVersion.EAP]!!
KotlinVersion.Stable -> switcherState.value[KotlinVersion.Stable]!!
}),
KotlinVersion.Stable to (
when (it) {
KotlinVersion.EAP -> switcherState.value[KotlinVersion.EAP]!!
KotlinVersion.Stable -> !switcherState.value[KotlinVersion.Stable]!!
})
)
}
}
}
Expand Down
7 changes: 0 additions & 7 deletions src/jsMain/kotlin/org/jetbrains/webwiz/style/WtOffest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package org.jetbrains.webwiz.style

import org.jetbrains.compose.web.ExperimentalComposeWebApi
import org.jetbrains.compose.web.css.*
import org.jetbrains.compose.web.css.keywords.CSSAutoKeyword
import org.jetbrains.compose.web.css.selectors.descendant
import org.jetbrains.compose.web.css.selectors.selector
import org.jetbrains.compose.web.css.selectors.type

object WtOffsets : StyleSheet(AppStylesheet) {
val wtTopOffset96 by style {
Expand Down Expand Up @@ -44,11 +42,6 @@ object WtOffsets : StyleSheet(AppStylesheet) {
}
}

val kotlinSwitcherStyle by style {
maxWidth(202.px)
minWidth(202.px)
}

val textInputLabelsStyle by style {
width(20.percent)
display(DisplayStyle.InlineBlock)
Expand Down

0 comments on commit 766e8d2

Please sign in to comment.