@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windstream/react-shared-components",
3
- "version": "0.0.58",
3
+ "version": "0.0.59",
4
4
  "type": "module",
5
5
  "description": "Shared React components for Kinetic applications",
6
6
  "main": "dist/index.js",
@@ -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
- } = props;
21
- const [open, setOpen] = useState<boolean>(Boolean(defaultOpen));
22
-
23
- return (
24
- <div className={cx("rounded-lg border", containerClassName)}>
25
- <Button
26
- type="button"
27
- className={cx(
28
- "flex w-full items-center justify-between gap-4 rounded-t-lg px-4 py-3 text-left",
29
- buttonClassName
30
- )}
31
- onClick={() => setOpen(v => !v)}
32
- >
33
- <span className={cx("label5", titleClassName)}>{title}</span>
34
- <MaterialIcon
35
- name={open ? "keyboard_arrow_down" : "keyboard_arrow_up"}
36
- fill={1}
37
- size={24}
38
- />
39
- </Button>
40
- <Collapse open={open}>
41
- <div className={cx("px-4 py-4", className)}>{children}</div>
42
- </Collapse>
43
- </div>
44
- );
45
- };
46
-
47
- Accordion.displayName = "Accordion";
48
-
49
- export type { AccordionProps };
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 };
@@ -1,6 +1,7 @@
1
1
  export type AccordionProps = {
2
2
  title: string;
3
3
  defaultOpen?: boolean;
4
+ openOnlyOnDesktop?: boolean;
4
5
  containerClassName?: string;
5
6
  children: React.ReactNode;
6
7
  titleClassName?: string;
@@ -38,6 +38,7 @@ export const Accordion: React.FC<AccordionProps> = ({
38
38
  <AccordionComponent
39
39
  title={item.title}
40
40
  containerClassName="border-0 border-b-[1px] rounded-none"
41
+ openOnlyOnDesktop={true}
41
42
  >
42
43
  <Text>{item.description}</Text>
43
44
  </AccordionComponent>