-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Pivot tooltip functionality (#4938)
* initial commit * cleanup * remove import
- Loading branch information
1 parent
3f54f66
commit 3253a7c
Showing
4 changed files
with
148 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
web-common/src/components/virtualized-table/VirtualTooltip.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<script lang="ts"> | ||
import { portal } from "@rilldata/web-common/lib/actions/portal"; | ||
import TooltipContent from "../tooltip/TooltipContent.svelte"; | ||
import TooltipTitle from "../tooltip/TooltipTitle.svelte"; | ||
import TooltipShortcutContainer from "../tooltip/TooltipShortcutContainer.svelte"; | ||
import Shortcut from "../tooltip/Shortcut.svelte"; | ||
import StackingWord from "../tooltip/StackingWord.svelte"; | ||
import FormattedDataType from "../data-types/FormattedDataType.svelte"; | ||
import { isClipboardApiSupported } from "@rilldata/web-common/lib/actions/copy-to-clipboard"; | ||
type HoveringData = { | ||
value: string | number | null; | ||
index?: number; | ||
column?: string; | ||
type?: string; | ||
isHeader?: boolean; | ||
isPin?: boolean; | ||
}; | ||
export let hoverPosition = { top: 0, left: 0, width: 0 }; | ||
export let pinned: boolean; | ||
export let hovering: HoveringData; | ||
export let sortable: boolean; | ||
</script> | ||
|
||
<aside | ||
class="w-fit h-fit absolute -translate-x-1/2 -translate-y-full z-[1000]" | ||
use:portal | ||
style:top="{hoverPosition.top - 8}px" | ||
style:left="{hoverPosition.left + hoverPosition.width / 2}px" | ||
> | ||
<TooltipContent maxWidth="360px"> | ||
{#if hovering.isPin} | ||
{pinned ? "Unpin" : "Pin"} this column to left side of the table | ||
{:else} | ||
<TooltipTitle> | ||
<svelte:fragment slot="name"> | ||
{#if hovering.isHeader} | ||
{hovering.value} | ||
{:else} | ||
<FormattedDataType | ||
dark | ||
type={hovering?.type} | ||
value={hovering?.value} | ||
/> | ||
{/if} | ||
</svelte:fragment> | ||
|
||
<svelte:fragment slot="description"> | ||
{hovering.isHeader ? hovering.type : ""} | ||
</svelte:fragment> | ||
</TooltipTitle> | ||
|
||
{#if !hovering.isPin} | ||
<TooltipShortcutContainer> | ||
{#if hovering.isHeader && sortable} | ||
<div>Sort column</div> | ||
<Shortcut>Click</Shortcut> | ||
{/if} | ||
{#if isClipboardApiSupported()} | ||
<div> | ||
<StackingWord key="shift">Copy</StackingWord> | ||
{hovering.isHeader ? "column name" : "this value"} to clipboard | ||
</div> | ||
<Shortcut> | ||
<span style="font-family: var(--system);">⇧</span> + Click | ||
</Shortcut> | ||
{/if} | ||
</TooltipShortcutContainer> | ||
{/if} | ||
{/if} | ||
</TooltipContent> | ||
</aside> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3253a7c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Published on https://ui.rilldata.in as production
🚀 Deployed on https://665cb164ea270e1408c147e1--rill-ui-dev.netlify.app