plane/web/components/view/display-properties/property-selection.tsx

39 lines
1.3 KiB
TypeScript
Raw Normal View History

2024-02-09 09:03:22 +00:00
import { FC } from "react";
import { observer } from "mobx-react-lite";
// hooks
import { useViewDetail } from "hooks/store";
// types
import { TViewDisplayProperties, TViewTypes } from "@plane/types";
type TViewDisplayPropertySelection = {
workspaceSlug: string;
projectId: string | undefined;
viewId: string;
viewType: TViewTypes;
property: keyof TViewDisplayProperties;
};
export const ViewDisplayPropertySelection: FC<TViewDisplayPropertySelection> = observer((props) => {
2024-02-13 06:58:05 +00:00
const { workspaceSlug, projectId, viewId, viewType, property } = props;
2024-02-09 09:03:22 +00:00
// hooks
const viewDetailStore = useViewDetail(workspaceSlug, projectId, viewId, viewType);
const propertyIsSelected = viewDetailStore?.appliedFilters?.display_properties?.[property];
2024-02-13 06:58:05 +00:00
const handlePropertySelection = () => viewDetailStore?.setDisplayProperties(property);
2024-02-09 09:03:22 +00:00
return (
<div
className={`relative flex items-center gap-1 text-xs rounded p-0.5 px-2 border transition-all capitalize cursor-pointer
${
propertyIsSelected
? `border-custom-primary-100 bg-custom-primary-100`
: `border-custom-border-300 hover:bg-custom-background-80`
}`}
onClick={handlePropertySelection}
>
{["key"].includes(property) ? "ID" : property.replaceAll("_", " ")}
</div>
);
});