mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-24 01:51:57 +03:00
feat: add tooltip option to ContextMenuItem
This commit is contained in:
parent
a9ecf285f6
commit
c760a0b482
@ -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}
|
||||
|
||||
<span class="label text-12">
|
||||
{label}
|
||||
</span>
|
||||
<slot name="control" />
|
||||
<Tooltip text={tooltip}>
|
||||
<span class="label text-12">
|
||||
{label}
|
||||
</span>
|
||||
</Tooltip>
|
||||
{#if control}
|
||||
{@render control()}
|
||||
{/if}
|
||||
</button>
|
||||
|
||||
<style lang="postcss">
|
||||
|
Loading…
Reference in New Issue
Block a user