mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-30 06:12:03 +00:00
fix: address code review feedback
- Fix git+ssh URL to git+https for @electron/node-gyp (build compatibility) - Remove duplicate @fontsource packages from root package.json - Refactor font state initialization to reduce code duplication
This commit is contained in:
@@ -43,40 +43,28 @@ export function ProjectThemeSection({ project }: ProjectThemeSectionProps) {
|
||||
const [activeTab, setActiveTab] = useState<'dark' | 'light'>(isLightTheme ? 'light' : 'dark');
|
||||
|
||||
// Helper to validate fonts against available options
|
||||
const isValidSansFont = (font: string | undefined): boolean => {
|
||||
if (!font) return false;
|
||||
return UI_SANS_FONT_OPTIONS.some((opt) => opt.value === font);
|
||||
};
|
||||
const isValidMonoFont = (font: string | undefined): boolean => {
|
||||
if (!font) return false;
|
||||
return UI_MONO_FONT_OPTIONS.some((opt) => opt.value === font);
|
||||
};
|
||||
const isValidSansFont = (font?: string): boolean =>
|
||||
!!font && UI_SANS_FONT_OPTIONS.some((opt) => opt.value === font);
|
||||
const isValidMonoFont = (font?: string): boolean =>
|
||||
!!font && UI_MONO_FONT_OPTIONS.some((opt) => opt.value === font);
|
||||
|
||||
// Helper to get initial font value with validation
|
||||
const getInitialFontValue = (font: string | undefined, validator: (f?: string) => boolean) =>
|
||||
font && validator(font) ? font : DEFAULT_FONT_VALUE;
|
||||
|
||||
// Font local state - tracks what's selected when using custom fonts
|
||||
// Falls back to default if stored font is not in available options
|
||||
const [fontSansLocal, setFontSansLocal] = useState<string>(
|
||||
project.fontFamilySans && isValidSansFont(project.fontFamilySans)
|
||||
? project.fontFamilySans
|
||||
: DEFAULT_FONT_VALUE
|
||||
const [fontSansLocal, setFontSansLocal] = useState<string>(() =>
|
||||
getInitialFontValue(project.fontFamilySans, isValidSansFont)
|
||||
);
|
||||
const [fontMonoLocal, setFontMonoLocal] = useState<string>(
|
||||
project.fontFamilyMono && isValidMonoFont(project.fontFamilyMono)
|
||||
? project.fontFamilyMono
|
||||
: DEFAULT_FONT_VALUE
|
||||
const [fontMonoLocal, setFontMonoLocal] = useState<string>(() =>
|
||||
getInitialFontValue(project.fontFamilyMono, isValidMonoFont)
|
||||
);
|
||||
|
||||
// Sync state when project changes
|
||||
useEffect(() => {
|
||||
setFontSansLocal(
|
||||
project.fontFamilySans && isValidSansFont(project.fontFamilySans)
|
||||
? project.fontFamilySans
|
||||
: DEFAULT_FONT_VALUE
|
||||
);
|
||||
setFontMonoLocal(
|
||||
project.fontFamilyMono && isValidMonoFont(project.fontFamilyMono)
|
||||
? project.fontFamilyMono
|
||||
: DEFAULT_FONT_VALUE
|
||||
);
|
||||
setFontSansLocal(getInitialFontValue(project.fontFamilySans, isValidSansFont));
|
||||
setFontMonoLocal(getInitialFontValue(project.fontFamilyMono, isValidMonoFont));
|
||||
// Also sync the active tab based on current theme
|
||||
const currentIsLight = lightThemes.some((t) => t.value === (project.theme || globalTheme));
|
||||
setActiveTab(currentIsLight ? 'light' : 'dark');
|
||||
|
||||
18
package-lock.json
generated
18
package-lock.json
generated
@@ -13,13 +13,6 @@
|
||||
"libs/*"
|
||||
],
|
||||
"dependencies": {
|
||||
"@fontsource/cascadia-code": "^5.2.3",
|
||||
"@fontsource/iosevka": "^5.2.5",
|
||||
"@fontsource/lato": "^5.2.7",
|
||||
"@fontsource/montserrat": "^5.2.8",
|
||||
"@fontsource/playfair-display": "^5.2.8",
|
||||
"@fontsource/raleway": "^5.2.8",
|
||||
"@fontsource/source-sans-3": "^5.2.9",
|
||||
"cross-spawn": "7.0.6",
|
||||
"rehype-sanitize": "6.0.0",
|
||||
"tree-kill": "1.2.2"
|
||||
@@ -1503,7 +1496,7 @@
|
||||
},
|
||||
"node_modules/@electron/node-gyp": {
|
||||
"version": "10.2.0-electron.1",
|
||||
"resolved": "git+ssh://git@github.com/electron/node-gyp.git#06b29aafb7708acef8b3669835c8a7857ebc92d2",
|
||||
"resolved": "git+https://github.com/electron/node-gyp.git#06b29aafb7708acef8b3669835c8a7857ebc92d2",
|
||||
"integrity": "sha512-4MSBTT8y07YUDqf69/vSh80Hh791epYqGtWHO3zSKhYFwQg+gx9wi1PqbqP6YqC4WMsNxZ5l9oDmnWdK5pfCKQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
@@ -2927,15 +2920,6 @@
|
||||
"url": "https://github.com/sponsors/ayuhito"
|
||||
}
|
||||
},
|
||||
"node_modules/@fontsource/playfair-display": {
|
||||
"version": "5.2.8",
|
||||
"resolved": "https://registry.npmjs.org/@fontsource/playfair-display/-/playfair-display-5.2.8.tgz",
|
||||
"integrity": "sha512-fUEhib70SszNhQVsGbUMSsWJhr7Je0rdeuZdtGpDNu0GKF1xJM8QhpI/y0pckU25GcChXm9TLOmeZupkvvZo2g==",
|
||||
"license": "OFL-1.1",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ayuhito"
|
||||
}
|
||||
},
|
||||
"node_modules/@fontsource/poppins": {
|
||||
"version": "5.2.7",
|
||||
"resolved": "https://registry.npmjs.org/@fontsource/poppins/-/poppins-5.2.7.tgz",
|
||||
|
||||
@@ -62,13 +62,6 @@
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@fontsource/cascadia-code": "^5.2.3",
|
||||
"@fontsource/iosevka": "^5.2.5",
|
||||
"@fontsource/lato": "^5.2.7",
|
||||
"@fontsource/montserrat": "^5.2.8",
|
||||
"@fontsource/playfair-display": "^5.2.8",
|
||||
"@fontsource/raleway": "^5.2.8",
|
||||
"@fontsource/source-sans-3": "^5.2.9",
|
||||
"cross-spawn": "7.0.6",
|
||||
"rehype-sanitize": "6.0.0",
|
||||
"tree-kill": "1.2.2"
|
||||
|
||||
Reference in New Issue
Block a user