@yourdash/uikit 1.0.3 → 1.0.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.
- package/components/buttonCombo/buttonCombo.module.scss +23 -0
- package/components/buttonCombo/buttonCombo.tsx +14 -0
- package/components/buttonWithIcon/buttonWithIcon.module.scss +0 -1
- package/components/card/card.module.scss +1 -1
- package/components/image/image.tsx +83 -83
- package/components/link/link.module.scss +4 -0
- package/components/link/link.tsx +29 -21
- package/package.json +1 -1
@@ -0,0 +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
|
+
.component {
|
7
|
+
display: flex;
|
8
|
+
flex-direction: row;
|
9
|
+
|
10
|
+
> *:not(:first-child):not(:last-child) {
|
11
|
+
border-radius: 0 !important;
|
12
|
+
}
|
13
|
+
|
14
|
+
> *:first-child {
|
15
|
+
border-top-right-radius: 0 !important;
|
16
|
+
border-bottom-right-radius: 0 !important;
|
17
|
+
}
|
18
|
+
|
19
|
+
> *:last-child {
|
20
|
+
border-top-left-radius: 0 !important;
|
21
|
+
border-bottom-left-radius: 0 !important;
|
22
|
+
}
|
23
|
+
}
|
@@ -0,0 +1,14 @@
|
|
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 clippy from "@yourdash/shared/web/helpers/clippy.ts";
|
7
|
+
import React from "react";
|
8
|
+
import styles from "./buttonCombo.module.scss";
|
9
|
+
|
10
|
+
const ButtonCombo: React.FC<{ children: React.ReactNode[] }> = ({ children }) => {
|
11
|
+
return <div className={clippy(styles.component)}>{children}</div>;
|
12
|
+
};
|
13
|
+
|
14
|
+
export default ButtonCombo;
|
@@ -66,6 +66,7 @@
|
|
66
66
|
}
|
67
67
|
|
68
68
|
.content {
|
69
|
+
box-sizing: border-box;
|
69
70
|
display: flex;
|
70
71
|
flex-direction: column;
|
71
72
|
gap: var(#{$theme+$gap});
|
@@ -74,5 +75,4 @@
|
|
74
75
|
//padding-top: var(#{$theme+$gap});
|
75
76
|
//padding-bottom: var(#{$theme+$gap});
|
76
77
|
height: 100%;
|
77
|
-
width: 100%;
|
78
78
|
}
|
@@ -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;
|
package/components/link/link.tsx
CHANGED
@@ -1,21 +1,29 @@
|
|
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 clippy from "@yourdash/shared/web/helpers/clippy.ts";
|
7
|
-
import
|
8
|
-
import {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
{props.
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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 clippy from "@yourdash/shared/web/helpers/clippy.ts";
|
7
|
+
import Icon from "../icon/icon.tsx";
|
8
|
+
import { UKIcon } from "../icon/iconDictionary.ts";
|
9
|
+
import styles from "./link.module.scss";
|
10
|
+
import { FC } from "react";
|
11
|
+
|
12
|
+
const Link: FC<{ text: string; to: string; className?: string; hideLinkIcon: boolean }> = (props) => {
|
13
|
+
return (
|
14
|
+
<a
|
15
|
+
href={props.to}
|
16
|
+
className={clippy(styles.component, props.className)}
|
17
|
+
>
|
18
|
+
{props.text}
|
19
|
+
{!props.hideLinkIcon && (
|
20
|
+
<Icon
|
21
|
+
icon={UKIcon.Link}
|
22
|
+
className={styles.icon}
|
23
|
+
/>
|
24
|
+
)}
|
25
|
+
</a>
|
26
|
+
);
|
27
|
+
};
|
28
|
+
|
29
|
+
export default Link;
|