Skip to content

Commit

Permalink
Feat: Add resizer for timeseries leaderboard split (#6256)
Browse files Browse the repository at this point in the history
  • Loading branch information
djbarnwal authored Dec 12, 2024
1 parent d95acaa commit f979e7d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
3 changes: 0 additions & 3 deletions web-common/src/features/dashboards/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ export const MEASURE_CONFIG = {
height: 125,
fullHeight: 220,
},
container: {
width: { full: 580, breakpoint: 420 },
},
bigNumber: {
widthWithChart: 140,
widthWithoutChart: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
export let exploreName: string;
export let workspaceWidth: number;
export let timeSeriesWidth: number;
export let hideStartPivotButton = false;
const {
Expand Down Expand Up @@ -290,6 +291,7 @@
end={endValue}
start={startValue}
{workspaceWidth}
{timeSeriesWidth}
>
<div class:mb-6={isAlternateChart} class="flex items-center gap-x-1 px-2.5">
{#if isInTimeDimensionView}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ A container GraphicContext for the time series in a metrics dashboard.
export let start: Date | undefined;
export let end: Date | undefined;
export let workspaceWidth: number;
export let timeSeriesWidth: number;
export let enableFullWidth = false;
const paddingForFullWidth = 80;
const paddingForSplitView = 30;
</script>

<div class="max-w-full h-fit flex flex-col max-h-full pr-2">
Expand All @@ -26,10 +28,7 @@ A container GraphicContext for the time series in a metrics dashboard.
width={Math.max(
enableFullWidth
? workspaceWidth - paddingForFullWidth
: workspaceWidth >= MEASURE_CONFIG.breakpoint
? MEASURE_CONFIG.container.width.full
: MEASURE_CONFIG.container.width.breakpoint,
400,
: timeSeriesWidth - paddingForSplitView,
) - MEASURE_CONFIG.bigNumber.widthWithChart}
xMax={end}
xMaxTweenProps={{ duration: 400 }}
Expand Down
22 changes: 20 additions & 2 deletions web-common/src/features/dashboards/workspace/Dashboard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { useExploreValidSpec } from "@rilldata/web-common/features/explores/selectors";
import { featureFlags } from "@rilldata/web-common/features/feature-flags";
import { navigationOpen } from "@rilldata/web-common/layout/navigation/Navigation.svelte";
import Resizer from "@rilldata/web-common/layout/Resizer.svelte";
import { useExploreState } from "web-common/src/features/dashboards/stores/dashboard-stores";
import { runtime } from "../../../runtime-client/runtime-store";
import MeasuresContainer from "../big-number/MeasuresContainer.svelte";
Expand Down Expand Up @@ -83,6 +84,10 @@
: undefined;
$: metricsView = $validSpecStore.data?.metricsView ?? {};
let metricsWidth = 580; // Default width for metrics section
const MIN_METRICS_WIDTH = 440;
let resizing = false;
</script>

<article
Expand Down Expand Up @@ -124,11 +129,12 @@
class:flex-row={!expandedMeasureName}
class:left-shift={extraLeftPadding}
>
<div class="pt-2">
<div class="pt-2 flex-none" style:width="{metricsWidth}px">
{#key exploreName}
{#if hasTimeSeries}
<MetricsTimeSeriesCharts
{exploreName}
timeSeriesWidth={metricsWidth}
workspaceWidth={exploreContainerWidth}
hideStartPivotButton={hidePivot}
/>
Expand All @@ -146,7 +152,19 @@
hideStartPivotButton={hidePivot}
/>
{:else}
<div class="pt-2 pl-1 border-l overflow-auto w-full">
<div class="relative flex-none bg-gray-200 w-[1px]">
<Resizer
dimension={metricsWidth}
min={MIN_METRICS_WIDTH}
max={exploreContainerWidth - 500}
bind:resizing
side="right"
onUpdate={(width) => {
metricsWidth = width;
}}
/>
</div>
<div class="pt-2 pl-1 overflow-auto w-full">
{#if selectedDimension}
<DimensionDisplay
dimension={selectedDimension}
Expand Down
2 changes: 2 additions & 0 deletions web-common/src/layout/Resizer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
class:absolute
class="{direction} {side} justify-{justify}"
class:hang
class:minned={dimension === min}
class:maxed={dimension === max}
on:mousedown|stopPropagation|preventDefault={handleMousedown}
on:dblclick|stopPropagation={handleDoubleClick}
on:mouseenter={() => {
Expand Down

1 comment on commit f979e7d

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.