mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -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 type { WithShortcutProps } from "./WithShortcut";
|
||||
|
||||
import WithLabel from "./WithLabel.svelte";
|
||||
import type { WithLabelProps } from "./WithLabel";
|
||||
|
||||
import { dynamicComponent } from "sveltelib/dynamicComponent";
|
||||
|
||||
export const rawButton = dynamicComponent<typeof RawButton, { html: string }>(
|
||||
|
@ -71,3 +74,5 @@ export const withDropdownMenu = dynamicComponent<
|
|||
export const withShortcut = dynamicComponent<typeof WithShortcut, WithShortcutProps>(
|
||||
WithShortcut
|
||||
);
|
||||
|
||||
export const withLabel = dynamicComponent<typeof WithLabel, WithLabelProps>(WithLabel);
|
||||
|
|
Loading…
Reference in a new issue