diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml
new file mode 100644
index 0000000000000000000000000000000000000000..461dc74c894e589191a13401f758b178b5f96200
--- /dev/null
+++ b/.idea/dataSources.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="DataSourceManagerImpl" format="xml" multifile-model="true">
+ <data-source source="LOCAL" name="todolist@localhost" uuid="ba09c4df-fae5-497d-84f3-590b8d045d84">
+ <driver-ref>mongo</driver-ref>
+ <synchronize>true</synchronize>
+ <jdbc-driver>com.dbschema.MongoJdbcDriver</jdbc-driver>
+ <jdbc-url>mongodb://localhost:27017/todolist</jdbc-url>
+ <jdbc-additional-properties>
+ <property name="com.intellij.clouds.kubernetes.db.host.port" />
+ <property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
+ <property name="com.intellij.clouds.kubernetes.db.container.port" />
+ </jdbc-additional-properties>
+ <working-dir>$ProjectFileDir$</working-dir>
+ </data-source>
+ </component>
+</project>
\ No newline at end of file
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
new file mode 100644
index 0000000000000000000000000000000000000000..1c6e4f9fe9b360fa444a5b28390e47eff25ee3ce
--- /dev/null
+++ b/.idea/kotlinc.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="Kotlin2JvmCompilerArguments">
+ <option name="jvmTarget" value="11" />
+ </component>
+ <component name="KotlinCommonCompilerArguments">
+ <option name="apiVersion" value="2.0" />
+ <option name="languageVersion" value="2.0" />
+ </component>
+ <component name="KotlinCompilerSettings">
+ <option name="scriptTemplates" value="-jvm-target 1.8" />
+ </component>
+</project>
\ No newline at end of file
diff --git a/.idea/material_theme_project_new.xml b/.idea/material_theme_project_new.xml
new file mode 100644
index 0000000000000000000000000000000000000000..77e17563923b3625dfafa48a4e2b5d64fe9f7d93
--- /dev/null
+++ b/.idea/material_theme_project_new.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="MaterialThemeProjectNewConfig">
+ <option name="metadata">
+ <MTProjectMetadataState>
+ <option name="userId" value="385a729:192ac2e6929:-7fff" />
+ </MTProjectMetadataState>
+ </option>
+ </component>
+</project>
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 0dcb80b40b6d1915a6dbbc60509d32007183bfe4..1cb24d3db54cd5de9e7158eecb29b5f0e027285c 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
- <component name="ProjectRootManager" version="2" languageLevel="JDK_22" project-jdk-name="openjdk-22" project-jdk-type="JavaSDK" />
+ <component name="FrameworkDetectionExcludesConfiguration">
+ <file type="web" url="file://$PROJECT_DIR$" />
+ </component>
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="openjdk-22" project-jdk-type="JavaSDK" />
</project>
\ No newline at end of file
diff --git a/build.gradle.kts b/build.gradle.kts
index 702e39a27dd7fa6dad1bacab06c881c4e686bdea..fdbd8a1bc811a96f00650c4034241894721c9ddb 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -4,4 +4,7 @@ subprojects {
google()
maven("https://us-central1-maven.pkg.dev/varabyte-repos/public")
}
+
+
+
}
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 88ac71b12a4cb38700d1ef5820d1d14c754d1f53..380be43890851bd5b3a762f83112a7f6fbc250d4 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -2,7 +2,8 @@
jetbrains-compose = "1.6.11"
kobweb = "0.19.2"
kotlin = "2.0.20"
-kotlinx-serialization = "1.4.0"
+serialization = "1.4.0"
+mongodb-kotlin = "4.10.1"
[libraries]
compose-html-core = { module = "org.jetbrains.compose.html:html-core", version.ref = "jetbrains-compose" }
@@ -10,8 +11,10 @@ compose-runtime = { module = "org.jetbrains.compose.runtime:runtime", version.re
kobweb-api = { module = "com.varabyte.kobweb:kobweb-api", version.ref = "kobweb" }
kobweb-core = { module = "com.varabyte.kobweb:kobweb-core", version.ref = "kobweb" }
kobweb-silk = { module = "com.varabyte.kobweb:kobweb-silk", version.ref = "kobweb" }
-kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" }
+kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialization" }
silk-icons-fa = { module = "com.varabyte.kobwebx:silk-icons-fa", version.ref = "kobweb" }
+mongodb-kotlin-driver = { module = "org.mongodb:mongodb-driver-kotlin-coroutine", version.ref = "mongodb-kotlin" }
+
[plugins]
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 489f506c9d481380bae85da619870ed2e810d98b..4d8aa47f86316ba08e37950884c688e81a2aecd5 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -1,3 +1,5 @@
+import org.gradle.kotlin.dsl.support.kotlinCompilerOptions
+
pluginManagement {
repositories {
gradlePluginPortal()
diff --git a/site/build.gradle.kts b/site/build.gradle.kts
index d883bc465159f70b9863282767b2ea03c8d0ec25..bb9e81375ebd0c8561348387a3f439c78fa22652 100644
--- a/site/build.gradle.kts
+++ b/site/build.gradle.kts
@@ -1,4 +1,8 @@
import com.varabyte.kobweb.gradle.application.util.configAsKobwebApplication
+import com.varabyte.kobweb.gradle.core.kmp.JvmTarget
+import com.varabyte.kobweb.gradle.core.kmp.jvmTarget
+import org.gradle.kotlin.dsl.support.kotlinCompilerOptions
+import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
alias(libs.plugins.kotlin.multiplatform)
@@ -19,20 +23,26 @@ version = "1.0-SNAPSHOT"
kotlin {
configAsKobwebApplication(includeServer = true)
+ jvmToolchain(11)
+
sourceSets {
+
commonMain.dependencies {
implementation(libs.compose.runtime)
implementation(libs.kotlinx.serialization.json)
- }
+ }
+
jsMain.dependencies {
implementation(libs.compose.html.core)
implementation(libs.kobweb.core)
implementation(libs.kobweb.silk)
+
}
jvmMain.dependencies {
compileOnly(libs.kobweb.api) // Provided by Kobweb backend at runtime
+ implementation(libs.mongodb.kotlin.driver)
}
}
}
diff --git a/site/src/commonMain/kotlin/todo/model/Task.kt b/site/src/commonMain/kotlin/todo/model/Task.kt
new file mode 100644
index 0000000000000000000000000000000000000000..62a17dbd8ed8841788e468ca62f917248e9bcad6
--- /dev/null
+++ b/site/src/commonMain/kotlin/todo/model/Task.kt
@@ -0,0 +1,9 @@
+package todo.model
+
+import kotlinx.serialization.Serializable
+
+@Serializable
+data class Task(
+ val _id : String = "",
+ val task : String = ""
+)
diff --git a/site/src/jsMain/kotlin/todo/AppEntry.kt b/site/src/jsMain/kotlin/todo/AppEntry.kt
index 4b6849ce9b8d401dffd51ccf472358d885c103b3..c1763511124de5617087295af4deaa81757b6c28 100644
--- a/site/src/jsMain/kotlin/todo/AppEntry.kt
+++ b/site/src/jsMain/kotlin/todo/AppEntry.kt
@@ -44,7 +44,7 @@ fun initSiteStyles(ctx: InitSilkContext) = ctx.stylesheet.apply {
ctx.theme.palettes.light.button.default = Colors.WhiteSmoke
ctx.theme.palettes.light.button.hover = Colors.Gold
- ctx.theme.palettes.dark.background = Colors.DarkGray
+ ctx.theme.palettes.dark.background = Colors.Black
ctx.theme.palettes.dark.color = Colors.White
ctx.theme.palettes.dark.link.default = Colors.Purple
ctx.theme.palettes.dark.link.visited = Colors.BlueViolet
diff --git a/site/src/jsMain/kotlin/todo/pages/Index.kt b/site/src/jsMain/kotlin/todo/pages/Index.kt
index f75d37a9f6ce8c9d738db02c13dd596f9cfeb915..3c165471681e81d407f83ab6889fc5c5f681e8a4 100644
--- a/site/src/jsMain/kotlin/todo/pages/Index.kt
+++ b/site/src/jsMain/kotlin/todo/pages/Index.kt
@@ -4,21 +4,24 @@ import androidx.compose.runtime.*
import androidx.compose.runtime.snapshots.Snapshot
import androidx.compose.runtime.snapshots.SnapshotStateList
import com.varabyte.kobweb.browser.api
-import com.varabyte.kobweb.compose.css.FontWeight
-import com.varabyte.kobweb.compose.css.TextAlign
-import com.varabyte.kobweb.compose.css.WhiteSpace
+import com.varabyte.kobweb.compose.css.*
+import com.varabyte.kobweb.compose.css.AlignItems
import com.varabyte.kobweb.compose.foundation.layout.*
import com.varabyte.kobweb.compose.ui.Alignment
import com.varabyte.kobweb.compose.ui.Modifier
import com.varabyte.kobweb.compose.ui.graphics.Color.Companion.rgb
import com.varabyte.kobweb.compose.ui.graphics.Colors
import com.varabyte.kobweb.compose.ui.modifiers.*
+import com.varabyte.kobweb.compose.ui.modifiers.alignContent
+import com.varabyte.kobweb.compose.ui.modifiers.alignItems
+import com.varabyte.kobweb.compose.ui.modifiers.verticalAlign
import com.varabyte.kobweb.compose.ui.toAttrs
import com.varabyte.kobweb.core.Page
import com.varabyte.kobweb.silk.components.navigation.Link
import com.varabyte.kobweb.silk.components.text.SpanText
import com.varabyte.kobweb.silk.style.CssStyle
import com.varabyte.kobweb.silk.style.base
+import com.varabyte.kobweb.silk.style.selectors.hover
import com.varabyte.kobweb.silk.style.toModifier
import com.varabyte.kobweb.silk.theme.colors.ColorMode
import com.varabyte.kobweb.silk.theme.colors.ColorSchemes
@@ -28,10 +31,9 @@ import kotlinx.browser.window
import kotlinx.coroutines.launch
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json
-import org.jetbrains.compose.web.css.CSSColorValue
-import org.jetbrains.compose.web.css.cssRem
-import org.jetbrains.compose.web.css.em
-import org.jetbrains.compose.web.css.px
+import org.jetbrains.compose.web.css.*
+import org.jetbrains.compose.web.css.AlignContent
+import org.jetbrains.compose.web.css.AlignSelf
import org.jetbrains.compose.web.dom.Footer
import org.jetbrains.compose.web.dom.*
import org.jetbrains.compose.web.dom.Span
@@ -61,11 +63,24 @@ val HeaderStyle = CssStyle.base {
Modifier
.backgroundColor(if (colorMode.isLight) Colors.Grey else Colors.MediumPurple)
.whiteSpace(WhiteSpace.PreWrap)
- .textAlign(TextAlign.Left)
- .margin(40.px)
- .padding(40.px)
+ .padding(20.px)
.fontSize(80.px)
.fontWeight(FontWeight.Bold)
+ .fillMaxWidth()
+
+}
+
+val ButtonStyle = CssStyle {
+ base {
+ Modifier
+ .backgroundColor(if (colorMode.isLight) Colors.White else Colors.Black)
+ .color(if (colorMode.isLight) Colors.Black else Colors.White)
+ .padding(10.px)
+ }
+ hover {
+ Modifier
+ .cursor(Cursor.Pointer)
+ }
}
@@ -107,16 +122,24 @@ fun HomePage() {
return@Column
}
- // ====== HEADER ======
- Header {
- Span(HeaderStyle.toModifier().toAttrs()) {
- Text("To do:")
- }
- Button( Modifier
- .onClick {colorMode = colorMode.opposite}
- .toAttrs()
- ) {
- Text(value = "Change theme")
+ // ======== H E A D E R ========
+ Header(HeaderStyle.toModifier().toAttrs()
+ ) {
+ Row {
+ Span(
+ HeaderStyle.toModifier()
+ //.justifySelf(JustifySelf.Left)
+ .toAttrs(),
+ ) {
+ Text("To do:")
+ }
+ Button(ButtonStyle.toModifier()
+ .onClick { colorMode = colorMode.opposite }
+ //.justifySelf(JustifySelf.Right)
+ .toAttrs()
+ ) {
+ Text(value = "Change theme")
+ }
}
}
diff --git a/site/src/jvmMain/kotlin/todo/api/tasks b/site/src/jvmMain/kotlin/todo/api/tasks
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/site/src/jvmMain/kotlin/todo/api/tasks.kt b/site/src/jvmMain/kotlin/todo/api/tasks.kt
new file mode 100644
index 0000000000000000000000000000000000000000..f27e427f5ed5430498d108cfc1f5e9d1dfcf264f
--- /dev/null
+++ b/site/src/jvmMain/kotlin/todo/api/tasks.kt
@@ -0,0 +1,10 @@
+package todo.api
+
+import com.varabyte.kobweb.api.Api
+import com.varabyte.kobweb.api.ApiContext
+
+
+@Api(routeOverride = "addtask")
+suspend fun addTask(context: ApiContext) {
+
+}
\ No newline at end of file
diff --git a/site/src/jvmMain/kotlin/todo/data/MongoDb.kt b/site/src/jvmMain/kotlin/todo/data/MongoDb.kt
new file mode 100644
index 0000000000000000000000000000000000000000..3ef54397bdcf2a3d563957ab562ba6ab25e7127b
--- /dev/null
+++ b/site/src/jvmMain/kotlin/todo/data/MongoDb.kt
@@ -0,0 +1,8 @@
+package todo.data
+
+import todo.model.Task
+
+interface MongoDb {
+ suspend fun getAllTasks(): List<Task>
+ suspend fun addTask(task: Task): Boolean
+}
\ No newline at end of file
diff --git a/site/src/jvmMain/kotlin/todo/data/MongoDbImplementation.kt b/site/src/jvmMain/kotlin/todo/data/MongoDbImplementation.kt
new file mode 100644
index 0000000000000000000000000000000000000000..6b1304e24d54c4864f2a312deba2757869cdde40
--- /dev/null
+++ b/site/src/jvmMain/kotlin/todo/data/MongoDbImplementation.kt
@@ -0,0 +1,33 @@
+package todo.data
+
+import com.mongodb.kotlin.client.coroutine.MongoClient
+import com.varabyte.kobweb.api.data.add
+import com.varabyte.kobweb.api.init.InitApiContext
+import kotlinx.coroutines.flow.toList
+import todo.model.Task
+
+fun initializeMongo(context: InitApiContext) {
+ System.setProperty(
+ "org.litote.mongo.test.mapping.service",
+ "org.litote.kmongo.serialization.SerializationClassMappingTypeService"
+ )
+ context.data.add(MongoDbImplementation())
+}
+
+class MongoDbImplementation():MongoDb {
+
+ private val client = MongoClient.create()
+ private val database = client.getDatabase("tasks")
+ private val tasksCollection = database.getCollection<Task>("tasks")
+
+
+
+
+ override suspend fun getAllTasks(): List<Task> {
+ return tasksCollection.find().toList()
+ }
+
+ override suspend fun addTask(task: Task): Boolean {
+ return tasksCollection.insertOne(task).wasAcknowledged()
+ }
+}
\ No newline at end of file