Skip to content

Commit fea8fb1

Browse files
committed
Use font-manager package
1 parent 5253ea3 commit fea8fb1

File tree

7 files changed

+46
-59
lines changed

7 files changed

+46
-59
lines changed

package.json

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@
1717
"react",
1818
"react-component"
1919
],
20-
"main": "dist/FontPicker.js",
21-
"module": "dist/FontPicker.es.js",
22-
"types": "dist/FontPicker.d.ts",
20+
"main": "./dist/FontPicker.js",
21+
"module": "./dist/FontPicker.es.js",
22+
"types": "./dist/FontPicker.d.ts",
2323
"files": [
24-
"lib/"
24+
"./dist/"
2525
],
2626
"scripts": {
2727
"start": "npm-run-all build:rollup --parallel start:*",
2828
"start:rollup": "rollup --config --sourcemap --watch",
2929
"start:storybook": "start-storybook --port 3000",
3030
"build": "run-s build:*",
31-
"build:clean": "rm -rf dist/",
31+
"build:clean": "rm -rf ./dist/",
3232
"build:rollup": "rollup --config",
3333
"format": "prettier --write",
3434
"lint:css": "stylelint --fix --max-warnings 0",
@@ -39,16 +39,16 @@
3939
"release": "np"
4040
},
4141
"dependencies": {
42-
"font-picker": "^3.1.0"
42+
"@samuelmeuli/font-manager": "^1.0.0"
4343
},
4444
"peerDependencies": {
4545
"@types/react": "^16.8.10",
4646
"react": "^16.0.0"
4747
},
4848
"devDependencies": {
4949
"@babel/core": "^7.4.0",
50-
"@samuelmeuli/eslint-config": "~2.0.1",
51-
"@samuelmeuli/stylelint-config": "~1.0.0",
50+
"@samuelmeuli/eslint-config": "^2.1.0",
51+
"@samuelmeuli/stylelint-config": "^1.0.2",
5252
"@storybook/react": "^5.0.5",
5353
"@types/react": "^16.8.10",
5454
"@typescript-eslint/eslint-plugin": "^1.5.0",
@@ -69,7 +69,7 @@
6969
"react-dom": "^16.8.6",
7070
"rollup": "^1.7.4",
7171
"rollup-plugin-typescript2": "^0.21.0",
72-
"stylelint": "^10.0.1",
72+
"stylelint": "^10.1.0",
7373
"typescript": "^3.3.4000"
7474
},
7575
"eslintConfig": {
@@ -88,13 +88,12 @@
8888
"error",
8989
{
9090
"devDependencies": [
91-
".storybook/**/*.js",
92-
"rollup.config.js",
93-
"stories/**/*.jsx"
91+
"./.storybook/**/*.js",
92+
"./rollup.config.js",
93+
"./stories/**/*.jsx"
9494
]
9595
}
9696
],
97-
"import/no-unresolved": "off",
9897
"react/jsx-sort-default-props": "off"
9998
}
10099
},

rollup.config.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ import typescript from "rollup-plugin-typescript2";
22

33
import pkg from "./package.json";
44

5-
const TS_CACHE_DIR = "node_modules/.cache/rollup-plugin-typescript2";
6-
75
export default {
8-
input: "src/FontPicker.tsx",
6+
input: "./src/FontPicker.tsx",
97
output: [
108
{
119
file: pkg.main,
@@ -16,10 +14,10 @@ export default {
1614
format: "es",
1715
},
1816
],
19-
external: ["font-picker", "react"],
17+
external: ["font-manager", "react"],
2018
plugins: [
2119
typescript({
22-
cacheRoot: TS_CACHE_DIR,
20+
cacheRoot: "./node_modules/.cache/rollup-plugin-typescript2/",
2321
}),
2422
],
2523
};

src/FontPicker.tsx

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import FontManager from "font-picker/dist/font-manager/font-manager/FontManager";
21
import {
32
Category,
43
Font,
4+
FontManager,
55
Options,
66
Script,
77
SortOption,
88
Variant,
9-
} from "font-picker/dist/font-manager/shared/types";
10-
import "font-picker/dist/styles.min.css";
9+
} from "@samuelmeuli/font-manager";
1110
import React, { PureComponent } from "react";
1211

1312
type LoadingStatus = "loading" | "finished" | "error";
@@ -89,23 +88,19 @@ export default class FontPicker extends PureComponent<Props, State> {
8988
this.fontManager = new FontManager(apiKey, activeFontFamily, options, onChange);
9089
this.fontManager
9190
.init()
92-
.then(
93-
(): void => {
94-
this.setState({
95-
loadingStatus: "finished",
96-
});
97-
},
98-
)
99-
.catch(
100-
(err: Error): void => {
101-
// On error: Log error message
102-
this.setState({
103-
loadingStatus: "error",
104-
});
105-
console.error("Error trying to fetch the list of available fonts");
106-
console.error(err);
107-
},
108-
);
91+
.then((): void => {
92+
this.setState({
93+
loadingStatus: "finished",
94+
});
95+
})
96+
.catch((err: Error): void => {
97+
// On error: Log error message
98+
this.setState({
99+
loadingStatus: "error",
100+
});
101+
console.error("Error trying to fetch the list of available fonts");
102+
console.error(err);
103+
});
109104

110105
// Function bindings
111106
this.onClose = this.onClose.bind(this);

stories/index.stories.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { storiesOf } from "@storybook/react";
22
import React, { useState } from "react";
33

4-
import FontPicker from "../dist/FontPicker.es.js";
5-
import "./style.css";
4+
import FontPicker from "../dist/FontPicker.es.js"; /* eslint-disable-line import/extensions */
5+
import "./styles.css";
66

77
const API_KEY = "AIzaSyAOkdDlx49HCSBdu86oe8AD1Q7piIxlR6k";
88

File renamed without changes.

tsconfig.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,19 @@
22
"compilerOptions": {
33
"allowSyntheticDefaultImports": true,
44
"declaration": true,
5-
"declarationDir": "./dist/js/",
65
"declarationMap": true,
6+
"esModuleInterop": true,
77
"forceConsistentCasingInFileNames": true,
88
"jsx": "react",
9-
"module": "es6",
10-
"moduleResolution": "node",
119
"noFallthroughCasesInSwitch": true,
1210
"noImplicitAny": true,
1311
"noImplicitReturns": true,
1412
"noImplicitThis": true,
1513
"noUnusedLocals": true,
1614
"noUnusedParameters": true,
17-
"outDir": "./dist/js/",
1815
"removeComments": true,
1916
"sourceMap": true,
2017
"strictBindCallApply": true,
21-
"strictFunctionTypes": true,
22-
"target": "es5"
23-
},
24-
"include": ["src/**/*"]
18+
"strictFunctionTypes": true
19+
}
2520
}

