mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Switching AceEditor theme reactively
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
c7061a3ea4
commit
ee71c5aae8
@ -3,10 +3,11 @@
|
|||||||
import "./ace-editor.scss"
|
import "./ace-editor.scss"
|
||||||
|
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import { observer } from "mobx-react";
|
import { observer, disposeOnUnmount } from "mobx-react";
|
||||||
import AceBuild, { Ace } from "ace-builds"
|
import AceBuild, { Ace } from "ace-builds"
|
||||||
import { autobind, cssNames } from "../../utils";
|
import { autobind, cssNames } from "../../utils";
|
||||||
import { themeStore } from "../../theme.store";
|
import { themeStore } from "../../theme.store";
|
||||||
|
import { reaction } from "mobx";
|
||||||
|
|
||||||
interface Props extends Partial<Ace.EditorOptions> {
|
interface Props extends Partial<Ace.EditorOptions> {
|
||||||
className?: string;
|
className?: string;
|
||||||
@ -46,6 +47,11 @@ export class AceEditor extends React.Component<Props, State> {
|
|||||||
require("ace-builds/src-noconflict/ext-searchbox")
|
require("ace-builds/src-noconflict/ext-searchbox")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@disposeOnUnmount
|
||||||
|
themeSwitcher = reaction(() => themeStore.activeTheme, () => {
|
||||||
|
this.setTheme(this.theme);
|
||||||
|
});
|
||||||
|
|
||||||
get theme() {
|
get theme() {
|
||||||
switch (themeStore.activeTheme.type) {
|
switch (themeStore.activeTheme.type) {
|
||||||
case "light":
|
case "light":
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user