feat: migrate web UI from kotlinx.html to xemantic-kotlin-js#55
feat: migrate web UI from kotlinx.html to xemantic-kotlin-js#55
Conversation
Replace kotlinx.html dependency with xemantic-kotlin-js library in the
golem-xiv-web module. All view code now uses the `node { }` DSL pattern
from com.xemantic.kotlin.js.dom.html.* instead of kotlinx.html TagConsumer.
Changes:
- Replace libs.kotlinx.html with libs.xemantic.kotlin.js in build.gradle.kts
- Remove js/Dom.kt (GolemTagConsumer/inject pattern replaced by node { +el })
- Remove js/Accessibility.kt (ariaLabel now from com.xemantic.kotlin.js.dom)
- Remove js/Storage.kt (setItems now from com.xemantic.kotlin.js.dom)
- Rewrite HtmlMainView, HtmlHeaderView, HtmlNavigationRailView,
HtmlNotFoundView, HtmlMemoryView, HtmlCognitionView, UiElements
using xemantic-kotlin-js node { } DSL
Closes #54
Co-authored-by: Kazik Pogoda <morisil@users.noreply.github.com>
PR Review: Migrate web UI from kotlinx.html to xemantic-kotlin-jsOverall this is a clean and well-motivated migration. The Positive changesRemoval of Cleaner element construction — The pattern
Issues and observations1. Before: After: The new version renders 2. Missing newline at end of file in The diff ends with 3. The old code used 4. Before: After: Good simplification, but worth verifying: does 5. Commented-out code removal in The large block of commented-out 6.
7. The Minor nits
SummaryThe migration is sound and the resulting code is cleaner. The main item to verify before merging is issue #1 (the Generated with Claude Code |
| import com.xemantic.ai.golem.web.ui.Icon | ||
| import com.xemantic.ai.golem.web.ui.IconButton | ||
| import com.xemantic.ai.golem.web.view.HasRootHtmlElement | ||
| import com.xemantic.kotlin.js.dom.html.article |
There was a problem hiding this comment.
you can use wildcard here
|
|
||
| private val promptInput = dom.textArea { | ||
| placeholder = "Another question from the carbon side..." | ||
| private val promptInput: HTMLTextAreaElement = node { |
There was a problem hiding this comment.
I guess explicit type is not needed here?
| import com.xemantic.ai.golem.web.navigation.HtmlNavigationRailView | ||
| import com.xemantic.ai.golem.web.cognition.HtmlCognitionView | ||
| import com.xemantic.ai.golem.web.view.HasRootHtmlElement | ||
| import com.xemantic.kotlin.js.dom.html.div |
There was a problem hiding this comment.
use wildcard import here
| import kotlinx.browser.document | ||
| import kotlinx.html.dom.create | ||
| import kotlinx.html.js.iframe | ||
| import com.xemantic.kotlin.js.dom.html.iframe |
| import com.xemantic.ai.golem.web.js.dom | ||
| import com.xemantic.ai.golem.web.js.inject | ||
| import com.xemantic.ai.golem.web.view.HasRootHtmlElement | ||
| import com.xemantic.kotlin.js.dom.ariaLabel |
| div { +"Initiate" } | ||
| private val initiateCognitionItem = node { | ||
| a { | ||
| it.setAttribute("data-target", "initiate-cognition") |
There was a problem hiding this comment.
it["data-target"] = "initiate-cognition"]
should be possible here
| div { +"Memory" } | ||
| private val memoryItem = node { | ||
| a { | ||
| it.setAttribute("data-target", "memory") |
There was a problem hiding this comment.
see previous comment, apply everywhere if possible
| i { | ||
| +name | ||
| } | ||
| fun Icon(name: String): HTMLSpanElement = node { |
There was a problem hiding this comment.
we can remove this code since icon("foo") was added to the library, and is now the preferred way of using icons with beer css.
| ): HTMLButtonElement = node { | ||
| button("round") { | ||
| if (icon != null) { | ||
| i { +icon } |
There was a problem hiding this comment.
you can also use icon(icon) from xemantic-kotlin-js
| ): HTMLAnchorElement = node { | ||
| a("wave round") { | ||
| if (icon != null) { | ||
| i { +icon } |
|
Claude finished @morisil's task in 1m 39s —— View job Addressing Review Comments
SummaryAll review comments have been addressed in commit
|
- Use wildcard imports (com.xemantic.kotlin.js.dom.html.*) in all view files
- Remove explicit type annotation on promptInput in HtmlCognitionView
- Replace setAttribute("data-target", ...) with dataset["target"] = ... in HtmlNavigationRailView
- Remove Icon() factory function (superseded by icon() DSL from xemantic-kotlin-js)
- Use icon() DSL instead of i {} in Button, IconButton, and Link in UiElements
Co-authored-by: Kazik Pogoda <morisil@users.noreply.github.com>
Replace kotlinx.html dependency with xemantic-kotlin-js library in the golem-xiv-web module. All view code now uses the
node { }DSL pattern from com.xemantic.kotlin.js.dom.html.* instead of kotlinx.html TagConsumer.Closes #54
Generated with Claude Code