From 8c2c48a7199f369a1bb51b02a409d16ab51174fe Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sun, 28 Jan 2024 19:00:46 -0500 Subject: [PATCH 1/3] Add dark mode support for the AST tree. --- src/OrgAst.module.css | 71 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 56 insertions(+), 15 deletions(-) diff --git a/src/OrgAst.module.css b/src/OrgAst.module.css index ce174ac..ccfcd93 100644 --- a/src/OrgAst.module.css +++ b/src/OrgAst.module.css @@ -1,16 +1,57 @@ .OrgAst { - background: #eeeeee; + --ast-background-color: #111111; + --ast-font-color: #ffffff; + + --ast-node-border-color: #bbbbbb; + --ast-node-shadow-color: #bbbbbb; + + --ast-node-type-background-color: #933009; + --ast-node-type-hover-background-color: #8f0745; + --ast-node-type-selected-background-color: #630368; + + --ast-node-subsection-border-color: #ffffff; + + --ast-node-children-background-color: #111111; + + --ast-node-table-row-odd-background-color: #111111; + --ast-node-table-row-even-background-color: #000000; +} +@media (prefers-color-scheme: light) { + .OrgAst { + --ast-background-color: #eeeeee; + --ast-font-color: #000000; + + --ast-node-background-color: #ffffff; + --ast-node-border-color: #000000; + --ast-node-shadow-color: #000000; + + --ast-node-type-background-color: #6ccff6; + --ast-node-type-hover-background-color: #70f8ba; + --ast-node-type-selected-background-color: #9cfc97; + + --ast-node-subsection-border-color: #000000; + + --ast-node-children-background-color: #eeeeee; + + --ast-node-table-row-odd-background-color: #eeeeee; + --ast-node-table-row-even-background-color: #ffffff; + } +} + +.OrgAst { + background: var(--ast-background-color); + color: var(--ast-font-color); padding: 5px; overflow: auto; } .OrgAstNode { - border: 1px solid #000000; - background: #ffffff; - box-shadow: -3px 3px 1px #000000; + border: 1px solid var(--ast-node-border-color); + background: var(--ast-node-background-color); + box-shadow: -3px 3px 1px var(--ast-node-shadow-color); > details { - border: 1px solid #000000; + border: 1px solid var(--ast-node-subsection-border-color); margin: 5px 5px 5px 2px; > summary { @@ -23,25 +64,25 @@ > summary { border-width: 0 0 1px 0; border-style: dotted; - border-color: #000000; + border-color: var(--ast-node-subsection-border-color); } } } .OrgAstNode.selected { > .OrgAstNodeType { - background: #9cfc97; + background: var(--ast-node-type-selected-background-color); } } .OrgAstNode.hovered:not(.selected) { > .OrgAstNodeType { - background: #70f8ba; + background: var(--ast-node-type-hover-background-color); } } .OrgAstNodeType { - background: #6ccff6; + background: var(--ast-node-type-background-color); padding: 3px; overflow: hidden; cursor: pointer; @@ -64,20 +105,20 @@ .OrgAstChildren { padding: 5px 5px 5px 20px; - background: #eeeeee; + background: var(--ast-node-children-background-color); } .OrgAstProperties, .OrgAstObjectTree, .OrgAstOptionalPair { - border: 1px solid #000000; + border: 1px solid var(--ast-node-subsection-border-color); margin: 5px; > tbody { > tr { border-width: 1px 0; border-style: solid; - border-color: #000000; + border-color: var(--ast-node-subsection-border-color); > th, > td { @@ -92,10 +133,10 @@ } > tr:nth-child(odd) { - background-color: #eeeeee; + background-color: var(--ast-node-table-row-odd-background-color); } > tr:nth-child(even) { - background-color: #ffffff; + background-color: var(--ast-node-table-row-even-background-color); } } } @@ -103,7 +144,7 @@ .OrgAstObjectTree { > tbody { border-style: dashed; - border-color: #000000; + border-color: var(--ast-node-subsection-border-color); } > tbody:not(:first-child, :last-child) { border-width: 3px 0; From ff3618b67d021358d7da6abd96b9f8b5ee170b24 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sun, 28 Jan 2024 19:09:41 -0500 Subject: [PATCH 2/3] Add dark mode support for the editor. --- src/Editor.module.css | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Editor.module.css b/src/Editor.module.css index b5aa502..c195c16 100644 --- a/src/Editor.module.css +++ b/src/Editor.module.css @@ -1,6 +1,19 @@ +.EditorTextWrapper { + --editor-background-color: #000000; + --editor-font-color: #ffffff; + --editor-highlight-color: #0000ff; +} +@media (prefers-color-scheme: light) { + .EditorTextWrapper { + --editor-background-color: #ffffff; + --editor-font-color: #000000; + --editor-highlight-color: #ffff00; + } +} + .EditorTextWrapper { position: relative; - background: white; + background: var(--editor-background-color); font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, "DejaVu Sans Mono", monospace; font-weight: normal; @@ -10,6 +23,7 @@ .EditorTextArea, .EditorUnderlay { + color: var(--editor-font-color); font-family: inherit; font-weight: inherit; font-size: inherit; @@ -44,6 +58,6 @@ overflow-y: scroll; .EditorHighlighted { - background: #ffff00; + background: var(--editor-highlight-color); } } From 43d65b4fe39c477e518586e75bfeab61f5f3f3fe Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sun, 28 Jan 2024 19:11:07 -0500 Subject: [PATCH 3/3] Disable spellcheck to remove red squiggles. --- src/Editor.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Editor.tsx b/src/Editor.tsx index 27d3816..c4f4c68 100644 --- a/src/Editor.tsx +++ b/src/Editor.tsx @@ -42,6 +42,7 @@ function Editor({ className={styles.EditorTextArea} value={value} onScroll={onTextAreaScroll} + spellCheck={false} />
{buildShadow(highlights, value)}