mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
Add withLabel component
This commit is contained in:
parent
4379f1e84f
commit
d250d39d64
3 changed files with 35 additions and 0 deletions
8
ts/editor-toolbar/WithLabel.d.ts
vendored
Normal file
8
ts/editor-toolbar/WithLabel.d.ts
vendored
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
// Copyright: Ankitects Pty Ltd and contributors
|
||||||
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
import type { ToolbarItem } from "./types";
|
||||||
|
|
||||||
|
export interface WithLabelProps {
|
||||||
|
button: ToolbarItem;
|
||||||
|
label: string;
|
||||||
|
}
|
22
ts/editor-toolbar/WithLabel.svelte
Normal file
22
ts/editor-toolbar/WithLabel.svelte
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<!--
|
||||||
|
Copyright: Ankitects Pty Ltd and contributors
|
||||||
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
-->
|
||||||
|
<script lang="typescript">
|
||||||
|
import type { DynamicSvelteComponent } from "sveltelib/dynamicComponent";
|
||||||
|
import type { ToolbarItem } from "./types";
|
||||||
|
import type { Modifier } from "lib/shortcuts";
|
||||||
|
|
||||||
|
import { onDestroy } from "svelte";
|
||||||
|
import { registerShortcut, getPlatformString } from "lib/shortcuts";
|
||||||
|
|
||||||
|
export let button: ToolbarItem;
|
||||||
|
export let label: string;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!-- svelte-ignore a11y-label-has-associated-control -->
|
||||||
|
|
||||||
|
<label>
|
||||||
|
{label}
|
||||||
|
<svelte:component this={button.component} {...button} />
|
||||||
|
</label>
|
|
@ -26,6 +26,9 @@ import type { WithDropdownMenuProps } from "./WithDropdownMenu";
|
||||||
import WithShortcut from "./WithShortcut.svelte";
|
import WithShortcut from "./WithShortcut.svelte";
|
||||||
import type { WithShortcutProps } from "./WithShortcut";
|
import type { WithShortcutProps } from "./WithShortcut";
|
||||||
|
|
||||||
|
import WithLabel from "./WithLabel.svelte";
|
||||||
|
import type { WithLabelProps } from "./WithLabel";
|
||||||
|
|
||||||
import { dynamicComponent } from "sveltelib/dynamicComponent";
|
import { dynamicComponent } from "sveltelib/dynamicComponent";
|
||||||
|
|
||||||
export const rawButton = dynamicComponent<typeof RawButton, { html: string }>(
|
export const rawButton = dynamicComponent<typeof RawButton, { html: string }>(
|
||||||
|
@ -71,3 +74,5 @@ export const withDropdownMenu = dynamicComponent<
|
||||||
export const withShortcut = dynamicComponent<typeof WithShortcut, WithShortcutProps>(
|
export const withShortcut = dynamicComponent<typeof WithShortcut, WithShortcutProps>(
|
||||||
WithShortcut
|
WithShortcut
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const withLabel = dynamicComponent<typeof WithLabel, WithLabelProps>(WithLabel);
|
||||||
|
|
Loading…
Reference in a new issue