Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge some PRs and add better Typescript support #69

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: 'dherault',
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/node_modules
yarn-error.log
.DS_Store
/dist
/build
5 changes: 0 additions & 5 deletions .npmignore

This file was deleted.

11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.validate": ["javascript", "typescript"],
"eslint.workingDirectories": [
{
"mode": "auto"
}
]
}
73 changes: 39 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,53 @@
# 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)
# GoogleFontLoader [![npm](https://img.shields.io/npm/v/react-google-font.svg?style=for-the-badge)](https://www.npmjs.com/package/react-google-font)

Maintained fork of [react-google-font-loader](https://github.com/jakewtaylor/react-google-font-loader).

This is a _really_ simple component that can automatically handle loading Google fonts for you.

You simply pass it a config array and it will load the fonts for you by appending a `<link />` tag to the document head. It will update itself if the config changes, and will remove itself on unmount.

## Installation

Install with either yarn or npm:

```
yarn add react-google-font-loader
npm install --save react-google-font-loader
npm install --save react-google-font
```

## Usage

```JavaScript
// Import the Component, you can call it whatever you like.
import GoogleFontLoader from 'react-google-font-loader';

const App = () => (
<>
{/* Use it! */}
<GoogleFontLoader
fonts={[
{
font: 'Roboto',
weights: [400, '400i'],
},
{
font: 'Roboto Mono',
weights: [400, 700],
},
]}
subsets={['cyrillic-ext', 'greek']}
/>

<p style={{ fontFamily: 'Roboto Mono, monospaced' }}>This will be in Roboto Mono!</p>
<p style={{ fontFamily: 'Roboto, sans-serif' }}>This will be in Roboto!</p>
</>
);
```jsx
import GoogleFontLoader from 'react-google-font'

function App() {
return (
<>
<GoogleFontLoader
fonts={[
{
font: 'Roboto',
weights: [400, '400i'],
},
{
font: 'Roboto Mono',
weights: [400, 700],
},
]}
subsets={['cyrillic-ext', 'greek']}
/>
<p style={{ fontFamily: 'Roboto Mono, monospaced' }}>This will be in Roboto Mono!</p>
<p style={{ fontFamily: 'Roboto, sans-serif' }}>This will be in Roboto!</p>
</>
)
}
```

## Props

The Component takes two props: `fonts` and `subsets`.
The Component takes three props: `fonts`, `subsets` and `text`.

#### `fonts`
`fonts` should be an array of objects describing the fonts you want to load:

```JavaScript
```js
[
{
font: 'Roboto Mono', // The name of the font on Google Fonts.
Expand All @@ -61,8 +59,15 @@ The Component takes two props: `fonts` and `subsets`.
```

#### `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.
`subsets` should be an array of subsets you want to load. **This prop is optional and shouldn't be used with `text`** - 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
#### `text`
`text` should be a string containing the characters you wan't the loaded font files to contain. **This prop is optional and shouldn't be used with `subsets`** - if you do not specify a `text` prop then the 'text' query param will be omitted from the URL.

```js
['cyrillic-ext', 'greek']
```

## License

MIT
18 changes: 0 additions & 18 deletions build/index.d.ts

This file was deleted.

77 changes: 0 additions & 77 deletions build/index.js

This file was deleted.

Loading