Fun changes
Some checks failed
CI / Python (lint + test) (push) Failing after 3m38s
CI / Rust (lint + test) (push) Failing after 3m32s
CI / Frontend (lint + typecheck) (push) Failing after 4m12s
Build and publish Docker image / build-and-push (push) Failing after 4m48s

This commit is contained in:
Andras Schmelczer 2026-04-04 22:59:44 +01:00
parent cd778dd088
commit 349a6c1d53
60 changed files with 1260 additions and 2600 deletions

View file

@ -5,17 +5,23 @@ import {
FEATURE_GRADIENT,
DENSITY_GRADIENT,
DENSITY_GRADIENT_DARK,
ENUM_PALETTE,
getEnumPaletteForFeature,
} from '../../lib/consts';
import { gradientToCss } from '../../lib/utils';
import { CloseIcon } from '../ui/icons/CloseIcon';
import { TickerValue } from '../ui/TickerValue';
function EnumSwatches({ values }: { values: string[] }) {
function EnumSwatches({
values,
palette,
}: {
values: string[];
palette: [number, number, number][];
}) {
return (
<div className="flex flex-col gap-1">
{values.map((label, i) => {
const color = ENUM_PALETTE[i % ENUM_PALETTE.length];
const color = palette[i % palette.length];
return (
<div key={label} className="flex items-center gap-1.5">
<div
@ -30,11 +36,17 @@ function EnumSwatches({ values }: { values: string[] }) {
);
}
function InlineEnumSwatches({ values }: { values: string[] }) {
function InlineEnumSwatches({
values,
palette,
}: {
values: string[];
palette: [number, number, number][];
}) {
return (
<div className="flex items-center gap-2 flex-1 min-w-[40%] flex-wrap">
{values.map((label, i) => {
const color = ENUM_PALETTE[i % ENUM_PALETTE.length];
const color = palette[i % palette.length];
return (
<div key={label} className="flex items-center gap-1">
<div
@ -58,6 +70,7 @@ export default function MapLegend({
onCancel,
mode,
enumValues,
featureName,
theme = 'light',
inline = false,
suffix,
@ -70,6 +83,7 @@ export default function MapLegend({
onCancel: () => void;
mode: 'feature' | 'density';
enumValues?: string[];
featureName?: string;
theme?: 'light' | 'dark';
inline?: boolean;
suffix?: string;
@ -78,6 +92,7 @@ export default function MapLegend({
}) {
const { t } = useTranslation();
const isEnum = enumValues && enumValues.length > 0;
const enumPalette = getEnumPaletteForFeature(featureName ?? null, enumValues);
const densityGradient = theme === 'dark' ? DENSITY_GRADIENT_DARK : DENSITY_GRADIENT;
const gradientStyle =
mode === 'density' ? gradientToCss(densityGradient) : gradientToCss(FEATURE_GRADIENT);
@ -114,7 +129,7 @@ export default function MapLegend({
</button>
)}
{isEnum ? (
<InlineEnumSwatches values={enumValues} />
<InlineEnumSwatches values={enumValues} palette={enumPalette} />
) : (
<div className="flex items-center gap-1.5 flex-1 min-w-[40%] text-warm-500 dark:text-warm-400">
{rangeMin}
@ -144,7 +159,7 @@ export default function MapLegend({
)}
</div>
{isEnum ? (
<EnumSwatches values={enumValues} />
<EnumSwatches values={enumValues} palette={enumPalette} />
) : (
<>
<div className="h-3 rounded" style={{ background: gradientStyle }} />