Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit 5973969

Browse files
committed
fix(docz-theme-default): use webfontloader instead of css import
1 parent 4bc3bb5 commit 5973969

File tree

6 files changed

+16
-8
lines changed

6 files changed

+16
-8
lines changed

packages/docz-theme-default/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
"react-feather": "^1.1.0",
3333
"react-lightweight-tooltip": "^1.0.0",
3434
"react-powerplug": "^0.1.6",
35-
"react-spinners": "^0.3.2"
35+
"react-spinners": "^0.3.2",
36+
"webfontloader": "^1.6.28"
3637
},
3738
"peerDependencies": {
3839
"react": "^16.3.0",

packages/docz-theme-default/src/components/shared/Main/index.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import * as React from 'react'
22
import { Component } from 'react'
33
import styled from 'react-emotion'
44
import equals from 'fast-deep-equal'
5-
65
import { base } from '../../../styles/base'
6+
import webfont from 'webfontloader'
77

88
const Wrapper = styled('div')`
99
display: flex;
@@ -14,6 +14,13 @@ interface MainProps {
1414
config: any
1515
}
1616

17+
const loadfonts = () =>
18+
webfont.load({
19+
google: {
20+
families: ['Inconsolata', 'Source Sans Pro:300,400,600,700'],
21+
},
22+
})
23+
1724
export class Main extends Component<MainProps> {
1825
public componentDidUpdate(prevProps: MainProps): void {
1926
const { config } = this.props
@@ -25,6 +32,7 @@ export class Main extends Component<MainProps> {
2532

2633
public componentDidMount(): void {
2734
base(this.props.config)
35+
loadfonts()
2836
}
2937

3038
public render(): React.ReactNode {

packages/docz-theme-default/src/styles/base.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ const selection = (color: string) => css`
99
export const base = (config: any) => {
1010
injectGlobal`
1111
@import url('https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css');
12-
1312
${css(config.prismTheme)};
14-
${css(config.styles.inject)};
1513
1614
*, *:before, *:after {
1715
box-sizing: border-box;

packages/docz-theme-default/src/styles/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import * as colors from './colors'
22

33
export const styles = {
4-
inject: `
5-
@import url('https://fonts.googleapis.com/css?family=Inconsolata');
6-
@import url('https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700');
7-
`,
84
body: {
95
fontFamily: "'Source Sans Pro', Helvetica, sans-serif",
106
fontSize: '16px',

packages/docz-theme-default/src/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ declare module 'react-powerplug'
33
declare module 'react-lightweight-tooltip'
44
declare module 'react-feather/dist/icons/chevron-down'
55
declare module 'react-spinners'
6+
declare module 'webfontloader'
67

78
declare module '*.svg' {
89
const content: any

yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11635,6 +11635,10 @@ wcwidth@^1.0.0:
1163511635
dependencies:
1163611636
defaults "^1.0.3"
1163711637

11638+
webfontloader@^1.6.28:
11639+
version "1.6.28"
11640+
resolved "https://registry.npmjs.org/webfontloader/-/webfontloader-1.6.28.tgz#db786129253cb6e8eae54c2fb05f870af6675bae"
11641+
1163811642
webpack-chain@^4.8.0:
1163911643
version "4.8.0"
1164011644
resolved "https://registry.npmjs.org/webpack-chain/-/webpack-chain-4.8.0.tgz#06fc3dbb9f2707d4c9e899fc6250fbcf2afe6fd1"

0 commit comments

Comments
 (0)