Skip to content

Commit

Permalink
Move glyph map to fonts dir
Browse files Browse the repository at this point in the history
  • Loading branch information
arniu committed Mar 8, 2020
1 parent bc0d91e commit 0ac65da
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 1,264 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ typings/
.next

### Customize
fonts/

This comment has been minimized.

Copy link
@JacksonLaw

JacksonLaw Mar 9, 2020

this removed the fonts file from the branch?

This comment has been minimized.

Copy link
@arniu

arniu Mar 10, 2020

Author Owner

Yes, they're all generated by the script. So, there is no need to track it.


package-lock.json
yarn.lock

Expand Down
8 changes: 4 additions & 4 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.editorconfig
.gitignore
.npmignore
generate-icon.js
.*

script/
test/
Binary file removed fonts/Ionicons.ttf
Binary file not shown.
10 changes: 3 additions & 7 deletions glyph/index.js → glyph.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import glyphs from "./map.json";

export const UNKNOWN_ICON = "";
import map from "./fonts/Ionicons.json";

/**
* Try glyph
Expand All @@ -11,12 +9,10 @@ export const UNKNOWN_ICON = "";
*/
export function tryGlyph(iconNames, mapper) {
const code = iconNames.reduce((prev, name) => {
return prev || glyphs[name in glyphs ? name : mapper(name)];
return prev || map[name in map ? name : mapper(name)];
}, undefined);

return code ? String.fromCharCode(code) : UNKNOWN_ICON;
}

/**
* @typedef
*/
export const UNKNOWN_ICON = "";
Loading

0 comments on commit 0ac65da

Please sign in to comment.