@rabbitio/ui-kit 1.0.0-alpha.9 → 1.0.0-beta.10

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,42 @@
1
+ @import "../../../../styles/index";
2
+
3
+ .asset-icon {
4
+ width: 34px;
5
+ height: 34px;
6
+ position: relative;
7
+
8
+ &.small {
9
+ width: 24px;
10
+ height: 24px;
11
+ }
12
+
13
+ &-primary {
14
+ height: 34px;
15
+ width: 34px;
16
+
17
+ &.small {
18
+ width: 24px;
19
+ height: 24px;
20
+ }
21
+ }
22
+
23
+ &-secondary {
24
+ width: 17px;
25
+ height: 17px;
26
+
27
+ position: absolute;
28
+ right: -3px;
29
+ bottom: -3px;
30
+ box-shadow: -2px -2px 4px 1px rgba(SolidColor("dark"), 0.3);
31
+ border-radius: 100%;
32
+
33
+ &.small {
34
+ width: 12px;
35
+ height: 12px;
36
+
37
+ right: -2px;
38
+ bottom: -2px;
39
+ box-shadow: -1px -1px 8px 1px rgba(SolidColor("dark"), 0.3);
40
+ }
41
+ }
42
+ }
@@ -1,4 +1,4 @@
1
- @import "../../../styles/index";
1
+ @import "../../../../styles/index";
2
2
 
