mirror of
https://github.com/cssgunc/compass.git
synced 2025-04-10 06:10:17 -04:00
Add non-functional search bar
Does not do anything at the moment.
This commit is contained in:
parent
af8055002c
commit
d82913a45d
|
@ -1,12 +1,36 @@
|
||||||
import { MagnifyingGlassIcon } from "@heroicons/react/24/solid";
|
import { MagnifyingGlassIcon } from "@heroicons/react/24/solid";
|
||||||
|
import { useRef, useState } from "react";
|
||||||
|
|
||||||
export const TableAction = () => {
|
export const TableAction = () => {
|
||||||
return (
|
const searchInput = useRef<HTMLInputElement>(null);
|
||||||
<div className="w-40 flex flex-row items-center justify-between text-xs font-medium text-gray-500 p-2">
|
const [searchActive, setSearchActive] = useState(false);
|
||||||
<span>Filter</span>
|
const activateSearch = () => {
|
||||||
<span>Sort</span>
|
setSearchActive(true);
|
||||||
<span className="w-4 h-4"><MagnifyingGlassIcon /></span>
|
if (searchInput.current === null) { return; }
|
||||||
</div>
|
searchInput.current.focus();
|
||||||
);
|
searchInput.current.addEventListener("focusout", () => {
|
||||||
};
|
if (searchInput.current?.value.trim() === "") {
|
||||||
|
searchInput.current.value = "";
|
||||||
|
deactivateSearch();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const deactivateSearch = () => setSearchActive(false);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="w-auto flex flex-row gap-x-0.5 items-center justify-between text-xs font-medium text-gray-500 p-2">
|
||||||
|
<span className="p-1 rounded hover:bg-gray-100">Filter</span>
|
||||||
|
<span className="p-1 rounded hover:bg-gray-100">Sort</span>
|
||||||
|
<span className="p-1 rounded hover:bg-gray-100" onClick={() => activateSearch()}>
|
||||||
|
<MagnifyingGlassIcon className="w-4 h-4 inline" />
|
||||||
|
</span>
|
||||||
|
<input
|
||||||
|
ref={searchInput}
|
||||||
|
className={"outline-none transition-all duration-300 " + (searchActive ? "w-48" : "w-0")}
|
||||||
|
type="text"
|
||||||
|
name="search"
|
||||||
|
placeholder="Type to search..." />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user