@integrigo/integrigo-ui 1.2.1 → 1.2.2

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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "registry": "https://npm.pkg.github.com/integrigo"
5
5
  },
6
- "version": "1.2.1",
6
+ "version": "1.2.2",
7
7
  "main": "lib/index.js",
8
8
  "module": "lib/index.esm.js",
9
9
  "types": "lib/index.d.ts",
@@ -34,6 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@fortawesome/fontawesome-svg-core": "^6.1.1",
37
+ "@fortawesome/free-brands-svg-icons": "^6.1.1",
37
38
  "@fortawesome/free-solid-svg-icons": "^6.1.1",
38
39
  "@fortawesome/react-fontawesome": "^0.1.18"
39
40
  },
@@ -17,4 +17,13 @@ export const Plus = Template.bind({});
17
17
  Plus.args = { icon: 'plus' };
18
18
 
19
19
  export const Minus = Template.bind({});
20
- Minus.args = { icon: 'minus' };
20
+ Minus.args = { icon: 'minus' };
21
+
22
+ export const Facebook = Template.bind({});
23
+ Facebook.args = { icon: 'facebook' };
24
+
25
+ export const Instagram = Template.bind({});
26
+ Instagram.args = { icon: 'instagram' };
27
+
28
+ export const Linkedin = Template.bind({});
29
+ Linkedin.args = { icon: 'linkedin' };
@@ -1,18 +1,40 @@
1
- import React from 'react'
2
- import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
3
- import * as SolidIcons from '@fortawesome/free-solid-svg-icons'
4
- import { IconProp } from '@fortawesome/fontawesome-svg-core'
1
+ import React from "react";
2
+ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
3
+ import * as SolidIcons from "@fortawesome/free-solid-svg-icons";
4
+ import * as BrandIcons from "@fortawesome/free-brands-svg-icons";
5
+ import { IconProp } from "@fortawesome/fontawesome-svg-core";
5
6
 
6
- type IconType = "bars" | "plus" | "minus"
7
+ type IconType = "bars" | "plus" | "minus";
8
+
9
+ const SOCIAL_ICONS = ["facebook", "instagram", "linkedin"];
10
+
11
+ type IconSocialType = typeof SOCIAL_ICONS[number];
7
12
 
8
13
  type IconProps = {
9
- icon: IconType
10
- }
14
+ icon: IconType | IconSocialType;
15
+ };
16
+
17
+ const getIcon = (icon: IconType | IconSocialType): IconProp => {
18
+ if (SOCIAL_ICONS.includes(icon)) {
19
+ if (icon === "facebook") {
20
+ return BrandIcons.faFacebookSquare;
21
+ }
22
+
23
+ const iconName = `fa${
24
+ icon.charAt(0).toUpperCase() + icon.slice(1)
25
+ }` as keyof typeof BrandIcons;
26
+
27
+ return BrandIcons[iconName] as IconProp;
28
+ }
29
+
30
+ const iconName = `fa${
31
+ icon.charAt(0).toUpperCase() + icon.slice(1)
32
+ }` as keyof typeof SolidIcons;
33
+ return SolidIcons[iconName] as IconProp;
34
+ };
11
35
 
12
36
  export const Icon: React.FC<IconProps> = ({ icon }) => {
13
- const iconName = `fa${icon.charAt(0).toUpperCase() + icon.slice(1)}` as keyof typeof SolidIcons
37
+ const iconType = getIcon(icon);
14
38
 
15
- return (
16
- <FontAwesomeIcon icon={SolidIcons[iconName] as IconProp} />
17
- )
18
- }
39
+ return <FontAwesomeIcon icon={iconType} />;
40
+ };