import { useLayoutStore } from "../store/module";
import SearchBar from "./SearchBar";
import TagList from "./TagList";
import UsageHeatMap from "./UsageHeatMap";

const HomeSidebar = () => {
  const layoutStore = useLayoutStore();
  const showHomeSidebar = layoutStore.state.showHomeSidebar;

  return (
    <div
      className={`fixed @lg:sticky top-0 left-0 w-full @lg:w-56 h-full shrink-0 pointer-events-none @lg:pointer-events-auto z-10 ${
        showHomeSidebar && "pointer-events-auto"
      }`}
    >
      <div
        className={`fixed top-0 left-0 w-full h-full opacity-0 pointer-events-none transition-opacity duration-300 @lg:!hidden ${
          showHomeSidebar && "opacity-60 pointer-events-auto"
        }`}
        onClick={() => layoutStore.setHomeSidebarStatus(false)}
      ></div>
      <aside
        className={`absolute @lg:relative top-0 right-0 w-56 pr-2 @lg:w-full h-full max-h-screen border-l sm:border-none dark:border-l-zinc-700 overflow-auto hide-scrollbar flex flex-col justify-start items-start py-4 z-30 bg-zinc-100 dark:bg-zinc-800 @lg:bg-transparent @lg:shadow-none transition-all duration-300 translate-x-full @lg:translate-x-0 ${
          showHomeSidebar && "!translate-x-0 shadow-2xl"
        }`}
      >
        <div className="px-4 pr-8 mb-4 w-full">
          <SearchBar />
        </div>
        <UsageHeatMap />
        <TagList />
      </aside>
    </div>
  );
};

export default HomeSidebar;
