diff --git a/apps/dashboard/app/(main)/settings/appearance/_components/chart-type-option.tsx b/apps/dashboard/app/(main)/settings/appearance/_components/chart-type-option.tsx new file mode 100644 index 000000000..4e08a0c32 --- /dev/null +++ b/apps/dashboard/app/(main)/settings/appearance/_components/chart-type-option.tsx @@ -0,0 +1,15 @@ +import type { ChartBarIcon } from "@databuddy/ui/icons"; + +interface ChartTypeOptionProps { + icon: typeof ChartBarIcon; + label: string; +} + +export function ChartTypeOption({ icon: Icon, label }: ChartTypeOptionProps) { + return ( + + + {label} + + ); +} diff --git a/apps/dashboard/app/(main)/settings/appearance/page.tsx b/apps/dashboard/app/(main)/settings/appearance/page.tsx index c7899c4fd..8c3d1eed1 100644 --- a/apps/dashboard/app/(main)/settings/appearance/page.tsx +++ b/apps/dashboard/app/(main)/settings/appearance/page.tsx @@ -34,6 +34,7 @@ import { } from "@databuddy/ui/icons"; import { Select } from "@databuddy/ui/client"; import { Card, Text, Tooltip } from "@databuddy/ui"; +import { ChartTypeOption } from "./_components/chart-type-option"; const MOCK_CHART_DATA = [ { date: "2024-01-01", value: 186 }, @@ -68,6 +69,16 @@ const STEP_TYPE_OPTIONS: { id: ChartCurveType; name: string }[] = [ { id: "stepAfter", name: "Step After" }, ]; +const CHART_TYPE_ITEMS = CHART_TYPE_OPTIONS.map(({ id, name }) => ({ + label: name, + value: id, +})); + +const STEP_TYPE_ITEMS = STEP_TYPE_OPTIONS.map(({ id, name }) => ({ + label: name, + value: id, +})); + const DEFAULT_DATE_RANGE_OPTIONS: DefaultDateRangePreset[] = [ "24h", "7d", @@ -85,6 +96,11 @@ const LOCATION_ICONS: Record = { events: CursorClickIcon, }; +const CHART_LOCATION_ITEMS = CHART_LOCATIONS.map((value) => ({ + label: CHART_LOCATION_LABELS[value], + value, +})); + export default function AppearanceSettingsPage() { const { theme, setTheme } = useTheme(); const { defaultDateRange, setDefaultDateRange } = useDefaultDateRange(); @@ -191,6 +207,7 @@ export default function AppearanceSettingsPage() { {showGranular && ( setPreviewLocation(v as ChartLocation) } @@ -239,6 +256,7 @@ export default function AppearanceSettingsPage() { All Charts updateAllPreferences({ chartType: v as ChartSeriesKind, @@ -250,14 +268,14 @@ export default function AppearanceSettingsPage() { {CHART_TYPE_OPTIONS.map(({ id, name, icon: OptIcon }) => ( - - {name} + ))} updateAllPreferences({ chartStepType: v as ChartCurveType, @@ -355,6 +373,7 @@ export default function AppearanceSettingsPage() { updateLocationPreferences(location, { chartType: v as ChartSeriesKind, @@ -367,11 +386,10 @@ export default function AppearanceSettingsPage() { {CHART_TYPE_OPTIONS.map( ({ id, name, icon: OptIcon }) => ( - - {name} ) )} @@ -379,6 +397,7 @@ export default function AppearanceSettingsPage() { updateLocationPreferences(location, { chartStepType: v as ChartCurveType, diff --git a/packages/ui/src/components/select.tsx b/packages/ui/src/components/select.tsx index fa6596127..43fe94063 100644 --- a/packages/ui/src/components/select.tsx +++ b/packages/ui/src/components/select.tsx @@ -57,7 +57,9 @@ function Root(props: ComponentPropsWithoutRef) { ); return ( - + );