Skip to content

Commit ddbf70d

Browse files
committed
Use our segmented control instead
1 parent 1e21fdd commit ddbf70d

1 file changed

Lines changed: 24 additions & 42 deletions

File tree

apps/webapp/app/components/code/ChartConfigPanel.tsx

Lines changed: 24 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { OutputColumnMetadata } from "@internal/clickhouse";
2+
import { IconSortAscending, IconSortDescending } from "@tabler/icons-react";
23
import { BarChart, CheckIcon, LineChart, Plus, XIcon } from "lucide-react";
34
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
45
import { cn } from "~/utils/cn";
@@ -514,9 +515,29 @@ export function ChartConfigPanel({ columns, config, onChange, className }: Chart
514515
{/* Sort Direction (only when sorting) */}
515516
{config.sortByColumn && (
516517
<ConfigField label="Sort direction">
517-
<SortDirectionToggle
518-
direction={config.sortDirection}
519-
onChange={(direction) => updateConfig({ sortDirection: direction })}
518+
<SegmentedControl
519+
name="sortDirection"
520+
value={config.sortDirection}
521+
variant="secondary/small"
522+
options={[
523+
{
524+
label: (
525+
<span className="flex items-center gap-1">
526+
<IconSortAscending className="size-3" /> Asc
527+
</span>
528+
),
529+
value: "asc",
530+
},
531+
{
532+
label: (
533+
<span className="flex items-center gap-1">
534+
<IconSortDescending className="size-3" /> Desc
535+
</span>
536+
),
537+
value: "desc",
538+
},
539+
]}
540+
onChange={(value) => updateConfig({ sortDirection: value as SortDirection })}
520541
/>
521542
</ConfigField>
522543
)}
@@ -534,45 +555,6 @@ function ConfigField({ label, children }: { label: string; children: React.React
534555
);
535556
}
536557

537-
function SortDirectionToggle({
538-
direction,
539-
onChange,
540-
}: {
541-
direction: SortDirection;
542-
onChange: (direction: SortDirection) => void;
543-
}) {
544-
return (
545-
<div className="flex gap-1">
546-
<button
547-
type="button"
548-
onClick={() => onChange("asc")}
549-
className={cn(
550-
"rounded px-2 py-1 text-xs transition-colors",
551-
direction === "asc"
552-
? "bg-charcoal-700 text-text-bright"
553-
: "text-text-dimmed hover:bg-charcoal-800 hover:text-text-bright"
554-
)}
555-
title="Ascending"
556-
>
557-
Asc
558-
</button>
559-
<button
560-
type="button"
561-
onClick={() => onChange("desc")}
562-
className={cn(
563-
"rounded px-2 py-1 text-xs transition-colors",
564-
direction === "desc"
565-
? "bg-charcoal-700 text-text-bright"
566-
: "text-text-dimmed hover:bg-charcoal-800 hover:text-text-bright"
567-
)}
568-
title="Descending"
569-
>
570-
Desc
571-
</button>
572-
</div>
573-
);
574-
}
575-
576558
function SeriesColorPicker({
577559
color,
578560
onColorChange,

0 commit comments

Comments
 (0)