Skip to content

Commit 52896d8

Browse files
committed
fix: add free-text input for custom Google Fonts in Customization Studio
1 parent a4dcf09 commit 52896d8

3 files changed

Lines changed: 1798 additions & 284 deletions

File tree

app/customize/components/ControlsPanel.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,14 +277,35 @@ export function ControlsPanel({
277277

278278
<ControlRow label="Font">
279279
<div className="relative">
280-
<StyledSelect id="font-select" value={font} onChange={(v) => onFontChange(v as Font)}>
280+
<StyledSelect
281+
id="font-select"
282+
value={FONTS.some((f) => f.value === font) ? font : 'custom'}
283+
onChange={(v) => {
284+
if (v === 'custom') {
285+
onFontChange('' as Font);
286+
} else {
287+
onFontChange(v as Font);
288+
}
289+
}}
290+
>
281291
{FONTS.map((fontOption) => (
282292
<option key={fontOption.value} value={fontOption.value}>
283293
{fontOption.label}
284294
</option>
285295
))}
296+
<option value="custom">Custom Google Font...</option>
286297
</StyledSelect>
287298
</div>
299+
{!FONTS.some((f) => f.value === font) && (
300+
<input
301+
id="font-custom-input"
302+
type="text"
303+
value={font}
304+
onChange={(e) => onFontChange(e.target.value as Font)}
305+
placeholder="e.g. Orbitron, Space Mono, Inter"
306+
className="w-full bg-gray-100/80 backdrop-blur-md border border-black/10 dark:bg-white/[0.03] dark:border-white/10 rounded-xl px-4 py-2.5 text-sm font-mono text-black dark:text-emerald-300 placeholder:text-gray-400 dark:placeholder:text-white/60 outline-none focus:border-emerald-500/50 transition-colors mt-2"
307+
/>
308+
)}
288309
</ControlRow>
289310

290311
<ControlRow label="Border Radius">

app/customize/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const FONTS = [
3434
{ value: 'roboto', label: 'Roboto' },
3535
] as const satisfies readonly { value: string; label: string }[];
3636

37-
export type Font = (typeof FONTS)[number]['value'];
37+
export type Font = (typeof FONTS)[number]['value'] | string;
3838

3939
export const VIEW_MODES = [
4040
{ value: 'default', label: 'Default' },

0 commit comments

Comments
 (0)