@yakad/ui 1.2.7 → 1.2.9

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,9 +1,14 @@
1
1
  import React from "react";
2
2
  interface ButtonProps extends React.HTMLAttributes<HTMLButtonElement> {
3
- variant?: "text" | "outlined" | "filled" | "tonal" | "elevated" | "link";
3
+ loading?: boolean;
4
4
  size?: "small" | "medium" | "large";
5
+ variant?: "text" | "outlined" | "filled" | "tonal" | "elevated" | "link";
5
6
  borderStyle?: "none" | "semi" | "rounded";
6
7
  icon?: JSX.Element;
8
+ iconPosition?: "start" | "end";
9
+ loadingPosition?: "default" | "center";
10
+ loadingVariant?: "scaleOut" | "dots" | "spinner";
11
+ disabled?: boolean;
7
12
  }
8
13
  declare function Button(props: ButtonProps): JSX.Element;
9
14
  export default Button;
package/button/button.js CHANGED
@@ -2,18 +2,24 @@ import React from "react";
2
2
  import { joinClassNames } from "@yakad/lib";
3
3
  import styles from "./button.module.css";
4
4
  import SvgIcon from "../svgIcon/svgIcon";
5
+ import Loading from "../loading/loading";
5
6
  const svgSizeMaps = {
6
7
  small: 2,
7
8
  medium: 2.4,
8
9
  large: 3,
9
10
  };
10
11
  function Button(props) {
11
- const joinedClassNames = joinClassNames(styles.button, props.variant ? styles[props.variant] : styles.text, props.size ? styles[props.size] : styles.medium, props.borderStyle ? styles[props.borderStyle] : styles.rounded, props.icon && !props.children ? styles.iconButton : "", props.className);
12
+ const startChildren = props.iconPosition === "end";
13
+ const centerLoading = !props.icon || (props.loading && props.loadingPosition === "center");
14
+ const joinedClassNames = joinClassNames(styles.button, props.loading ? styles.loading : "", props.variant ? styles[props.variant] : styles.text, props.loading && centerLoading ? styles.loadingPositionCenter : "", props.size ? styles[props.size] : styles.medium, props.borderStyle ? styles[props.borderStyle] : styles.rounded, props.icon && !props.children ? styles.iconButton : "", props.className);
12
15
  return (React.createElement("button", { ...props, className: joinedClassNames },
13
- props.icon ? (React.createElement(SvgIcon, { size: props.size
16
+ startChildren ? props.children : null,
17
+ props.loading ? (React.createElement("div", { className: joinClassNames(centerLoading ? styles.positionCenter : "", styles.displayOnDisabled) },
18
+ React.createElement(Loading, { size: props.size, variant: props.loadingVariant }))) : null,
19
+ props.icon ? (React.createElement(SvgIcon, { className: styles.hideOnDisabled, size: props.size
14
20
  ? svgSizeMaps[props.size]
15
21
  : svgSizeMaps.medium }, props.icon)) : null,
16
- props.children));
22
+ !startChildren ? props.children : null));
17
23
  }
18
24
  export default Button;
19
25
  //# sourceMappingURL=button.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"button.js","sourceRoot":"","sources":["button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,OAAO,MAAM,oBAAoB,CAAC;AAezC,MAAM,WAAW,GAAe;IAC5B,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,GAAG;IACX,KAAK,EAAE,CAAC;CACX,CAAC;AAEF,SAAS,MAAM,CAAC,KAAkB;IAC9B,MAAM,gBAAgB,GAAG,cAAc,CACnC,MAAM,CAAC,MAAM,EACb,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EACnD,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,EAC/C,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,EAC9D,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,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I;QACP,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAClC,CACZ,CAAC;AACN,CAAC;AAED,eAAe,MAAM,CAAC"}
@@ -1,4 +1,5 @@
1
1
  .button {
2
+ position: relative;
2
3
  display: flex;
3
4
  align-items: center;
4
5
  line-height: 3rem;
@@ -88,7 +89,7 @@
88
89
  }
89
90
  .link {
90
91
  background: transparent;
91
- display: block;
92
+ display: flex;
92
93
  position: relative;
93
94
  transition: 0.3s;
94
95
  }
@@ -105,9 +106,39 @@
105
106
  background-color: var(--secondaryColor);
106
107
  transition: 0.3s;
107
108
  }
