@windstream/react-shared-components 0.0.58 → 0.0.59
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/dist/contentful/index.esm.js +1 -1
- package/dist/contentful/index.esm.js.map +1 -1
- package/dist/contentful/index.js +1 -1
- package/dist/contentful/index.js.map +1 -1
- package/dist/core.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/accordion/index.tsx +61 -49
- package/src/components/accordion/types.ts +1 -0
- package/src/contentful/blocks/accordion/index.tsx +1 -0
package/package.json
CHANGED
|
@@ -1,49 +1,61 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { useState } from "react";
|
|
4
|
-
|
|
5
|
-
import { AccordionProps } from "@shared/components/accordion/types";
|
|
6
|
-
import { Button } from "@shared/components/button";
|
|
7
|
-
import { Collapse } from "@shared/components/collapse";
|
|
8
|
-
import { MaterialIcon } from "@shared/components/material-icon";
|
|
9
|
-
import { cx } from "@shared/utils";
|
|
10
|
-
|
|
11
|
-
export const Accordion: React.FC<AccordionProps> = props => {
|
|
12
|
-
const {
|
|
13
|
-
title,
|
|
14
|
-
defaultOpen,
|
|
15
|
-
children,
|
|
16
|
-
containerClassName,
|
|
17
|
-
titleClassName,
|
|
18
|
-
className,
|
|
19
|
-
buttonClassName,
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
|
|
5
|
+
import { AccordionProps } from "@shared/components/accordion/types";
|
|
6
|
+
import { Button } from "@shared/components/button";
|
|
7
|
+
import { Collapse } from "@shared/components/collapse";
|
|
8
|
+
import { MaterialIcon } from "@shared/components/material-icon";
|
|
9
|
+
import { cx } from "@shared/utils";
|
|
10
|
+
|
|
11
|
+
export const Accordion: React.FC<AccordionProps> = props => {
|
|
12
|
+
const {
|
|
13
|
+
title,
|
|
14
|
+
defaultOpen,
|
|
15
|
+
children,
|
|
16
|
+
containerClassName,
|
|
17
|
+
titleClassName,
|
|
18
|
+
className,
|
|
19
|
+
buttonClassName,
|
|
20
|
+
openOnlyOnDesktop,
|
|
21
|
+
} = props;
|
|
22
|
+
const [open, setOpen] = useState<boolean>(Boolean(false));
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
// Only execute responsive logic if the prop is true
|
|
26
|
+
if (openOnlyOnDesktop) {
|
|
27
|
+
const isDesktop = window.innerWidth >= 1024;
|
|
28
|
+
setOpen(isDesktop);
|
|
29
|
+
} else {
|
|
30
|
+
// Otherwise, fall back to standard defaultOpen behavior
|
|
31
|
+
setOpen(Boolean(defaultOpen));
|
|
32
|
+
}
|
|
33
|
+
}, [openOnlyOnDesktop, defaultOpen]);
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div className={cx("rounded-lg border", containerClassName)}>
|
|
37
|
+
<Button
|
|
38
|
+
type="button"
|
|
39
|
+
className={cx(
|
|
40
|
+
"flex w-full items-center justify-between gap-4 rounded-t-lg px-4 py-3 text-left",
|
|
41
|
+
buttonClassName
|
|
42
|
+
)}
|
|
43
|
+
onClick={() => setOpen(v => !v)}
|
|
44
|
+
>
|
|
45
|
+
<span className={cx("label5", titleClassName)}>{title}</span>
|
|
46
|
+
<MaterialIcon
|
|
47
|
+
name={open ? "keyboard_arrow_down" : "keyboard_arrow_up"}
|
|
48
|
+
fill={1}
|
|
49
|
+
size={24}
|
|
50
|
+
/>
|
|
51
|
+
</Button>
|
|
52
|
+
<Collapse open={open}>
|
|
53
|
+
<div className={cx("px-4 py-4", className)}>{children}</div>
|
|
54
|
+
</Collapse>
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
Accordion.displayName = "Accordion";
|
|
60
|
+
|
|
61
|
+
export type { AccordionProps };
|