@shish2k/react-faicon 0.0.0 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.d.ts +5 -15
- package/dist/index.js +15 -13
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# Tiny FontAwesome Icon Component for React
|
|
2
2
|
|
|
3
|
-
Because
|
|
3
|
+
Because `@fortawesome/react-fontawesome` bloats my final bundle by 80KB, to render <1KB of SVG tags.
|
|
4
4
|
|
|
5
5
|
This package has fewer features (no animation, no invert-opacity mode, etc). But if all you want is to render an icon, it does that. It uses the same icon data from `@fortawesome/free-solid-svg-icons`, so it should be a drop-in replacement for basic use cases.
|
|
6
6
|
|
|
7
7
|
Example usage:
|
|
8
8
|
|
|
9
9
|
```tsx
|
|
10
|
-
import { FAIcon } from '@
|
|
10
|
+
import { FAIcon } from '@shish2k/react-faicon';
|
|
11
11
|
import { faPlay } from '@fortawesome/free-solid-svg-icons';
|
|
12
12
|
|
|
13
13
|
export function App() {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
number,
|
|
6
|
-
number,
|
|
7
|
-
string[],
|
|
8
|
-
string,
|
|
9
|
-
string
|
|
10
|
-
];
|
|
11
|
-
prefix: string;
|
|
12
|
-
iconName: string;
|
|
13
|
-
};
|
|
1
|
+
import type { RefAttributes, SVGAttributes } from 'react';
|
|
2
|
+
import type { IconDefinition } from '@fortawesome/fontawesome-common-types';
|
|
3
|
+
export interface FAIconProps extends Omit<SVGAttributes<SVGSVGElement>, 'children' | 'mask' | 'transform'>, RefAttributes<SVGSVGElement> {
|
|
4
|
+
icon: IconDefinition;
|
|
14
5
|
className?: string;
|
|
15
|
-
}
|
|
6
|
+
}
|
|
16
7
|
export declare function FAIcon({ icon, className, ...svgProps }: FAIconProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
-
export {};
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
function FAIcon({ icon, className = '', ...svgProps }) {
|
|
3
|
+
let [width, height, _ligatures, _unicode, svgPathData] = icon.icon;
|
|
4
|
+
if ('string' == typeof svgPathData) svgPathData = [
|
|
5
|
+
svgPathData
|
|
6
|
+
];
|
|
5
7
|
return /*#__PURE__*/ jsx("svg", {
|
|
6
8
|
"aria-hidden": "true",
|
|
7
9
|
focusable: "false",
|
|
@@ -9,21 +11,21 @@ function FAIcon({ icon, className = "", ...svgProps }) {
|
|
|
9
11
|
"data-icon": icon.iconName,
|
|
10
12
|
className: `fa-${icon.iconName} ${className}`,
|
|
11
13
|
style: {
|
|
12
|
-
boxSizing:
|
|
13
|
-
display:
|
|
14
|
-
height:
|
|
15
|
-
width:
|
|
16
|
-
overflow:
|
|
17
|
-
verticalAlign:
|
|
14
|
+
boxSizing: 'content-box',
|
|
15
|
+
display: 'inline-block',
|
|
16
|
+
height: '1em',
|
|
17
|
+
width: '1em',
|
|
18
|
+
overflow: 'visible',
|
|
19
|
+
verticalAlign: '-0.125em'
|
|
18
20
|
},
|
|
19
21
|
role: "img",
|
|
20
22
|
xmlns: "http://www.w3.org/2000/svg",
|
|
21
23
|
viewBox: `0 0 ${width} ${height}`,
|
|
22
24
|
...svgProps,
|
|
23
|
-
children:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
children: svgPathData.map((d, i)=>/*#__PURE__*/ jsx("path", {
|
|
26
|
+
fill: "currentColor",
|
|
27
|
+
d: d
|
|
28
|
+
}, i))
|
|
27
29
|
});
|
|
28
30
|
}
|
|
29
31
|
export { FAIcon };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shish2k/react-faicon",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1",
|
|
4
4
|
"author": "Shish <shish+npm@shishnet.org>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "shish/react-faicon",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"react": ">=16.9.0",
|
|
39
|
-
"react-dom": ">=16.9.0"
|
|
39
|
+
"react-dom": ">=16.9.0",
|
|
40
|
+
"@fortawesome/fontawesome-common-types": ">=7.0.0"
|
|
40
41
|
}
|
|
41
42
|
}
|