Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy-maven-central.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
if: success()
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
github-token: ${{ secrets.GIT_TOKEN }}
script: |
const pr = context.payload.pull_request;
if (pr) {
Expand Down
2 changes: 1 addition & 1 deletion convention-plugins/src/main/kotlin/common.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ kotlin {
}
sourceSets["commonMain"].dependencies {
implementation("net.kigawa:hakate:3.3.1")
implementation("net.kigawa:renlin:1.0.1")
implementation("net.kigawa:renlin:1.3.1")
}
sourceSets["commonTest"].dependencies {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package net.kigawa.renlin.router.link

import net.kigawa.renlin.tag.Tag
import net.kigawa.renlin.component.component
import net.kigawa.renlin.tag.a
import net.kigawa.renlin.tag.component.Component1

val link = a.component { }
val link = a.component { }
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package net.kigawa.renlin.router.route

import net.kigawa.kutil.kutil.api.io.fs.KuPath

class Route(private val path: KuPath) {
data class Route(val path: KuPath) {
fun isMach(path: KuPath): Boolean {
return this.path == path
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
package net.kigawa.renlin.router.route.tag

import net.kigawa.renlin.component.Component1
import net.kigawa.renlin.dsl.DslBase
import net.kigawa.renlin.dsl.RegisteredDslData
import net.kigawa.renlin.dsl.StatedDsl
import net.kigawa.renlin.router.route.Route
import net.kigawa.renlin.state.DslState
import net.kigawa.renlin.tag.Tag
import net.kigawa.renlin.tag.component.Component1
import net.kigawa.renlin.w3c.category.ContentCategory
import net.kigawa.renlin.w3c.element.TagNode
import kotlin.uuid.ExperimentalUuidApi
import kotlin.uuid.Uuid

class RouteComponent<CONTENT_CATEGORY : ContentCategory>(
class RouteComponent<CONTENT_CATEGORY: ContentCategory>(
val routerDsl: RouterDsl<CONTENT_CATEGORY>,
val route: Route,
) :
Component1<Tag<CONTENT_CATEGORY>, StatedDsl<CONTENT_CATEGORY>> {
override fun newDsl(dslState: DslState): StatedDsl<CONTENT_CATEGORY> {
return object : DslBase<CONTENT_CATEGORY>(dslState) {
): Component1<Tag<CONTENT_CATEGORY>, CONTENT_CATEGORY, StatedDsl<CONTENT_CATEGORY>.() -> Unit> {
fun newDsl(dslState: DslState): StatedDsl<CONTENT_CATEGORY> {
return object: DslBase<CONTENT_CATEGORY>(dslState) {
override fun applyElement(element: TagNode): () -> Unit {
return {}
}
}
}


@OptIn(ExperimentalUuidApi::class)
override fun render(
parentDsl: StatedDsl<*>,
block: StatedDsl<CONTENT_CATEGORY>.() -> Unit, key: String?,
parentDsl: StatedDsl<out CONTENT_CATEGORY>,
arg1: StatedDsl<CONTENT_CATEGORY>.() -> Unit, key: String?,
) {
if (!route.isMach(routerDsl.routePath)) return
val key = key ?: Uuid.random().toString()
val dslState = parentDsl.dslState.getOrCreateSubDslState(key, this)
val dsl = newDsl(dslState)
dsl.block()
dsl.arg1()
parentDsl.registerSubDsl(RegisteredDslData(dsl, this, {
render(parentDsl, block, key)
render(parentDsl, arg1, key)
}, key))
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package net.kigawa.renlin.router.route.tag

import net.kigawa.renlin.component.StructuredComponent
import net.kigawa.renlin.router.route.provider.RouterProvider
import net.kigawa.renlin.state.DslState
import net.kigawa.renlin.tag.Tag
import net.kigawa.renlin.tag.component.StructuredComponent
import net.kigawa.renlin.w3c.category.ContentCategory

class RouterComponent<CONTENT_CATEGORY : ContentCategory>(
class RouterComponent<CONTENT_CATEGORY: ContentCategory>(
private val routerProvider: RouterProvider,
) :
StructuredComponent<Tag<CONTENT_CATEGORY>, RouterDsl<CONTENT_CATEGORY>> {
): StructuredComponent<Tag<CONTENT_CATEGORY>, CONTENT_CATEGORY, RouterDsl<CONTENT_CATEGORY>> {
override fun newDsl(dslState: DslState): RouterDsl<CONTENT_CATEGORY> {
return RouterDsl(routerProvider, dslState)
}
Expand Down
31 changes: 15 additions & 16 deletions sample/src/commonMain/kotlin/sample/SampleComponent.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package sample

import net.kigawa.renlin.component.component
import net.kigawa.renlin.router.route.tag.route
import net.kigawa.renlin.router.route.tag.router
import net.kigawa.renlin.tag.div
Expand All @@ -17,13 +18,17 @@ class SampleComponent(

router().invoke {
route(Routes.top).invoke {
p {
t("top")
div {
p {
t("top")
}
}
}
route(Routes.page).invoke {
p {
t("page")
div {
p {
t("page")
}
}
}
}
Expand All @@ -33,9 +38,7 @@ class SampleComponent(
+"repeat "
}
}
sub.display {

}
sub.display()

fragment {
div {
Expand All @@ -50,17 +53,13 @@ class SampleComponent(
}
}
// fragment {
sub.display {

}
sub.display ()
// }
sub.controller {

}
p {
sub.controller ()
div {
p {
// key = "uuid 5"
}
}
sub.test {}
sub.test1 {}
}
}
47 changes: 22 additions & 25 deletions sample/src/commonMain/kotlin/sample/Sub.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ package sample

import net.kigawa.hakate.api.HakateInitializer
import net.kigawa.hakate.api.state.MutableState
import net.kigawa.renlin.component.component
import net.kigawa.renlin.tag.div
import net.kigawa.renlin.tag.fragment
import net.kigawa.renlin.tag.p
import net.kigawa.renlin.tag.text
import net.kigawa.renlin.w3c.category.integration.FlowPhrasingIntegration
import net.kigawa.renlin.w3c.category.native.FlowContent
import net.kigawa.renlin.w3c.category.native.PhrasingContent
import net.kigawa.renlin.w3c.category.t

interface MarginValue
Expand All @@ -18,37 +15,37 @@ class Sub {
val state: MutableState<String> = HakateInitializer().newStateDispatcher().newState("state")

val display = div.component {
t("display")
div(key = "key display") {
val value = state.useValue()
t("display1", key = "key display1")
div {
t("display1-1", key = "key display1-1")
p {
t("display1-1-1 $value", key = "key display1-1-1")
text {
div {
t("display")
div(key = "key display") {
val value = state.useValue()
t("display1", key = "key display1")
div {
t("display1-1", key = "key display1-1")
p {
t("display1-1-1 $value", key = "key display1-1-1")
text {
// margin = "asd"
}
}
}
}
}
div {
t("display2")
div {
t("display2-1")
t("display2")
div {
t("display2-1")

}
}
}
div {
t("display3")
div {
t("display3")

}
}
}
val controller = div.component {
t("controller")

div {
t("controller")
}
}
val test = fragment<FlowContent>().component { }
val test1 = fragment<PhrasingContent>().component { }
val test2 = fragment<FlowPhrasingIntegration>().component { }
}
Loading