@yourdash/uikit 1.0.1 → 1.0.3
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/box/box.module.scss +1 -1
- package/components/box/box.tsx +3 -3
- package/components/button/button.module.scss +3 -3
- package/components/button/button.tsx +2 -1
- package/components/buttonLink/buttonLink.module.scss +5 -1
- package/components/buttonLink/buttonLink.tsx +13 -12
- package/components/buttonWithIcon/buttonWithIcon.module.scss +56 -0
- package/components/buttonWithIcon/buttonWithIcon.tsx +36 -0
- package/components/card/card.module.scss +6 -6
- package/components/card/card.tsx +23 -20
- package/components/container/container.module.scss +20 -0
- package/components/container/container.tsx +22 -0
- package/components/contextMenu/contextMenu.tsx +1 -1
- package/components/contextMenu/contextMenuRoot.module.scss +1 -1
- package/components/contextMenu/contextMenuRoot.tsx +83 -83
- package/components/flex/flex.module.scss +31 -19
- package/components/flex/flex.tsx +23 -2
- package/components/heading/heading.module.scss +1 -1
- package/components/heading/heading.tsx +1 -1
- package/components/icon/icon.tsx +1 -1
- package/components/iconButton/iconButton.module.scss +1 -1
- package/components/iconButton/iconButton.tsx +3 -3
- package/components/image/image.module.scss +72 -1
- package/components/image/image.tsx +65 -10
- package/components/link/link.module.scss +1 -1
- package/components/link/link.tsx +1 -1
- package/components/progressBar/progressBar.module.scss +25 -0
- package/components/progressBar/progressBar.tsx +21 -0
- package/components/redirect/redirect.tsx +1 -1
- package/components/separator/separator.module.scss +9 -4
- package/components/separator/separator.tsx +3 -3
- package/components/spinner/spinner.module.scss +1 -6
- package/components/spinner/spinner.tsx +1 -1
- package/components/subtext/subtext.module.scss +1 -1
- package/components/subtext/subtext.tsx +1 -1
- package/components/tag/tag.module.scss +13 -0
- package/components/tag/tag.tsx +21 -0
- package/components/text/text.module.scss +1 -1
- package/components/text/text.tsx +1 -1
- package/components/textButton/textButton.module.scss +1 -1
- package/components/textButton/textButton.tsx +1 -1
- package/components/textInput/textInput.module.scss +1 -1
- package/components/textInput/textInput.tsx +40 -10
- package/components/toast/toast.module.scss +71 -31
- package/components/toast/toast.ts +12 -0
- package/components/toast/toastAction.ts +12 -0
- package/components/toast/toastContext.ts +5 -3
- package/components/toast/toasts.tsx +99 -0
- package/core/decrementLevel.tsx +13 -13
- package/core/incrementLevel.tsx +1 -1
- package/core/level.tsx +1 -1
- package/core/remToPx.ts +8 -0
- package/core/root.tsx +26 -32
- package/core/toast.ts +18 -17
- package/imports.d.ts +81 -0
- package/package.json +9 -40
- package/theme/defaultTheme.module.scss +16 -4
- package/theme/themeValues.scss +8 -5
- package/tsconfig.json +19 -9
- package/utilityComponent/hasBeenShown/hasBeenShown.tsx +47 -0
- package/utilityComponent/onInView/onInView.tsx +83 -0
- package/views/carousel/carousel.module.scss +77 -0
- package/views/carousel/carousel.tsx +138 -0
- package/views/header/header.module.scss +16 -0
- package/views/header/header.tsx +28 -0
- package/views/infiniteScroll/infiniteScroll.module.scss +26 -0
- package/views/infiniteScroll/infiniteScroll.tsx +90 -0
- package/views/navBar/components/navImage/navImage.module.scss +7 -0
- package/views/navBar/components/navImage/navImage.tsx +15 -0
- package/views/navBar/components/navTitle/navTitle.tsx +13 -0
- package/views/navBar/navBar.module.scss +22 -0
- package/views/navBar/navBar.tsx +37 -0
- package/views/onBoarding/onBoarding.module.scss +84 -0
- package/views/onBoarding/onBoarding.tsx +138 -0
- package/views/panAndZoom/panAndZoom.tsx +121 -114
- package/views/sidebar/Sidebar.module.scss +49 -0
- package/views/sidebar/Sidebar.tsx +30 -0
- package/views/sidebar/SidebarContainer.module.scss +22 -0
- package/views/sidebar/SidebarContainer.tsx +38 -0
- package/views/sidebar/SidebarContext.tsx +15 -0
- package/views/sidebar/SidebarToggleButton.tsx +25 -0
- package/components/toast/toast.tsx +0 -65
package/components/box/box.tsx
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
* YourDash is licensed under the MIT License. (https://ewsgit.mit-license.org)
|
4
4
|
*/
|
5
5
|
|
6
|
-
import clippy from "@yourdash/shared/web/helpers/clippy.
|
6
|
+
import clippy from "@yourdash/shared/web/helpers/clippy.ts";
|
7
7
|
import { FC, ReactNode } from "react";
|
8
|
-
import IncrementLevel from "../../core/incrementLevel.
|
9
|
-
import { useLevel, useLevelClass } from "../../core/level.
|
8
|
+
import IncrementLevel from "../../core/incrementLevel.tsx";
|
9
|
+
import { useLevel, useLevelClass } from "../../core/level.tsx";
|
10
10
|
import styles from "./box.module.scss";
|
11
11
|
|
12
12
|
const Box: FC<{ className?: string; level?: 0 | 1 | 2 | 3; children: ReactNode | ReactNode[] }> = (props) => {
|
@@ -3,12 +3,10 @@
|
|
3
3
|
* YourDash is licensed under the MIT License. (https://ewsgit.mit-license.org)
|
4
4
|
*/
|
5
5
|
|
6
|
-
@
|
6
|
+
@use "@yourdash/uikit/theme/themeValues" as *;
|
7
7
|
|
8
8
|
.component {
|
9
9
|
font-family: var(#{$theme}#{$font}#{$family});
|
10
|
-
text-align: center;
|
11
|
-
min-width: 6rem;
|
12
10
|
padding: 0 var(#{$theme}#{$button}#{$padding}#{$horizontal});
|
13
11
|
color: var(#{$theme}#{$button}#{$color});
|
14
12
|
border: var(#{$theme}#{$button}#{$border});
|
@@ -18,6 +16,8 @@
|
|
18
16
|
height: var(#{$theme+$input+$height});
|
19
17
|
width: max-content;
|
20
18
|
cursor: pointer;
|
19
|
+
padding-left: var(#{$theme+$padding});
|
20
|
+
padding-right: var(#{$theme+$padding});
|
21
21
|
|
22
22
|
&:hover {
|
23
23
|
color: var(#{$theme}#{$button}#{$hover}#{$color});
|
@@ -3,7 +3,7 @@
|
|
3
3
|
* YourDash is licensed under the MIT License. (https://ewsgit.mit-license.org)
|
4
4
|
*/
|
5
5
|
|
6
|
-
import clippy from "@yourdash/shared/web/helpers/clippy.
|
6
|
+
import clippy from "@yourdash/shared/web/helpers/clippy.ts";
|
7
7
|
import styles from "./button.module.scss";
|
8
8
|
import { FC } from "react";
|
9
9
|
|
@@ -14,6 +14,7 @@ const Button: FC<{ onClick: () => void; text: string; className?: string; disabl
|
|
14
14
|
onClick={props.onClick}
|
15
15
|
aria-label={props.text}
|
16
16
|
disabled={props.disabled}
|
17
|
+
type={"button"}
|
17
18
|
>
|
18
19
|
{props.text}
|
19
20
|
</button>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
* YourDash is licensed under the MIT License. (https://ewsgit.mit-license.org)
|
4
4
|
*/
|
5
5
|
|
6
|
-
@
|
6
|
+
@use "@yourdash/uikit/theme/themeValues" as *;
|
7
7
|
|
8
8
|
.component {
|
9
9
|
font-family: var(#{$theme}#{$font}#{$family});
|
@@ -45,3 +45,7 @@
|
|
45
45
|
cursor: not-allowed;
|
46
46
|
}
|
47
47
|
}
|
48
|
+
|
49
|
+
.link {
|
50
|
+
display: inline;
|
51
|
+
}
|
@@ -3,23 +3,24 @@
|
|
3
3
|
* YourDash is licensed under the MIT License. (https://ewsgit.mit-license.org)
|
4
4
|
*/
|
5
5
|
|
6
|
-
import clippy from "@yourdash/shared/web/helpers/clippy.
|
7
|
-
import Button from "../button/button.
|
8
|
-
import {
|
6
|
+
import clippy from "@yourdash/shared/web/helpers/clippy.ts";
|
7
|
+
import Button from "../button/button.tsx";
|
8
|
+
import { useNavigate } from "react-router-dom";
|
9
9
|
import styles from "./buttonLink.module.scss";
|
10
10
|
import { FC } from "react";
|
11
11
|
|
12
12
|
const ButtonLink: FC<{ text: string; to: string; className?: string }> = (props) => {
|
13
|
+
const navigate = useNavigate();
|
14
|
+
|
13
15
|
return (
|
14
|
-
<
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
</Link>
|
16
|
+
<Button
|
17
|
+
onClick={() => {
|
18
|
+
navigate(props.to);
|
19
|
+
return 0;
|
20
|
+
}}
|
21
|
+
text={props.text}
|
22
|
+
className={clippy(styles.component, props.className)}
|
23
|
+
/>
|
23
24
|
);
|
24
25
|
};
|
25
26
|
|
@@ -0,0 +1,56 @@
|
|
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
|
+
@use "@yourdash/uikit/theme/themeValues" as *;
|
7
|
+
|
8
|
+
.component {
|
9
|
+
display: flex;
|
10
|
+
align-items: center;
|
11
|
+
justify-content: center;
|
12
|
+
font-family: var(#{$theme}#{$font}#{$family});
|
13
|
+
text-align: center;
|
14
|
+
min-width: 6rem;
|
15
|
+
padding: 0 var(#{$theme}#{$button}#{$padding}#{$horizontal}) 0 0;
|
16
|
+
color: var(#{$theme}#{$button}#{$color});
|
17
|
+
border: var(#{$theme}#{$button}#{$border});
|
18
|
+
border-radius: var(#{$theme}#{$button}#{$radius});
|
19
|
+
background: var(#{$theme}#{$button}#{$background});
|
20
|
+
transition: var(#{$theme}#{$button}#{$transition});
|
21
|
+
height: var(#{$theme+$input+$height});
|
22
|
+
width: max-content;
|
23
|
+
gap: var(#{$theme+$input+$padding+$horizontal});
|
24
|
+
cursor: pointer;
|
25
|
+
|
26
|
+
&:hover {
|
27
|
+
color: var(#{$theme}#{$button}#{$hover}#{$color});
|
28
|
+
border: var(#{$theme}#{$button}#{$hover}#{$border});
|
29
|
+
border-radius: var(#{$theme}#{$button}#{$hover}#{$radius});
|
30
|
+
background: var(#{$theme}#{$button}#{$hover}#{$background});
|
31
|
+
transition: var(#{$theme}#{$button}#{$hover}#{$transition});
|
32
|
+
}
|
33
|
+
|
34
|
+
&:active {
|
35
|
+
color: var(#{$theme}#{$button}#{$active}#{$color});
|
36
|
+
border: var(#{$theme}#{$button}#{$active}#{$border});
|
37
|
+
border-radius: var(#{$theme}#{$button}#{$active}#{$radius});
|
38
|
+
background: var(#{$theme}#{$button}#{$active}#{$background});
|
39
|
+
transition: var(#{$theme}#{$button}#{$active}#{$transition});
|
40
|
+
}
|
41
|
+
|
42
|
+
&:disabled {
|
43
|
+
opacity: 0.8;
|
44
|
+
|
45
|
+
color: var(#{$theme}#{$button}#{$color});
|
46
|
+
border: var(#{$theme}#{$button}#{$border});
|
47
|
+
border-radius: var(#{$theme}#{$button}#{$radius});
|
48
|
+
background: var(#{$theme}#{$button}#{$background});
|
49
|
+
cursor: not-allowed;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
.icon {
|
54
|
+
margin-left: calc(var(#{$theme}#{$button}#{$padding}#{$horizontal}) / 2);
|
55
|
+
margin-right: calc(var(#{$theme}#{$button}#{$padding}#{$horizontal}) / 4);
|
56
|
+
}
|
@@ -0,0 +1,36 @@
|
|
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 "./buttonWithIcon.module.scss";
|
10
|
+
import { FC } from "react";
|
11
|
+
|
12
|
+
const ButtonWithIcon: FC<{
|
13
|
+
icon: UKIcon;
|
14
|
+
onClick: () => void;
|
15
|
+
text: string;
|
16
|
+
className?: string;
|
17
|
+
disabled?: boolean;
|
18
|
+
}> = (props) => {
|
19
|
+
return (
|
20
|
+
<button
|
21
|
+
className={clippy(styles.component, props.className)}
|
22
|
+
onClick={props.onClick}
|
23
|
+
aria-label={props.text}
|
24
|
+
disabled={props.disabled}
|
25
|
+
>
|
26
|
+
<Icon
|
27
|
+
size={"1.25rem"}
|
28
|
+
className={styles.icon}
|
29
|
+
icon={props.icon}
|
30
|
+
/>
|
31
|
+
{props.text}
|
32
|
+
</button>
|
33
|
+
);
|
34
|
+
};
|
35
|
+
|
36
|
+
export default ButtonWithIcon;
|
@@ -3,7 +3,7 @@
|
|
3
3
|
* YourDash is licensed under the MIT License. (https://ewsgit.mit-license.org)
|
4
4
|
*/
|
5
5
|
|
6
|
-
@
|
6
|
+
@use "@yourdash/uikit/theme/themeValues" as *;
|
7
7
|
|
8
8
|
.component {
|
9
9
|
box-sizing: border-box;
|
@@ -58,12 +58,11 @@
|
|
58
58
|
}
|
59
59
|
|
60
60
|
.actions {
|
61
|
-
border
|
62
|
-
border-right: none;
|
63
|
-
border-bottom: none;
|
61
|
+
border: none;
|
64
62
|
display: flex;
|
65
63
|
align-items: flex-end;
|
66
64
|
width: 100%;
|
65
|
+
background: transparent;
|
67
66
|
}
|
68
67
|
|
69
68
|
.content {
|
@@ -71,8 +70,9 @@
|
|
71
70
|
flex-direction: column;
|
72
71
|
gap: var(#{$theme+$gap});
|
73
72
|
padding: var(#{$theme+$padding});
|
74
|
-
|
75
|
-
padding-
|
73
|
+
// dont remember why this was here but it might be needed again
|
74
|
+
//padding-top: var(#{$theme+$gap});
|
75
|
+
//padding-bottom: var(#{$theme+$gap});
|
76
76
|
height: 100%;
|
77
77
|
width: 100%;
|
78
78
|
}
|
package/components/card/card.tsx
CHANGED
@@ -3,12 +3,13 @@
|
|
3
3
|
* YourDash is licensed under the MIT License. (https://ewsgit.mit-license.org)
|
4
4
|
*/
|
5
5
|
|
6
|
-
import clippy from "@yourdash/shared/web/helpers/clippy.
|
7
|
-
import IncrementLevel from "../../core/incrementLevel.
|
8
|
-
import { useLevel, useLevelClass } from "../../core/level.
|
9
|
-
import Box from "../box/box.
|
6
|
+
import clippy from "@yourdash/shared/web/helpers/clippy.ts";
|
7
|
+
import IncrementLevel from "../../core/incrementLevel.tsx";
|
8
|
+
import { useLevel, useLevelClass } from "../../core/level.tsx";
|
9
|
+
import Box from "../box/box.tsx";
|
10
10
|
import styles from "./card.module.scss";
|
11
11
|
import { FC, Ref } from "react";
|
12
|
+
import DecrementLevel from "../../core/decrementLevel.tsx";
|
12
13
|
|
13
14
|
const Card: FC<{
|
14
15
|
level?: 0 | 1 | 2 | 3;
|
@@ -27,33 +28,35 @@ const Card: FC<{
|
|
27
28
|
if (props.onClick) {
|
28
29
|
return (
|
29
30
|
<>
|
30
|
-
<
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
<IncrementLevel>
|
32
|
+
<button
|
33
|
+
style={props.style}
|
34
|
+
className={clippy(styles.component, useLevelClass(level), props.containerClassName, styles.clickable)}
|
35
|
+
onClick={props.onClick}
|
36
|
+
>
|
36
37
|
{props.header && <Box className={clippy(styles.header, props.headerClassName)}>{props.header}</Box>}
|
37
38
|
<div className={clippy(styles.content, props.className)}>{props.children}</div>
|
38
39
|
{props.actions && <Box className={clippy(styles.actions, props.actionsClassName)}>{props.actions}</Box>}
|
39
|
-
</
|
40
|
-
</
|
40
|
+
</button>
|
41
|
+
</IncrementLevel>
|
41
42
|
</>
|
42
43
|
);
|
43
44
|
}
|
44
45
|
|
45
46
|
return (
|
46
47
|
<>
|
47
|
-
<
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
<IncrementLevel>
|
49
|
+
<div
|
50
|
+
style={props.style}
|
51
|
+
className={clippy(styles.component, useLevelClass(level), props.containerClassName)}
|
52
|
+
>
|
52
53
|
{props.header && <Box className={clippy(styles.header, props.headerClassName)}>{props.header}</Box>}
|
53
54
|
<div className={clippy(styles.content, props.className)}>{props.children}</div>
|
54
|
-
|
55
|
-
|
56
|
-
|
55
|
+
<DecrementLevel>
|
56
|
+
{props.actions && <Box className={clippy(styles.actions, props.actionsClassName)}>{props.actions}</Box>}
|
57
|
+
</DecrementLevel>
|
58
|
+
</div>
|
59
|
+
</IncrementLevel>
|
57
60
|
</>
|
58
61
|
);
|
59
62
|
};
|
@@ -0,0 +1,20 @@
|
|
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
|
+
@use "@yourdash/uikit/theme/themeValues" as *;
|
7
|
+
|
8
|
+
.component {
|
9
|
+
box-sizing: border-box;
|
10
|
+
display: flex;
|
11
|
+
flex-direction: column;
|
12
|
+
|
13
|
+
font-weight: var(#{$theme}#{$font}#{$weight});
|
14
|
+
font-size: var(#{$theme}#{$font}#{$size});
|
15
|
+
font-family: var(#{$theme}#{$font}#{$family});
|
16
|
+
background: var(#{$theme}#{$background});
|
17
|
+
padding: var(#{$theme}#{$padding});
|
18
|
+
border-radius: 0;
|
19
|
+
gap: var(#{$theme}#{$gap});
|
20
|
+
}
|
@@ -0,0 +1,22 @@
|
|
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 { FC, ReactNode } from "react";
|
8
|
+
import IncrementLevel from "../../core/incrementLevel.tsx";
|
9
|
+
import { useLevel, useLevelClass } from "../../core/level.tsx";
|
10
|
+
import styles from "./container.module.scss";
|
11
|
+
|
12
|
+
const Container: FC<{ className?: string; level?: 0 | 1 | 2 | 3; children: ReactNode | ReactNode[] }> = (props) => {
|
13
|
+
const level = props.level || useLevel();
|
14
|
+
|
15
|
+
return (
|
16
|
+
<div className={clippy(styles.component, props.className, useLevelClass(level))}>
|
17
|
+
<IncrementLevel>{props.children}</IncrementLevel>
|
18
|
+
</div>
|
19
|
+
);
|
20
|
+
};
|
21
|
+
|
22
|
+
export default Container;
|
@@ -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 React
|
7
|
-
import { FC, useEffect, useRef } from "react";
|
8
|
-
import Button from "../button/button.
|
9
|
-
import ContextMenuRootContext from "./contextMenuRootContext.
|
10
|
-
import styles from "./contextMenuRoot.module.scss";
|
11
|
-
|
12
|
-
const ContextMenuRoot: FC<{ children: ReactNode | ReactNode[] }> = ({ children }) => {
|
13
|
-
const [position, setPosition] = React.useState({ x: 0, y: 0 });
|
14
|
-
const [visible, setVisible] = React.useState(false);
|
15
|
-
const [items, setItems] = React.useState([] as { label: string; onClick: () => void }[]);
|
16
|
-
const ref = useRef<HTMLDivElement>(null);
|
17
|
-
|
18
|
-
useEffect(() => {
|
19
|
-
window.addEventListener("resize", () => {
|
20
|
-
setVisible(false);
|
21
|
-
});
|
22
|
-
}, []);
|
23
|
-
|
24
|
-
return (
|
25
|
-
<ContextMenuRootContext.Provider
|
26
|
-
value={{
|
27
|
-
createMenu: ({ x, y, width, height, items: i }) => {
|
28
|
-
const screenWidth = window.innerWidth;
|
29
|
-
const screenHeight = window.innerHeight;
|
30
|
-
|
31
|
-
const MENU_WIDTH = ref.current?.getBoundingClientRect().width || 200;
|
32
|
-
const MENU_HEIGHT = ref.current?.getBoundingClientRect().height || 200;
|
33
|
-
|
34
|
-
let resultX = x;
|
35
|
-
let resultY = y;
|
36
|
-
|
37
|
-
if (x + MENU_WIDTH >= screenWidth) {
|
38
|
-
resultX = screenWidth - MENU_WIDTH;
|
39
|
-
}
|
40
|
-
|
41
|
-
if (y + MENU_HEIGHT >= screenHeight) {
|
42
|
-
resultY = screenHeight - MENU_HEIGHT;
|
43
|
-
}
|
44
|
-
|
45
|
-
setPosition({
|
46
|
-
x: resultX,
|
47
|
-
y: resultY,
|
48
|
-
});
|
49
|
-
|
50
|
-
setItems(i);
|
51
|
-
setVisible(true);
|
52
|
-
},
|
53
|
-
destroyMenu: () => {
|
54
|
-
setVisible(false);
|
55
|
-
},
|
56
|
-
}}
|
57
|
-
>
|
58
|
-
<div
|
59
|
-
ref={ref}
|
60
|
-
style={{
|
61
|
-
display: visible ? "flex" : "none",
|
62
|
-
left: position.x,
|
63
|
-
top: position.y,
|
64
|
-
}}
|
65
|
-
className={styles.component}
|
66
|
-
>
|
67
|
-
{items.map((item) => {
|
68
|
-
return (
|
69
|
-
<Button
|
70
|
-
className={styles.button}
|
71
|
-
text={item.label}
|
72
|
-
onClick={item.onClick}
|
73
|
-
key={item.label}
|
74
|
-
/>
|
75
|
-
);
|
76
|
-
})}
|
77
|
-
</div>
|
78
|
-
{children}
|
79
|
-
</ContextMenuRootContext.Provider>
|
80
|
-
);
|
81
|
-
};
|
82
|
-
|
83
|
-
export default ContextMenuRoot;
|
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 React from "react";
|
7
|
+
import { FC, useEffect, useRef } from "react";
|
8
|
+
import Button from "../button/button.tsx";
|
9
|
+
import ContextMenuRootContext from "./contextMenuRootContext.tsx";
|
10
|
+
import styles from "./contextMenuRoot.module.scss";
|
11
|
+
|
12
|
+
const ContextMenuRoot: FC<{ children: React.ReactNode | React.ReactNode[] }> = ({ children }) => {
|
13
|
+
const [position, setPosition] = React.useState({ x: 0, y: 0 });
|
14
|
+
const [visible, setVisible] = React.useState(false);
|
15
|
+
const [items, setItems] = React.useState([] as { label: string; onClick: () => void }[]);
|
16
|
+
const ref = useRef<HTMLDivElement>(null);
|
17
|
+
|
18
|
+
useEffect(() => {
|
19
|
+
window.addEventListener("resize", () => {
|
20
|
+
setVisible(false);
|
21
|
+
});
|
22
|
+
}, []);
|
23
|
+
|
24
|
+
return (
|
25
|
+
<ContextMenuRootContext.Provider
|
26
|
+
value={{
|
27
|
+
createMenu: ({ x, y, width, height, items: i }) => {
|
28
|
+
const screenWidth = window.innerWidth;
|
29
|
+
const screenHeight = window.innerHeight;
|
30
|
+
|
31
|
+
const MENU_WIDTH = ref.current?.getBoundingClientRect().width || 200;
|
32
|
+
const MENU_HEIGHT = ref.current?.getBoundingClientRect().height || 200;
|
33
|
+
|
34
|
+
let resultX = x;
|
35
|
+
let resultY = y;
|
36
|
+
|
37
|
+
if (x + MENU_WIDTH >= screenWidth) {
|
38
|
+
resultX = screenWidth - MENU_WIDTH;
|
39
|
+
}
|
40
|
+
|
41
|
+
if (y + MENU_HEIGHT >= screenHeight) {
|
42
|
+
resultY = screenHeight - MENU_HEIGHT;
|
43
|
+
}
|
44
|
+
|
45
|
+
setPosition({
|
46
|
+
x: resultX,
|
47
|
+
y: resultY,
|
48
|
+
});
|
49
|
+
|
50
|
+
setItems(i);
|
51
|
+
setVisible(true);
|
52
|
+
},
|
53
|
+
destroyMenu: () => {
|
54
|
+
setVisible(false);
|
55
|
+
},
|
56
|
+
}}
|
57
|
+
>
|
58
|
+
<div
|
59
|
+
ref={ref}
|
60
|
+
style={{
|
61
|
+
display: visible ? "flex" : "none",
|
62
|
+
left: position.x,
|
63
|
+
top: position.y,
|
64
|
+
}}
|
65
|
+
className={styles.component}
|
66
|
+
>
|
67
|
+
{items.map((item) => {
|
68
|
+
return (
|
69
|
+
<Button
|
70
|
+
className={styles.button}
|
71
|
+
text={item.label}
|
72
|
+
onClick={item.onClick}
|
73
|
+
key={item.label}
|
74
|
+
/>
|
75
|
+
);
|
76
|
+
})}
|
77
|
+
</div>
|
78
|
+
{children}
|
79
|
+
</ContextMenuRootContext.Provider>
|
80
|
+
);
|
81
|
+
};
|
82
|
+
|
83
|
+
export default ContextMenuRoot;
|
@@ -1,19 +1,31 @@
|
|
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
|
-
@
|
7
|
-
|
8
|
-
.component {
|
9
|
-
display: flex;
|
10
|
-
gap: var(#{$theme}#{$gap});
|
11
|
-
}
|
12
|
-
|
13
|
-
.row {
|
14
|
-
flex-direction: row;
|
15
|
-
}
|
16
|
-
|
17
|
-
.column {
|
18
|
-
flex-direction: column;
|
19
|
-
}
|
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
|
+
@use "@yourdash/uikit/theme/themeValues" as *;
|
7
|
+
|
8
|
+
.component {
|
9
|
+
display: flex;
|
10
|
+
gap: var(#{$theme}#{$gap});
|
11
|
+
}
|
12
|
+
|
13
|
+
.row {
|
14
|
+
flex-direction: row;
|
15
|
+
}
|
16
|
+
|
17
|
+
.column {
|
18
|
+
flex-direction: column;
|
19
|
+
}
|
20
|
+
|
21
|
+
.centerHorizontally {
|
22
|
+
align-items: center;
|
23
|
+
}
|
24
|
+
|
25
|
+
.centerVertically {
|
26
|
+
justify-content: center;
|
27
|
+
}
|
28
|
+
|
29
|
+
.padding {
|
30
|
+
padding: var(#{$theme+$padding});
|
31
|
+
}
|
package/components/flex/flex.tsx
CHANGED
@@ -3,11 +3,32 @@
|
|
3
3
|
* YourDash is licensed under the MIT License. (https://ewsgit.mit-license.org)
|
4
4
|
*/
|
5
5
|
|
6
|
+
import clippy from "@yourdash/shared/web/helpers/clippy.ts";
|
6
7
|
import styles from "./flex.module.scss";
|
7
8
|
import { FC, ReactNode } from "react";
|
8
9
|
|
9
|
-
const Flex: FC<{
|
10
|
-
|
10
|
+
const Flex: FC<{
|
11
|
+
direction: "row" | "column";
|
12
|
+
className?: string;
|
13
|
+
children: ReactNode | ReactNode[];
|
14
|
+
centerHorizontally?: boolean;
|
15
|
+
centerVertically?: boolean;
|
16
|
+
padding?: boolean;
|
17
|
+
}> = (props) => {
|
18
|
+
return (
|
19
|
+
<div
|
20
|
+
className={clippy(
|
21
|
+
styles.component,
|
22
|
+
styles[props.direction],
|
23
|
+
props.className,
|
24
|
+
props.centerHorizontally && styles.centerHorizontally,
|
25
|
+
props.centerVertically && styles.centerVertically,
|
26
|
+
props.padding && styles.padding,
|
27
|
+
)}
|
28
|
+
>
|
29
|
+
{props.children}
|
30
|
+
</div>
|
31
|
+
);
|
11
32
|
};
|
12
33
|
|
13
34
|
export default Flex;
|
@@ -4,7 +4,7 @@
|
|
4
4
|
*/
|
5
5
|
|
6
6
|
import styles from "./heading.module.scss";
|
7
|
-
import clippy from "@yourdash/shared/web/helpers/clippy";
|
7
|
+
import clippy from "@yourdash/shared/web/helpers/clippy.ts";
|
8
8
|
import { FC } from "react";
|
9
9
|
|
10
10
|
const Heading: FC<{ text: string; level?: 1 | 2 | 3 | 4 | 5 | 6; className?: string }> = (props) => {
|