Skip to content

Commit 2326a30

Browse files
Adds itemCount prop to Dropdown story to test long lists.
1 parent 0e75a47 commit 2326a30

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/components/Dropdown/Dropdown.stories.tsx

+14-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@ import { DropdownMenuProps } from "@radix-ui/react-dropdown-menu";
22
import { Dropdown } from "./Dropdown";
33
import { GridCenter } from "../commonElement";
44
import { Button } from "..";
5+
import { Key } from "react";
56

67
interface Props extends DropdownMenuProps {
78
disabled?: boolean;
89
showArrow?: boolean;
910
side: "top" | "right" | "left" | "bottom";
1011
type: "text" | "button";
12+
itemCount: number
1113
}
12-
const DropdownExample = ({ showArrow, disabled, side, ...props }: Props) => {
14+
const DropdownExample = ({ showArrow, disabled, side, itemCount, ...props }: Props) => {
15+
const items = Array.from({ length: itemCount }, (_, i) => `Item ${i + 1}`);
1316
return (
1417
<GridCenter>
1518
<Dropdown {...props}>
@@ -21,6 +24,9 @@ const DropdownExample = ({ showArrow, disabled, side, ...props }: Props) => {
2124
<Dropdown.Group>
2225
<Dropdown.Item data-state="checked">Content0</Dropdown.Item>
2326
</Dropdown.Group>
27+
{items.map((item:string, index: Key | null | undefined) => (
28+
<Dropdown.Item key={index}>{item}</Dropdown.Item>
29+
))}
2430
<Dropdown.Item icon="activity">Content1 long text content</Dropdown.Item>
2531
<Dropdown.Sub>
2632
<Dropdown.Trigger sub>Hover over</Dropdown.Trigger>
@@ -85,6 +91,7 @@ const DropdownExample = ({ showArrow, disabled, side, ...props }: Props) => {
8591
</GridCenter>
8692
);
8793
};
94+
8895
export default {
8996
component: DropdownExample,
9097
title: "Display/Dropdown",
@@ -95,12 +102,16 @@ export default {
95102
defaultOpen: { control: "boolean" },
96103
showArrow: { control: "boolean" },
97104
side: { control: "select", options: ["top", "right", "left", "bottom"] },
98-
type: { control: "inline-radio", options: ["text", "button"] },
105+
itemCount: {
106+
control: { type: "number", min: 0, max: 100, step: 1 },
107+
description: "Number of items to display",
108+
},
99109
},
100110
};
101111

102112
export const Playground = {
103113
args: {
104114
side: "bottom",
115+
itemCount: 0,
105116
},
106-
};
117+
};

0 commit comments

Comments
 (0)