mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-01 20:23:36 +00:00
refactor: reduce code duplication in font settings and sync logic
Address CodeRabbit review feedback: - Create getEffectiveFont helper to deduplicate getEffectiveFontSans/Mono - Extract getSettingsFieldValue and hasSettingsFieldChanged helpers - Create reusable FontSelector component for font selection UI - Refactor project-theme-section and appearance-section to use FontSelector
This commit is contained in:
47
apps/ui/src/components/shared/font-selector.tsx
Normal file
47
apps/ui/src/components/shared/font-selector.tsx
Normal file
@@ -0,0 +1,47 @@
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/components/ui/select';
|
||||
import { DEFAULT_FONT_VALUE } from '@/config/ui-font-options';
|
||||
|
||||
interface FontOption {
|
||||
value: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
interface FontSelectorProps {
|
||||
id: string;
|
||||
value: string;
|
||||
options: readonly FontOption[];
|
||||
placeholder: string;
|
||||
onChange: (value: string) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reusable font selector component with live preview styling
|
||||
*/
|
||||
export function FontSelector({ id, value, options, placeholder, onChange }: FontSelectorProps) {
|
||||
return (
|
||||
<Select value={value} onValueChange={onChange}>
|
||||
<SelectTrigger id={id} className="w-full">
|
||||
<SelectValue placeholder={placeholder} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{options.map((option) => (
|
||||
<SelectItem key={option.value} value={option.value}>
|
||||
<span
|
||||
style={{
|
||||
fontFamily: option.value === DEFAULT_FONT_VALUE ? undefined : option.value,
|
||||
}}
|
||||
>
|
||||
{option.label}
|
||||
</span>
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
);
|
||||
}
|
||||
@@ -5,3 +5,6 @@ export {
|
||||
type UseModelOverrideOptions,
|
||||
type UseModelOverrideResult,
|
||||
} from './use-model-override';
|
||||
|
||||
// Font Components
|
||||
export { FontSelector } from './font-selector';
|
||||
|
||||
Reference in New Issue
Block a user