From 830fd447408693ca70b206701633841cf2918e1a Mon Sep 17 00:00:00 2001 From: Sophia Mersmann Date: Mon, 9 Dec 2024 11:45:16 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20add=20foreground=20to=20interact?= =?UTF-8?q?ion=20states?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/@ourworldindata/grapher/src/chart/ChartUtils.tsx | 4 +--- .../grapher/src/selection/InteractionArray.ts | 3 +-- .../grapher/src/stackedCharts/StackedAreaChart.tsx | 6 +++--- .../@ourworldindata/types/src/grapherTypes/GrapherTypes.ts | 3 +-- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/@ourworldindata/grapher/src/chart/ChartUtils.tsx b/packages/@ourworldindata/grapher/src/chart/ChartUtils.tsx index ffb08fabb59..0d0a1ee1ca4 100644 --- a/packages/@ourworldindata/grapher/src/chart/ChartUtils.tsx +++ b/packages/@ourworldindata/grapher/src/chart/ChartUtils.tsx @@ -203,10 +203,8 @@ export function byInteractionState(series: { switch (series.hover) { case InteractionState.background: return 1 - case InteractionState.none: + case InteractionState.foreground: return 2 - case InteractionState.active: - return 3 } } diff --git a/packages/@ourworldindata/grapher/src/selection/InteractionArray.ts b/packages/@ourworldindata/grapher/src/selection/InteractionArray.ts index 206f622f5ef..daff9a814df 100644 --- a/packages/@ourworldindata/grapher/src/selection/InteractionArray.ts +++ b/packages/@ourworldindata/grapher/src/selection/InteractionArray.ts @@ -60,9 +60,8 @@ export class InteractionArray { * isn't currently interacted with. */ state(seriesName: SeriesName): InteractionState { - if (this.isEmpty) return InteractionState.none return this.isInForeground(seriesName) - ? InteractionState.active + ? InteractionState.foreground : InteractionState.background } diff --git a/packages/@ourworldindata/grapher/src/stackedCharts/StackedAreaChart.tsx b/packages/@ourworldindata/grapher/src/stackedCharts/StackedAreaChart.tsx index ed5ba2eb03d..3ca4cc85160 100644 --- a/packages/@ourworldindata/grapher/src/stackedCharts/StackedAreaChart.tsx +++ b/packages/@ourworldindata/grapher/src/stackedCharts/StackedAreaChart.tsx @@ -296,10 +296,10 @@ export class StackedAreaChart extends AbstractStackedChart { private hoverStateForSeries( series: StackedSeries - ): InteractionState | undefined { - if (!this.focusedSeriesName) return undefined + ): InteractionState { + if (!this.focusedSeriesName) return InteractionState.foreground return this.focusedSeriesName === series.seriesName - ? InteractionState.active + ? InteractionState.foreground : InteractionState.background } diff --git a/packages/@ourworldindata/types/src/grapherTypes/GrapherTypes.ts b/packages/@ourworldindata/types/src/grapherTypes/GrapherTypes.ts index 9c61760e449..93d27e98d0d 100644 --- a/packages/@ourworldindata/types/src/grapherTypes/GrapherTypes.ts +++ b/packages/@ourworldindata/types/src/grapherTypes/GrapherTypes.ts @@ -96,8 +96,7 @@ export enum DimensionProperty { } export enum InteractionState { - none = "none", // series is in its default state since the chart is not interacted with - active = "active", // series is actively hovered/focused + foreground = "foreground", // series is either actively hovered/focused or the chart is not currently being interacted with background = "background", // another series is actively hovered/focused }