Docz: Make loaded fonts in docz-theme-default configurable

Created on 14 Jan 2019  Â·  2Comments  Â·  Source: doczjs/docz

At the moment, docz-theme-default preloads a hard-coded collection of fonts:

https://github.com/pedronauck/docz/blob/a17e9142cfc995257c621fcf4a68504ad2e977c7/packages/docz-theme-default/src/index.tsx#L49-L58

Not all of them are always necessary, especially when the theme is configured to use some alternative font, e.g. like this:

  themeConfig: {
    styles: {
      body: {
        fontFamily: '"My Cool Font", sans-serif',
      },
      h1: {
        fontFamily: '"My Other Cool Font", serif',
        fontWeight: "normal",
        fontSize: 48,
      },
    },
  },

It'd be great if the argument of webfont.load() was a part of the theme config so that the developers could load alternative fonts. When all selected fonts are built-in, the argument can be set to an empty object to avoid unnecessary network requests:

  themeConfig: {
    styles: {
      body: { fontFamily: 'Helvetica, sans-serif' },
      h1: { fontFamily: 'Helvetica, sans-serif' },
      h2: { fontFamily: 'Helvetica, sans-serif' },
      code: { fontFamily: '"Courier New", sans-serif' },
      pre: { fontFamily: '"Courier New", sans-serif' },
      table: { fontFamily: '"Courier New", sans-serif' },
    },
    fontsToLoad: {}
  },

No need to fetch stuff from google → docz works offline and in internal-only networks. WDYT?

Most helpful comment

Add codemirror is same issue, I hope can load local codemirror.css file instead of download css file from codemirror.net

All 2 comments

will the new version can give a solution of this issue @pedronauck

Add codemirror is same issue, I hope can load local codemirror.css file instead of download css file from codemirror.net

Was this page helpful?
0 / 5 - 0 ratings