Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169const DETECTED_FONT_VALUE_PREFIX = "detected:" as const;type DetectedFontFamilyValue = `${typeof DETECTED_FONT_VALUE_PREFIX}${string}`;
export type FontFamilyValue = | "geist-sans" | "jetbrains-mono" | "menlo" | "inter" | "manrope" | "sora" | "ui-sans" | "system-ui" | "geist-pixel" | "fira-code" | "cascadia-code" | "source-code-pro" | "ibm-plex-mono" | "geist-mono" | "ui-monospace" | "system-sans" | DetectedFontFamilyValue;
export type FontOption = { value: FontFamilyValue; label: string; cssFamily: string;};
export const FONT_FAMILY_OPTIONS: ReadonlyArray<FontOption> = [ { value: "geist-sans", label: "Geist Sans", cssFamily: '"Geist Sans", Inter, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif', }, { value: "jetbrains-mono", label: "JetBrains Mono", cssFamily: '"JetBrains Mono", "Fira Code", "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace', }, { value: "menlo", label: "Menlo", cssFamily: 'Menlo, "Geist Mono", ui-monospace, "SF Mono", Monaco, Consolas, "Liberation Mono", "Courier New", monospace', }, { value: "inter", label: "Inter", cssFamily: 'Inter, "Geist Sans", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif', }, { value: "manrope", label: "Manrope", cssFamily: 'Manrope, Inter, "Geist Sans", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif', }, { value: "sora", label: "Sora", cssFamily: 'Sora, Inter, "Geist Sans", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif', }, { value: "ui-sans", label: "UI Sans", cssFamily: 'ui-sans-serif, "Geist Sans", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif', }, { value: "system-ui", label: "System UI", cssFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif', }, { value: "geist-pixel", label: "Geist Pixel", cssFamily: '"Geist Pixel", "Geist Mono", "JetBrains Mono", "Fira Code", "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace', }, { value: "fira-code", label: "Fira Code", cssFamily: '"Fira Code", "JetBrains Mono", "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace', }, { value: "cascadia-code", label: "Cascadia Code", cssFamily: '"Cascadia Code", "JetBrains Mono", "Fira Code", "SF Mono", Monaco, "Roboto Mono", Consolas, "Courier New", monospace', }, { value: "source-code-pro", label: "Source Code Pro", cssFamily: '"Source Code Pro", "JetBrains Mono", "Fira Code", "SF Mono", Monaco, "Roboto Mono", Consolas, "Courier New", monospace', }, { value: "ibm-plex-mono", label: "IBM Plex Mono", cssFamily: '"IBM Plex Mono", "JetBrains Mono", "Fira Code", "SF Mono", Monaco, "Roboto Mono", Consolas, "Courier New", monospace', }, { value: "geist-mono", label: "Geist Mono", cssFamily: '"Geist Mono", "JetBrains Mono", "Fira Code", "SF Mono", Monaco, "Roboto Mono", Consolas, "Courier New", monospace', }, { value: "ui-monospace", label: "UI Monospace", cssFamily: 'ui-monospace, "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace', }, { value: "system-sans", label: "System Sans", cssFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif', },];
export const SANS_FONT_FAMILY_OPTIONS: ReadonlyArray<{ value: FontFamilyValue; label: string;}> = [ { value: "geist-sans", label: "Geist Sans" }, { value: "inter", label: "Inter" }, { value: "manrope", label: "Manrope" }, { value: "sora", label: "Sora" }, { value: "ui-sans", label: "UI Sans" }, { value: "system-ui", label: "System UI" }, { value: "system-sans", label: "System Sans" },];
export const MONO_FONT_FAMILY_OPTIONS: ReadonlyArray<{ value: FontFamilyValue; label: string;}> = [ { value: "menlo", label: "Menlo" }, { value: "jetbrains-mono", label: "JetBrains Mono" }, { value: "fira-code", label: "Fira Code" }, { value: "cascadia-code", label: "Cascadia Code" }, { value: "source-code-pro", label: "Source Code Pro" }, { value: "ibm-plex-mono", label: "IBM Plex Mono" }, { value: "geist-mono", label: "Geist Mono" }, { value: "ui-monospace", label: "UI Monospace" }, { value: "geist-pixel", label: "Geist Pixel" },];
export const DEFAULT_FONT_FAMILY: FontFamilyValue = "menlo";
export function makeDetectedFontFamilyValue(name: string): FontFamilyValue { return `${DETECTED_FONT_VALUE_PREFIX}${name}` as FontFamilyValue;}
export function isDetectedFontFamilyValue(value: FontFamilyValue): value is DetectedFontFamilyValue { return value.startsWith(DETECTED_FONT_VALUE_PREFIX);}
export function getDetectedFontName(value: FontFamilyValue): string | null { if (!isDetectedFontFamilyValue(value)) return null; return value.slice(DETECTED_FONT_VALUE_PREFIX.length);}
function quoteFontName(name: string) { return `"${name.replace(/"/g, '\\"')}"`;}
export function fontFamilyToCss(value: FontFamilyValue): string { const option = FONT_FAMILY_OPTIONS.find((item) => item.value === value); if (option) return option.cssFamily; const detectedName = getDetectedFontName(value); if (detectedName) { return `${quoteFontName(detectedName)}, monospace`; } return FONT_FAMILY_OPTIONS[0].cssFamily;}