-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
49bfa1b
commit b1ed6b5
Showing
8 changed files
with
249 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { JSXOutput, QRL, component$, useVisibleTask$ } from '@builder.io/qwik'; | ||
import { initFlowbite } from 'flowbite'; | ||
import { Button } from '../Button'; | ||
|
||
interface optionDropdownInterface { | ||
id: string; | ||
icon: JSXOutput; | ||
label?: string; | ||
options: { value: string; onChange: QRL }[]; | ||
hidden?: boolean; | ||
} | ||
|
||
export const OptionDropdown = component$<optionDropdownInterface>( | ||
({ id, icon, label, options, hidden }) => { | ||
const buttonId = `dropdown-menu-icon-button-${id}`; | ||
const dropdownId = `dropdown-dots-${id}`; | ||
|
||
useVisibleTask$(() => { | ||
initFlowbite(); | ||
}); | ||
|
||
return ( | ||
<form class={['relative w-full', hidden ? 'hidden' : 'block']}> | ||
<Button variant={'link'} id={buttonId} data-dropdown-toggle={dropdownId}> | ||
<span class='inline-flex items-start gap-1'> | ||
{icon} | ||
{label} | ||
</span> | ||
</Button> | ||
|
||
<div | ||
id={dropdownId} | ||
class='z-10 hidden w-44 divide-y divide-gray-100 rounded-lg bg-white shadow dark:divide-gray-600 dark:bg-gray-700' | ||
> | ||
<ul | ||
class='py-2 text-sm text-gray-700 dark:text-gray-200' | ||
aria-labelledby={buttonId} | ||
> | ||
{options.map((option) => ( | ||
<li | ||
class='block px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white' | ||
onClick$={option.onChange} | ||
> | ||
{option.value} | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
</form> | ||
); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.