diff --git a/ts/components/ButtonDropdown.svelte b/ts/components/ButtonDropdown.svelte index c4512842f..530defa1a 100644 --- a/ts/components/ButtonDropdown.svelte +++ b/ts/components/ButtonDropdown.svelte @@ -9,7 +9,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import WithTheming from "./WithTheming.svelte"; import ButtonToolbar from "./ButtonToolbar.svelte"; - export let id: string | undefined; + export let id: string; let className = ""; export { className as class }; diff --git a/ts/components/DropdownDivider.svelte b/ts/components/DropdownDivider.svelte new file mode 100644 index 000000000..7f3db50bf --- /dev/null +++ b/ts/components/DropdownDivider.svelte @@ -0,0 +1,5 @@ + + diff --git a/ts/components/DropdownMenu.svelte b/ts/components/DropdownMenu.svelte index c988ff1dc..b3cc9e1b4 100644 --- a/ts/components/DropdownMenu.svelte +++ b/ts/components/DropdownMenu.svelte @@ -6,7 +6,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import { setContext } from "svelte"; import { dropdownKey } from "./contextKeys"; - export let id: string | undefined; + export let id: string; setContext(dropdownKey, null); diff --git a/ts/components/LabelButton.svelte b/ts/components/LabelButton.svelte index b138dee12..1c89e5beb 100644 --- a/ts/components/LabelButton.svelte +++ b/ts/components/LabelButton.svelte @@ -11,6 +11,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html export let id: string | undefined = undefined; let className: string = ""; export { className as class }; + export let theme = "anki"; + + function extendClassName(className: string, theme: string): string { + return `btn ${theme !== "anki" ? `btn-${theme}` : ""}${className}`; + } export let tooltip: string | undefined = undefined; export let active = false; @@ -48,11 +53,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html - - - + + + + + Add Config + Rename Config + Remove Config + + save(true)}> + Save to All Children + + + + + diff --git a/ts/deckoptions/deckoptions-base.scss b/ts/deckoptions/deckoptions-base.scss index b178fba05..79bdada4b 100644 --- a/ts/deckoptions/deckoptions-base.scss +++ b/ts/deckoptions/deckoptions-base.scss @@ -1,3 +1,4 @@ +@use "ts/sass/vars"; @use "ts/sass/scrollbar"; @use "ts/sass/bootstrap-dark"; diff --git a/ts/deckoptions/index.ts b/ts/deckoptions/index.ts index 7af7871f0..fd622204f 100644 --- a/ts/deckoptions/index.ts +++ b/ts/deckoptions/index.ts @@ -1,6 +1,10 @@ // Copyright: Ankitects Pty Ltd and contributors // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html +/* eslint +@typescript-eslint/no-explicit-any: "off", + */ + import { getDeckOptionsInfo, DeckOptionsState } from "./lib"; import { setupI18n, ModuleName } from "lib/i18n"; import { checkNightMode } from "lib/nightmode"; @@ -10,20 +14,33 @@ import SpinBoxFloat from "./SpinBoxFloat.svelte"; import EnumSelector from "./EnumSelector.svelte"; import CheckBox from "./CheckBox.svelte"; +import { nightModeKey } from "components/contextKeys"; + export async function deckOptions( target: HTMLDivElement, deckId: number ): Promise { - checkNightMode(); - await setupI18n({ - modules: [ModuleName.SCHEDULING, ModuleName.ACTIONS, ModuleName.DECK_CONFIG], - }); - const info = await getDeckOptionsInfo(deckId); + const [info] = await Promise.all([ + getDeckOptionsInfo(deckId), + setupI18n({ + modules: [ + ModuleName.SCHEDULING, + ModuleName.ACTIONS, + ModuleName.DECK_CONFIG, + ], + }), + ]); + + const nightMode = checkNightMode(); + const context = new Map(); + context.set(nightModeKey, nightMode); + const state = new DeckOptionsState(deckId, info); return new DeckOptionsPage({ target, props: { state }, - }); + context, + } as any); } export const deckConfigComponents = { diff --git a/ts/editor/BUILD.bazel b/ts/editor/BUILD.bazel index b3e440e53..2617271fe 100644 --- a/ts/editor/BUILD.bazel +++ b/ts/editor/BUILD.bazel @@ -153,6 +153,7 @@ prettier_test( name = "format_check", srcs = glob([ "*.ts", + "*.svelte", ]), ) diff --git a/ts/editor/TemplateButtons.svelte b/ts/editor/TemplateButtons.svelte index 003cbfcb7..eb88d2473 100644 --- a/ts/editor/TemplateButtons.svelte +++ b/ts/editor/TemplateButtons.svelte @@ -62,7 +62,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html - + {@html functionIcon} diff --git a/ts/editor/toolbar.ts b/ts/editor/toolbar.ts index 4ad858d41..856d69014 100644 --- a/ts/editor/toolbar.ts +++ b/ts/editor/toolbar.ts @@ -20,7 +20,7 @@ export function initToolbar(i18n: Promise): Promise { toolbarResolve = resolve; }); - document.addEventListener("DOMContentLoaded", () => { + document.addEventListener("DOMContentLoaded", () => i18n.then(() => { const target = document.body; const anchor = document.getElementById("fields")!; @@ -33,8 +33,8 @@ export function initToolbar(i18n: Promise): Promise { ); toolbarResolve(new EditorToolbar({ target, anchor, context } as any)); - }); - }); + }) + ); return toolbarPromise; } diff --git a/ts/sass/bootstrap-dark.scss b/ts/sass/bootstrap-dark.scss index 48441617b..e833e1888 100644 --- a/ts/sass/bootstrap-dark.scss +++ b/ts/sass/bootstrap-dark.scss @@ -5,8 +5,7 @@ @use 'fusion_vars'; @mixin night-mode { - input, - select { + input { background-color: var(--frame-bg); border-color: var(--border); @@ -15,19 +14,6 @@ } } - .dropdown-menu { - background-color: var(--frame-bg); - - .dropdown-item { - color: var(--text-fg); - - &:hover, - &:active { - background-color: var(--window-bg); - } - } - } - .modal-content { background-color: var(--window-bg); color: var(--text-fg); diff --git a/ts/sass/button_mixins.scss b/ts/sass/button_mixins.scss index 4720df764..a4c62c956 100644 --- a/ts/sass/button_mixins.scss +++ b/ts/sass/button_mixins.scss @@ -17,22 +17,31 @@ $btn-base-color-day: white; border-color: var(--medium-border) !important; } -@mixin btn-day($with-disabled: true, $with-margin: true) { +@mixin btn-day( + $with-hover: true, + $with-active: true, + $with-disabled: true, + $with-margin: true +) { .btn-day { @include btn-day-base; @content ($btn-base-color-day); - &:hover { - background-color: darken($btn-base-color-day, 8%); + @if ($with-hover) { + &:hover { + background-color: darken($btn-base-color-day, 8%); + } } - &:active, - &.active { - @include impressed-shadow(0.25); - } + @if ($with-active) { + &:active, + &.active { + @include impressed-shadow(0.25); + } - &:active.active { - box-shadow: none; + &:active.active { + box-shadow: none; + } } @if ($with-disabled) { @@ -56,25 +65,34 @@ $btn-base-color-night: #666; border-color: $btn-base-color-night; } -@mixin btn-night($with-disabled: true, $with-margin: true) { +@mixin btn-night( + $with-hover: true, + $with-active: true, + $with-disabled: true, + $with-margin: true +) { .btn-night { @include btn-night-base; @content ($btn-base-color-night); - &:hover { - background-color: lighten($btn-base-color-night, 8%); - border-color: lighten($btn-base-color-night, 8%); + @if ($with-hover) { + &:hover { + background-color: lighten($btn-base-color-night, 8%); + border-color: lighten($btn-base-color-night, 8%); + } } - &:active, - &.active { - @include impressed-shadow(0.35); - border-color: darken($btn-base-color-night, 8%); - } + @if ($with-disabled) { + &:active, + &.active { + @include impressed-shadow(0.35); + border-color: darken($btn-base-color-night, 8%); + } - &:active.active { - box-shadow: none; - border-color: $btn-base-color-night; + &:active.active { + box-shadow: none; + border-color: $btn-base-color-night; + } } @if ($with-disabled) {