@integrigo/integrigo-ui 1.2.2 → 1.2.5

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.2",
6
+ "version": "1.2.5",
7
7
  "main": "lib/index.js",
8
8
  "module": "lib/index.esm.js",
9
9
  "types": "lib/index.d.ts",
@@ -1,17 +1,21 @@
1
- import React from 'react';
2
- import styled from 'styled-components';
1
+ import React from "react";
2
+ import styled from "styled-components";
3
3
 
4
- export interface ButtonProps extends React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> {
4
+ export interface ButtonProps
5
+ extends React.DetailedHTMLProps<
6
+ React.ButtonHTMLAttributes<HTMLButtonElement>,
7
+ HTMLButtonElement
8
+ > {
5
9
  primary?: boolean;
6
10
  ghost?: boolean;
7
- size?: 'small' | 'medium' | 'large';
11
+ size?: "small" | "medium" | "large";
8
12
  }
9
13
 
10
- export const Button = styled.button<Omit<ButtonProps, 'label'>>`
14
+ export const Button = styled.button<Omit<ButtonProps, "label">>`
11
15
  background-color: transparent;
12
16
  border: none;
13
- border-radius: var(--padding-l);
14
- padding: var(--padding-s) var(--padding-l);
17
+ border-radius: var(--padding-xl);
18
+ padding: var(--padding-m) var(--padding-xl);
15
19
  font-weight: var(--font-bold);
16
20
  font-size: var(--font-size-l);
17
21
  cursor: pointer;
@@ -19,36 +23,42 @@ export const Button = styled.button<Omit<ButtonProps, 'label'>>`
19
23
  position: relative;
20
24
 
21
25
  &:before {
22
- content: '';
26
+ content: "";
23
27
  position: absolute;
24
28
  left: 0;
25
29
  top: 0;
26
30
  width: calc(100% - 4px);
27
31
  height: calc(100% - 4px);
28
- background-color: ${p => p.primary && !p.ghost ? 'var(--color-orange)' : 'transparent'};
29
- border: ${p => p.ghost ? 'none' : '2px solid var(--color-orange)'};
32
+ background-color: ${(p) =>
33
+ p.primary && !p.ghost ? "var(--color-orange)" : "transparent"};
34
+ border: ${(p) => (p.ghost ? "none" : "2px solid var(--color-orange)")};
30
35
  border-radius: var(--padding-l);
31
36
  z-index: -1;
32
37
  transition: opacity var(--transition-speed);
33
38
  }
34
39
 
35
- &:focus, &:active {
36
- color: ${p => p.primary && !p.ghost ? 'var(--color-white)' : 'var(--color-navy)'};
40
+ &:focus,
41
+ &:active {
42
+ color: ${(p) =>
43
+ p.primary && !p.ghost ? "var(--color-white)" : "var(--color-navy)"};
37
44
  outline: none;
38
45
  }
39
46
 
40
- &:focus:before, &:active:before {
41
- background-color: ${p => p.primary && !p.ghost ? 'var(--color-green)' : 'transparent'};
42
- border: ${p => p.ghost ? 'none' : '2px solid var(--color-green)'};
47
+ &:focus:before,
48
+ &:active:before {
49
+ background-color: ${(p) =>
50
+ p.primary && !p.ghost ? "var(--color-green)" : "transparent"};
51
+ border: ${(p) => (p.ghost ? "none" : "2px solid var(--color-green)")};
43
52
  }
44
53
 
45
54
  &:hover:before {
46
55
  opacity: 0.5;
47
56
  }
48
57
 
49
- &:hover:focus:before, &:hover:active:before {
50
- opacity: 1
58
+ &:hover:focus:before,
59
+ &:hover:active:before {
60
+ opacity: 1;
51
61
  }
52
- `
62
+ `;
53
63
 
54
- Button.displayName = 'Button'
64
+ Button.displayName = "Button";
@@ -1,29 +1,29 @@
1
- import React from 'react';
2
- import { ComponentStory, ComponentMeta } from '@storybook/react';
1
+ import React from "react";
2
+ import { ComponentStory, ComponentMeta } from "@storybook/react";
3
3
 
4
- import { Icon } from './Icon';
4
+ import { Icon } from "./Icon";
5
5
 
6
6
  export default {
7
- title: 'Atoms/Icon',
8
- component: Icon,
7
+ title: "Atoms/Icon",
8
+ component: Icon,
9
9
  } as ComponentMeta<typeof Icon>;
10
10
 
11
11
  const Template: ComponentStory<typeof Icon> = (args) => <Icon {...args} />;
12
12
 
13
13
  export const Bars = Template.bind({});
14
- Bars.args = { icon: 'bars' };
14
+ Bars.args = { icon: "bars" };
15
15
 
16
16
  export const Plus = Template.bind({});
17
- Plus.args = { icon: 'plus' };
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
21
 
22
22
  export const Facebook = Template.bind({});
23
- Facebook.args = { icon: 'facebook' };
23
+ Facebook.args = { icon: "facebook" };
24
24
 
25
25
  export const Instagram = Template.bind({});
26
- Instagram.args = { icon: 'instagram' };
26
+ Instagram.args = { icon: "instagram" };
27
27
 
28
28
  export const Linkedin = Template.bind({});
29
- Linkedin.args = { icon: 'linkedin' };
29
+ Linkedin.args = { icon: "linkedin" };
@@ -1,40 +1,43 @@
1
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";
2
+ import {
3
+ FontAwesomeIcon,
4
+ FontAwesomeIconProps,
5
+ } from "@fortawesome/react-fontawesome";
5
6
  import { IconProp } from "@fortawesome/fontawesome-svg-core";
6
7
 
7
- type IconType = "bars" | "plus" | "minus";
8
+ import * as SolidIcons from "@fortawesome/free-solid-svg-icons";
9
+ import * as BrandIcons from "@fortawesome/free-brands-svg-icons";
8
10
 
11
+ const ICONS = ["bars", "plus", "minus", "phone", "envelope"];
9
12
  const SOCIAL_ICONS = ["facebook", "instagram", "linkedin"];
10
13
 
14
+ type IconType = typeof ICONS[number];
11
15
  type IconSocialType = typeof SOCIAL_ICONS[number];
12
16
 
13
- type IconProps = {
17
+ type IconProps = Omit<FontAwesomeIconProps, "icon"> & {
14
18
  icon: IconType | IconSocialType;
15
19
  };
16
20
 
21
+ const toFaIcon = <T extends typeof BrandIcons | typeof SolidIcons>(
22
+ icon: IconType | IconSocialType
23
+ ): keyof T => `fa${icon.charAt(0).toUpperCase() + icon.slice(1)}` as keyof T;
24
+
17
25
  const getIcon = (icon: IconType | IconSocialType): IconProp => {
18
26
  if (SOCIAL_ICONS.includes(icon)) {
19
27
  if (icon === "facebook") {
20
28
  return BrandIcons.faFacebookSquare;
21
29
  }
22
30
 
23
- const iconName = `fa${
24
- icon.charAt(0).toUpperCase() + icon.slice(1)
25
- }` as keyof typeof BrandIcons;
26
-
31
+ const iconName = toFaIcon(icon);
27
32
  return BrandIcons[iconName] as IconProp;
28
33
  }
29
34
 
30
- const iconName = `fa${
31
- icon.charAt(0).toUpperCase() + icon.slice(1)
32
- }` as keyof typeof SolidIcons;
35
+ const iconName = toFaIcon(icon) as keyof typeof SolidIcons;
33
36
  return SolidIcons[iconName] as IconProp;
34
37
  };
35
38
 
36
- export const Icon: React.FC<IconProps> = ({ icon }) => {
39
+ export const Icon: React.FC<IconProps> = ({ icon, ...props }) => {
37
40
  const iconType = getIcon(icon);
38
41
 
39
- return <FontAwesomeIcon icon={iconType} />;
42
+ return <FontAwesomeIcon icon={iconType} {...props} />;
40
43
  };