mirror of
https://github.com/koloml/furbooru-tagging-assistant.git
synced 2025-12-23 23:02:58 +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:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user