summaryrefslogtreecommitdiff
path: root/src/components/user_dropdown_button.tsx
blob: f4148bc9e1db6e8ae80144b947da4a6b3734e237 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { useEffect } from "react";
import { PersonCircle } from "react-bootstrap-icons";
import { Dropdown, DropdownOptions } from 'flowbite';
import UserAccountDropdownMenu from "./user_account_dropdown_menu";

export default function UserDropdownButton() {
  useEffect(() => {
    const target = document.getElementById("userAccountDropdownMenu");
    const trigger = document.getElementById("userAccountButton");
    const options: DropdownOptions = {
      triggerType: 'click',
      placement: 'bottom'
    };
    const dropdown_menu = new Dropdown(target, trigger, options);
    trigger?.addEventListener("click", () => {
      if(dropdown_menu.isVisible())
        dropdown_menu.show();
    });
  }, []);

  return (
    <>
      <button id="userAccountButton" className="mr-4 text-neutral-500 hover:text-neutral-700 focus:text-neutral-700 disabled:text-black/30 dark:text-neutral-200 dark:hover:text-neutral-300 dark:focus:text-neutral-300 [&.active]:text-black/90 dark:[&.active]:text-neutral-400">
        <span className="[&>svg]:w-5">
          <PersonCircle color="#394490" size={32}/>
        </span>
      </button>

      <UserAccountDropdownMenu/>
    </>
  );
}