-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathThemePrompt.ts
More file actions
151 lines (141 loc) · 6.05 KB
/
Copy pathThemePrompt.ts
File metadata and controls
151 lines (141 loc) · 6.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// Copyright (C) 2020 John Nesky, distributed under the MIT license.
import { HTML } from "imperative-html/dist/esm/elements-strict";
import { Prompt } from "./Prompt";
import { SongDocument } from "./SongDocument";
import { ColorConfig } from "./ColorConfig";
//namespace beepbox {
const { button, div, h2, select, option, optgroup } = HTML;
export class ThemePrompt implements Prompt {
private readonly _themeSelect: HTMLSelectElement = select({ style: "width: 100%;" },
optgroup({ label: "Objectively The Best Ones" },
option({ value: "violet verdant" }, "Violet Verdant"),
option({ value: "nebula" }, "Nebula"),
option({ value: "dark competition" }, "BeepBox Competition Dark"),
),
optgroup({ label: "Cool Stuff That You Should At Least Check Out" },
option({ value: "forest" }, "Forest"),
option({ value: "midnight" }, "Midnight"),
option({ value: "lemmbox dark"}, "LemmBox"),
),
optgroup({ label: "Default Themes" },
option({ value: "forest" }, "Forest"),
option({ value: "canyon" }, "Canyon"),
option({ value: "beachcombing" }, "Beachcombing"),
option({ value: "violet verdant" }, "Violet Verdant"),
option({ value: "sunset" }, "Sunset"),
option({ value: "autumn" }, "Autumn"),
option({ value: "fruit" }, "Shadowfruit"),
option({ value: "toxic" }, "Toxic"),
option({ value: "roe" }, "Roe"),
option({ value: "moonlight" }, "Moonlight"),
option({ value: "portal" }, "Portal"),
option({ value: "fusion" }, "Fusion"),
option({ value: "inverse" }, "Inverse"),
option({ value: "nebula" }, "Nebula"),
option({ value: "roe light" }, "Roe Light"),
option({ value: "amoled dark" }, "High Contrast Dark"),
option({ value: "energized" }, "Energized"),
option({ value: "neapolitan" }, "Neapolitan"),
option({ value: "poly" }, "Poly"),
option({ value: "blutonium" }, "Blutonium"),
option({ value: "greyscale" }, "Greyscale"),
option({ value: "slushie" }, "Slushie"),
),
optgroup({ label: "Mod Themes" },
option({ value: "dark classic" }, "BeepBox Dark"),
option({ value: "light classic" }, "BeepBox Light"),
option({ value: "dark competition" }, "BeepBox Competition Dark"),
option({ value: "jummbox classic" }, "JummBox Dark"),
// let's retire this again.
// option({ value: "jummbox light" }, "JummBox Light"),
option({ value: "modbox classic" }, "Modbox"),
option({ value: "sandbox classic" }, "Sandbox"),
option({ value: "harrybox" }, "Haileybox"),
option({ value: "brucebox" }, "Brucebox"),
option({ value: "shitbox 3.0" }, "Shitbox 1.0/3.0"),
option({ value: "shitbox 2.0" }, "Shitbox 2.0"),
option({ value: "nerdbox" }, "NerdBox"),
option({ value: "zefbox" }, "Zefbox"),
option({ value: "cardboardbox classic" }, "Cardboardbox"),
option({ value: "blubox classic" }, "Blubox"),
option({ value: "dogebox classic" }, "Dogebox"),
option({ value: "wackybox" }, "Wackybox"),
option({ value: "todbox dark mode" }, "Todbox Dark Mode"),
option({ value: "mainbox 1.0" }, "Mainbox"),
option({ value: "microbox" }, "MicroBox"),
option({ value: "paandorasbox" }, "PaandorasBox"),
option({ value: "foxbox" }, "FoxBox"),
option({ value: "midbox" }, "Midbox"),
option({ value: "dogebox2" }, "Dogebox2"),
option({ value: "abyssbox classic"}, "AbyssBox Classic"),
option({ value: "abyssbox light"}, "AbyssBox Light"),
option({ value: "nepbox" }, "Nepbox"),
option({ value: "ultrabox dark" }, "UltraBox"),
option({ value: "awesomebox" }, "AwesomeBox"),
option({ value: "slarmoosbox" }, "Slarmoo's Box"),
option({ value: "voxonium" }, "Voxonium"),
option({ value: "axobox"}, "AxoBox"),
option({ value: "lemmbox dark"}, "LemmBox"),
option({ value: "edobox classic" }, "EdoBox"),
option({ value: "bloxbox classic" }, "BloxBox"),
option({ value: "death"}, "D's Quick Box Mod"),
option({ value: "fmbox" }, "FMBox"),
option({ value: "41box" }, "41Box"),
),
optgroup({ label: "Misc" },
option({ value: "azur lane" }, "Azur Lane"),
option({ value: "custom" }, "Custom")
),
);
private readonly _cancelButton: HTMLButtonElement = button({ class: "cancelButton" });
private readonly _okayButton: HTMLButtonElement = button({ class: "okayButton", style: "width:45%;" }, "Okay");
public readonly container: HTMLDivElement = div({ class: "prompt noSelection", style: "width: 220px;" },
h2("Set Theme"),
div({ style: "display: flex; flex-direction: row; align-items: center; height: 2em; justify-content: flex-end;" },
div({ class: "selectContainer", style: "width: 100%;" }, this._themeSelect),
),
div({ style: "display: flex; flex-direction: row-reverse; justify-content: space-between;" },
this._okayButton,
),
this._cancelButton,
);
private readonly lastTheme: string | null = window.localStorage.getItem("colorTheme")
constructor(private _doc: SongDocument) {
if (this.lastTheme != null) {
this._themeSelect.value = this.lastTheme;
}
this._okayButton.addEventListener("click", this._saveChanges);
this._cancelButton.addEventListener("click", this._close);
this.container.addEventListener("keydown", this._whenKeyPressed);
this._themeSelect.addEventListener("change", this._previewTheme);
}
private _close = (): void => {
if (this.lastTheme != null) {
ColorConfig.setTheme(this.lastTheme);
} else {
ColorConfig.setTheme(ColorConfig.defaultTheme);
}
this._doc.undo();
}
public cleanUp = (): void => {
this._okayButton.removeEventListener("click", this._saveChanges);
this._cancelButton.removeEventListener("click", this._close);
this.container.removeEventListener("keydown", this._whenKeyPressed);
}
private _whenKeyPressed = (event: KeyboardEvent): void => {
if ((<Element>event.target).tagName != "BUTTON" && event.keyCode == 13) { // Enter key
this._saveChanges();
}
}
private _saveChanges = (): void => {
window.localStorage.setItem("colorTheme", this._themeSelect.value);
this._doc.prompt = null;
this._doc.prefs.colorTheme = this._themeSelect.value;
this._doc.undo();
}
private _previewTheme = (): void => {
ColorConfig.setTheme(this._themeSelect.value);
this._doc.notifier.changed();
}
}
//}