Skip to content

Commit

Permalink
Merge pull request raxjs#185 from raxjs/icon-beta
Browse files Browse the repository at this point in the history
fix: rax-icon multi code points
  • Loading branch information
SoloJiang committed May 18, 2020
2 parents 2f0bf3e + 41440d1 commit fa000b0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 20 deletions.
2 changes: 1 addition & 1 deletion packages/rax-icon/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rax-icon",
"version": "1.3.1",
"version": "1.3.2",
"description": "icon component for Rax.",
"license": "BSD-3-Clause",
"main": "lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/rax-icon/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if (isWeex) {
const fontCache = new Map();
const Icon = forwardRef<HTMLSpanElement | HTMLImageElement, IconProps>(
({ source: { uri, codePoint }, fontFamily, style = {}, ...rest }, ref) => {
if (uri && !codePoint) {
if (uri && !codePoint && !fontFamily) {
return <Image {...rest} source={{ uri }} style={style} />;
}
const fontFile = fontCache.get(fontFamily);
Expand Down
6 changes: 3 additions & 3 deletions packages/rax-icon/src/miniapp-wechat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ Component({
family: fontFamily,
source: "url('" + uri + "')"
});
this.setData({
style: `font-family: ${fontFamily};${style}`
});
} else if (fontFile !== uri) {
console.error(`font-family ${fontFamily} should be unique!`);
}
this.setData({
style: `font-family: ${fontFamily};${style}`
});
}
}
},
Expand Down
24 changes: 9 additions & 15 deletions packages/rax-icon/src/miniapp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ const noop = () => {};
Component({
data: {
styleSheet: '',
isImage: false,
fontCache: new Map()
isImage: false
},
// @ts-ignore
props: {
Expand Down Expand Up @@ -43,19 +42,14 @@ Component({
styleSheet: style
});
} else {
const fontFile = this.data.fontCache.get(fontFamily);
if (!fontFile) {
this.data.fontCache.set(fontFamily, uri);
my.loadFontFace({
family: fontFamily,
source: "url('" + uri + "')"
});
this.setData({
styleSheet: {...style, fontFamily}
});
} else if (fontFile !== uri) {
console.error(`font-family ${fontFamily} should be unique!`);
}
// loadFontFace only work for current page
my.loadFontFace({
family: fontFamily,
source: "url('" + uri + "')"
});
this.setData({
styleSheet: {...style, fontFamily}
});
}
},
onTap(e) {
Expand Down

0 comments on commit fa000b0

Please sign in to comment.