109
+
108
110
  .link:hover {
109
111
  box-shadow: none;
110
112
  }
111
113
  .link:hover:before {
112
114
  width: calc(100% - var(--padding));
113
115
  }
116
+
117
+ .loadingPositionCenter:disabled {
118
+ color: transparent;
119
+ fill: transparent;
120
+ }
121
+ .positionCenter {
122
+ position: absolute;
123
+ left: 50%;
124
+ transform: translate(-50%);
125
+ }
126
+
127
+ .button:disabled {
128
+ cursor: default;
129
+ box-shadow: none;
130
+ box-shadow: inset 0 0 10rem #7d7d7d20;
131
+ }
132
+ .button.link:disabled:before {
133
+ display: none;
134
+ }
135
+
136
+ .loading .displayOnDisabled {
137
+ display: none;
138
+ }
139
+ .loading:disabled .displayOnDisabled {
140
+ display: block;
141
+ }
142
+ .loading:disabled .hideOnDisabled {
143
+ display: none;
144
+ }
package/button/button.tsx CHANGED
@@ -2,12 +2,18 @@ import React from "react";
2
2
  import { joinClassNames } from "@yakad/lib";
3
3
  import styles from "./button.module.css";
4
4
  import SvgIcon from "../svgIcon/svgIcon";
5
+ import Loading from "../loading/loading";
5
6
 
6
7
  interface ButtonProps extends React.HTMLAttributes<HTMLButtonElement> {
7
- variant?: "text" | "outlined" | "filled" | "tonal" | "elevated" | "link";
8
+ loading?: boolean;
8
9
  size?: "small" | "medium" | "large";
10
+ variant?: "text" | "outlined" | "filled" | "tonal" | "elevated" | "link";
9
11
  borderStyle?: "none" | "semi" | "rounded";
10
12
  icon?: JSX.Element;
13
+ iconPosition?: "start" | "end";
14
+ loadingPosition?: "default" | "center";
15
+ loadingVariant?: "scaleOut" | "dots" | "spinner";
16
+ disabled?: boolean;
11
17
  }
12
18
 
