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.
Files changed (36) hide show
  1. package/components/Button/Button.tsx +0 -1
  2. package/components/Carousel/Carousel.tsx +68 -34
  3. package/components/FormField/FormField.tsx +1 -0
  4. package/components/Layout/Main.tsx +11 -2
  5. package/components/Modal/Modal.tsx +2 -2
  6. package/dist/athameui.cjs +248 -245
  7. package/dist/athameui.cjs.map +1 -1
  8. package/dist/athameui.mjs +244 -230
  9. package/dist/athameui.mjs.map +1 -1
  10. package/dist/components/Button/Button.d.ts.map +1 -1
  11. package/dist/components/Carousel/Carousel.d.ts +2 -1
  12. package/dist/components/Carousel/Carousel.d.ts.map +1 -1
  13. package/dist/components/FormField/FormField.d.ts.map +1 -1
  14. package/dist/components/Layout/Main.d.ts +2 -1
  15. package/dist/components/Layout/Main.d.ts.map +1 -1
  16. package/dist/styles/components/carousel.css +17 -6
  17. package/dist/styles/components/form-input.css +29 -8
  18. package/dist/styles/components/main.css +17 -2
  19. package/dist/styles/index.d.ts +0 -1
  20. package/dist/styles/index.d.ts.map +1 -1
  21. package/dist/styles/index.ts +0 -1
  22. package/dist/styles/tokens.css +16 -20
  23. package/dist/styles/tokens.d.ts +209 -26
  24. package/dist/styles/tokens.d.ts.map +1 -1
  25. package/dist/styles/tokens.ts +190 -165
  26. package/package.json +1 -1
  27. package/styles/components/carousel.css +17 -6
  28. package/styles/components/form-input.css +29 -8
  29. package/styles/components/main.css +17 -2
  30. package/styles/index.ts +0 -1
  31. package/styles/tokens.css +16 -20
  32. package/styles/tokens.ts +190 -165
  33. package/dist/styles/breakpoints.d.ts +0 -29
  34. package/dist/styles/breakpoints.d.ts.map +0 -1
  35. package/dist/styles/breakpoints.ts +0 -34
  36. package/styles/breakpoints.ts +0 -34
@@ -65,7 +65,6 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
65
65
  },
66
66
  ref,
67
67
  ) => {
68
- console.log(sx);
69
68
  const isIconOnly = icon && !children;
70
69
 
71
70
  const sharedClasses = cx(
@@ -1,7 +1,14 @@
1
- import { Children, useState, useRef, type ReactNode } from "react";
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
- "ath-carousel",
29
- isHovered ? "ath-carousel-hover" : "",
30
- className?.carousel,
31
- );
32
- const hasItems = Children.count(children) > 0;
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 className="ath-carousel-wrapper">
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={carouselClasses}
61
- css={sx?.carousel}
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
- <Button
67
- className={{ button: "ath-carousel-arrow ath-carousel-left-arrow" }}
68
- onClick={handleLeftArrowClick}
69
- onMouseEnter={handleMouseEnter}
70
- onMouseLeave={handleMouseLeave}
71
- icon={<HugeiconsIcon icon={ArrowLeftIcon} size={36} />}
72
- />
73
- {hasItems ? children : emptyMessage}
74
- <Button
75
- className={{ button: "ath-carousel-arrow ath-carousel-right-arrow" }}
76
- onClick={handleRightArrowClick}
77
- onMouseEnter={handleMouseEnter}
78
- onMouseLeave={handleMouseLeave}
79
- icon={<HugeiconsIcon icon={ArrowRightIcon} size={36} />}
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 = ({ children, className, sx }: MainProps) => {
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
- <h1 css={sx?.title} className={titleClasses} id={titleId}>
184
+ <h2 css={sx?.title} className={titleClasses} id={titleId}>
185
185
  {title}
186
- </h1>
186
+ </h2>
187
187
  )}
188
188
  {showCloseButton && (
189
189
  <Button