feat: add tooltip option to ContextMenuItem

This commit is contained in:
ndom91 2024-10-17 16:07:54 +02:00 committed by Nico Domino
parent a9ecf285f6
commit c760a0b482

View File

@ -1,21 +1,34 @@
<script lang="ts">
import Icon from '@gitbutler/ui/Icon.svelte';
import Tooltip from '@gitbutler/ui/Tooltip.svelte';
import type iconsJson from '@gitbutler/ui/data/icons.json';
import type { Snippet } from 'svelte';
export let icon: keyof typeof iconsJson | undefined = undefined;
export let label: string;
export let disabled = false;
interface Props {
icon?: keyof typeof iconsJson | undefined;
label: string;
disabled?: boolean;
control?: Snippet;
tooltip?: string;
onclick: () => void;
}
const { onclick, icon = undefined, label, disabled, control, tooltip = '' }: Props = $props();
</script>
<button class="menu-item" class:disabled {disabled} on:click>
<button class="menu-item" class:disabled {disabled} {onclick}>
{#if icon}
<Icon name={icon} />
{/if}
<Tooltip text={tooltip}>
<span class="label text-12">
{label}
</span>
<slot name="control" />
</Tooltip>
{#if control}
{@render control()}
{/if}
</button>
<style lang="postcss">