13
19
  interface svgSizeMap {
@@ -23,9 +29,15 @@ const svgSizeMaps: svgSizeMap = {
23
29
  };
24
30
 
25
31
  function Button(props: ButtonProps) {
32
+ const startChildren = props.iconPosition === "end";
33
+ const centerLoading =
34
+ !props.icon || (props.loading && props.loadingPosition === "center");
35
+
26
36
  const joinedClassNames = joinClassNames(
27
37
  styles.button,
38
+ props.loading ? styles.loading : "",
28
39
  props.variant ? styles[props.variant] : styles.text,
40
+ props.loading && centerLoading ? styles.loadingPositionCenter : "",
29
41
  props.size ? styles[props.size] : styles.medium,
30
42
  props.borderStyle ? styles[props.borderStyle] : styles.rounded,
31
43
  props.icon && !props.children ? styles.iconButton : "",
@@ -34,8 +46,20 @@ function Button(props: ButtonProps) {
34
46
 
35
47
  return (
36
48
  <button {...props} className={joinedClassNames}>
49
+ {startChildren ? props.children : null}
50
+ {props.loading ? (
51
+ <div
52
+ className={joinClassNames(
53
+ centerLoading ? styles.positionCenter : "",
54
+ styles.displayOnDisabled
55
+ )}
56
+ >
57
+ <Loading size={props.size} variant={props.loadingVariant} />
58
+ </div>
59
+ ) : null}
37
60
  {props.icon ? (
38
61
  <SvgIcon
62
+ className={styles.hideOnDisabled}
39
63
  size={
40
64
  props.size
41
65
  ? svgSizeMaps[props.size]
@@ -45,7 +69,7 @@ function Button(props: ButtonProps) {
45
69
  {props.icon}
46
70
  </SvgIcon>
47
71
  ) : null}
48
- {props.children}
72
+ {!startChildren ? props.children : null}
49
73
  </button>
50
74
  );
51
75
  }
package/index.tsx CHANGED
@@ -16,6 +16,7 @@ import Row from "./row/row";
16
16
  import Spacer from "./spacer/spacer";
17
17
  import Stack from "./stack/stack";
18
18
  import SvgIcon from "./svgIcon/svgIcon";
19
+ import Loading from "./loading/loading";
19
20
 
20
21
  export {
21
22
  Button,
@@ -36,4 +37,5 @@ export {
36
37
  Stack,
37
38
  Spacer,
38
39
  SvgIcon,
40
+ Loading,
39
41
  };
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ interface LoadingProps extends React.HTMLAttributes<HTMLButtonElement> {
3
+ size?: "small" | "medium" | "large";
4
+ variant?: "scaleOut" | "dots" | "spinner";
5
+ }
6
+ declare function Loading(props: LoadingProps): JSX.Element;
7
+ export default Loading;
@@ -0,0 +1,9 @@
1
+ import styles from "./loading.module.css";
2
+ import { joinClassNames } from "@yakad/lib";
3
+ function Loading(props) {
4
+ const joinedClassNames = joinClassNames(styles.loading, props.size ? styles[props.size] : styles.medium, props.variant ? styles[props.variant] : styles.spinner, props.className);
5
+ return (React.createElement("div", { className: joinedClassNames },
6
+ React.createElement("div", null)));
7
+ }
8
+ export default Loading;
9
+ //# sourceMappingURL=loading.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loading.js","sourceRoot":"","sources":["loading.tsx"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAO5C,SAAS,OAAO,CAAC,KAAmB;IAChC,MAAM,gBAAgB,GAAG,cAAc,CACnC,MAAM,CAAC,OAAO,EACd,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,EAC/C,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,EACtD,KAAK,CAAC,SAAU,CACnB,CAAC;IAEF,OAAO,CACH,6BAAK,SAAS,EAAE,gBAAgB;QAC5B,gCAAW,CACT,CACT,CAAC;AACN,CAAC;AAED,eAAe,OAAO,CAAC"}
@@ -0,0 +1,91 @@
1
+ .small {
2
+ --size: 2rem;
3
+ }
4
+ .medium {
5
+ --size: 2.4rem;
6
+ }
7
+ .large {
8
+ --size: 3rem;
9
+ }
10
+
11
+ .loading {
12
+ display: flex;
13
+ align-items: center;
14
+ justify-content: center;
15
+ width: var(--size);
16
+ height: var(--size);
17
+ box-sizing: border-box;
18
+ --color: #7d7d7d;
19
+ }
20
+ .spinner div {
21
+ display: flex;
22
+ width: 75%;
23
+ height: 75%;
24
+ --spinner-border: calc(var(--size) / 8);
25
+ border-top: var(--spinner-border) solid var(--color);
26
+ border-right: var(--spinner-border) solid transparent;
27
+ border-bottom: none;
28
+ border-left: none;
29
+ border-radius: 50%;
30
+ animation: spinner 1000ms linear infinite;
31
+ }
32
+ @keyframes spinner {
33
+ to {
34
+ transform: rotate(360deg);
35
+ }
36
+ }
37
+
38
+ .dots div {
39
+ width: 20%;
40
+ height: 20%;
41
+ border-radius: 50%;
42
+ background-color: var(--color);
43
+ --dots-space: calc(var(--size) / 3);
44
+ --dots-space-negative: calc(0rem - (var(--size) / 3));
45
+ box-shadow: var(--dots-space) 0 var(--color),
46
+ var(--dots-space-negative) 0 var(--color);
47
+ position: relative;
48
+ animation: flash 0.6s ease-out infinite alternate;
49
+ }
50
+ @keyframes flash {
51
+ 0% {
52
+ background-color: var(--color);
53
+ box-shadow: var(--dots-space) 0 var(--color),
54
+ var(--dots-space-negative) 0 transparent;
55
+ }
56
+ 50% {
57
+ background-color: transparent;
58
+ box-shadow: var(--dots-space) 0 var(--color),
59
+ var(--dots-space-negative) 0 var(--color);
60
+ }
61
+ 100% {
62
+ background-color: var(--color);
63
+ box-shadow: var(--dots-space) 0 transparent,
64
+ var(--dots-space-negative) 0 var(--color);
65
+ }
66
+ }
67
+
68
+ .scaleOut div {
69
+ width: 90%;
70
+ height: 90%;
71
+ border-radius: 50%;
72
+ background-color: var(--color);
73
+ animation: sk-scaleout 1s infinite ease-in-out;
74
+ }
75
+ @keyframes sk-scaleout {
76
+ 0% {
77
+ transform: scale(0);
78
+ opacity: 1;
79
+ }
80
+ 5% {
81
+ transform: scale(0);
82
+ opacity: 1;
83
+ }
84
+ 50% {
85
+ opacity: 0.9;
86
+ }
87
+ 100% {
88
+ transform: scale(1);
89
+ opacity: 0;
90
+ }
91
+ }
@@ -0,0 +1,24 @@
1
+ import styles from "./loading.module.css";
2
+ import { joinClassNames } from "@yakad/lib";
3
+
4
+ interface LoadingProps extends React.HTMLAttributes<HTMLButtonElement> {
5
+ size?: "small" | "medium" | "large";
6
+ variant?: "scaleOut" | "dots" | "spinner";
7
+ }
8
+
9
+ function Loading(props: LoadingProps) {
10
+ const joinedClassNames = joinClassNames(
11
+ styles.loading,
12
+ props.size ? styles[props.size] : styles.medium,
13
+ props.variant ? styles[props.variant] : styles.spinner,
14
+ props.className!
15
+ );
16
+
17
+ return (
18
+ <div className={joinedClassNames}>
19
+ <div></div>
20
+ </div>
21
+ );
22
+ }
23
+
24
+ export default Loading;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yakad/ui",
3
- "version": "1.2.7",
3
+ "version": "1.2.9",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
package/color.css DELETED
@@ -1,34 +0,0 @@
1
- html {
2
- --primaryColor: #222222;
3
- --primaryVariantColor: #303030;
4
- --secondaryColor: #aa8a59;
5
- --secondaryVariantColor: #aa8a59;
6
- --backgroundColor: #ffffff;
7
- --headerColor: #222222;
8
- --surfaceColor: #ffffff;
9
- --errorColor: #b00020;
10
- --onPrimaryColor: #ffffff;
11
- --onSecondaryColor: #000000;
12
- --onBackgroundColor: #000000;
13
- --onHeaderColor: #e9e9e9;
14
- --onSurfaceColor: #000000;
15
- --onErrorColor: #ffffff;
16
- }
17
- @media (prefers-color-scheme: dark) {
18
- html {
19
- --primaryColor: #8955ff;
20
- --primaryVariantColor: #bb86fc;
21
- --secondaryColor: #03dac6;
22
- --secondaryVariantColor: #00d6c2;
23
- --backgroundColor: #121212;
24
- --headerColor: #222222;
25
- --surfaceColor: #1d1d1d;
26
- --errorColor: #cf6679;
27
- --onPrimaryColor: #000000;
28
- --onSecondaryColor: #000000;
29
- --onBackgroundColor: #ffffff;
30
- --onHeaderColor: #e9e9e9;
31
- --onSurfaceColor: #ffffff;
32
- --onErrorColor: #000000;
33
- }
34
- }