@yourdash/uikit 1.0.10 → 1.0.12
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.
- package/components/buttonWithIcon/buttonWithIcon.module.scss +1 -1
- package/components/buttonWithIcon/buttonWithIcon.tsx +2 -2
- package/components/icon/icon.tsx +16 -4
- package/components/icon/iconDictionary.ts +285 -566
- package/components/iconButton/iconButton.tsx +1 -1
- package/components/image/image.tsx +83 -83
- package/components/textInput/textInput.tsx +2 -2
- package/components/toast/toastAction.ts +12 -12
- package/package.json +1 -1
- package/views/dialog/dialog.tsx +23 -23
- package/views/onBoarding/onBoarding.tsx +143 -138
- package/views/onBoarding/onBoarding.tsx~ +0 -138
@@ -1,83 +1,83 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright ©2024 Ewsgit<https://github.com/ewsgit> and YourDash<https://github.com/yourdash> contributors.
|
3
|
-
* YourDash is licensed under the MIT License. (https://ewsgit.mit-license.org)
|
4
|
-
*/
|
5
|
-
|
6
|
-
import Icon from "../icon/icon.tsx";
|
7
|
-
import { UKIcon } from "../icon/iconDictionary.ts";
|
8
|
-
import styles from "./image.module.scss";
|
9
|
-
import { FC, useEffect, useRef, useState } from "react";
|
10
|
-
import clippy from "@yourdash/shared/web/helpers/clippy.ts";
|
11
|
-
|
12
|
-
const Image: FC<{
|
13
|
-
src: string;
|
14
|
-
accessibleLabel: string;
|
15
|
-
containerClassName?: string;
|
16
|
-
className?: string;
|
17
|
-
disableLazyLoading?: boolean;
|
18
|
-
noRounding?: boolean;
|
19
|
-
width?: number;
|
20
|
-
height?: number;
|
21
|
-
}> = (props) => {
|
22
|
-
const ref = useRef<HTMLDivElement>(null);
|
23
|
-
const [src, setSrc] = useState<string>(props.src);
|
24
|
-
const [loaded, setLoaded] = useState<boolean>(false);
|
25
|
-
const [hasFailed, setHasFailed] = useState<boolean>(false);
|
26
|
-
const [backgroundSize, setBackgroundSize] = useState<number>(0);
|
27
|
-
|
28
|
-
useEffect(() => {
|
29
|
-
const rc = ref.current;
|
30
|
-
|
31
|
-
if (!rc) {
|
32
|
-
return;
|
33
|
-
}
|
34
|
-
|
35
|
-
setTimeout(() => {
|
36
|
-
const bounds = rc.getBoundingClientRect();
|
37
|
-
|
38
|
-
setBackgroundSize(bounds.height > bounds.width ? bounds.height : bounds.width);
|
39
|
-
}, 0);
|
40
|
-
}, [src]);
|
41
|
-
|
42
|
-
useEffect(() => {
|
43
|
-
setHasFailed(false);
|
44
|
-
setLoaded(false);
|
45
|
-
}, [src]);
|
46
|
-
|
47
|
-
useEffect(() => {
|
48
|
-
if (props.src !== src) {
|
49
|
-
setSrc(props.src);
|
50
|
-
}
|
51
|
-
}, [props.src]);
|
52
|
-
|
53
|
-
return (
|
54
|
-
<div
|
55
|
-
ref={ref}
|
56
|
-
className={clippy(styles.componentContainer, props.containerClassName, !loaded && styles.loading, hasFailed && styles.serverError)}
|
57
|
-
style={{
|
58
|
-
// @ts-ignore
|
59
|
-
"--background-size": backgroundSize + "px",
|
60
|
-
}}
|
61
|
-
>
|
62
|
-
{!hasFailed ? (
|
63
|
-
<img
|
64
|
-
className={clippy(styles.component, props.className, loaded && styles.loaded, props.noRounding && styles.noRounding)}
|
65
|
-
draggable={false}
|
66
|
-
width={props.width}
|
67
|
-
height={props.height}
|
68
|
-
onError={() => setHasFailed(true)}
|
69
|
-
loading={props.disableLazyLoading ? "eager" : "lazy"}
|
70
|
-
alt={props.accessibleLabel}
|
71
|
-
onLoad={(e) => {
|
72
|
-
setLoaded(e.currentTarget.complete);
|
73
|
-
}}
|
74
|
-
src={src}
|
75
|
-
/>
|
76
|
-
) : (
|
77
|
-
<Icon icon={UKIcon.ServerError} />
|
78
|
-
)}
|
79
|
-
</div>
|
80
|
-
);
|
81
|
-
};
|
82
|
-
|
83
|
-
export default Image;
|
1
|
+
/*
|
2
|
+
* Copyright ©2024 Ewsgit<https://github.com/ewsgit> and YourDash<https://github.com/yourdash> contributors.
|
3
|
+
* YourDash is licensed under the MIT License. (https://ewsgit.mit-license.org)
|
4
|
+
*/
|
5
|
+
|
6
|
+
import Icon from "../icon/icon.tsx";
|
7
|
+
import { UKIcon } from "../icon/iconDictionary.ts";
|
8
|
+
import styles from "./image.module.scss";
|
9
|
+
import { FC, useEffect, useRef, useState } from "react";
|
10
|
+
import clippy from "@yourdash/shared/web/helpers/clippy.ts";
|
11
|
+
|
12
|
+
const Image: FC<{
|
13
|
+
src: string;
|
14
|
+
accessibleLabel: string;
|
15
|
+
containerClassName?: string;
|
16
|
+
className?: string;
|
17
|
+
disableLazyLoading?: boolean;
|
18
|
+
noRounding?: boolean;
|
19
|
+
width?: number;
|
20
|
+
height?: number;
|
21
|
+
}> = (props) => {
|
22
|
+
const ref = useRef<HTMLDivElement>(null);
|
23
|
+
const [src, setSrc] = useState<string>(props.src);
|
24
|
+
const [loaded, setLoaded] = useState<boolean>(false);
|
25
|
+
const [hasFailed, setHasFailed] = useState<boolean>(false);
|
26
|
+
const [backgroundSize, setBackgroundSize] = useState<number>(0);
|
27
|
+
|
28
|
+
useEffect(() => {
|
29
|
+
const rc = ref.current;
|
30
|
+
|
31
|
+
if (!rc) {
|
32
|
+
return;
|
33
|
+
}
|
34
|
+
|
35
|
+
setTimeout(() => {
|
36
|
+
const bounds = rc.getBoundingClientRect();
|
37
|
+
|
38
|
+
setBackgroundSize(bounds.height > bounds.width ? bounds.height : bounds.width);
|
39
|
+
}, 0);
|
40
|
+
}, [src]);
|
41
|
+
|
42
|
+
useEffect(() => {
|
43
|
+
setHasFailed(false);
|
44
|
+
setLoaded(false);
|
45
|
+
}, [src]);
|
46
|
+
|
47
|
+
useEffect(() => {
|
48
|
+
if (props.src !== src) {
|
49
|
+
setSrc(props.src);
|
50
|
+
}
|
51
|
+
}, [props.src]);
|
52
|
+
|
53
|
+
return (
|
54
|
+
<div
|
55
|
+
ref={ref}
|
56
|
+
className={clippy(styles.componentContainer, props.containerClassName, !loaded && styles.loading, hasFailed && styles.serverError)}
|
57
|
+
style={{
|
58
|
+
// @ts-ignore
|
59
|
+
"--background-size": backgroundSize + "px",
|
60
|
+
}}
|
61
|
+
>
|
62
|
+
{!hasFailed ? (
|
63
|
+
<img
|
64
|
+
className={clippy(styles.component, props.className, loaded && styles.loaded, props.noRounding && styles.noRounding)}
|
65
|
+
draggable={false}
|
66
|
+
width={props.width}
|
67
|
+
height={props.height}
|
68
|
+
onError={() => setHasFailed(true)}
|
69
|
+
loading={props.disableLazyLoading ? "eager" : "lazy"}
|
70
|
+
alt={props.accessibleLabel}
|
71
|
+
onLoad={(e) => {
|
72
|
+
setLoaded(e.currentTarget.complete);
|
73
|
+
}}
|
74
|
+
src={src}
|
75
|
+
/>
|
76
|
+
) : (
|
77
|
+
<Icon icon={UKIcon.ServerError} />
|
78
|
+
)}
|
79
|
+
</div>
|
80
|
+
);
|
81
|
+
};
|
82
|
+
|
83
|
+
export default Image;
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
import clippy from "@yourdash/shared/web/helpers/clippy.ts";
|
7
7
|
import Icon from "../icon/icon.tsx";
|
8
|
-
import {
|
8
|
+
import { UKIconType } from "../icon/iconDictionary.ts";
|
9
9
|
import styles from "./textInput.module.scss";
|
10
10
|
import React, { useEffect, useRef, useState } from "react";
|
11
11
|
|
@@ -15,7 +15,7 @@ const TextInputComponent: React.FC<{
|
|
15
15
|
onChange?: (value: string) => void;
|
16
16
|
onSubmit?: (value: string) => void;
|
17
17
|
placeholder: string;
|
18
|
-
icon?:
|
18
|
+
icon?: UKIconType;
|
19
19
|
onEnter?: (value: string) => void;
|
20
20
|
defaultValue?: string;
|
21
21
|
value?: string;
|
@@ -1,12 +1,12 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright ©2024 Ewsgit<https://ewsgit.uk> and YourDash<https://yourdash.ewsgit.uk> contributors.
|
3
|
-
* YourDash is licensed under the MIT License. (https://mit.ewsgit.uk)
|
4
|
-
*/
|
5
|
-
|
6
|
-
import {
|
7
|
-
|
8
|
-
export default interface IToastAction {
|
9
|
-
label: string;
|
10
|
-
icon?:
|
11
|
-
onClick: () => void;
|
12
|
-
}
|
1
|
+
/*
|
2
|
+
* Copyright ©2024 Ewsgit<https://ewsgit.uk> and YourDash<https://yourdash.ewsgit.uk> contributors.
|
3
|
+
* YourDash is licensed under the MIT License. (https://mit.ewsgit.uk)
|
4
|
+
*/
|
5
|
+
|
6
|
+
import { UKIconType } from "../icon/iconDictionary.ts";
|
7
|
+
|
8
|
+
export default interface IToastAction {
|
9
|
+
label: string;
|
10
|
+
icon?: UKIconType;
|
11
|
+
onClick: () => void;
|
12
|
+
}
|
package/package.json
CHANGED
package/views/dialog/dialog.tsx
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright ©2024 Ewsgit <https://ewsgit.uk> and YourDash <https://yourdash.ewsgit.uk> contributors.
|
3
|
-
* YourDash is licensed under the MIT License. (https://mit.ewsgit.uk)
|
4
|
-
*/
|
5
|
-
|
6
|
-
import React from "react";
|
7
|
-
import Card from "../../components/card/card.tsx";
|
8
|
-
import styles from "./dialog.module.scss";
|
9
|
-
|
10
|
-
const Dialog: React.FC<{ children: React.ReactNode | React.ReactNode[]; className?: string }> = ({ children, className }) => {
|
11
|
-
return (
|
12
|
-
<div className={styles.background}>
|
13
|
-
<Card
|
14
|
-
containerClassName={styles.view}
|
15
|
-
className={className}
|
16
|
-
>
|
17
|
-
{children}
|
18
|
-
</Card>
|
19
|
-
</div>
|
20
|
-
);
|
21
|
-
};
|
22
|
-
|
23
|
-
export default Dialog;
|
1
|
+
/*
|
2
|
+
* Copyright ©2024 Ewsgit <https://ewsgit.uk> and YourDash <https://yourdash.ewsgit.uk> contributors.
|
3
|
+
* YourDash is licensed under the MIT License. (https://mit.ewsgit.uk)
|
4
|
+
*/
|
5
|
+
|
6
|
+
import React from "react";
|
7
|
+
import Card from "../../components/card/card.tsx";
|
8
|
+
import styles from "./dialog.module.scss";
|
9
|
+
|
10
|
+
const Dialog: React.FC<{ children: React.ReactNode | React.ReactNode[]; className?: string }> = ({ children, className }) => {
|
11
|
+
return (
|
12
|
+
<div className={styles.background}>
|
13
|
+
<Card
|
14
|
+
containerClassName={styles.view}
|
15
|
+
className={className}
|
16
|
+
>
|
17
|
+
{children}
|
18
|
+
</Card>
|
19
|
+
</div>
|
20
|
+
);
|
21
|
+
};
|
22
|
+
|
23
|
+
export default Dialog;
|
@@ -1,138 +1,143 @@
|
|
1
|
-
import * as React from "react";
|
2
|
-
import Card from "../../components/card/card.tsx";
|
3
|
-
import { UKIcon } from "../../components/icon/iconDictionary.ts";
|
4
|
-
import IconButton from "../../components/iconButton/iconButton.tsx";
|
5
|
-
import Image from "../../components/image/image.tsx";
|
6
|
-
import Heading from "../../components/heading/heading.tsx";
|
7
|
-
import Text from "../../components/text/text.tsx";
|
8
|
-
import ButtonWithIcon from "../../components/buttonWithIcon/buttonWithIcon.tsx";
|
9
|
-
import Button from "../../components/button/button.tsx";
|
10
|
-
import { Outlet } from "react-router";
|
11
|
-
import styles from "./onBoarding.module.scss";
|
12
|
-
import Flex from "../../components/flex/flex.tsx";
|
13
|
-
import clippy from "@yourdash/shared/web/helpers/clippy.ts";
|
14
|
-
|
15
|
-
const OnBoarding: React.FC<{
|
16
|
-
meta: { id: string };
|
17
|
-
pages: {
|
18
|
-
headerImage: string;
|
19
|
-
header: string;
|
20
|
-
body: string;
|
21
|
-
actions: {
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
}
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
<
|
56
|
-
className={styles.
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
break;
|
88
|
-
case "
|
89
|
-
setCurrentPage(
|
90
|
-
break;
|
91
|
-
|
92
|
-
break;
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
break;
|
120
|
-
case "
|
121
|
-
setCurrentPage(
|
122
|
-
break;
|
123
|
-
|
124
|
-
break;
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
}
|
137
|
-
|
138
|
-
|
1
|
+
import * as React from "react";
|
2
|
+
import Card from "../../components/card/card.tsx";
|
3
|
+
import { UKIcon, UKIconType } from "../../components/icon/iconDictionary.ts";
|
4
|
+
import IconButton from "../../components/iconButton/iconButton.tsx";
|
5
|
+
import Image from "../../components/image/image.tsx";
|
6
|
+
import Heading from "../../components/heading/heading.tsx";
|
7
|
+
import Text from "../../components/text/text.tsx";
|
8
|
+
import ButtonWithIcon from "../../components/buttonWithIcon/buttonWithIcon.tsx";
|
9
|
+
import Button from "../../components/button/button.tsx";
|
10
|
+
import { Outlet } from "react-router";
|
11
|
+
import styles from "./onBoarding.module.scss";
|
12
|
+
import Flex from "../../components/flex/flex.tsx";
|
13
|
+
import clippy from "@yourdash/shared/web/helpers/clippy.ts";
|
14
|
+
|
15
|
+
const OnBoarding: React.FC<{
|
16
|
+
meta: { id: string };
|
17
|
+
pages: {
|
18
|
+
headerImage: string;
|
19
|
+
header: string;
|
20
|
+
body: string;
|
21
|
+
actions: {
|
22
|
+
label: string;
|
23
|
+
icon?: UKIconType;
|
24
|
+
onClick: () => void;
|
25
|
+
changeTo?: "next" | "previous" | "remain" | "completed";
|
26
|
+
}[];
|
27
|
+
allowGoBack?: boolean;
|
28
|
+
}[];
|
29
|
+
}> = ({ pages, meta }) => {
|
30
|
+
const [currentPage, setCurrentPage] = React.useState<number>(0);
|
31
|
+
const page = pages[currentPage];
|
32
|
+
|
33
|
+
if (localStorage.getItem(`yourdash-application-visited-${meta.id}`) || currentPage > pages.length - 1) {
|
34
|
+
localStorage.setItem(`yourdash-application-visited-${meta.id}`, "true");
|
35
|
+
|
36
|
+
return <Outlet />;
|
37
|
+
}
|
38
|
+
|
39
|
+
return (
|
40
|
+
<div className={styles.page}>
|
41
|
+
<Card
|
42
|
+
className={styles.card}
|
43
|
+
containerClassName={styles.cardContainer}
|
44
|
+
>
|
45
|
+
{page.allowGoBack && (
|
46
|
+
<IconButton
|
47
|
+
className={clippy(styles.goBackButton, "animate__animated animate__fadeInDown")}
|
48
|
+
accessibleLabel="Go back to the last page"
|
49
|
+
icon={UKIcon.ChevronLeft}
|
50
|
+
onClick={() => {
|
51
|
+
setCurrentPage(currentPage - 1);
|
52
|
+
}}
|
53
|
+
/>
|
54
|
+
)}
|
55
|
+
<Image
|
56
|
+
className={styles.headerImage}
|
57
|
+
src={page.headerImage}
|
58
|
+
accessibleLabel=""
|
59
|
+
/>
|
60
|
+
<Heading
|
61
|
+
className={styles.header}
|
62
|
+
text={page.header}
|
63
|
+
/>
|
64
|
+
<Text
|
65
|
+
className={styles.body}
|
66
|
+
text={page.body}
|
67
|
+
/>
|
68
|
+
<Flex
|
69
|
+
className={styles.actions}
|
70
|
+
direction="row"
|
71
|
+
>
|
72
|
+
{page.actions.map((action) => {
|
73
|
+
if (action.icon) {
|
74
|
+
return (
|
75
|
+
<>
|
76
|
+
<ButtonWithIcon
|
77
|
+
key={action.label}
|
78
|
+
className={clippy(styles.action, styles.actionWithIcon, "animate__animated animate__fadeInUp")}
|
79
|
+
text={action.label}
|
80
|
+
icon={action.icon}
|
81
|
+
onClick={() => {
|
82
|
+
action.onClick();
|
83
|
+
if (action.changeTo) {
|
84
|
+
switch (action.changeTo) {
|
85
|
+
case "next":
|
86
|
+
setCurrentPage(currentPage + 1);
|
87
|
+
break;
|
88
|
+
case "previous":
|
89
|
+
if (currentPage > 0) setCurrentPage(currentPage - 1);
|
90
|
+
break;
|
91
|
+
case "remain":
|
92
|
+
break;
|
93
|
+
case "completed":
|
94
|
+
setCurrentPage(pages.length + 1);
|
95
|
+
break;
|
96
|
+
default:
|
97
|
+
break;
|
98
|
+
}
|
99
|
+
}
|
100
|
+
}}
|
101
|
+
/>
|
102
|
+
</>
|
103
|
+
);
|
104
|
+
}
|
105
|
+
|
106
|
+
return (
|
107
|
+
<>
|
108
|
+
<Button
|
109
|
+
key={action.icon}
|
110
|
+
className={clippy(styles.action, styles.actionWithoutIcon, "animate__animated animate__fadeInUp")}
|
111
|
+
text={action.label}
|
112
|
+
onClick={() => {
|
113
|
+
action.onClick();
|
114
|
+
|
115
|
+
if (action.changeTo) {
|
116
|
+
switch (action.changeTo) {
|
117
|
+
case "next":
|
118
|
+
setCurrentPage(currentPage + 1);
|
119
|
+
break;
|
120
|
+
case "previous":
|
121
|
+
if (currentPage > 0) setCurrentPage(currentPage - 1);
|
122
|
+
break;
|
123
|
+
case "remain":
|
124
|
+
break;
|
125
|
+
case "completed":
|
126
|
+
setCurrentPage(pages.length + 1);
|
127
|
+
break;
|
128
|
+
default:
|
129
|
+
break;
|
130
|
+
}
|
131
|
+
}
|
132
|
+
}}
|
133
|
+
/>
|
134
|
+
</>
|
135
|
+
);
|
136
|
+
})}
|
137
|
+
</Flex>
|
138
|
+
</Card>
|
139
|
+
</div>
|
140
|
+
);
|
141
|
+
};
|
142
|
+
|
143
|
+
export default OnBoarding;
|