yarn.lock

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,12 +1048,17 @@
10481048
react-lifecycles-compat "^3.0.4"
10491049
warning "^3.0.0"
10501050

1051-
"@samuelmeuli/eslint-config@~2.0.1":
1052-
version "2.0.1"
1053-
resolved "https://registry.yarnpkg.com/@samuelmeuli/eslint-config/-/eslint-config-2.0.1.tgz#10b2f70bf455f14938bbde5983f5a900d7bbc225"
1054-
integrity sha512-mPD6Uu1/skwxkMYC+PDtZC5VoK9Eg/B/bpzY9KX5L51yC7sKtxelS0Pb00QiCfKU8YEs5DbJfGciEFsnoqALag==
1051+
"@samuelmeuli/eslint-config@^2.1.0":
1052+
version "2.1.0"
1053+
resolved "https://registry.yarnpkg.com/@samuelmeuli/eslint-config/-/eslint-config-2.1.0.tgz#f2824925419529b3501d888e0c5adc72bd0bacde"
1054+
integrity sha512-hIC0kuSlkIDLR99FEoyangrtcqSdUgmg3T3y+/7rTjYI80j//16iULEFtoZT+lS1Kau/z+XFHNjChSBBEkXhaw==
1055+
1056+
"@samuelmeuli/font-manager@^1.0.0":
1057+
version "1.0.0"
1058+
resolved "https://registry.yarnpkg.com/@samuelmeuli/font-manager/-/font-manager-1.0.0.tgz#df1cd3b382c89a85d1261ba8fd69e0c383d8d9f1"
1059+
integrity sha512-rrnURUgZKL7UIUq5jwsMXy6MK29LjW+FIqjrFFXsoKhyLJa9jGSRo0kx+XMPRGAxuR+2+uWuOoaRPjaXsXuAdA==
10551060

1056-
"@samuelmeuli/stylelint-config@~1.0.0":
1061+
"@samuelmeuli/stylelint-config@^1.0.2":
10571062
version "1.0.2"
10581063
resolved "https://registry.yarnpkg.com/@samuelmeuli/stylelint-config/-/stylelint-config-1.0.2.tgz#fb66d6529a33239202a69fa204dd8636398fa714"
10591064
integrity sha512-j8sYYH0lYmmm8POd6rl7R6TZsnDC8GLnbl7UAgXhNNBPobcz7ETiwV2S3cOaAb4xBkrIx38mNbPenIgwFLDEYw==
@@ -4492,11 +4497,6 @@ focus-lock@^0.6.3:
44924497
resolved "https://registry.yarnpkg.com/focus-lock/-/focus-lock-0.6.5.tgz#f6eb37832a9b1b205406175f5277396a28c0fce1"
44934498
integrity sha512-i/mVBOoa9o+tl+u9owOJUF8k8L85odZNIsctB+JAK2HFT8jckiBwmk+3uydlm6FN8czgnkIwQtBv6yyAbrzXjw==
44944499

4495-
font-picker@^3.1.0:
4496-
version "3.1.0"
4497-
resolved "https://registry.yarnpkg.com/font-picker/-/font-picker-3.1.0.tgz#587afeb46517d3788adbe538d3823c8c6bc2b5df"
4498-
integrity sha512-OB5gPtAoSY0CVfolwKd3PXaKl59F0QeP6+Ylt+4js0o1JkKGjvON5MO8lUlYq6VLPJlWx8l/ZmUrvHcAu94CJg==
4499-
45004500
for-in@^0.1.3:
45014501
version "0.1.8"
45024502
resolved "https://registry.yarnpkg.com/for-in/-/for-in-0.1.8.tgz#d8773908e31256109952b1fdb9b3fa867d2775e1"
@@ -9308,7 +9308,7 @@ stylelint-scss@^3.4.0:
93089308
postcss-selector-parser "^6.0.2"
93099309
postcss-value-parser "^3.3.1"
93109310

9311-
stylelint@^10.0.1:
9311+
stylelint@^10.1.0:
93129312
version "10.1.0"
93139313
resolved "https://registry.yarnpkg.com/stylelint/-/stylelint-10.1.0.tgz#1bc4c4ce878107e7c396b19226d91ba28268911a"
93149314
integrity sha512-OmlUXrgzEMLQYj1JPTpyZPR9G4bl0StidfHnGJEMpdiQ0JyTq0MPg1xkHk1/xVJ2rTPESyJCDWjG8Kbpoo7Kuw==

0 commit comments

Comments
 (0)