mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-24 04:26:22 +00:00
b7793bd856
* Add textHighlight theme setting * update docs to include textHighlight * Remove errant `S`
72 lines
2.1 KiB
TypeScript
72 lines
2.1 KiB
TypeScript
export interface ColorScheme {
|
|
light: string
|
|
lightgray: string
|
|
gray: string
|
|
darkgray: string
|
|
dark: string
|
|
secondary: string
|
|
tertiary: string
|
|
highlight: string
|
|
textHighlight: string
|
|
}
|
|
|
|
interface Colors {
|
|
lightMode: ColorScheme
|
|
darkMode: ColorScheme
|
|
}
|
|
|
|
export interface Theme {
|
|
typography: {
|
|
header: string
|
|
body: string
|
|
code: string
|
|
}
|
|
cdnCaching: boolean
|
|
colors: Colors
|
|
fontOrigin: "googleFonts" | "local"
|
|
}
|
|
|
|
export type ThemeKey = keyof Colors
|
|
|
|
const DEFAULT_SANS_SERIF =
|
|
'-apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif'
|
|
const DEFAULT_MONO = "ui-monospace, SFMono-Regular, SF Mono, Menlo, monospace"
|
|
|
|
export function googleFontHref(theme: Theme) {
|
|
const { code, header, body } = theme.typography
|
|
return `https://fonts.googleapis.com/css2?family=${code}&family=${header}:wght@400;700&family=${body}:ital,wght@0,400;0,600;1,400;1,600&display=swap`
|
|
}
|
|
|
|
export function joinStyles(theme: Theme, ...stylesheet: string[]) {
|
|
return `
|
|
${stylesheet.join("\n\n")}
|
|
|
|
:root {
|
|
--light: ${theme.colors.lightMode.light};
|
|
--lightgray: ${theme.colors.lightMode.lightgray};
|
|
--gray: ${theme.colors.lightMode.gray};
|
|
--darkgray: ${theme.colors.lightMode.darkgray};
|
|
--dark: ${theme.colors.lightMode.dark};
|
|
--secondary: ${theme.colors.lightMode.secondary};
|
|
--tertiary: ${theme.colors.lightMode.tertiary};
|
|
--highlight: ${theme.colors.lightMode.highlight};
|
|
--textHighlight: ${theme.colors.lightMode.textHighlight};
|
|
|
|
--headerFont: "${theme.typography.header}", ${DEFAULT_SANS_SERIF};
|
|
--bodyFont: "${theme.typography.body}", ${DEFAULT_SANS_SERIF};
|
|
--codeFont: "${theme.typography.code}", ${DEFAULT_MONO};
|
|
}
|
|
|
|
:root[saved-theme="dark"] {
|
|
--light: ${theme.colors.darkMode.light};
|
|
--lightgray: ${theme.colors.darkMode.lightgray};
|
|
--gray: ${theme.colors.darkMode.gray};
|
|
--darkgray: ${theme.colors.darkMode.darkgray};
|
|
--dark: ${theme.colors.darkMode.dark};
|
|
--secondary: ${theme.colors.darkMode.secondary};
|
|
--tertiary: ${theme.colors.darkMode.tertiary};
|
|
--highlight: ${theme.colors.darkMode.highlight};
|
|
--textHighlight: ${theme.colors.darkMode.textHighlight};
|
|
}
|
|
`
|
|
}
|