react-google-font-loader
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -5,3 +5,3 @@ import * as React from 'react'; | ||
font: string; | ||
weights?: number[]; | ||
weights?: (string|number)[]; | ||
} | ||
@@ -11,2 +11,3 @@ | ||
fonts: Font[]; | ||
subsets?: string[]; | ||
} | ||
@@ -13,0 +14,0 @@ |
@@ -40,3 +40,5 @@ 'use strict'; | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = GoogleFontLoader.__proto__ || Object.getPrototypeOf(GoogleFontLoader)).call.apply(_ref, [this].concat(args))), _this), _this.link = null, _this.createLink = function () { | ||
var fonts = _this.props.fonts; | ||
var _this$props = _this.props, | ||
fonts = _this$props.fonts, | ||
subsets = _this$props.subsets; | ||
@@ -57,2 +59,6 @@ | ||
if (subsets && Array.isArray(subsets) && subsets.length > 0) { | ||
link.href += '&subset=' + subsets.join(','); | ||
} | ||
return link; | ||
@@ -98,6 +104,7 @@ }, _this.appendLink = function () { | ||
font: _propTypes2.default.string.isRequired, | ||
weights: _propTypes2.default.arrayOf(_propTypes2.default.number) | ||
})).isRequired | ||
weights: _propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number])) | ||
})).isRequired, | ||
subsets: _propTypes2.default.arrayOf(_propTypes2.default.string) | ||
}; | ||
exports.default = GoogleFontLoader; |
{ | ||
"name": "react-google-font-loader", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Simple React component to load Google Fonts.", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -25,12 +25,15 @@ # GoogleFontLoader [![npm](https://img.shields.io/npm/v/react-google-font-loader.svg?style=for-the-badge)](https://www.npmjs.com/package/react-google-font-loader) | ||
{/* Use it! */} | ||
<GoogleFontLoader fonts={[ | ||
{ | ||
font: 'Roboto', | ||
weights: [400], | ||
}, | ||
{ | ||
font: 'Roboto Mono', | ||
weights: [400, 700], | ||
}, | ||
]} /> | ||
<GoogleFontLoader | ||
fonts={[ | ||
{ | ||
font: 'Roboto', | ||
weights: [400, '400i'], | ||
}, | ||
{ | ||
font: 'Roboto Mono', | ||
weights: [400, 700], | ||
}, | ||
]} | ||
subsets={['cyrillic-ext', 'greek']} | ||
/> | ||
@@ -45,4 +48,7 @@ <p style={{ fontFamily: 'Roboto Mono, monospaced' }}>This will be in Roboto Mono!</p> | ||
The Component takes one prop: `fonts`. It should be an array of objects describing the fonts you want to load. | ||
The Component takes two props: `fonts` and `subsets`. | ||
#### `fonts` | ||
`fonts` should be an array of objects describing the fonts you want to load: | ||
```JavaScript | ||
@@ -52,3 +58,3 @@ [ | ||
font: 'Roboto Mono', // The name of the font on Google Fonts. | ||
weights: [400, 700], // An array of weights you want to load. | ||
weights: [400, 700], // An array of weights you want to load, can be strings or numbers. | ||
}, | ||
@@ -59,1 +65,8 @@ // ... | ||
``` | ||
#### `subsets` | ||
`subsets` should be an array of subsets you want to load. **This prop is optional** - if you do not specify a `subsets` prop then the 'subset' query param will be omitted from the URL and only latin will be loaded. | ||
```JavaScript | ||
['cyrillic-ext', 'greek'] | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
248475
5
6731
69
1