@mailstep/design-system 0.7.73 → 0.7.74-beta.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mailstep/design-system",
3
- "version": "0.7.73",
3
+ "version": "0.7.74-beta.2",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "main": "./ui/index.js",
@@ -24,7 +24,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
24
24
  import { Spinner } from '../Spinner';
25
25
  import { StyledButton, LoadingIconWrapper, StyledIcon, StyledWrapper } from './styles';
26
26
  var Button = function (_a) {
27
- var isLoading = _a.isLoading, loadingText = _a.loadingText, icon = _a.icon, iconLeft = _a.iconLeft, iconRight = _a.iconRight, _b = _a.variant, variant = _b === void 0 ? 'default' : _b, _c = _a.appearance, appearance = _c === void 0 ? 'primary' : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.fullWidth, fullWidth = _e === void 0 ? false : _e, height = _a.height, buttonRef = _a.buttonRef, onClick = _a.onClick, props = __rest(_a, ["isLoading", "loadingText", "icon", "iconLeft", "iconRight", "variant", "appearance", "disabled", "fullWidth", "height", "buttonRef", "onClick"]);
28
- return (_jsx(StyledButton, __assign({}, props, { onClick: !disabled && !isLoading ? onClick : undefined, "data-variant": variant, "data-appearance": appearance, disabled: disabled, iconPadding: !!icon && !props.children, ref: buttonRef, fullWidth: fullWidth, height: height, children: _jsxs(StyledWrapper, { children: [iconLeft && (typeof iconLeft === 'string' ? _jsx(StyledIcon, { "$addMarginRight": !!iconLeft, icon: iconLeft }) : iconLeft), isLoading ? (_jsxs(_Fragment, { children: [_jsx(LoadingIconWrapper, { "$addMarginRight": !!loadingText || !!props.children, children: _jsx(Spinner, { variant: "sm" }) }), loadingText || loadingText === '' ? loadingText : 'Loading'] })) : props.children ? (props.children) : (icon && (typeof icon === 'string' ? _jsx(StyledIcon, { icon: icon }) : icon)), iconRight && (typeof iconRight === 'string' ? _jsx(StyledIcon, { "$addMarginLeft": !!iconRight, icon: iconRight }) : iconRight)] }) })));
27
+ var isLoading = _a.isLoading, loadingText = _a.loadingText, icon = _a.icon, iconLeft = _a.iconLeft, iconRight = _a.iconRight, iconFillColor = _a.iconFillColor, iconStrokeColor = _a.iconStrokeColor, _b = _a.variant, variant = _b === void 0 ? 'default' : _b, _c = _a.appearance, appearance = _c === void 0 ? 'primary' : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.fullWidth, fullWidth = _e === void 0 ? false : _e, height = _a.height, buttonRef = _a.buttonRef, onClick = _a.onClick, props = __rest(_a, ["isLoading", "loadingText", "icon", "iconLeft", "iconRight", "iconFillColor", "iconStrokeColor", "variant", "appearance", "disabled", "fullWidth", "height", "buttonRef", "onClick"]);
28
+ return (_jsx(StyledButton, __assign({}, props, { onClick: !disabled && !isLoading ? onClick : undefined, "data-variant": variant, "data-appearance": appearance, disabled: disabled, iconPadding: !!icon && !props.children, ref: buttonRef, fullWidth: fullWidth, height: height, children: _jsxs(StyledWrapper, { children: [iconLeft && (typeof iconLeft === 'string' ? _jsx(StyledIcon, { "$addMarginRight": !!iconLeft, icon: iconLeft, fill: iconFillColor, stroke: iconStrokeColor }) : iconLeft), isLoading ? (_jsxs(_Fragment, { children: [_jsx(LoadingIconWrapper, { "$addMarginRight": !!loadingText || !!props.children, children: _jsx(Spinner, { variant: "sm" }) }), loadingText || loadingText === '' ? loadingText : 'Loading'] })) : props.children ? (props.children) : (icon && (typeof icon === 'string' ? _jsx(StyledIcon, { icon: icon, fill: iconFillColor, stroke: iconStrokeColor }) : icon)), iconRight && (typeof iconRight === 'string' ? _jsx(StyledIcon, { "$addMarginLeft": !!iconRight, icon: iconRight, fill: iconFillColor, stroke: iconStrokeColor }) : iconRight)] }) })));
29
29
  };
30
30
  export default Button;
@@ -25,4 +25,5 @@ export declare const GhostSecondary: Story;
25
25
  export declare const LinkPrimary: Story;
26
26
  export declare const LinkSecondary: Story;
27
27
  export declare const Icon: Story;
28
+ export declare const IconCustom: Story;
28
29
  export declare const Floating: Story;
@@ -100,6 +100,16 @@ export var Icon = {
100
100
  disabled: false,
101
101
  },
102
102
  };
