react-artasys-ui 0.1.3 → 0.1.4

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.
@@ -1,7 +1,9 @@
1
1
  import { FormHTMLAttributes, ReactNode } from 'react';
2
+ import { TSpinner } from '../Spinner';
2
3
  interface IForm extends FormHTMLAttributes<HTMLFormElement> {
3
4
  children: ReactNode;
4
5
  wait?: boolean;
6
+ spinnerColor?: TSpinner['color'];
5
7
  }
6
- declare const Form: ({ children, wait, className, onSubmit, ...props }: IForm) => JSX.Element;
8
+ declare const Form: ({ children, wait, className, spinnerColor, onSubmit, ...props }: IForm) => JSX.Element;
7
9
  export default Form;
@@ -1,6 +1,7 @@
1
- export type TSpinner = {
1
+ import { AllHTMLAttributes } from "react";
2
+ export type TSpinner = Omit<AllHTMLAttributes<HTMLDivElement>, 'size' | 'color'> & {
2
3
  size?: 'small' | 'middle' | 'large';
3
- color?: 'default' | 'contrast';
4
+ color?: 'contrast' | 'orange';
4
5
  };
5
- declare const Spinner: ({ size, color }: TSpinner) => JSX.Element;
6
+ declare const Spinner: ({ size, color, ...props }: TSpinner) => JSX.Element;
6
7
  export default Spinner;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-artasys-ui",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "lib/index.d.ts",
package/src/Form/Form.tsx CHANGED
@@ -1,14 +1,17 @@
1
1
  import { FormHTMLAttributes, ReactNode, FormEvent } from 'react';
2
2
  import styles from './style.module.css';
3
3
 
4
- import Spinner from '../Spinner';
4
+ import Spinner,{
5
+ TSpinner
6
+ } from '../Spinner';
5
7
 
6
8
  interface IForm extends FormHTMLAttributes<HTMLFormElement> {
7
9
  children: ReactNode;
8
10
  wait?: boolean;
11
+ spinnerColor?: TSpinner['color'];
9
12
  }
10
13
 
11
- const Form = ({children, wait, className, onSubmit, ...props}: IForm) => {
14
+ const Form = ({children, wait, className, spinnerColor, onSubmit, ...props}: IForm) => {
12
15
 
13
16
  const submit = (e: FormEvent<HTMLFormElement>) => {
14
17
  e.preventDefault();
@@ -26,7 +29,7 @@ const Form = ({children, wait, className, onSubmit, ...props}: IForm) => {
26
29
  return(<form {...props} onSubmit={submit} className={classes.join(' ')}>
27
30
  {children}
28
31
  <div className={styles['wait-indicator']}>
29
- <Spinner size="large" color="contrast"/>
32
+ <Spinner color={spinnerColor}/>
30
33
  </div>
31
34
  </form>);
32
35
  };
@@ -1,21 +1,21 @@
1
- import React from "react";
1
+ import { AllHTMLAttributes } from "react";
2
2
  import styles from "./style.module.css";
3
3
 
4
- export type TSpinner = {
4
+ export type TSpinner = Omit<AllHTMLAttributes<HTMLDivElement>, 'size' | 'color'> & {
5
5
  size?: 'small' | 'middle' | 'large';
6
- color?: 'default' | 'contrast';
6
+ color?: 'contrast' | 'orange';
7
7
  }
8
8
 
9
- const Spinner = ({size, color = 'default'}: TSpinner) => {
9
+ const Spinner = ({size, color, ...props}: TSpinner) => {
10
10
 
11
11
  const classes = ['ui-spinner'];
12
12
 
13
13
  classes.push(styles['spinner']);
14
- if (size) classes.push(styles[size]);
15
- if (color) classes.push(styles[color]);
16
- classes.push(styles['animate']);
14
+ if (size) classes.push(styles[size], 'ui-spinner-' + size);
15
+ if (color) classes.push(styles[color], 'ui-spinner-' + color);
16
+ if (props.className) classes.push(props.className);
17
17
 
18
- return(<div className={classes.join(' ')}></div>);
18
+ return(<div {...props} className={classes.join(' ')}></div>);
19
19
  };
20
20
 
21
21
  export default Spinner;
@@ -1,4 +1,12 @@
1
+ /* Spinner */
2
+
1
3
  .spinner {
4
+ --color-rgb: 94, 190, 214;
5
+ width: 100%;
6
+ height: 100%;
7
+ max-width: 100px;
8
+ max-height: 100px;
9
+ aspect-ratio: 1/1;
2
10
  padding-left: calc(-0.5rem / 2);
3
11
  padding-right: calc(-0.5rem / 2);
4
12
  }
@@ -6,8 +14,9 @@
6
14
  .spinner::before {
7
15
  content: '';
8
16
  display: inline-block;
9
- width: 1rem;
10
- height: 1rem;
17
+ width: 100%;
18
+ max-width: 100%;
19
+ max-height: 100%;
11
20
  --border-width: clamp(0.2em, 10%, 0.5em);
12
21
  border-radius: 50%;
13
22
  aspect-ratio: 1/1;
@@ -17,56 +26,34 @@
17
26
  #000 calc(100% - var(--border-width) + 0.5px)
18
27
  );
19
28
  mask: var(--mask);
20
- background: linear-gradient(to top, rgba(251, 163, 29, 1), rgba(251, 163, 29, 0.5)) 100% 0/50% 100% no-repeat,
21
- linear-gradient(rgba(251, 163, 29, 0.5) 50%, transparent 95%) 0 0/50% 100% no-repeat;
29
+ background: linear-gradient(to top, rgba(var(--color-rgb), 1), rgba(var(--color-rgb), 0.5)) 100% 0/50% 100% no-repeat,
30
+ linear-gradient(rgba(var(--color-rgb), 0.5) 50%, transparent 95%) 0 0/50% 100% no-repeat;
31
+ animation: button-spinner-border .85s linear infinite;
22
32
  }
23
33
 
24
- .spinner.default::before {
25
- border-color: #FFFFFF;
34
+ .spinner.contrast {
35
+ --color-rgb: 255, 255, 255;
26
36
  }
27
37
 
28
- .spinner.contrast::before {
29
- background: linear-gradient(to top, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0.5)) 100% 0/50% 100% no-repeat,
30
- linear-gradient(rgba(255, 255, 255, 0.5) 50%, transparent 95%) 0 0/50% 100% no-repeat;
38
+ .spinner.orange {
39
+ --color-rgb: 251, 163, 29;
31
40
  }
32
41
 
33
- .spinner.small::before {
42
+ .spinner.small {
34
43
  width: 1rem;
35
44
  height: 1rem;
36
45
  }
37
46
 
38
- .spinner.middle::before {
47
+ .spinner.middle {
39
48
  width: 4rem;
40
49
  height: 4rem;
41
50
  }
42
51
 
43
- .spinner.large::before {
52
+ .spinner.large {
44
53
  width: 8rem;
45
54
  height: 8rem;
46
55
  }
47
56
 
48
- .spinner.big::before {
49
- width: 2rem;
50
- height: 2rem;
51
- }
52
-
53
- .spinner.full {
54
- display: flex;
55
- justify-content: center;
56
- align-items: center;
57
- width: 100%;
58
- height: 100%;
59
- }
60
-
61
- .spinner.full::before {
62
- width: 80%;
63
- height: 80%;
64
- }
65
-
66
- .spinner.animate::before {
67
- animation: button-spinner-border .85s linear infinite;
68
- }
69
-
70
57
  @keyframes button-spinner-border {
71
58
  to{
72
59
  transform:rotate(360deg)
@@ -78,7 +78,7 @@ const Image = ({onChange, onClick, onId, onRemove, ...props}: IImage) => {
78
78
  <span className={styles['close']} onClick={handleRemove} onBlur={handleCancelRemove} tabIndex={1}/>
79
79
  <img src={src ?? base64?.toString()} onLoad={handleLoad}/>
80
80
  {wait && <span className={styles['wait']}>
81
- <Spinner size="small" color="contrast"/>
81
+ <Spinner/>
82
82
  </span>}
83
83
  </span>);
84
84
  };