@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 CHANGED
@@ -1,13 +1,13 @@
1
1
  # Tiny FontAwesome Icon Component for React
2
2
 
3
- Because for some reason `@fortawesome/react-fontawesome` bloats my final bundle by 80KB, to render <1KB of SVG tags.
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 '@shish/react-faicon';
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 React from "react";
2
- type FAIconProps = React.SVGProps<SVGSVGElement> & {
3
- icon: {
4
- icon: [
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
- import "react";
3
- function FAIcon({ icon, className = "", ...svgProps }) {
4
- const [width, height, _aliases, _unicode, svgPathData] = icon.icon;
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: "content-box",
13
- display: "inline-block",
14
- height: "1em",
15
- width: "1em",
16
- overflow: "visible",
17
- verticalAlign: "-0.125em"
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: /*#__PURE__*/ jsx("path", {
24
- fill: "currentColor",
25
- d: svgPathData
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.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
  }