A tooltip with a new approach (#2172)

Signed-off-by: Alexander Platov <sas_lord@mail.ru>
This commit is contained in:
Alexander Platov
2022-06-30 10:41:46 +07:00
committed by GitHub
parent c1a8b89855
commit 94ee6f5afe
56 changed files with 704 additions and 656 deletions
@@ -21,7 +21,6 @@
import Button from './Button.svelte'
import DropdownLabelsPopupIntl from './DropdownLabelsPopupIntl.svelte'
import Label from './Label.svelte'
import Tooltip from './Tooltip.svelte'
export let icon: Asset | AnySvelteComponent | undefined = undefined
export let label: IntlString
@@ -48,33 +47,32 @@
</script>
<div bind:this={container} class="min-w-0">
<Tooltip {label} fill={width === '100%'} direction={labelDirection}>
<Button
{icon}
width={width ?? 'min-content'}
{size}
{kind}
{justify}
on:click={() => {
if (!opened) {
opened = true
showPopup(DropdownLabelsPopupIntl, { placeholder, items, selected }, container, (result) => {
if (result) {
selected = result
dispatch('selected', result)
}
opened = false
})
}
}}
>
<span slot="content" class="overflow-label disabled">
{#if selectedItem}
<Label label={selectedItem.label} />
{:else}
<Label label={label ?? ui.string.NotSelected} />
{/if}
</span>
</Button>
</Tooltip>
<Button
{icon}
width={width ?? 'min-content'}
{size}
{kind}
{justify}
showTooltip={{ label, direction: labelDirection }}
on:click={() => {
if (!opened) {
opened = true
showPopup(DropdownLabelsPopupIntl, { placeholder, items, selected }, container, (result) => {
if (result) {
selected = result
dispatch('selected', result)
}
opened = false
})
}
}}
>
<span slot="content" class="overflow-label disabled">
{#if selectedItem}
<Label label={selectedItem.label} />
{:else}
<Label label={label ?? ui.string.NotSelected} />
{/if}
</span>
</Button>
</div>