tududi/frontend/components/Inbox/SuggestionsDropdown.tsx
Chris 75a1e68730
Tc refactor pt1 (#589)
* Refactor ProfileSettings

* Cleanup comments

* Refactor TaskDetails

* Refactor InboxModal

* fixup! Refactor InboxModal

* Fix project layout

* Add visuals to project details

* Refactor projectdetails

* Remake project metrics

* Complete project details refactor

* Fix note issues and enhance view

* Add filters

* Fix project tasks filters

* Add filters to task lists

* Add filters to task lists

* fixup! Add filters to task lists
2025-11-23 21:48:49 +02:00

49 lines
1.5 KiB
TypeScript

import React from 'react';
interface SuggestionsDropdownProps<T> {
isVisible: boolean;
items: T[];
position: { left: number; top: number };
selectedIndex: number;
onSelect: (item: T) => void;
renderLabel: (item: T) => React.ReactNode;
}
const SuggestionsDropdown = <T,>({
isVisible,
items,
position,
selectedIndex,
onSelect,
renderLabel,
}: SuggestionsDropdownProps<T>) => {
if (!isVisible || items.length === 0) return null;
return (
<div
className="absolute bg-white dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-md shadow-lg z-50"
style={{
left: `${position.left}px`,
top: `${position.top + 4}px`,
minWidth: '120px',
maxWidth: '200px',
}}
>
{items.map((item, index) => (
<button
key={index}
onClick={() => onSelect(item)}
className={`w-full text-left px-3 py-2 text-sm text-gray-900 dark:text-gray-100 first:rounded-t-md last:rounded-b-md ${
selectedIndex === index
? 'bg-blue-100 dark:bg-blue-800'
: 'hover:bg-gray-100 dark:hover:bg-gray-600'
}`}
>
{renderLabel(item)}
</button>
))}
</div>
);
};
export default SuggestionsDropdown;