3
3
  .loading-dots {
4
4
  display: flex;
@@ -0,0 +1,40 @@
1
+ import { useEffect } from "react";
2
+ import PropTypes from "prop-types";
3
+
4
+ export const SupportChat = ({ url, websiteToken, welcomeMessage = "" }) => {
5
+ useEffect(() => {
6
+ window.chatwootSettings = {
7
+ position: "right",
8
+ type: "standard",
9
+ launcherTitle: welcomeMessage,
10
+ };
11
+ (function (d, t) {
12
+ var BASE_URL = url;
13
+ var g = d.createElement(t),
14
+ s = d.getElementsByTagName(t)[0];
15
+ g.src = BASE_URL + "/packs/js/sdk.js";
16
+ g.defer = true;
17
+ g.async = true;
18
+ s.parentNode.insertBefore(g, s);
19
+ g.onload = function () {
20
+ window.chatwootSDK.run({
21
+ websiteToken: websiteToken,
22
+ baseUrl: BASE_URL,
23
+ });
24
+ };
25
+ })(document, "script");
26
+ // eslint-disable-next-line react-hooks/exhaustive-deps
27
+ }, []);
28
+
29
+ return null;
30
+ };
31
+
32
+ SupportChat.propTypes = {
33
+ url: PropTypes.string.isRequired,
34
+ websiteToken: PropTypes.string.isRequired,
35
+ welcomeMessage: PropTypes.string,
36
+ };
37
+
38
+ SupportChat.defaultProps = {
39
+ welcomeMessage: "",
40
+ };
@@ -1,5 +1,4 @@
1
1
  import React, { useEffect, useRef, useState } from "react";
2
- import { Link } from "react-router-dom";
3
2
  import PropTypes from "prop-types";
4
3
 
5
4
  import styles from "./Button.module.scss";
@@ -9,7 +8,7 @@ import { LoadingDots } from "../../LoadingDots/LoadingDots.jsx";
9
8
  /**
10
9
  * Button component - A versatile and customizable button for React applications.
11
10
  * It supports various sizes, styles, and functionalities, including loaders, icons, and handling of click events.
12
- * This component can also be used as a link when integrated with `react-router-dom`.
11
+ * This component can also be used as a link if "to" is provided.
13
12
  *
14
13
  * @component
15
14
  * @param {Object} props
@@ -108,11 +107,11 @@ export const Button = ({
108
107
  <>
109
108
  {isFormSubmittingButton ? <input type="submit" hidden /> : null}
110
109
  {to ? (
111
- <Link
110
+ <a
112
111
  className={classNames}
113
112
  onClick={(e) => handleError(buttonClick, e)}
114
- to={to}
115
- innerRef={buttonRef}
113
+ href={to}
114
+ ref={buttonRef}
116
115
  >
117
116
  {icon ? (
118
117
  <div
@@ -129,7 +128,7 @@ export const Button = ({
129
128
  ) : (
130
129
  content
131
130
  )}
132
- </Link>
131
+ </a>
133
132
  ) : (
134
133
  <div
135
134
  className={classNames}
@@ -188,6 +187,7 @@ Button.propTypes = {
188
187
  mode: PropTypes.oneOf([
189
188
  "transparent",
190
189
  "white",
190
+ "white-flat",
191
191
  "primary",
192
192
  "primary-bordered",
193
193
  "primary-transparent",
@@ -1,4 +1,4 @@
1
- @import "../../../../styles/index";
1
+ @import "../../../../../styles/index";
2
2
 
3
3
  .button {
4
4
  @extend %text-very-bold;
@@ -122,6 +122,11 @@
122
122
  box-shadow: 0 20px 20px rgba(15, 24, 75, 0.2);
123
123
  }
124
124
 
125
+ &.white-flat {
126
+ background: $white;
127
+ color: SolidColor("dark");
128
+ }
129
+
125
130
  &-primary-dots-wrapper {
126
131
  position: absolute;
127
132
  top: 50%;
package/src/index.js ADDED
@@ -0,0 +1,10 @@
1
+ // UI-KIT components
2
+ export { Button } from "./components/atoms/buttons/Button/Button.jsx";
3
+ export { LoadingDots } from "./components/atoms/LoadingDots/LoadingDots.jsx";
4
+ export { SupportChat } from "./components/atoms/SupportChat/SupportChat.jsx";
5
+ export { AssetIcon } from "./components/atoms/AssetIcon/AssetIcon.jsx";
6
+
7
+ // Common code
8
+ export { improveAndRethrow } from "./common/errorUtils.js";
9
+ export { FiatCurrenciesService } from "./common/fiatCurrenciesService.js";
10
+ export { AmountUtils } from "./common/amountUtils.js";
package/styles/index.scss CHANGED
@@ -3,31 +3,31 @@
3
3
  @import "placeholder";
4
4
 
5
5
  @font-face {
6
- src: url("fonts/NunitoSans-ExtraBold.ttf");
7
- font-family: "NunitoSans";
6
+ //src: url("fonts/NunitoSans-ExtraBold.ttf");
7
+ //font-family: "NunitoSans";
8
8
  font-weight: $extra-bold;
9
9
  }
10
10
 
11
11
  @font-face {
12
- src: url("fonts/NunitoSans-Bold.ttf");
13
- font-family: "NunitoSans";
12
+ //src: url("fonts/NunitoSans-Bold.ttf");
13
+ //font-family: "NunitoSans";
14
14
  font-weight: $bold;
15
15
  }
16
16
 
17
17
  @font-face {
18
- src: url("fonts/NunitoSans-SemiBold.ttf");
19
- font-family: "NunitoSans";
18
+ //src: url("fonts/NunitoSans-SemiBold.ttf");
19
+ //font-family: "NunitoSans";
20
20
  font-weight: 600;
21
21
  }
22
22
 
23
23
  @font-face {
24
- src: url("fonts/NunitoSans-Regular.ttf");
25
- font-family: "NunitoSans";
24
+ //src: url("fonts/NunitoSans-Regular.ttf");
25
+ //font-family: "NunitoSans";
26
26
  font-weight: 400;
27
27
  }
28
28
 
29
29
  @font-face {
30
- src: url("fonts/NunitoSans-Light.ttf");
31
- font-family: "NunitoSans";
30
+ //src: url("fonts/NunitoSans-Light.ttf");
31
+ //font-family: "NunitoSans";
32
32
  font-weight: 300;
33
33
  }
@@ -1,7 +0,0 @@
1
- <svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">
2
- <path d="M19.4926 15.7679V18.5068C19.4926 19.2507 18.8422 19.8534 18.04 19.8534H5.45266C4.65042 19.8534 4 19.2507 4 18.5068V5.84658C4 5.10268 4.65042 4.5 5.45266 4.5H18.04C18.8422 4.5 19.4926 5.10268 19.4926 5.84658V8.92496" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
3
- <path fill-rule="evenodd" clip-rule="evenodd" d="M20.1958 15.4383H15.9518C14.1789 15.4383 12.7422 14.0016 12.7422 12.2287C12.7422 10.4558 14.1789 9.01904 15.9518 9.01904H20.1958C20.6639 9.01904 21.0431 9.39829 21.0431 9.86637V14.5904C21.0431 15.0591 20.6639 15.4383 20.1958 15.4383Z" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
4
- <path d="M4 7.25582H8.04903" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
5
- <path d="M4 17.1181H8.04903" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
6
- <path fill-rule="evenodd" clip-rule="evenodd" d="M17.1414 12.2284C17.1414 12.778 16.6958 13.2229 16.1469 13.2229C15.5972 13.2229 15.1523 12.778 15.1523 12.2284C15.1523 11.6794 15.5972 11.2339 16.1469 11.2339C16.6958 11.2339 17.1414 11.6794 17.1414 12.2284Z" fill="white"/>
7
- </svg>
@@ -1,47 +0,0 @@
1
- // import { LoadingDots } from "./../../../dist/index";
2
- import React from "react";
3
- import { LoadingDots } from "./LoadingDots.jsx";
4
-
5
- export default {
6
- title: "LoadingDots",
7
- component: LoadingDots,
8
- parameters: {
9
- backgrounds: {
10
- default: "dark",
11
- },
12
- },
13
- argTypes: {
14
- size: {
15
- control: {
16
- type: "select",
17
- options: ["big", "small", "extra-small"],
18
- },
19
- },
20
- align: {
21
- control: { type: "select", options: ["left", "right", false] },
22
- },
23
- isColored: { control: { type: "boolean" } },
24
- noMargins: { control: { type: "boolean" } },
25
- },
26
- tags: ["autodocs"],
27
- };
28
-
29
- const Template = (args) => <LoadingDots {...args} />;
30
-
31
- export const Default = Template.bind({});
32
- Default.args = {};
33
-
34
- export const Colored = Template.bind({});
35
- Colored.args = {
36
- isColored: true,
37
- };
38
-
39
- export const NoMargins = Template.bind({});
40
- NoMargins.args = {
41
- noMargins: true,
42
- };
43
-
44
- export const AlignRight = Template.bind({});
45
- AlignRight.args = {
46
- align: "right",
47
- };
@@ -1,289 +0,0 @@
1
- import React from "react";
2
- import { Button } from "./Button.jsx";
3
- import icon from "../../../assets/icons/transactions-icon.svg";
4
-
5
- // import { Button } from "./../../../../dist/web/index";
6
- // const Button = RabbitioUiKit.Button;
7
-
8
- const sizes = ["xl", "lg", "md", "sm"];
9
- const modes = [
10
- "transparent",
11
- "white",
12
- "primary",
13
- "primary-bordered",
14
- "primary-transparent",
15
- "transparent-bordered",
16
- "transparent-without-shadow",
17
- ];
18
-
19
- export default {
20
- title: "Button",
21
- component: Button,
22
- parameters: {
23
- viewport: {
24
- defaultViewport: "reset",
25
- },
26
- backgrounds: {
27
- default: "dark",
28
- },
29
- },
30
- argTypes: {
31
- size: {
32
- control: { type: "select", options: sizes },
33
- },
34
- content: { control: "text" },
35
- className: { table: { disable: true } },
36
- onClick: { table: { disable: true } },
37
- to: { table: { disable: true } },
38
- icon: { table: { disable: true } },
39
- setClickTrigger: { table: { disable: true } },
40
- isFormSubmittingButton: { table: { disable: true } },
41
- propagatePrimaryButtonClick: { table: { disable: true } },
42
- handleError: { table: { disable: true } },
43
- },
44
- tags: ["autodocs"],
45
- };
46
-
47
- const ModeStory = ({ mode }) => (
48
- <>
49
- {sizes.map((size) => (
50
- <div key={size} style={{ marginBottom: "10px" }}>
51
- <Button
52
- size={size}
53
- mode={mode}
54
- content={`${
55
- mode.charAt(0).toUpperCase() + mode.slice(1)
56
- } ${size.toUpperCase()} Button`}
57
- />
58
- </div>
59
- ))}
60
- </>
61
- );
62
-
63
- const Template = (args) => <Button {...args} />;
64
-
65
- export const Default = Template.bind({});
66
- Default.args = { content: "Button" };
67
-
68
- export const Transparent = () => <ModeStory mode="transparent" />;
69
-
70
- export const White = () => <ModeStory mode="white" />;
71
-
72
- export const Primary = () => <ModeStory mode="primary" />;
73
-
74
- export const PrimaryBordered = () => <ModeStory mode="primary-bordered" />;
75
-
76
- export const PrimaryTransparent = () => (
77
- <ModeStory mode="primary-transparent" />
78
- );
79
-
80
- export const TransparentBordered = () => (
81
- <ModeStory mode="transparent-bordered" />
82
- );
83
-
84
- export const TransparentWithoutShadow = () => (
85
- <ModeStory mode="transparent-without-shadow" />
86
- );
87
-
88
- // TODO: [dev] requires fix
89
- // export const LinkButton = () => (
90
- // <>
91
- // <h3>Link Button</h3>
92
- // {sizes.map((size) => (
93
- // <div key={size} style={{ marginBottom: "10px" }}>
94
- // <Button
95
- // size={size}
96
- // mode="primary"
97
- // content={`Link ${size.toUpperCase()} Button`}
98
- // to="/example-path"
99
- // />
100
- // </div>
101
- // ))}
102
- // </>
103
- // );
104
-
105
- export const LoadingButton = () => (
106
- <>
107
- <h3>Loading Button</h3>
108
- {sizes.map((size) => (
109
- <div key={size} style={{ marginBottom: "10px" }}>
110
- <Button
111
- size={size}
112
- mode="primary"
113
- content={`Loading ${size.toUpperCase()} Button`}
114
- loader={true}
115
- loading={true}
116
- />
117
- </div>
118
- ))}
119
- </>
120
- );
121
-
122
- export const IconButton = () => (
123
- <>
124
- <h3>Button with Icon</h3>
125
- {modes.map((mode) => (
126
- <div key={mode} style={{ marginBottom: "20px" }}>
127
- <h4>Mode: {mode.charAt(0).toUpperCase() + mode.slice(1)}</h4>
128
- {sizes.map((size) => (
129
- <div key={size} style={{ marginBottom: "10px" }}>
130
- <Button
131
- size={size}
132
- mode={mode}
133
- icon={icon}
134
- content={`${
135
- mode.charAt(0).toUpperCase() + mode.slice(1)
136
- } ${size.toUpperCase()} Button with Icon`}
137
- />
138
- </div>
139
- ))}
140
- </div>
141
- ))}
142
- </>
143
- );
144
-
145
- export const DisabledButton = () => (
146
- <>
147
- <h3>Disabled Button</h3>
148
- {sizes.map((size) => (
149
- <div
150
- key={size}
151
- style={{
152
- marginBottom: "10px",
153
- display: "flex",
154
- justifyContent: "space-between",
155
- }}
156
- >
157
- <Button
158
- size={size}
159
- mode={"primary"}
160
- content={`${size.toUpperCase()} Button`}
161
- isDisabled={true}
162
- />
163
- <div style={{ marginRight: "10px" }} />
164
- <Button
165
- size={size}
166
- mode={"primary"}
167
- icon={icon}
168
- content={`${size.toUpperCase()} Button with Icon`}
169
- isDisabled={true}
170
- />
171
- </div>
172
- ))}
173
- </>
174
- );
175
-
176
- export const CheckmarkOnClickButton = () => (
177
- <>
178
- <h3>Button with Checkmark on Click</h3>
179
- {modes.map((mode) => (
180
- <div key={mode} style={{ marginBottom: "10px" }}>
181
- <Button
182
- size={"xl"}
183
- mode={mode}
184
- content={`${
185
- mode.charAt(0).toUpperCase() + mode.slice(1)
186
- } XL Button`}
187
- checkmarkOnClick={true}
188
- loader={false}
189
- />
190
- </div>
191
- ))}
192
- </>
193
- );
194
-
195
- export const BigIconButton = () => (
196
- <>
197
- <h3>Button with Big Icon</h3>
198
- {modes.map((mode) => (
199
- <div key={mode} style={{ marginBottom: "20px" }}>
200
- <h4>Mode: {mode.charAt(0).toUpperCase() + mode.slice(1)}</h4>
201
- {sizes.map((size) => (
202
- <div key={size} style={{ marginBottom: "10px" }}>
203
- <Button
204
- size={size}
205
- mode={mode}
206
- icon={icon}
207
- content={`${
208
- mode.charAt(0).toUpperCase() + mode.slice(1)
209
- } ${size.toUpperCase()} Button with Big Icon`}
210
- bigIcon={true}
211
- />
212
- </div>
213
- ))}
214
- </div>
215
- ))}
216
- </>
217
- );
218
-
219
- export const FullWidthOnMobiles = () => (
220
- <>
221
- <h3>Full Width on Mobiles</h3>
222
- {modes.map((mode) => (
223
- <div key={mode} style={{ marginBottom: "10px" }}>
224
- <Button
225
- mode={mode}
226
- content={`Full Width Mobile ${
227
- mode.charAt(0).toUpperCase() + mode.slice(1)
228
- } Button`}
229
- fullWidthOnMobiles={true}
230
- />
231
- </div>
232
- ))}
233
- </>
234
- );
235
- FullWidthOnMobiles.parameters = {
236
- viewport: {
237
- defaultViewport: "iphone14promax",
238
- },
239
- };
240
-
241
- export const FullWidthOnTablets = () => (
242
- <>
243
- <h3>Full Width on Tablets</h3>
244
- {modes.map((mode) => (
245
- <div key={mode} style={{ marginBottom: "10px" }}>
246
- <Button
247
- mode={mode}
248
- content={`Full Width Tablet ${
249
- mode.charAt(0).toUpperCase() + mode.slice(1)
250
- } Button`}
251
- fullWidthOnTablets={true}
252
- />
253
- </div>
254
- ))}
255
- </>
256
- );
257
- FullWidthOnTablets.parameters = {
258
- viewport: {
259
- defaultViewport: "ipad",
260
- },
261
- };
262
-
263
- export const SmallPaddingOnSmallMobilesButton = () => (
264
- <>
265
- <h3>Button with Small Padding on Small Mobiles</h3>
266
- {modes.map((mode) => (
267
- <div key={mode} style={{ marginBottom: "20px" }}>
268
- <h4>Mode: {mode.charAt(0).toUpperCase() + mode.slice(1)}</h4>
269
- {sizes.map((size) => (
270
- <div key={size} style={{ marginBottom: "10px" }}>
271
- <Button
272
- size={size}
273
- mode={mode}
274
- content={`${
275
- mode.charAt(0).toUpperCase() + mode.slice(1)
276
- } ${size.toUpperCase()} Button`}
277
- smallPaddingOnSmallMobiles={true}
278
- />
279
- </div>
280
- ))}
281
- </div>
282
- ))}
283
- </>
284
- );
285
- SmallPaddingOnSmallMobilesButton.parameters = {
286
- viewport: {
287
- defaultViewport: "iphone14",
288
- },
289
- };
package/stories/index.js DELETED
@@ -1,4 +0,0 @@
1
- // export { default as Button } from "./atoms/buttons/Button/Button.jsx";
2
- // export { default as LoadingDots } from "./atoms/LoadingDots/LoadingDots.jsx";
3
- export { Button } from "./atoms/buttons/Button/Button.jsx";
4
- export { LoadingDots } from "./atoms/LoadingDots/LoadingDots.jsx";