File tree Expand file tree Collapse file tree 2 files changed +6
-9
lines changed Expand file tree Collapse file tree 2 files changed +6
-9
lines changed Original file line number Diff line number Diff line change 1
1
import { Fragment } from 'react'
2
2
import { Menu , Transition } from '@headlessui/react'
3
3
import { ChevronDownIcon } from '@heroicons/react/20/solid'
4
- import { DropdownProps , OptionProps } from '../types/dropdown' ;
4
+ import { DropdownProps } from '../types/dropdown' ;
5
5
import { combineClassNames } from '../../javascript-functions/general' ;
6
6
import { IconClock } from '@tabler/icons' ;
7
7
8
8
9
9
export default function Dropdown ( props : DropdownProps ) {
10
10
const isDisabled = props . disabled || props . options . length < 1 ;
11
11
return (
12
- < Menu as = "div" className = " relative inline-block text-left w-full" >
12
+ < Menu as = "div" className = { ` relative inline-block text-left ${ props . dropdownWidth ? props . dropdownWidth : ' w-full' } ` } >
13
13
< div >
14
14
< Menu . Button className = { `inline-flex w-full justify-between items-center rounded-md border border-gray-300
15
15
bg-white px-4 py-2 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2
@@ -36,7 +36,7 @@ export default function Dropdown(props: DropdownProps) {
36
36
>
37
37
< Menu . Items className = { `absolute z-10 mt-2 w-40 origin-top-right rounded-md bg-white shadow-sm ring-1 ring-black ring-opacity-5 focus:outline-none ${ props . itemsClasses ? props . itemsClasses : '' } ` } >
38
38
< div className = "py-1" >
39
- { props . options . map ( ( option : OptionProps ) => (
39
+ { props . options . map ( ( option : any ) => (
40
40
< div key = { option . id } >
41
41
< Menu . Item >
42
42
{ ( { active } ) => (
@@ -49,7 +49,7 @@ export default function Dropdown(props: DropdownProps) {
49
49
props . selectedOption ( option ) ;
50
50
} }
51
51
>
52
- { option . name }
52
+ { props . onlyArray ? option : option . name }
53
53
</ a >
54
54
) }
55
55
</ Menu . Item >
Original file line number Diff line number Diff line change @@ -5,9 +5,6 @@ export type DropdownProps = {
5
5
selectedOption : ( event : any ) => void ;
6
6
itemsClasses ?: string ;
7
7
hasIconClock ?: boolean ;
8
- }
9
-
10
- export type OptionProps = {
11
- name : string ;
12
- id : string ;
8
+ onlyArray ?: boolean ;
9
+ dropdownWidth ?: string ;
13
10
}
You can’t perform that action at this time.
0 commit comments