Skip to content

Commit

Permalink
Add itemCount prop to Dropdown story to test long lists.
Browse files Browse the repository at this point in the history
  • Loading branch information
natalyjazzviolin authored Jan 30, 2025
2 parents 0e75a47 + 2326a30 commit 4d7facb
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/components/Dropdown/Dropdown.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ import { DropdownMenuProps } from "@radix-ui/react-dropdown-menu";
import { Dropdown } from "./Dropdown";
import { GridCenter } from "../commonElement";
import { Button } from "..";
import { Key } from "react";

interface Props extends DropdownMenuProps {
disabled?: boolean;
showArrow?: boolean;
side: "top" | "right" | "left" | "bottom";
type: "text" | "button";
itemCount: number
}
const DropdownExample = ({ showArrow, disabled, side, ...props }: Props) => {
const DropdownExample = ({ showArrow, disabled, side, itemCount, ...props }: Props) => {
const items = Array.from({ length: itemCount }, (_, i) => `Item ${i + 1}`);
return (
<GridCenter>
<Dropdown {...props}>
Expand All @@ -21,6 +24,9 @@ const DropdownExample = ({ showArrow, disabled, side, ...props }: Props) => {
<Dropdown.Group>
<Dropdown.Item data-state="checked">Content0</Dropdown.Item>
</Dropdown.Group>
{items.map((item:string, index: Key | null | undefined) => (
<Dropdown.Item key={index}>{item}</Dropdown.Item>
))}
<Dropdown.Item icon="activity">Content1 long text content</Dropdown.Item>
<Dropdown.Sub>
<Dropdown.Trigger sub>Hover over</Dropdown.Trigger>
Expand Down Expand Up @@ -85,6 +91,7 @@ const DropdownExample = ({ showArrow, disabled, side, ...props }: Props) => {
</GridCenter>
);
};

export default {
component: DropdownExample,
title: "Display/Dropdown",
Expand All @@ -95,12 +102,16 @@ export default {
defaultOpen: { control: "boolean" },
showArrow: { control: "boolean" },
side: { control: "select", options: ["top", "right", "left", "bottom"] },
type: { control: "inline-radio", options: ["text", "button"] },
itemCount: {
control: { type: "number", min: 0, max: 100, step: 1 },
description: "Number of items to display",
},
},
};

export const Playground = {
args: {
side: "bottom",
itemCount: 0,
},
};
};

0 comments on commit 4d7facb

Please sign in to comment.