forked from github/plane
style: redesign view (#770)
* style: add new design to the view item * feat: add no of filters
This commit is contained in:
parent
2dbe1dd401
commit
d411cd7576
@ -1,23 +1,24 @@
|
||||
import React, { useState } from "react";
|
||||
|
||||
import { mutate } from "swr";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
import { IView } from "types";
|
||||
|
||||
// icons
|
||||
import { TrashIcon, StarIcon } from "@heroicons/react/24/outline";
|
||||
import { TrashIcon, StarIcon, PencilIcon } from "@heroicons/react/24/outline";
|
||||
import { StackedLayersIcon } from "components/icons";
|
||||
|
||||
//components
|
||||
import { CustomMenu } from "components/ui";
|
||||
|
||||
import { CustomMenu, Tooltip } from "components/ui";
|
||||
// services
|
||||
import viewsService from "services/views.service";
|
||||
|
||||
import { mutate } from "swr";
|
||||
|
||||
// types
|
||||
import { IView } from "types";
|
||||
// fetch keys
|
||||
import { VIEWS_LIST } from "constants/fetch-keys";
|
||||
|
||||
// hooks
|
||||
import useToast from "hooks/use-toast";
|
||||
// helpers
|
||||
import { truncateText } from "helpers/string.helper";
|
||||
import { renderShortDate, renderShortTime } from "helpers/date-time.helper";
|
||||
|
||||
type Props = {
|
||||
view: IView;
|
||||
@ -81,16 +82,34 @@ export const SingleViewItem: React.FC<Props> = ({ view, setSelectedView }) => {
|
||||
};
|
||||
|
||||
return (
|
||||
<li>
|
||||
<Link href={`/${workspaceSlug}/projects/${projectId}/views/${view.id}`}>
|
||||
<a>
|
||||
<div className="flex items-center cursor-pointer justify-between border-b bg-white p-4 first:rounded-t-[10px] last:rounded-b-[10px]">
|
||||
<div className="flex flex-col w-full gap-3">
|
||||
<div className="flex justify-between w-full">
|
||||
<div className="relative rounded p-4 hover:bg-gray-100">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<StackedLayersIcon height={18} width={18} />
|
||||
<a>{view.name}</a>
|
||||
<p className="mr-2 truncate text-sm font-medium">{truncateText(view.name, 75)}</p>
|
||||
</div>
|
||||
<div className="flex">
|
||||
<div className="ml-2 flex flex-shrink-0">
|
||||
<div className="flex items-center gap-2">
|
||||
<p className="text-xs bg-gray-300 text-gray-600 py-0.5 px-2 rounded-full">
|
||||
{Object.keys(view.query_data)
|
||||
.map((key: string) =>
|
||||
view.query_data[key as keyof typeof view.query_data] !== null
|
||||
? (view.query_data[key as keyof typeof view.query_data] as any).length
|
||||
: 0
|
||||
)
|
||||
.reduce((curr, prev) => curr + prev, 0)}{" "}
|
||||
filters
|
||||
</p>
|
||||
<Tooltip
|
||||
tooltipContent={`Last updated at ${renderShortTime(
|
||||
view.updated_at
|
||||
)} ${renderShortDate(view.updated_at)}`}
|
||||
>
|
||||
<p className="text-sm text-gray-400">{renderShortTime(view.updated_at)}</p>
|
||||
</Tooltip>
|
||||
{view.is_favorite ? (
|
||||
<button
|
||||
type="button"
|
||||
@ -111,33 +130,46 @@ export const SingleViewItem: React.FC<Props> = ({ view, setSelectedView }) => {
|
||||
handleAddToFavorites();
|
||||
}}
|
||||
>
|
||||
<StarIcon className="h-4 w-4 " color="#858E96" />
|
||||
<StarIcon className="h-4 w-4 " color="#858e96" />
|
||||
</button>
|
||||
)}
|
||||
<CustomMenu width="auto" verticalEllipsis>
|
||||
{/* <CustomMenu.MenuItem
|
||||
onClick={(e: any) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
// handleEditView();
|
||||
}}
|
||||
>
|
||||
<span className="flex items-center justify-start gap-2">
|
||||
<PencilIcon className="h-3.5 w-3.5" />
|
||||
<span>Edit View</span>
|
||||
</span>
|
||||
</CustomMenu.MenuItem> */}
|
||||
<CustomMenu.MenuItem
|
||||
onClick={(e) => {
|
||||
onClick={(e: any) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
setSelectedView(view);
|
||||
}}
|
||||
>
|
||||
<span className="flex items-center justify-start gap-2">
|
||||
<TrashIcon className="h-4 w-4" />
|
||||
<span>Delete</span>
|
||||
<TrashIcon className="h-3.5 w-3.5" />
|
||||
<span>Delete View</span>
|
||||
</span>
|
||||
</CustomMenu.MenuItem>
|
||||
</CustomMenu>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{view?.description && (
|
||||
<p className="text-sm text-[#858E96] font-normal leading-5 px-[27px]">
|
||||
<p className="text-sm text-gray-400 font-normal leading-5 px-[27px]">
|
||||
{view.description}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</Link>
|
||||
</li>
|
||||
);
|
||||
};
|
||||
|
@ -86,11 +86,11 @@ const ProjectViews: NextPage = () => {
|
||||
views.length > 0 ? (
|
||||
<div className="space-y-5">
|
||||
<h3 className="text-3xl font-semibold text-black">Views</h3>
|
||||
<div className="rounded-[10px] border">
|
||||
<ul role="list" className="divide-y">
|
||||
{views.map((view) => (
|
||||
<SingleViewItem key={view.id} view={view} setSelectedView={setSelectedView} />
|
||||
))}
|
||||
</div>
|
||||
</ul>
|
||||
</div>
|
||||
) : (
|
||||
<EmptyState
|
||||
|
Loading…
Reference in New Issue
Block a user