1
0
mirror of https://github.com/koloml/furbooru-tagging-assistant.git synced 2025-12-23 23:02:58 +00:00

Refactored menu & menu items

Once again, breaking change for a lot of components, would be tackled separately
This commit is contained in:
2025-02-17 04:51:15 +04:00
parent 49986ec497
commit 5a07fa3d60
3 changed files with 37 additions and 39 deletions

View File

@@ -1,9 +1,9 @@
<script lang="ts">
interface Props {
interface MenuProps {
children?: import('svelte').Snippet;
}
let { children }: Props = $props();
let { children }: MenuProps = $props();
</script>
<nav>

View File

@@ -1,33 +1,31 @@
<script>
import { createBubbler, stopPropagation } from 'svelte/legacy';
<script lang="ts">
import MenuLink from "$components/ui/menu/MenuItem.svelte";
import type { Snippet } from "svelte";
import type { FormEventHandler, MouseEventHandler } from "svelte/elements";
const bubble = createBubbler();
interface MenuCheckboxItemProps {
checked: boolean;
name?: string;
value?: string;
href?: string;
children?: Snippet;
onclick?: MouseEventHandler<HTMLInputElement>;
oninput?: FormEventHandler<HTMLInputElement>;
}
/**
* @typedef {Object} Props
* @property {boolean} checked
* @property {string|undefined} [name]
* @property {string|undefined} [value]
* @property {string|null} [href]
* @property {import('svelte').Snippet} [children]
*/
/** @type {Props} */
let {
checked = $bindable(),
name = undefined,
value = undefined,
href = null,
children
} = $props();
href = undefined,
children,
onclick,
oninput,
}: MenuCheckboxItemProps = $props();
</script>
<MenuLink {href}>
<input bind:checked={checked} {name} onclick={stopPropagation(bubble('click'))} oninput={bubble('input')}
type="checkbox"
{value}>
<input bind:checked={checked} {name} {onclick} {oninput} type="checkbox" {value}>
{@render children?.()}
</MenuLink>

View File

@@ -1,31 +1,31 @@
<script>
import { createBubbler, stopPropagation } from 'svelte/legacy';
<script lang="ts">
import MenuLink from "$components/ui/menu/MenuItem.svelte";
import type { Snippet } from "svelte";
import type { FormEventHandler, MouseEventHandler } from "svelte/elements";
const bubble = createBubbler();
interface MenuRadioItemProps {
checked: boolean;
name: string;
value: string;
href?: string | null;
children?: Snippet;
onclick?: MouseEventHandler<HTMLInputElement>;
oninput?: FormEventHandler<HTMLInputElement>;
}
/**
* @typedef {Object} Props
* @property {boolean} checked
* @property {string} name
* @property {string} value
* @property {string|null} [href]
* @property {import('svelte').Snippet} [children]
*/
/** @type {Props} */
let {
checked,
name,
value,
href = null,
children
} = $props();
children,
onclick,
oninput,
}: MenuRadioItemProps = $props();
</script>
<MenuLink {href}>
<input {checked} {name} onclick={stopPropagation(bubble('click'))} oninput={bubble('input')} type="radio" {value}>
<input {checked} {name} {onclick} {oninput} type="radio" {value}>
{@render children?.()}
</MenuLink>