2024-02-05 13:42:33 +00:00
|
|
|
import { observer } from "mobx-react";
|
2024-01-18 10:19:54 +00:00
|
|
|
import { Tab } from "@headlessui/react";
|
2024-03-19 14:38:35 +00:00
|
|
|
import { TIssuesListTypes } from "@plane/types";
|
2024-01-18 10:19:54 +00:00
|
|
|
// helpers
|
2024-03-19 14:38:35 +00:00
|
|
|
import { EDurationFilters, FILTERED_ISSUES_TABS_LIST, UNFILTERED_ISSUES_TABS_LIST } from "@/constants/dashboard";
|
|
|
|
import { cn } from "@/helpers/common.helper";
|
2024-02-05 13:42:33 +00:00
|
|
|
// types
|
2024-01-18 10:19:54 +00:00
|
|
|
// constants
|
|
|
|
|
2024-02-05 13:42:33 +00:00
|
|
|
type Props = {
|
2024-03-06 08:54:36 +00:00
|
|
|
durationFilter: EDurationFilters;
|
2024-02-05 13:42:33 +00:00
|
|
|
selectedTab: TIssuesListTypes;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const TabsList: React.FC<Props> = observer((props) => {
|
|
|
|
const { durationFilter, selectedTab } = props;
|
|
|
|
|
|
|
|
const tabsList = durationFilter === "none" ? UNFILTERED_ISSUES_TABS_LIST : FILTERED_ISSUES_TABS_LIST;
|
2024-02-08 12:27:22 +00:00
|
|
|
const selectedTabIndex = tabsList.findIndex((tab) => tab.key === selectedTab);
|
2024-02-05 13:42:33 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Tab.List
|
|
|
|
as="div"
|
2024-02-08 12:27:22 +00:00
|
|
|
className="relative border-[0.5px] border-custom-border-200 rounded bg-custom-background-80 p-[1px] grid"
|
2024-02-05 13:42:33 +00:00
|
|
|
style={{
|
|
|
|
gridTemplateColumns: `repeat(${tabsList.length}, 1fr)`,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<div
|
2024-02-08 12:27:22 +00:00
|
|
|
className={cn(
|
|
|
|
"absolute top-1/2 left-[1px] bg-custom-background-100 rounded-[3px] transition-all duration-500 ease-in-out",
|
|
|
|
{
|
|
|
|
// right shadow
|
|
|
|
"shadow-[2px_0_8px_rgba(167,169,174,0.15)]": selectedTabIndex !== tabsList.length - 1,
|
|
|
|
// left shadow
|
|
|
|
"shadow-[-2px_0_8px_rgba(167,169,174,0.15)]": selectedTabIndex !== 0,
|
|
|
|
}
|
|
|
|
)}
|
2024-02-05 13:42:33 +00:00
|
|
|
style={{
|
2024-02-08 12:27:22 +00:00
|
|
|
height: "calc(100% - 2px)",
|
|
|
|
width: `calc(${100 / tabsList.length}% - 1px)`,
|
|
|
|
transform: `translate(${selectedTabIndex * 100}%, -50%)`,
|
2024-02-05 13:42:33 +00:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
{tabsList.map((tab) => (
|
|
|
|
<Tab
|
|
|
|
key={tab.key}
|
|
|
|
className={cn(
|
2024-02-08 12:27:22 +00:00
|
|
|
"relative z-[1] font-semibold text-xs rounded-[3px] py-1.5 text-custom-text-400 focus:outline-none transition duration-500",
|
2024-02-05 13:42:33 +00:00
|
|
|
{
|
2024-03-06 08:54:36 +00:00
|
|
|
"text-custom-text-100": selectedTab === tab.key,
|
2024-02-05 13:42:33 +00:00
|
|
|
"hover:text-custom-text-300": selectedTab !== tab.key,
|
|
|
|
}
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
<span className="scale-110">{tab.label}</span>
|
|
|
|
</Tab>
|
|
|
|
))}
|
|
|
|
</Tab.List>
|
|
|
|
);
|
|
|
|
});
|