Skip to content

Commit c66df55

Browse files
Dropdown props
1 parent ac14358 commit c66df55

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

components/Dropdown.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { Fragment } from 'react'
22
import { Menu, Transition } from '@headlessui/react'
33
import { ChevronDownIcon } from '@heroicons/react/20/solid'
4-
import { DropdownProps, OptionProps } from '../types/dropdown';
4+
import { DropdownProps } from '../types/dropdown';
55
import { combineClassNames } from '../../javascript-functions/general';
66
import { IconClock } from '@tabler/icons';
77

88

99
export default function Dropdown(props: DropdownProps) {
1010
const isDisabled = props.disabled || props.options.length < 1;
1111
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'}`}>
1313
<div>
1414
<Menu.Button className={`inline-flex w-full justify-between items-center rounded-md border border-gray-300
1515
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) {
3636
>
3737
<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 : ''}`}>
3838
<div className="py-1">
39-
{props.options.map((option: OptionProps) => (
39+
{props.options.map((option: any) => (
4040
<div key={option.id}>
4141
<Menu.Item >
4242
{({ active }) => (
@@ -49,7 +49,7 @@ export default function Dropdown(props: DropdownProps) {
4949
props.selectedOption(option);
5050
}}
5151
>
52-
{option.name}
52+
{props.onlyArray ? option : option.name}
5353
</a>
5454
)}
5555
</Menu.Item>

types/dropdown.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ export type DropdownProps = {
55
selectedOption: (event: any) => void;
66
itemsClasses?: string;
77
hasIconClock?: boolean;
8-
}
9-
10-
export type OptionProps = {
11-
name: string;
12-
id: string;
8+
onlyArray?: boolean;
9+
dropdownWidth?: string;
1310
}

0 commit comments

Comments
 (0)