@dtdot/lego 2.0.0-28 → 2.0.0-29

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.
@@ -16,6 +16,7 @@ export interface IInputProps {
16
16
  'data-testid'?: string;
17
17
  'suggestions'?: SelectOption[];
18
18
  'loading'?: boolean;
19
+ 'loadingVariant'?: 'default' | 'background';
19
20
  }
20
21
  declare const Input: React.ForwardRefExoticComponent<IInputProps & React.RefAttributes<HTMLInputElement>>;
21
22
  export default Input;
@@ -74,7 +74,7 @@ const messageVariants = {
74
74
  errorFocus: { opacity: 1, y: -4 },
75
75
  };
76
76
  const Input = React.forwardRef(function ForwardRefInput(props, ref) {
77
- const { label, name, description, placeholder, disabled, type = 'text', autoFocus, value, 'error': propsError, onChange, onFocus, onBlur, 'data-testid': dataTestId, suggestions, loading, } = props;
77
+ const { label, name, description, placeholder, disabled, type = 'text', autoFocus, value, 'error': propsError, onChange, onFocus, onBlur, 'data-testid': dataTestId, suggestions, loading, loadingVariant, } = props;
78
78
  const [isOpen, setIsOpen] = useState(false);
79
79
  const [isFocused, setIsFocused] = useState(false);
80
80
  const [referenceElement, setReferenceElement] = useState();
@@ -124,7 +124,7 @@ const Input = React.forwardRef(function ForwardRefInput(props, ref) {
124
124
  React.createElement(FontAwesomeIcon, { icon: faExclamationCircle }))),
125
125
  error && (React.createElement(ErrorMessage, { style: { opacity: 0, y: 0 }, animate: animationVariant, variants: messageVariants, transition: { type: 'spring', duration: 0.3 }, "data-testid": 'error-message' }, error)),
126
126
  loading && (React.createElement(LoadingContainer, null,
127
- React.createElement(Loader, { size: 'sm' })))),
127
+ React.createElement(Loader, { size: 'sm', variant: loadingVariant })))),
128
128
  splitDescription && (React.createElement(ControlDescription, null, splitDescription.map((line, index) => (React.createElement("span", { key: index },
129
129
  index !== 0 && React.createElement("br", null),
130
130
  line))))),
@@ -1,9 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  export interface BaseLoaderProps {
3
+ variant?: 'default' | 'background';
3
4
  size: 'sm' | 'md';
4
5
  }
5
6
  export interface LoaderProps {
6
- variant?: 'page-loader' | 'default';
7
+ variant?: 'page-loader' | 'default' | 'background';
7
8
  size?: 'sm' | 'md';
8
9
  }
9
10
  declare const Loader: ({ variant, size }: LoaderProps) => JSX.Element;
@@ -47,15 +47,16 @@ const loadingCircleTransition = {
47
47
  repeatType: 'reverse',
48
48
  ease: 'easeInOut',
49
49
  }; // Framer motion isn't accepting 'repeatType' but animation breaks without it
50
- const BaseLoader = ({ size }) => {
50
+ const BaseLoader = ({ size, variant }) => {
51
51
  const loadingCircleWithSize = useMemo(() => {
52
52
  const sizePx = size === 'md' ? '10px' : '5px';
53
53
  return {
54
54
  ...loadingCircle,
55
55
  width: sizePx,
56
56
  height: sizePx,
57
+ backgroundColor: variant === 'default' ? colours.grey30 : colours.grey50,
57
58
  };
58
- }, [size]);
59
+ }, [size, variant]);
59
60
  const loadingContainerWithSize = useMemo(() => {
60
61
  const widthPx = size === 'md' ? '40px' : '20px';
61
62
  const heightPx = size === 'md' ? '26px' : '13px';
@@ -75,6 +76,6 @@ const Loader = ({ variant = 'default', size = 'md' }) => {
75
76
  return (React.createElement(PageLoaderContainer, null,
76
77
  React.createElement(BaseLoader, { size: size })));
77
78
  }
78
- return React.createElement(BaseLoader, { size: size });
79
+ return React.createElement(BaseLoader, { size: size, variant: variant });
79
80
  };
80
81
  export default Loader;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dtdot/lego",
3
- "version": "2.0.0-28",
3
+ "version": "2.0.0-29",
4
4
  "description": "Some reusable components for building my applications",
5
5
  "main": "build/index.js",
6
6
  "scripts": {