Skip to content

Commit

Permalink
Update compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
altavir committed Feb 4, 2024
1 parent 95be28d commit 2cc24a2
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 69 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ val plotlyVersion by extra("2.29.0")

allprojects {
group = "space.kscience"
version = "0.7.0-dev-1"
version = "0.7.0-dev-2"
}

apiValidation {
Expand Down
4 changes: 2 additions & 2 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
val copyPlotlyResources by tasks.creating(Copy::class){
dependsOn(":plotlykt-core:jvmProcessResources")
mustRunAfter(":plotlykt-core:jvmTestProcessResources")
from(project(":plotlykt-core").buildDir.resolve("processedResources/jvm"))
into(buildDir.resolve("resources"))
from(project(":plotlykt-core").layout.buildDirectory.file("processedResources/jvm"))
into(layout.buildDirectory.file("resources"))
}

tasks.getByName("classes").dependsOn(copyPlotlyResources)
Expand Down
63 changes: 59 additions & 4 deletions examples/src/main/kotlin/tabPageLayout.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import kotlinx.html.*
import space.kscience.plotly.*
import space.kscience.plotly.models.Trace
import space.kscience.plotly.models.invoke
Expand All @@ -6,6 +7,60 @@ import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.sin


public class PlotTabs {
public data class Tab(val title: String, val id: String, val content: PlotlyFragment)

private val _tabs = ArrayList<Tab>()
public val tabs: List<Tab> get() = _tabs

public fun tab(title: String, id: String = title, block: FlowContent.(renderer: PlotlyRenderer) -> Unit) {
_tabs.add(Tab(title, id, PlotlyFragment(block)))
}
}

public fun Plotly.tabs(tabsID: String = "tabs", block: PlotTabs.() -> Unit): PlotlyPage {
val grid = PlotTabs().apply(block)

return page(cdnBootstrap, cdnPlotlyHeader) { container ->
ul("nav nav-tabs") {
role = "tablist"
id = tabsID
grid.tabs.forEachIndexed { index, tab ->
li("nav-item") {
a(classes = "nav-link") {
if (index == 0) {
classes = classes + "active"
}
id = "${tab.id}-tab"
attributes["data-toggle"] = "tab"
href = "#${tab.id}"
role = "tab"
attributes["aria-controls"] = tab.id
attributes["aria-selected"] = "true"
+tab.title
}
}
}
}
div("tab-content") {
id = "$tabsID-content"
grid.tabs.forEachIndexed { index, tab ->
div("tab-pane fade") {
if (index == 0) {
classes = classes + setOf("show", "active")
}
id = tab.id
role = "tabpanel"
attributes["aria-labelledby"] = "${tab.id}-tab"
tab.content.render(this, container)
}
}
}
}
}


@Suppress("DEPRECATION")
@UnstablePlotlyAPI
fun main() {
Expand All @@ -26,14 +81,14 @@ fun main() {

}

val responsive = PlotlyConfig{
val responsive = PlotlyConfig {
responsive = true
}

val plot = Plotly.tabs {

tab("First"){
plot (config = responsive){
tab("First") {
plot(config = responsive) {
traces(trace1)
layout {
title = "First graph"
Expand All @@ -42,7 +97,7 @@ fun main() {
}
}
}
tab("Second"){
tab("Second") {
plot(config = responsive) {
traces(trace2)
layout {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ kotlin.mpp.stability.nowarn=true
kotlin.jupyter.add.scanner=false
kotlin.incremental.js.ir=true

toolsVersion=0.15.2-kotlin-1.9.21
toolsVersion=0.15.2-kotlin-1.9.22
4 changes: 2 additions & 2 deletions plotlykt-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ kscience {

dependencies {
api("space.kscience:dataforge-meta:$dataforgeVersion")
//api(spclibs.kotlinx.html)
api("org.jetbrains.kotlinx:kotlinx-html:0.11.0")
api(spclibs.kotlinx.html)
// api("org.jetbrains.kotlinx:kotlinx-html:0.11.0")
}

jsMain{
Expand Down
59 changes: 0 additions & 59 deletions plotlykt-core/src/jvmMain/kotlin/space/kscience/plotly/PlotTabs.kt

This file was deleted.

0 comments on commit 2cc24a2

Please sign in to comment.