Skip to content

Commit

Permalink
feat: add support for custom global generic font family as a theme op…
Browse files Browse the repository at this point in the history
…tion closes #67
  • Loading branch information
jeangovil committed Jun 20, 2023
1 parent 07359f6 commit 1523be9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 20 additions & 1 deletion packages/logos-docusaurus-theme/src/client/lib/themes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useActivePlugin } from '@docusaurus/plugin-content-docs/lib/client/inde
import { useColorMode } from '@docusaurus/theme-common'
import { css } from '@emotion/react'
import { useMemo } from 'react'
import { useThemeOptions } from './useThemeOptions'

const typography: CreateThemeProps['typography'] = {
h1: {
Expand Down Expand Up @@ -99,8 +100,26 @@ const useThemeCssVars = (theme: Theme, colorMode: string) =>
export const useTheme = () => {
const colorMode = useColorMode()
const activePlugin = useActivePlugin()
const { typography } = useThemeOptions()
const genericFontFamily = typography?.genericFontFamily ?? 'sans-serif'

const themes = activePlugin ? docThemes : defaultThemes
const baseThemes = activePlugin ? docThemes : defaultThemes

const themes = useMemo(() => {
const options = {
breakpoints: {},
palette: {},
typography: {},
typographyGlobal: {
genericFontFamily,
},
}

return {
light: createTheme(options, baseThemes.light),
dark: createTheme(options, baseThemes.dark),
}
}, [baseThemes, genericFontFamily])

return {
dark: themes.dark,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { GlobalTypographyStyles } from '@acid-info/lsd-react'
import type { PluginOptions as DefaultPluginOptions } from '@docusaurus/theme-classic'

export type Author = {
Expand Down Expand Up @@ -28,4 +29,5 @@ export type DocConfig = {

export type ThemeOptions = DefaultPluginOptions & {
docs?: Record<string, DocConfig>
typography?: GlobalTypographyStyles
}

0 comments on commit 1523be9

Please sign in to comment.