Added dark mode and fixed the icon
This commit is contained in:
parent
3b60553141
commit
d841acd457
8 changed files with 55 additions and 1 deletions
|
|
@ -3,12 +3,17 @@ import './app.css';
|
|||
|
||||
import {basicSetup} from "codemirror";
|
||||
import {EditorView, keymap} from "@codemirror/view";
|
||||
import {Compartment} from "@codemirror/state";
|
||||
import {oneDark} from "@codemirror/theme-one-dark";
|
||||
import {Application} from "@hotwired/stimulus";
|
||||
|
||||
import {textProcessor} from "./services.js";
|
||||
import {multiCursorKeymap, commandPalette} from "./cmplugins.js";
|
||||
import {indentWithTab} from "@codemirror/commands";
|
||||
|
||||
const darkMode = window.matchMedia("(prefers-color-scheme: dark)");
|
||||
const themeCompartment = new Compartment();
|
||||
|
||||
import {StatusController} from "./controllers/status_controller.js";
|
||||
import {CommandsController} from "./controllers/commands_controller.js";
|
||||
import {PromptController} from "./controllers/prompt_controller.js";
|
||||
|
|
@ -24,9 +29,16 @@ const view = new EditorView({
|
|||
EditorView.lineWrapping,
|
||||
multiCursorKeymap,
|
||||
commandPalette,
|
||||
themeCompartment.of(darkMode.matches ? oneDark : []),
|
||||
]
|
||||
})
|
||||
|
||||
darkMode.addEventListener("change", (e) => {
|
||||
view.dispatch({
|
||||
effects: themeCompartment.reconfigure(e.matches ? oneDark : []),
|
||||
});
|
||||
});
|
||||
|
||||
window.Stimulus = Application.start()
|
||||
Stimulus.register("commands", CommandsController);
|
||||
Stimulus.register("prompt", PromptController);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue