athameui 0.0.11 → 0.0.13
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/Button/Button.tsx +0 -1
- package/components/Carousel/Carousel.tsx +68 -34
- package/components/FormField/FormField.tsx +1 -0
- package/components/Layout/Main.tsx +11 -2
- package/components/Modal/Modal.tsx +2 -2
- package/dist/athameui.cjs +248 -245
- package/dist/athameui.cjs.map +1 -1
- package/dist/athameui.mjs +244 -230
- package/dist/athameui.mjs.map +1 -1
- package/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/components/Carousel/Carousel.d.ts +2 -1
- package/dist/components/Carousel/Carousel.d.ts.map +1 -1
- package/dist/components/FormField/FormField.d.ts.map +1 -1
- package/dist/components/Layout/Main.d.ts +2 -1
- package/dist/components/Layout/Main.d.ts.map +1 -1
- package/dist/styles/components/carousel.css +17 -6
- package/dist/styles/components/form-input.css +29 -8
- package/dist/styles/components/main.css +17 -2
- package/dist/styles/index.d.ts +0 -1
- package/dist/styles/index.d.ts.map +1 -1
- package/dist/styles/index.ts +0 -1
- package/dist/styles/tokens.css +16 -20
- package/dist/styles/tokens.d.ts +209 -26
- package/dist/styles/tokens.d.ts.map +1 -1
- package/dist/styles/tokens.ts +190 -165
- package/package.json +1 -1
- package/styles/components/carousel.css +17 -6
- package/styles/components/form-input.css +29 -8
- package/styles/components/main.css +17 -2
- package/styles/index.ts +0 -1
- package/styles/tokens.css +16 -20
- package/styles/tokens.ts +190 -165
- package/dist/styles/breakpoints.d.ts +0 -29
- package/dist/styles/breakpoints.d.ts.map +0 -1
- package/dist/styles/breakpoints.ts +0 -34
- package/styles/breakpoints.ts +0 -34
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Children,
|
|
3
|
+
useState,
|
|
4
|
+
useRef,
|
|
5
|
+
useLayoutEffect,
|
|
6
|
+
type ReactNode,
|
|
7
|
+
} from "react";
|
|
2
8
|
import { CSSObject } from "@emotion/react";
|
|
3
9
|
import { cx } from "../../utils/cx";
|
|
4
10
|
import { Button } from "../Button/Button";
|
|
11
|
+
import { FormLabel } from "../FormLabel/FormLabel";
|
|
5
12
|
import { HugeiconsIcon } from "@hugeicons/react";
|
|
6
13
|
import { ArrowLeftIcon, ArrowRightIcon } from "@hugeicons/core-free-icons";
|
|
7
14
|
|
|
@@ -11,6 +18,7 @@ export type CarouselProps = {
|
|
|
11
18
|
carousel?: string | false | null | undefined;
|
|
12
19
|
};
|
|
13
20
|
emptyMessage?: string;
|
|
21
|
+
label?: string;
|
|
14
22
|
sx?: {
|
|
15
23
|
carousel?: CSSObject;
|
|
16
24
|
};
|
|
@@ -19,17 +27,36 @@ export type CarouselProps = {
|
|
|
19
27
|
export const Carousel = ({
|
|
20
28
|
children,
|
|
21
29
|
className,
|
|
22
|
-
emptyMessage,
|
|
30
|
+
emptyMessage = "Nothing here yet",
|
|
31
|
+
label,
|
|
23
32
|
sx,
|
|
24
33
|
}: CarouselProps) => {
|
|
25
34
|
const [isHovered, setIsHovered] = useState(false);
|
|
35
|
+
const [showLeftArrow, setShowLeftArrow] = useState(false);
|
|
36
|
+
const [showRightArrow, setShowRightArrow] = useState(false);
|
|
26
37
|
const carouselRef = useRef<HTMLDivElement>(null);
|
|
27
|
-
const carouselClasses = cx(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
const carouselClasses = cx("ath-carousel", className?.carousel);
|
|
39
|
+
const itemCount = Children.count(children);
|
|
40
|
+
|
|
41
|
+
useLayoutEffect(() => {
|
|
42
|
+
const el = carouselRef.current;
|
|
43
|
+
if (!el) return;
|
|
44
|
+
|
|
45
|
+
const updateArrows = () => {
|
|
46
|
+
const hidden = el.scrollWidth - el.clientWidth;
|
|
47
|
+
setShowLeftArrow(el.scrollLeft > 1);
|
|
48
|
+
setShowRightArrow(hidden - el.scrollLeft > 1);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
updateArrows();
|
|
52
|
+
el.addEventListener("scroll", updateArrows, { passive: true });
|
|
53
|
+
const observer = new ResizeObserver(updateArrows);
|
|
54
|
+
observer.observe(el);
|
|
55
|
+
return () => {
|
|
56
|
+
el.removeEventListener("scroll", updateArrows);
|
|
57
|
+
observer.disconnect();
|
|
58
|
+
};
|
|
59
|
+
}, [itemCount]);
|
|
33
60
|
|
|
34
61
|
const scrollByPage = (direction: -1 | 1) => {
|
|
35
62
|
const el = carouselRef.current;
|
|
@@ -40,13 +67,6 @@ export const Carousel = ({
|
|
|
40
67
|
});
|
|
41
68
|
};
|
|
42
69
|
|
|
43
|
-
const handleLeftArrowClick = () => {
|
|
44
|
-
scrollByPage(-1);
|
|
45
|
-
};
|
|
46
|
-
const handleRightArrowClick = () => {
|
|
47
|
-
scrollByPage(1);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
70
|
const handleMouseEnter = () => {
|
|
51
71
|
setIsHovered(true);
|
|
52
72
|
};
|
|
@@ -55,29 +75,43 @@ export const Carousel = ({
|
|
|
55
75
|
};
|
|
56
76
|
|
|
57
77
|
return (
|
|
58
|
-
<div
|
|
78
|
+
<div
|
|
79
|
+
className="ath-carousel-container"
|
|
80
|
+
style={{ minWidth: itemCount === 1 ? "" : 0 }}
|
|
81
|
+
>
|
|
82
|
+
{label && <FormLabel label={label} dark />}
|
|
59
83
|
<div
|
|
60
|
-
className={
|
|
61
|
-
|
|
84
|
+
className={cx(
|
|
85
|
+
"ath-carousel-wrapper",
|
|
86
|
+
isHovered && "ath-carousel-hover",
|
|
87
|
+
label && "ath-carousel-label",
|
|
88
|
+
)}
|
|
62
89
|
onMouseEnter={handleMouseEnter}
|
|
63
90
|
onMouseLeave={handleMouseLeave}
|
|
64
|
-
ref={carouselRef}
|
|
65
91
|
>
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
{
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
92
|
+
{showLeftArrow && (
|
|
93
|
+
<Button
|
|
94
|
+
className={{ button: "ath-carousel-arrow ath-carousel-left-arrow" }}
|
|
95
|
+
onClick={() => scrollByPage(-1)}
|
|
96
|
+
icon={<HugeiconsIcon icon={ArrowLeftIcon} size={36} />}
|
|
97
|
+
/>
|
|
98
|
+
)}
|
|
99
|
+
<div className={carouselClasses} css={sx?.carousel} ref={carouselRef}>
|
|
100
|
+
{itemCount > 0 ? (
|
|
101
|
+
children
|
|
102
|
+
) : (
|
|
103
|
+
<div className="ath-carousel-empty">{emptyMessage}</div>
|
|
104
|
+
)}
|
|
105
|
+
</div>
|
|
106
|
+
{showRightArrow && (
|
|
107
|
+
<Button
|
|
108
|
+
className={{
|
|
109
|
+
button: "ath-carousel-arrow ath-carousel-right-arrow",
|
|
110
|
+
}}
|
|
111
|
+
onClick={() => scrollByPage(1)}
|
|
112
|
+
icon={<HugeiconsIcon icon={ArrowRightIcon} size={36} />}
|
|
113
|
+
/>
|
|
114
|
+
)}
|
|
81
115
|
</div>
|
|
82
116
|
</div>
|
|
83
117
|
);
|
|
@@ -92,6 +92,7 @@ export const FormField: React.FC<FormFieldProps> = ({
|
|
|
92
92
|
|
|
93
93
|
const containerClasses = cx(
|
|
94
94
|
"ath-form-input-container",
|
|
95
|
+
readOnly && "ath-form-input-container-readonly",
|
|
95
96
|
(labelPosition === "left" || labelPosition === "right") &&
|
|
96
97
|
"ath-form-input-container-horizontal",
|
|
97
98
|
className?.container ? className.container : "",
|
|
@@ -8,14 +8,19 @@ type MainProps = {
|
|
|
8
8
|
main?: string | false | null | undefined;
|
|
9
9
|
mainContent?: string | false | null | undefined;
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
width?: "full" | "wide" | "medium" | "narrow";
|
|
12
12
|
sx?: {
|
|
13
13
|
main?: CSSObject;
|
|
14
14
|
mainContent?: CSSObject;
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
export const Main = ({
|
|
18
|
+
export const Main = ({
|
|
19
|
+
children,
|
|
20
|
+
className,
|
|
21
|
+
sx,
|
|
22
|
+
width = "wide",
|
|
23
|
+
}: MainProps) => {
|
|
19
24
|
const mainClasses = cx(
|
|
20
25
|
"ath-main",
|
|
21
26
|
typeof className === "object" && className !== null ? className.main : "",
|
|
@@ -26,6 +31,10 @@ export const Main = ({ children, className, sx }: MainProps) => {
|
|
|
26
31
|
typeof className === "object" && className !== null
|
|
27
32
|
? className.mainContent
|
|
28
33
|
: "",
|
|
34
|
+
width === "full" ? "full" : "",
|
|
35
|
+
width === "wide" ? "wide" : "",
|
|
36
|
+
width === "medium" ? "medium" : "",
|
|
37
|
+
width === "narrow" ? "narrow" : "",
|
|
29
38
|
);
|
|
30
39
|
|
|
31
40
|
return (
|
|
@@ -181,9 +181,9 @@ export const Modal: React.FC<ModalProps> = ({
|
|
|
181
181
|
{(title || showCloseButton) && (
|
|
182
182
|
<div css={sx?.header} className={headerClasses}>
|
|
183
183
|
{title && (
|
|
184
|
-
<
|
|
184
|
+
<h2 css={sx?.title} className={titleClasses} id={titleId}>
|
|
185
185
|
{title}
|
|
186
|
-
</
|
|
186
|
+
</h2>
|
|
187
187
|
)}
|
|
188
188
|
{showCloseButton && (
|
|
189
189
|
<Button
|