diff --git a/web-common/src/features/dashboards/leaderboard/LeaderboardCell.svelte b/web-common/src/features/dashboards/leaderboard/LeaderboardCell.svelte new file mode 100644 index 00000000000..54c622aacef --- /dev/null +++ b/web-common/src/features/dashboards/leaderboard/LeaderboardCell.svelte @@ -0,0 +1,124 @@ + + + + + shiftClickHandler(value), + })} + on:pointerover={() => { + if (value) { + // Always update the value in the store, but don't change visibility + cellInspectorStore.updateValue(value.toString()); + } + }} + on:focus={() => { + if (value) { + // Always update the value in the store, but don't change visibility + cellInspectorStore.updateValue(value.toString()); + } + }} + style:background + class="{type}-cell {className}" + > + + + + + {#if clipboardSupported && !disabled} + +
+ Copy + {value} to clipboard +
+ + + Click + +
+ {/if} +
+ + diff --git a/web-common/src/features/dashboards/leaderboard/LeaderboardRow.svelte b/web-common/src/features/dashboards/leaderboard/LeaderboardRow.svelte index e71970d7bf4..23a4f8bc295 100644 --- a/web-common/src/features/dashboards/leaderboard/LeaderboardRow.svelte +++ b/web-common/src/features/dashboards/leaderboard/LeaderboardRow.svelte @@ -2,14 +2,10 @@ import FormattedDataType from "@rilldata/web-common/components/data-types/FormattedDataType.svelte"; import PercentageChange from "@rilldata/web-common/components/data-types/PercentageChange.svelte"; import ExternalLink from "@rilldata/web-common/components/icons/ExternalLink.svelte"; - import { TOOLTIP_STRING_LIMIT } from "@rilldata/web-common/layout/config"; - import { copyToClipboard } from "@rilldata/web-common/lib/actions/copy-to-clipboard"; - import { modified } from "@rilldata/web-common/lib/actions/modified-click"; import { clamp } from "@rilldata/web-common/lib/clamp"; import { formatMeasurePercentageDifference } from "@rilldata/web-common/lib/number-formatting/percentage-formatter"; import { slide } from "svelte/transition"; import { type LeaderboardItemData, makeHref } from "./leaderboard-utils"; - import { cellInspectorStore } from "../stores/cell-inspector-store"; import LeaderboardItemFilterIcon from "./LeaderboardItemFilterIcon.svelte"; import LongBarZigZag from "./LongBarZigZag.svelte"; import { @@ -19,6 +15,7 @@ deltaColumn, MEASURES_PADDING, } from "./leaderboard-widths"; + import LeaderboardCell from "@rilldata/web-common/features/dashboards/leaderboard/LeaderboardCell.svelte"; export let itemData: LeaderboardItemData; export let dimensionName: string; @@ -160,16 +157,9 @@ }), ); - function shiftClickHandler(label: string) { - let truncatedLabel = label?.toString(); - if (truncatedLabel?.length > TOOLTIP_STRING_LIMIT) { - truncatedLabel = `${truncatedLabel.slice(0, TOOLTIP_STRING_LIMIT)}...`; - } - copyToClipboard( - label, - `copied dimension value "${truncatedLabel}" to clipboard`, - ); - } + $: dimensionCellClass = `relative size-full flex flex-none justify-between items-center leaderboard-label ${ + atLeastOneActive ? "cursor-pointer" : "" + } ${excluded ? "ui-copy-disabled" : ""} ${!excluded && selected ? "ui-copy-strong" : ""}`; function onDimensionCellClick(e: MouseEvent) { // Check if user has selected text @@ -211,30 +201,11 @@ selectionIndex={itemData?.selectedIndex} /> - shiftClickHandler(dimensionValue), - })} - on:pointerover={() => { - if (dimensionValue) { - // Always update the value in the store, but don't change visibility - cellInspectorStore.updateValue(dimensionValue.toString()); - } - }} - on:focus={() => { - if (dimensionValue) { - // Always update the value in the store, but don't change visibility - cellInspectorStore.updateValue(dimensionValue.toString()); - } - }} - class="relative size-full flex flex-none justify-between items-center leaderboard-label" - style:background={dimensionGradients} + @@ -263,31 +234,15 @@ {/if} - + {#each Object.keys(values) as measureName} - shiftClickHandler(values[measureName]?.toString() || ""), - })} - style:background={leaderboardMeasureNames.length === 1 + { - const value = values[measureName]?.toString() || ""; - if (value) { - cellInspectorStore.updateValue(value); - } - }} - on:focus={() => { - const value = values[measureName]?.toString() || ""; - if (value) { - cellInspectorStore.updateValue(value); - } - }} >
{/if} - + {#if isValidPercentOfTotal(measureName) && shouldShowContextColumns(measureName)} - - shiftClickHandler(pctOfTotals[measureName]?.toString() || ""), - })} - on:pointerover={() => { - const value = pctOfTotals[measureName]?.toString() || ""; - if (value) { - cellInspectorStore.updateValue(value); - } - }} - on:focus={() => { - const value = pctOfTotals[measureName]?.toString() || ""; - if (value) { - cellInspectorStore.updateValue(value); - } - }} + {/if} - + {/if} {#if isTimeComparisonActive && shouldShowContextColumns(measureName)} - - shiftClickHandler(deltaAbsMap[measureName]?.toString() || ""), - })} - on:pointerover={() => { - const value = deltaAbsMap[measureName]?.toString() || ""; - if (value) { - cellInspectorStore.updateValue(value); - } - }} - on:focus={() => { - const value = deltaAbsMap[measureName]?.toString() || ""; - if (value) { - cellInspectorStore.updateValue(value); - } - }} + - + {/if} {#if isTimeComparisonActive && shouldShowContextColumns(measureName)} - - shiftClickHandler(deltaRels[measureName]?.toString() || ""), - })} - on:pointerover={() => { - const value = deltaRels[measureName]?.toString() || ""; - if (value) { - cellInspectorStore.updateValue(value); - } - }} - on:focus={() => { - const value = deltaRels[measureName]?.toString() || ""; - if (value) { - cellInspectorStore.updateValue(value); - } - }} + {/if} - + {/if} {/each}