mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00

* Add sveltekit-svg plugin to fix svg icon styling Closes #3127. * Unify svg icon usage Moves all icons into ts/lib/components/icons.ts and uses a single component to render them both with eslint and svelte-kit. * Fix spinning revert icon not being centered * Use svg earth icon for global label * Add tooltip to global label icon * Remove eslint-plugin-simple-import-sort Imports are already sorted by dprint with conflicting rules.
67 lines
1.7 KiB
Svelte
67 lines
1.7 KiB
Svelte
<!--
|
|
Copyright: Ankitects Pty Ltd and contributors
|
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
-->
|
|
<script lang="ts">
|
|
import * as tr from "@generated/ftl";
|
|
import { getPlatformString, registerShortcut } from "@tslib/shortcuts";
|
|
import { createEventDispatcher, onDestroy } from "svelte";
|
|
|
|
import Badge from "$lib/components/Badge.svelte";
|
|
import Icon from "$lib/components/Icon.svelte";
|
|
import { plainTextIcon } from "$lib/components/icons";
|
|
|
|
import { context as editorFieldContext } from "./EditorField.svelte";
|
|
|
|
const animated = !document.body.classList.contains("reduce-motion");
|
|
|
|
const editorField = editorFieldContext.get();
|
|
const keyCombination = "Control+Shift+X";
|
|
const dispatch = createEventDispatcher();
|
|
|
|
export let show = false;
|
|
export let off = false;
|
|
|
|
function toggle() {
|
|
dispatch("toggle");
|
|
}
|
|
|
|
let unregister: ReturnType<typeof registerShortcut> | undefined;
|
|
|
|
editorField.element.then((target) => {
|
|
unregister = registerShortcut(toggle, keyCombination, { target });
|
|
});
|
|
|
|
onDestroy(() => unregister?.());
|
|
</script>
|
|
|
|
<span
|
|
class="plain-text-badge"
|
|
class:visible={show || !animated}
|
|
class:highlighted={!off}
|
|
on:click|stopPropagation={toggle}
|
|
>
|
|
<Badge
|
|
tooltip="{tr.editingToggleHtmlEditor()} ({getPlatformString(keyCombination)})"
|
|
iconSize={80}
|
|
>
|
|
<Icon icon={plainTextIcon} />
|
|
</Badge>
|
|
</span>
|
|
|
|
<style lang="scss">
|
|
span {
|
|
cursor: pointer;
|
|
opacity: 0;
|
|
|
|
&.visible {
|
|
opacity: 0.4;
|
|
&:hover {
|
|
opacity: 0.8;
|
|
}
|
|
}
|
|
&.highlighted {
|
|
opacity: 1;
|
|
}
|
|
}
|
|
</style>
|