From 349c759743229d0125358706c831bb0b2a8f25a0 Mon Sep 17 00:00:00 2001 From: Brian Holmes <120223836+briangregoryholmes@users.noreply.github.com> Date: Wed, 11 Dec 2024 05:00:39 -0500 Subject: [PATCH] fix: leaderboard column percent of total width (#6243) --- .../dashboards/leaderboard/Leaderboard.svelte | 52 ++----- .../leaderboard/LeaderboardDisplay.svelte | 51 +++---- .../leaderboard/LeaderboardRow.svelte | 136 +++++++++--------- .../leaderboard/leaderboard-widths.ts | 120 +++------------- 4 files changed, 127 insertions(+), 232 deletions(-) diff --git a/web-common/src/features/dashboards/leaderboard/Leaderboard.svelte b/web-common/src/features/dashboards/leaderboard/Leaderboard.svelte index c917e9740fe..75d440e4874 100644 --- a/web-common/src/features/dashboards/leaderboard/Leaderboard.svelte +++ b/web-common/src/features/dashboards/leaderboard/Leaderboard.svelte @@ -18,7 +18,6 @@ cleanUpComparisonValue, compareLeaderboardValues, getSort, - type LeaderboardItemData, prepareLeaderboardItemData, } from "./leaderboard-utils"; import type { DimensionThresholdFilter } from "../stores/metrics-explorer-entity"; @@ -39,13 +38,14 @@ getFiltersForOtherDimensions, } from "../selectors"; import { getIndependentMeasures } from "../state-managers/selectors/measures"; - import { - LEADERBOARD_DEFAULT_COLUMN_WIDTHS, - type ColumnWidths, - } from "./leaderboard-widths"; import LeaderboardHeader from "./LeaderboardHeader.svelte"; import LeaderboardRow from "./LeaderboardRow.svelte"; import LoadingRows from "./LoadingRows.svelte"; + import { + valueColumn, + deltaColumn, + DEFAULT_COL_WIDTH, + } from "./leaderboard-widths"; const slice = 7; const gutterWidth = 24; @@ -62,20 +62,16 @@ export let metricsViewName: string; export let metricsView: V1MetricsViewSpec; export let sortType: SortType; + export let tableWidth: number; export let sortedAscending: boolean; export let isValidPercentOfTotal: boolean; export let timeControlsReady: boolean; + export let firstColumnWidth: number; export let isSummableMeasure: boolean; export let filterExcludeMode: boolean; export let atLeastOneActive: boolean; export let isBeingCompared: boolean; export let parentElement: HTMLElement; - export let columnWidths: ColumnWidths = LEADERBOARD_DEFAULT_COLUMN_WIDTHS; - export let estimateAndUpdateLeaderboardWidths: ( - dimensionName: string, - aboveTheFold: LeaderboardItemData[], - belowTheFold: LeaderboardItemData[], - ) => void; export let toggleDimensionValueSelection: ( dimensionName: string, dimensionValue: string, @@ -260,24 +256,6 @@ ); $: columnCount = comparisonTimeRange ? 3 : isValidPercentOfTotal ? 2 : 1; - - // Estimate the common column widths for all leaderboards - $: if (aboveTheFold.length || belowTheFoldRows.length) { - estimateAndUpdateLeaderboardWidths( - dimensionName, - aboveTheFold, - belowTheFoldRows, - ); - } - - $: tableWidth = - columnWidths.dimension + - columnWidths.value + - (comparisonTimeRange - ? columnWidths.delta + columnWidths.deltaPercent - : isValidPercentOfTotal - ? columnWidths.percentOfTotal - : 0);