anki/ts/editor/image-overlay/FloatButtons.svelte
Matthias Metelka 365c5e1fb2
UI size tweaks (#2184)
* Reduce font size of answer button indicators

* Increase padding of browser rows with ResizeToContents on vertical header

* Remove 0.8 scale factor for dropdown item font-size

* Remove font-size prop entirely from DropdownItem

* Revert "Remove font-size prop entirely from DropdownItem"

This reverts commit bb0a158f96183cca74e198867070c2f99af04dc4.

* Remove hard-coded Python font sizes

* Move font size and scrollbar into _root-vars.scss

* Revert editor size variable to 1.6

* Fix icon alignment

* Fix checkbox alignment for dropdown items

* Remove unused classes from Tag.svelte

* Revert "Increase padding of browser rows with ResizeToContents on vertical header"

This reverts commit 77bfc854ba140dd99aae98efcdd4af7052615fa6.

* Remove option to set font size of browser entries

* Add setting for browser row padding to preferences

* Revert "Add setting for browser row padding to preferences"

This reverts commit 75c59da65a1028e2caa3c48b247f99825c1b0b6c.

* Revert "Remove option to set font size of browser entries"

This reverts commit a543783d8ea079f39b7ae445152573c96be29841.
2022-11-23 16:50:15 +10:00

66 lines
2.2 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 { getContext } from "svelte";
import { createEventDispatcher } from "svelte";
import type { Readable } from "svelte/store";
import ButtonGroup from "../../components/ButtonGroup.svelte";
import IconButton from "../../components/IconButton.svelte";
import { directionKey } from "../../lib/context-keys";
import * as tr from "../../lib/ftl";
import { removeStyleProperties } from "../../lib/styling";
import { floatLeftIcon, floatNoneIcon, floatRightIcon } from "./icons";
export let image: HTMLImageElement;
$: floatStyle = getComputedStyle(image).float;
const direction = getContext<Readable<"ltr" | "rtl">>(directionKey);
const [inlineStartIcon, inlineEndIcon] =
$direction === "ltr"
? [floatLeftIcon, floatRightIcon]
: [floatRightIcon, floatLeftIcon];
const dispatch = createEventDispatcher();
</script>
<ButtonGroup size={1.6} wrap={false}>
<IconButton
tooltip={tr.editingFloatLeft()}
active={floatStyle === "left"}
flipX={$direction === "rtl"}
on:click={() => {
image.style.float = "left";
setTimeout(() => dispatch("update"));
}}
--border-left-radius="5px">{@html inlineStartIcon}</IconButton
>
<IconButton
tooltip={tr.editingFloatNone()}
active={floatStyle === "none"}
flipX={$direction === "rtl"}
on:click={() => {
// We shortly set to none, because simply unsetting float will not
// trigger floatStyle being reset
image.style.float = "none";
removeStyleProperties(image, "float");
setTimeout(() => dispatch("update"));
}}>{@html floatNoneIcon}</IconButton
>
<IconButton
tooltip={tr.editingFloatRight()}
active={floatStyle === "right"}
flipX={$direction === "rtl"}
on:click={() => {
image.style.float = "right";
setTimeout(() => dispatch("update"));
}}
--border-right-radius="5px">{@html inlineEndIcon}</IconButton
>
</ButtonGroup>