@@ -2,14 +2,17 @@ import { DropdownMenuProps } from "@radix-ui/react-dropdown-menu";
2
2
import { Dropdown } from "./Dropdown" ;
3
3
import { GridCenter } from "../commonElement" ;
4
4
import { Button } from ".." ;
5
+ import { Key } from "react" ;
5
6
6
7
interface Props extends DropdownMenuProps {
7
8
disabled ?: boolean ;
8
9
showArrow ?: boolean ;
9
10
side : "top" | "right" | "left" | "bottom" ;
10
11
type : "text" | "button" ;
12
+ itemCount : number
11
13
}
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 } ` ) ;
13
16
return (
14
17
< GridCenter >
15
18
< Dropdown { ...props } >
@@ -21,6 +24,9 @@ const DropdownExample = ({ showArrow, disabled, side, ...props }: Props) => {
21
24
< Dropdown . Group >
22
25
< Dropdown . Item data-state = "checked" > Content0</ Dropdown . Item >
23
26
</ Dropdown . Group >
27
+ { items . map ( ( item :string , index : Key | null | undefined ) => (
28
+ < Dropdown . Item key = { index } > { item } </ Dropdown . Item >
29
+ ) ) }
24
30
< Dropdown . Item icon = "activity" > Content1 long text content</ Dropdown . Item >
25
31
< Dropdown . Sub >
26
32
< Dropdown . Trigger sub > Hover over</ Dropdown . Trigger >
@@ -85,6 +91,7 @@ const DropdownExample = ({ showArrow, disabled, side, ...props }: Props) => {
85
91
</ GridCenter >
86
92
) ;
87
93
} ;
94
+
88
95
export default {
89
96
component : DropdownExample ,
90
97
title : "Display/Dropdown" ,
@@ -95,12 +102,16 @@ export default {
95
102
defaultOpen : { control : "boolean" } ,
96
103
showArrow : { control : "boolean" } ,
97
104
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
+ } ,
99
109
} ,
100
110
} ;
101
111
102
112
export const Playground = {
103
113
args : {
104
114
side : "bottom" ,
115
+ itemCount : 0 ,
105
116
} ,
106
- } ;
117
+ } ;
0 commit comments