react-artasys-ui 0.0.1 → 0.0.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.
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ interface IButton extends React.ButtonHTMLAttributes<HTMLButtonElement> {
3
+ wait?: boolean;
4
+ }
5
+ declare const Button: ({ children, wait, ...props }: IButton) => JSX.Element;
6
+ export default Button;
@@ -0,0 +1,2 @@
1
+ import Button from "./Button";
2
+ export default Button;
@@ -0,0 +1,7 @@
1
+ import { TFileData } from "../File";
2
+ import { TUploadImageData } from "./UploadImages";
3
+ export type TImageData = TFileData & {
4
+ setWait: (status: boolean) => void;
5
+ };
6
+ declare const Image: ({ onChange, onClick, ...props }: TUploadImageData) => JSX.Element;
7
+ export default Image;
@@ -0,0 +1,9 @@
1
+ import { TFileData } from "../File";
2
+ import { TImageData } from "./Image";
3
+ export interface IUploadImages {
4
+ onChange?: (data: TImageData) => void;
5
+ onClick?: (data: TImageData) => void;
6
+ }
7
+ export type TUploadImageData = TFileData & IUploadImages & {};
8
+ declare const UploadImages: ({ onChange, onClick }: IUploadImages) => JSX.Element;
9
+ export default UploadImages;
@@ -0,0 +1,4 @@
1
+ import UploadImages, { TUploadImageData, IUploadImages } from "./UploadImages";
2
+ import { TImageData } from "./Image";
3
+ export type { TUploadImageData, IUploadImages, TImageData };
4
+ export default UploadImages;
package/lib/index.d.ts CHANGED
@@ -1,9 +1,12 @@
1
- import Form, { useForm } from "./Form";
1
+ import Form, { useForm, FormElement } from "./Form";
2
+ import Element, { IElement } from "./Form/Element";
2
3
  import Input from "./Input";
3
4
  import TextArea from "./TextArea";
4
5
  import Spinner from "./Spinner";
5
6
  import File, { TFileData, TFileMime } from "./File";
7
+ import Button from "./Button";
8
+ import UploadImages, { TUploadImageData, IUploadImages, TImageData } from "./UploadImages";
6
9
  declare const UI: {};
7
- export { Form, useForm, Input, TextArea, Spinner, File };
8
- export type { TFileData, TFileMime };
10
+ export { Form, FormElement, Element, useForm, Input, TextArea, Spinner, File, Button, UploadImages };
11
+ export type { TFileData, TFileMime, TUploadImageData, IUploadImages, TImageData, IElement };
9
12
  export default UI;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-artasys-ui",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -0,0 +1,19 @@
