overleaf-cep/services/web/frontend/js/shared/utils/styles.ts
Alf Eaton ce1d63d92c Create a shared module for CSS styles from user settings (#22925)
GitOrigin-RevId: 1e62258e1e38d8ab2ce8debc51c53a98f4e915f6
2025-01-20 09:04:57 +00:00

29 lines
733 B
TypeScript

export type OverallTheme = '' | 'light-'
export const fontFamilies = {
monaco: ['Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'monospace'],
lucida: ['Lucida Console', 'Source Code Pro', 'monospace'],
opendyslexicmono: ['OpenDyslexic Mono', 'monospace'],
}
export type FontFamily = keyof typeof fontFamilies
export const lineHeights = {
compact: 1.33,
normal: 1.6,
wide: 2,
}
export type LineHeight = keyof typeof lineHeights
type Options = {
fontFamily: FontFamily
fontSize: number
lineHeight: LineHeight
}
export const userStyles = ({ fontFamily, fontSize, lineHeight }: Options) => ({
fontFamily: fontFamilies[fontFamily]?.join(','),
fontSize: `${fontSize}px`,
lineHeight: lineHeights[lineHeight],
})