103
+ export var IconCustom = {
104
+ args: {
105
+ variant: 'icon',
106
+ appearance: 'primary',
107
+ icon: 'Print',
108
+ iconFillColor: 'none',
109
+ iconStrokeColor: 'white',
110
+ disabled: false,
111
+ },
112
+ };
103
113
  export var Floating = {
104
114
  args: {
105
115
  variant: 'floating',
@@ -16,6 +16,8 @@ export type Props = React.HTMLProps<HTMLButtonElement> & {
16
16
  icon?: string | ReactNode;
17
17
  iconLeft?: string | ReactNode;
18
18
  iconRight?: string | ReactNode;
19
+ iconFillColor?: string;
20
+ iconStrokeColor?: string;
19
21
  buttonRef?: any;
20
22
  type?: 'button' | 'submit' | 'reset';
21
23
  };
@@ -3,7 +3,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
3
3
  return cooked;
4
4
  };
5
5
  import { jsx as _jsx } from "react/jsx-runtime";
6
- import React from 'react';
6
+ import { useMemo } from 'react';
7
7
  import { library } from '@fortawesome/fontawesome-svg-core';
8
8
  import { faFacebookF } from '@fortawesome/free-brands-svg-icons/faFacebookF';
9
9
  import { faInstagram } from '@fortawesome/free-brands-svg-icons/faInstagram';
@@ -117,6 +117,7 @@ import { faWineGlassCrack } from '@fortawesome/pro-solid-svg-icons/faWineGlassCr
117
117
  import { faXmark as fasXmark } from '@fortawesome/pro-solid-svg-icons/faXmark';
118
118
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
119
119
  import styled, { useTheme, th } from '@xstyled/styled-components';
120
+ import * as icons from './icons';
120
121
  export var iconDictionary = {
121
122
  greaterThan: faAngleRight,
122
123
  startsWith: faAnglesRight,
@@ -250,18 +251,23 @@ var FaIconSizing = styled.div(templateObject_1 || (templateObject_1 = __makeTemp
250
251
  return ($fixedWidth ? 'contents' : 'block');
251
252
  });
252
253
  var Icon = function (_a) {
253
- var icon = _a.icon, fill = _a.fill, _b = _a.style, style = _b === void 0 ? 'normal' : _b, size = _a.size, className = _a.className, secondaryColor = _a.secondaryColor, _c = _a.fixedWidth, fixedWidth = _c === void 0 ? true : _c, spinning = _a.spinning;
254
+ var icon = _a.icon, fill = _a.fill, stroke = _a.stroke, _b = _a.style, style = _b === void 0 ? 'normal' : _b, size = _a.size, className = _a.className, secondaryColor = _a.secondaryColor, _c = _a.fixedWidth, fixedWidth = _c === void 0 ? true : _c, spinning = _a.spinning;
254
255
  var theme = useTheme();
255
- var colorFill = fill && th.color(fill)({ theme: theme }); // React.Text wont return number here
256
+ var colorFill = fill && th.color(fill)({ theme: theme });
257
+ var colorStroke = stroke && th.color(stroke)({ theme: theme });
256
258
  var colorSecondary = secondaryColor && th.color(secondaryColor)({ theme: theme });
257
259
  var namedIcon = (typeof icon === 'string' && (iconDictionary === null || iconDictionary === void 0 ? void 0 : iconDictionary[icon])) || false;
258
- var iconProp = React.useMemo(function () {
260
+ var iconProp = useMemo(function () {
259
261
  if (namedIcon) {
260
262
  return Array.isArray(namedIcon) ? namedIcon[0] : namedIcon;
261
263
  }
262
264
  return [iconPrefixMap[style], icon];
263
265
  }, [icon, style, namedIcon]);
264
266
  var flipProp = (namedIcon && Array.isArray(namedIcon) && namedIcon[1]) || undefined;
267
+ if (icons[icon]) {
268
+ var IconComponent = icons[icon];
269
+ return (_jsx(FaIconSizing, { size: size, className: className !== null && className !== void 0 ? className : '', "$colorSecondary": colorSecondary, "$fixedWidth": fixedWidth, children: _jsx(IconComponent, { fill: colorFill, stroke: colorStroke }) }));
270
+ }
265
271
  return (_jsx(FaIconSizing, { size: size, className: className !== null && className !== void 0 ? className : '', "$colorSecondary": colorSecondary, "$fixedWidth": fixedWidth, children: _jsx(FontAwesomeIcon, { color: colorFill, flip: flipProp, icon: iconProp, className: "faIcon ".concat(fixedWidth ? 'fa-fw' : '', " ").concat(spinning ? 'fa-spin' : '') }) }));
266
272
  };
267
273
  export default Icon;
@@ -10,6 +10,7 @@ declare const meta: {
10
10
  icon: string;
11
11
  style?: "normal" | "light" | "solid" | undefined;
12
12
  fill?: string | undefined;
13
+ stroke?: string | undefined;
13
14
  size?: number | string | undefined;
14
15
  className?: string | undefined;
15
16
  fixedWidth?: boolean | undefined;
@@ -4,6 +4,7 @@ export type IconProps = {
4
4
  icon: string;
5
5
  style?: 'normal' | 'light' | 'solid';
6
6
  fill?: string;
7
+ stroke?: string;
7
8
  size?: number | string;
8
9
  className?: string;
9
10
  fixedWidth?: boolean;