1
+ import React from "react";
2
+ import styles from "./style.module.css";
3
+ import Spinner from "../Spinner";
4
+
5
+ interface IButton extends React.ButtonHTMLAttributes<HTMLButtonElement> {
6
+ wait?: boolean
7
+ }
8
+
9
+ const Button = ({children, wait = false, ...props}: IButton) => {
10
+
11
+ return(<div className={styles['container']}>
12
+ <button {...props}>{children}</button>
13
+ <div className={styles['wait-indicator'] + (wait ? ' ' + styles['active'] : '')}>
14
+ <Spinner size="middle"/>
15
+ </div>
16
+ </div>)
17
+ };
18
+
19
+ export default Button;
@@ -0,0 +1,3 @@
1
+ import Button from "./Button";
2
+
3
+ export default Button;
@@ -0,0 +1,45 @@
1
+ /* Button */
2
+
3
+ .container {
4
+ position: relative;
5
+ border: 1px solid #5EBED6;
6
+ }
7
+
8
+ .container button {
9
+ display: block;
10
+ width: 100%;
11
+ height: 100%;
12
+ background-color: #BED4DB;
13
+ border: 0;
14
+ padding: 5px 8px;
15
+ font-size: 1.1em;
16
+ color: #1D1D1B;
17
+ cursor: pointer;
18
+ border-radius: 0.1em;
19
+ transition: background-color 0.3s;
20
+ }
21
+
22
+ .container button:hover {
23
+ background-color: #ADCED8;
24
+ color: #1D1D1B;
25
+ }
26
+
27
+ .container > .wait-indicator {
28
+ position: absolute;
29
+ display: flex;
30
+ top: 0;
31
+ left: 0;
32
+ width: 100%;
33
+ height: 100%;
34
+ justify-content: center;
35
+ align-items: center;
36
+ background-color: #BED4DB;
37
+ z-index: -1;
38
+ opacity: 0;
39
+ transition: opacity 0.3s;
40
+ }
41
+
42
+ .container > .wait-indicator.active {
43
+ opacity: 1;
44
+ z-index: 1;
45
+ }
@@ -0,0 +1,41 @@
1
+ import { useEffect, useState } from "react";
2
+ import Spinner from "../Spinner";
3
+ import { TFileData } from "../File";
4
+ import styles from "./style.module.css";
5
+
6
+ import { TUploadImageData } from "./UploadImages";
7
+
8
+ export type TImageData = TFileData & {
9
+ setWait: (status: boolean) => void;
10
+ };
11
+
12
+ const Image = ({onChange, onClick, ...props}: TUploadImageData) => {
13
+ const { base64 } = props;
14
+ const [wait, setWait] = useState(true);
15
+
16
+ const handleClick = () => {
17
+ if (typeof onClick === 'function') {
18
+ onClick({
19
+ ...props,
20
+ setWait
21
+ });
22
+ }
23
+ };
24
+
25
+ useEffect(() => {
26
+ if (typeof onChange !== 'function') return;
27
+ onChange({
28
+ ...props,
29
+ setWait
30
+ });
31
+ }, []);
32
+
33
+ return(<span className={styles['image']} onClick={handleClick}>
34
+ <img src={base64 as string}/>
35
+ {wait && <span className={styles['wait']}>
36
+ <Spinner size="small" color="contrast"/>
37
+ </span>}
38
+ </span>);
39
+ };
40
+
41
+ export default Image;
@@ -0,0 +1,31 @@
1
+ import { useState } from "react";
2
+ import File,{
3
+ TFileData
4
+ } from "../File";
5
+ import styles from "./style.module.css";
6
+
7
+ import Image,{
8
+ TImageData
9
+ } from "./Image";
10
+
11
+ export interface IUploadImages {
12
+ onChange?: (data: TImageData) => void;
13
+ onClick?: (data: TImageData) => void;
14
+ };
15
+
16
+ export type TUploadImageData = TFileData & IUploadImages & {};
17
+
18
+ const UploadImages = ({onChange, onClick}: IUploadImages) => {
19
+ const [images, setImages] = useState<TUploadImageData[]>([]);
20
+
21
+ const handleChange = (image: TFileData) => {
22
+ setImages((images) => [...images, {...image, onChange, onClick}]);
23
+ };
24
+
25
+ return(<div className={styles['container']}>
26
+ {images.map((image, index) => <Image key={(image.name + index)} {...image} />)}
27
+ <File onChange={handleChange} accept={['image/png']} className={styles['new']} multiple/>
28
+ </div>);
29
+ };
30
+
31
+ export default UploadImages;
@@ -0,0 +1,13 @@
1
+ import UploadImages,{
2
+ TUploadImageData,
3
+ IUploadImages
4
+ } from "./UploadImages";
5
+ import {
6
+ TImageData
7
+ } from "./Image";
8
+ export type {
9
+ TUploadImageData,
10
+ IUploadImages,
11
+ TImageData
12
+ };
13
+ export default UploadImages;
@@ -0,0 +1,65 @@
1
+ /* UploadImages */
2
+
3
+ .container {
4
+ display: flex;
5
+ flex-direction: row;
6
+ justify-content: flex-start;
7
+ flex-wrap: wrap;
8
+ width: 100%;
9
+ gap: 10px;
10
+ }
11
+
12
+ .image, .new {
13
+ position: relative;
14
+ display: flex;
15
+ justify-content: center;
16
+ align-items: center;
17
+ width: 80px;
18
+ height: 80px;
19
+ border: 1px solid #b1b0b0;
20
+ background-color: #BED4DB;
21
+ border-radius: 3px;
22
+ cursor: pointer;
23
+ transition: scale 0.3s, box-shadow 0.3s;
24
+ }
25
+
26
+ .image:hover, .new:hover {
27
+ scale: 1.03;
28
+ box-shadow: 0px 0px 6px 2px rgb(0 0 0 / 10%);
29
+ }
30
+
31
+ .image:active, .new:active {
32
+ scale: 0.99;
33
+ box-shadow: unset
34
+ }
35
+
36
+ .image > img {
37
+ width: 100%;
38
+ object-fit: cover;
39
+ }
40
+
41
+ .new {
42
+ display: flex;
43
+ justify-content: center;
44
+ align-items: center;
45
+ }
46
+
47
+ .new::after {
48
+ content: "+";
49
+ font-size: 1.9em;
50
+ color: #777777;
51
+ }
52
+
53
+ .wait {
54
+ display: flex;
55
+ position: absolute;
56
+ justify-content: center;
57
+ align-items: center;
58
+ width: 100%;
59
+ height: 100%;
60
+ top: 0;
61
+ left: 0;
62
+ backdrop-filter: blur(2px);
63
+ background-color: #BED4DB9F;
64
+ z-index: 1;
65
+ }
package/src/index.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  import Form,{
2
- useForm
2
+ useForm,
3
+ FormElement
3
4
  } from "./Form";
5
+ import Element,{
6
+ IElement
7
+ } from "./Form/Element";
4
8
  import Input from "./Input";
5
9
  import TextArea from "./TextArea";
6
10
  import Spinner from "./Spinner";
@@ -8,6 +12,12 @@ import File,{
8
12
  TFileData,
9
13
  TFileMime
10
14
  } from "./File";
15
+ import Button from "./Button";
16
+ import UploadImages,{
17
+ TUploadImageData,
18
+ IUploadImages,
19
+ TImageData
20
+ } from "./UploadImages";
11
21
 
12
22
  const UI = {
13
23
 
@@ -15,14 +25,22 @@ const UI = {
15
25
 
16
26
  export {
17
27
  Form,
28
+ FormElement,
29
+ Element,
18
30
  useForm,
19
31
  Input,
20
32
  TextArea,
21
33
  Spinner,
22
- File
34
+ File,
35
+ Button,
36
+ UploadImages
23
37
  };
24
38
  export type {
25
39
  TFileData,
26
- TFileMime
40
+ TFileMime,
41
+ TUploadImageData,
42
+ IUploadImages,
43
+ TImageData,
44
+ IElement
27
45
  };
28
46
  export default UI;