mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 23:12:21 -04:00
Merge pull request #1133 from hgiesel/toolbarcleanup
Toolbar PR Cleanup
This commit is contained in:
commit
0ce396d95c
6 changed files with 11 additions and 28 deletions
|
@ -7,7 +7,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
import { getContext } from "svelte";
|
import { getContext } from "svelte";
|
||||||
import { nightModeKey } from "./contextKeys";
|
import { nightModeKey } from "./contextKeys";
|
||||||
|
|
||||||
export let id: string;
|
export let id: string | undefined = undefined;
|
||||||
export let className = "";
|
export let className = "";
|
||||||
export let buttons: ToolbarItem[];
|
export let buttons: ToolbarItem[];
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
updateButton(command);
|
updateButton(command);
|
||||||
|
|
||||||
commandMap.subscribe((map: Map<string, boolean>): (() => void) => {
|
commandMap.subscribe((map: Map<string, boolean>): (() => void) => {
|
||||||
active = map.get(command);
|
active = Boolean(map.get(command));
|
||||||
return () => map.delete(command);
|
return () => map.delete(command);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
import { disabledKey, nightModeKey } from "./contextKeys";
|
import { disabledKey, nightModeKey } from "./contextKeys";
|
||||||
|
|
||||||
import ButtonGroup from "./ButtonGroup.svelte";
|
import ButtonGroup from "./ButtonGroup.svelte";
|
||||||
|
import type { ButtonGroupProps } from "./ButtonGroup";
|
||||||
|
|
||||||
export let buttons: Readable<ToolbarItem[]>;
|
export let buttons: Readable<
|
||||||
|
(ToolbarItem<typeof ButtonGroup> & ButtonGroupProps)[]
|
||||||
|
>;
|
||||||
export let menus: Readable<ToolbarItem[]>;
|
export let menus: Readable<ToolbarItem[]>;
|
||||||
|
|
||||||
$: _buttons = $buttons;
|
$: _buttons = $buttons;
|
||||||
|
|
|
@ -4,7 +4,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
-->
|
-->
|
||||||
<script lang="typescript">
|
<script lang="typescript">
|
||||||
import type { Writable } from "svelte/store";
|
import type { Writable } from "svelte/store";
|
||||||
import type { PreferencePayload } from "sveltelib/preferences";
|
import type { PreferenceRaw, PreferencePayload } from "sveltelib/preferences";
|
||||||
|
|
||||||
import pb from "anki/backend_proto";
|
import pb from "anki/backend_proto";
|
||||||
import { postRequest } from "anki/postrequest";
|
import { postRequest } from "anki/postrequest";
|
||||||
|
@ -60,7 +60,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
setGraphPreferences,
|
setGraphPreferences,
|
||||||
pb.BackendProto.GraphPreferences.toObject.bind(
|
pb.BackendProto.GraphPreferences.toObject.bind(
|
||||||
pb.BackendProto.GraphPreferences
|
pb.BackendProto.GraphPreferences
|
||||||
)
|
) as (
|
||||||
|
preferences: pb.BackendProto.GraphPreferences,
|
||||||
|
options: { defaults: boolean }
|
||||||
|
) => PreferenceRaw<pb.BackendProto.GraphPreferences>
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
<!--
|
|
||||||
Copyright: Ankitects Pty Ltd and contributors
|
|
||||||
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
||||||
-->
|
|
||||||
<script lang="typescript">
|
|
||||||
import useAsync from "sveltelib/async";
|
|
||||||
import { setupI18n } from "anki/i18n";
|
|
||||||
import { checkNightMode } from "anki/nightmode";
|
|
||||||
|
|
||||||
const nightMode = checkNightMode();
|
|
||||||
|
|
||||||
const { loading, value: i18n } = useAsync(() => setupI18n());
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{#if !$loading}
|
|
||||||
<slot i18n={$i18n} {nightMode} />
|
|
||||||
{/if}
|
|
|
@ -1,14 +1,8 @@
|
||||||
// Copyright: Ankitects Pty Ltd and contributors
|
// Copyright: Ankitects Pty Ltd and contributors
|
||||||
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
// languageServerHost taken from MIT sources - see below.
|
|
||||||
|
|
||||||
import { Writable, writable, get } from "svelte/store";
|
import { Writable, writable, get } from "svelte/store";
|
||||||
|
|
||||||
// import pb from "anki/backend_proto";
|
|
||||||
// export async function getGraphPreferences(): Promise<pb.BackendProto.GraphPreferences> {
|
|
||||||
// export async function setGraphPreferences(prefs: PreferencePayload): Promise<void> {
|
|
||||||
// pb.BackendProto.GraphPreferences.toObject(Preferences, {
|
|
||||||
|
|
||||||
export interface CustomStore<T> extends Writable<T> {
|
export interface CustomStore<T> extends Writable<T> {
|
||||||
subscribe: (getter: (value: T) => void) => () => void;
|
subscribe: (getter: (value: T) => void) => () => void;
|
||||||
set: (value: T) => void;
|
set: (value: T) => void;
|
||||||
|
|
Loading…
Reference in a new issue