diff --git a/.gitignore b/.gitignore index 2350960..26d670b 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ lerna-debug.log* public*/ bun.lock *.local.jsonc +docs/ diff --git a/frontend/src/components/ui/button-group.tsx b/frontend/src/components/ui/button-group.tsx new file mode 100644 index 0000000..a6e54f8 --- /dev/null +++ b/frontend/src/components/ui/button-group.tsx @@ -0,0 +1,63 @@ +import * as React from "react"; + +import { Button, type ButtonProps } from "@/components/ui/button"; +import { cn } from "@/lib/utils"; + +type ButtonGroupValue = string | number; + +export interface ButtonGroupOption { + label: React.ReactNode; + value: T; + disabled?: boolean; +} + +export interface ButtonGroupProps + extends Omit, "onChange"> { + value: T; + options: readonly ButtonGroupOption[]; + onValueChange: (value: T) => void; + size?: ButtonProps["size"]; + activeVariant?: ButtonProps["variant"]; + inactiveVariant?: ButtonProps["variant"]; + buttonClassName?: string; +} + +export function ButtonGroup({ + value, + options, + onValueChange, + size = "sm", + activeVariant = "default", + inactiveVariant = "outline", + className, + buttonClassName, + ...props +}: ButtonGroupProps) { + return ( +
+ {options.map((option) => { + const isActive = Object.is(option.value, value); + + return ( + + ); + })} +
+ ); +} diff --git a/frontend/src/pages/SystemSettings.tsx b/frontend/src/pages/SystemSettings.tsx index 4335c1f..e7a95ab 100644 --- a/frontend/src/pages/SystemSettings.tsx +++ b/frontend/src/pages/SystemSettings.tsx @@ -4,6 +4,7 @@ import { Bot, Check, FileText, Globe, Shield, SlidersHorizontal } from "lucide-r import { apiClient } from "@/api/client"; import { Button } from "@/components/ui/button"; +import { ButtonGroup } from "@/components/ui/button-group"; import { Card } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Switch } from "@/components/ui/switch"; @@ -366,27 +367,17 @@ export function SystemSettings() {
-
- {PRECISION_OPTIONS.map((option) => { - const isActive = normalizedSystemConfig.displayDecimals === option.value; - return ( - - ); - })} -
+ + setSystemConfig((current) => ({ + ...current, + displayDecimals: value, + })) + } + />