1
0
mirror of https://github.com/koloml/furbooru-tagging-assistant.git synced 2025-12-24 07:12:57 +00:00

Refactored MenuItem

This change will break a lot of menu items with `on:click`. These cases would be resolved separately.
This commit is contained in:
2025-02-17 03:46:29 +04:00
parent 927fa21d95
commit 9f08eb2171

View File

@@ -1,28 +1,25 @@
<script>
import { createBubbler } from 'svelte/legacy';
<script lang="ts">
import type { Snippet } from "svelte";
import type { MouseEventHandler } from "svelte/elements";
const bubble = createBubbler();
interface MenuItemProps {
href?: string | null;
icon?: App.IconName | null;
target?: App.LinkTarget | undefined;
children?: Snippet;
onclick?: MouseEventHandler<HTMLAnchorElement | HTMLSpanElement>;
}
/**
* @typedef {Object} Props
* @property {string|null} [href]
* @property {App.IconName|null} [icon]
* @property {App.LinkTarget|undefined} [target]
* @property {import('svelte').Snippet} [children]
*/
/** @type {Props} */
let {
href = null,
icon = null,
target = undefined,
children
} = $props();
children,
onclick
}: MenuItemProps = $props();
</script>
<svelte:element class="menu-item" {href} onclick={bubble('click')} role="link" tabindex="0" {target}
this="{href ? 'a': 'span'}">
<svelte:element class="menu-item" {href} {onclick} role="link" tabindex="0" {target} this="{href ? 'a': 'span'}">
{#if icon}
<i class="icon icon-{icon}"></i>
{/if}