diff --git a/fastn-js/js/dom.js b/fastn-js/js/dom.js index 8b211f8970..cfeb160700 100644 --- a/fastn-js/js/dom.js +++ b/fastn-js/js/dom.js @@ -1773,14 +1773,15 @@ class Node2 { } let theme = staticValue.replace("\.", "-"); this.#extraData.code = this.#extraData.code ? this.#extraData.code : {}; - if (this.#extraData.code.theme) { - this.#node.classList.remove(theme); + if (this.#extraData.code.theme !== theme) { + let codeNode = this.#children[0].getNode(); + this.#node.classList.remove(this.#extraData.code.theme); + codeNode.classList.remove(this.#extraData.code.theme); + this.#extraData.code.theme = theme; + this.#node.classList.add(theme); + codeNode.classList.add(theme); + fastn_utils.highlightCode(codeNode, this.#extraData.code); } - this.#extraData.code.theme = theme; - this.#node.classList.add(theme); - let codeNode = this.#children[0].getNode(); - codeNode.classList.add(theme); - fastn_utils.highlightCode(codeNode, this.#extraData.code); } else if (kind === fastn_dom.PropertyKind.CodeLanguage) { let language = `language-${staticValue}`; this.#extraData.code = this.#extraData.code ? this.#extraData.code : {}; diff --git a/ftd/t/js/57-code-dark-mode.ftd b/ftd/t/js/57-code-dark-mode.ftd new file mode 100644 index 0000000000..b0025b8672 --- /dev/null +++ b/ftd/t/js/57-code-dark-mode.ftd @@ -0,0 +1,15 @@ +-- ftd.code: +lang: ftd +role: $inherited.types.copy-small +theme: fastn-theme.light +theme if { ftd.dark-mode }: fastn-theme.dark + +\-- ftd.column: +padding.px: 10 ;; +spacing.fixed.px: "50" +height.fixed.px: 200 +width.fixed.px: 300 ;; +overflow-y: scroll +border-color: $red-yellow +border-style: solid +border-width.px: 2 diff --git a/ftd/t/js/57-code-dark-mode.html b/ftd/t/js/57-code-dark-mode.html new file mode 100644 index 0000000000..e4a62abc00 --- /dev/null +++ b/ftd/t/js/57-code-dark-mode.html @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + +
-- ftd.column:
+padding.px: 10 
+spacing.fixed.px: "50"
+height.fixed.px: 200
+width.fixed.px: 300 
+overflow-y: scroll
+border-color: $red-yellow
+border-style: solid
+border-width.px: 2
+
+ +