feat: preview modal, style: issues page

This commit is contained in:
Aaryan Khandelwal 2022-11-25 22:54:49 +05:30
parent d2cc452de8
commit 9e8afcf50a
14 changed files with 555 additions and 387 deletions

View File

@ -71,9 +71,9 @@ const ShortcutsModal: React.FC<Props> = ({ isOpen, setIsOpen }) => {
{
title: "Common",
shortcuts: [
{ key: "Ctrl + p", description: "To open create project modal" },
{ key: "Ctrl + i", description: "To open create issue modal" },
{ key: "Ctrl + q", description: "To open create cycle modal" },
{ key: "Ctrl + p", description: "To create project" },
{ key: "Ctrl + i", description: "To create issue" },
{ key: "Ctrl + q", description: "To create cycle" },
{ key: "Ctrl + h", description: "To open shortcuts guide" },
{
key: "Ctrl + alt + c",

View File

@ -199,8 +199,9 @@ const SingleBoard: React.FC<Props> = ({
{groupedByIssues[groupTitle].map((childIssue: any, index: number) => (
<Draggable key={childIssue.id} draggableId={childIssue.id} index={index}>
{(provided, snapshot) => (
<div
className={`border rounded bg-white shadow-sm cursor-pointer ${
<Link href={`/projects/${childIssue.project}/issues/${childIssue.id}`}>
<a
className={`group block border rounded bg-white shadow-sm ${
snapshot.isDragging ? "border-indigo-600 shadow-lg bg-indigo-50" : ""
}`}
ref={provided.innerRef}
@ -248,13 +249,9 @@ const SingleBoard: React.FC<Props> = ({
""
)}
{key === "name" && (
<Link
href={`/projects/${childIssue.project}/issues/${childIssue.id}`}
>
<a className="hover:text-theme duration-300">
<span className="group-hover:text-theme">
{childIssue.name}
</a>
</Link>
</span>
)}
{key === "state" && (
<>{addSpaceIfCamelCase(childIssue["state_detail"].name)}</>
@ -324,7 +321,8 @@ const SingleBoard: React.FC<Props> = ({
</button>
</div>
</div> */}
</div>
</a>
</Link>
)}
</Draggable>
))}

View File

@ -1,5 +1,5 @@
// react
import React from "react";
import React, { useEffect, useState } from "react";
// next
import Link from "next/link";
import Image from "next/image";
@ -25,6 +25,7 @@ import {
renderShortNumericDateFormat,
replaceUnderscoreIfSnakeCase,
} from "constants/common";
import IssuePreviewModal from "../PreviewModal";
// types
type Props = {
@ -44,6 +45,9 @@ const ListView: React.FC<Props> = ({
setSelectedIssue,
handleDeleteIssue,
}) => {
const [issuePreviewModal, setIssuePreviewModal] = useState(false);
const [previewModalIssueId, setPreviewModalIssueId] = useState<string | null>(null);
const { activeWorkspace, activeProject, states } = useUser();
const partialUpdateIssue = (formData: Partial<IIssue>, issueId: string) => {
@ -71,8 +75,23 @@ const ListView: React.FC<Props> = ({
activeWorkspace ? () => workspaceService.workspaceMembers(activeWorkspace.slug) : null
);
const handleHover = (issueId: string) => {
document.addEventListener("keydown", (e) => {
if (e.code === "Space") {
e.preventDefault();
setPreviewModalIssueId(issueId);
setIssuePreviewModal(true);
}
});
};
return (
<div className="mt-4 flex flex-col">
<IssuePreviewModal
isOpen={issuePreviewModal}
setIsOpen={setIssuePreviewModal}
issueId={previewModalIssueId}
/>
<div className="overflow-x-auto">
<div className="inline-block min-w-full p-0.5 align-middle">
<div className="overflow-hidden shadow ring-1 ring-black ring-opacity-5 md:rounded-lg">
@ -135,6 +154,7 @@ const ListView: React.FC<Props> = ({
index === 0 ? "border-gray-300" : "border-gray-200",
"border-t"
)}
onMouseEnter={() => handleHover(issue.id)}
>
{Object.keys(properties).map(
(key) =>

View File

@ -0,0 +1,138 @@
// next
import { useRouter } from "next/router";
// react
import { Fragment } from "react";
// headless ui
import { Dialog, Transition } from "@headlessui/react";
// hooks
import useUser from "lib/hooks/useUser";
// services
import issuesServices from "lib/services/issues.services";
import projectService from "lib/services/project.service";
// swr
import useSWR from "swr";
// types
import { IIssue, ProjectMember } from "types";
// constants
import { PROJECT_ISSUES_DETAILS, PROJECT_MEMBERS } from "constants/fetch-keys";
import { Button } from "ui";
import { ChartBarIcon, Squares2X2Icon, TagIcon, UserIcon } from "@heroicons/react/24/outline";
type Props = {
isOpen: boolean;
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
issueId: string | null;
};
const IssuePreviewModal = ({ isOpen, setIsOpen, issueId }: Props) => {
const closeModal = () => {
setIsOpen(false);
};
const { activeWorkspace, activeProject } = useUser();
const router = useRouter();
const { data: issueDetails } = useSWR<IIssue | null>(
activeWorkspace && activeProject && issueId ? PROJECT_ISSUES_DETAILS(issueId) : null,
activeWorkspace && activeProject && issueId
? () => issuesServices.getIssue(activeWorkspace.slug, activeProject.id, issueId)
: null
);
const { data: users } = useSWR<ProjectMember[] | null>(
activeWorkspace && activeProject ? PROJECT_MEMBERS(activeProject.id) : null,
activeWorkspace && activeProject
? () => projectService.projectMembers(activeWorkspace.slug, activeProject.id)
: null
);
return (
<>
<Transition.Root appear show={isOpen} as={Fragment}>
<Dialog as="div" className="relative z-10" onClose={closeModal}>
<Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0"
enterTo="opacity-100"
leave="ease-in duration-200"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<div className="fixed inset-0 bg-black bg-opacity-25" />
</Transition.Child>
<div className="fixed inset-0 overflow-y-auto">
<div className="flex min-h-full items-center justify-center p-4 text-center">
<Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0 scale-95"
enterTo="opacity-100 scale-100"
leave="ease-in duration-200"
leaveFrom="opacity-100 scale-100"
leaveTo="opacity-0 scale-95"
>
<Dialog.Panel className="w-full max-w-3xl transform overflow-hidden rounded-2xl bg-white p-6 text-left align-middle shadow-xl transition-all">
<Dialog.Title
as="h3"
className="text-xl flex flex-col gap-1 font-medium leading-6 text-gray-900"
>
{issueDetails?.project_detail.identifier}-{issueDetails?.sequence_id}{" "}
{issueDetails?.name}
<span className="text-sm text-gray-500 font-normal">
Created by{" "}
{users?.find((u) => u.id === issueDetails?.created_by)?.member.first_name}
</span>
</Dialog.Title>
<div className="mt-4">
<p className="text-sm text-gray-500">{issueDetails?.description}</p>
</div>
<div className="mt-4 flex flex-wrap gap-2">
<span className="flex items-center gap-1 hover:bg-gray-100 border rounded-md shadow-sm px-2 py-1 sm:text-sm">
<Squares2X2Icon className="h-3 w-3" />
{issueDetails?.state_detail.name}
</span>
<span className="flex items-center gap-1 hover:bg-gray-100 border rounded-md shadow-sm px-2 py-1 capitalize sm:text-sm">
<ChartBarIcon className="h-3 w-3" />
{issueDetails?.priority}
</span>
<span className="flex items-center gap-1 hover:bg-gray-100 border rounded-md shadow-sm px-2 py-1 capitalize sm:text-sm">
<TagIcon className="h-3 w-3" />
{issueDetails?.label_details && issueDetails.label_details.length > 0
? issueDetails.label_details.map((label) => (
<span key={label.id}>{label.name}</span>
))
: "None"}
</span>
<span className="flex items-center gap-1 hover:bg-gray-100 border rounded-md shadow-sm px-2 py-1 capitalize sm:text-sm">
<UserIcon className="h-3 w-3" />
{issueDetails?.assignee_details && issueDetails.assignee_details.length > 0
? issueDetails.assignee_details.map((assignee) => (
<span key={assignee.id}>{assignee.first_name}</span>
))
: "None"}
</span>
</div>
<div className="mt-4 flex gap-3 justify-end">
<Button
onClick={() =>
router.push(`/projects/${activeProject?.id}/issues/${issueId}`)
}
>
View in Detail
</Button>
<Button onClick={closeModal}>Close</Button>
</div>
</Dialog.Panel>
</Transition.Child>
</div>
</div>
</Dialog>
</Transition.Root>
</>
);
};
export default IssuePreviewModal;

View File

@ -409,17 +409,6 @@ const Sidebar: React.FC = () => {
</a>
</Link>
))}
<button
type="button"
className="w-full flex items-center gap-3 p-2 hover:bg-indigo-100 text-xs font-medium rounded-md outline-none"
onClick={() => {
const e = new KeyboardEvent("keydown", { key: "h", ctrlKey: true });
document.dispatchEvent(e);
}}
>
<QuestionMarkCircleIcon className="flex-shrink-0 h-4 w-4" />
{!sidebarCollapse && "Help Centre"}
</button>
</div>
</div>
<div
@ -432,15 +421,24 @@ const Sidebar: React.FC = () => {
{projects.length > 0 ? (
projects.map((project) => (
<Disclosure key={project?.id} defaultOpen={projectId === project?.id}>
{({ open }) => (
<>
<Disclosure.Button
className={`w-full flex items-center gap-2 font-medium rounded-md p-2 text-sm ${
sidebarCollapse ? "justify-center" : ""
}`}
>
<span className="bg-gray-700 text-white rounded h-7 w-7 grid place-items-center uppercase">
<span className="bg-gray-700 text-white rounded h-7 w-7 grid place-items-center uppercase flex-shrink-0">
{project?.name.charAt(0)}
</span>
{!sidebarCollapse && project?.name}
{!sidebarCollapse && (
<span className="flex items-center justify-between w-full">
{project?.name}
<ChevronDownIcon
className={`h-4 w-4 duration-300 ${open ? "rotate-180" : ""}`}
/>
</span>
)}
</Disclosure.Button>
<Transition
enter="transition duration-100 ease-out"
@ -482,18 +480,24 @@ const Sidebar: React.FC = () => {
))}
</Disclosure.Panel>
</Transition>
</>
)}
</Disclosure>
))
) : (
<div className="text-center space-y-3">
<h4 className="text-gray-700 text-sm">You don{"'"}t have any project yet</h4>
{!sidebarCollapse && (
<h4 className="text-gray-700 text-sm">
You don{"'"}t have any project yet
</h4>
)}
<button
type="button"
className="group flex justify-center items-center gap-2 w-full rounded-md p-2 text-sm bg-theme text-white"
onClick={() => setCreateProjectModal(true)}
>
<PlusIcon className="h-5 w-5" />
Create Project
{!sidebarCollapse && "Create Project"}
</button>
</div>
)}

View File

@ -25,6 +25,7 @@ import ChangeStateDropdown from "components/project/issues/my-issues/ChangeState
import { PlusIcon, RectangleStackIcon } from "@heroicons/react/24/outline";
// types
import { IIssue } from "types";
import Link from "next/link";
const MyIssues: NextPage = () => {
const { user } = useUser();
@ -139,8 +140,10 @@ const MyIssues: NextPage = () => {
"border-t text-sm text-gray-900"
)}
>
<td className="px-3 py-4 text-sm font-medium text-gray-900 max-w-[15rem]">
{myIssue.name}
<td className="px-3 py-4 text-sm font-medium text-gray-900 hover:text-theme max-w-[15rem] duration-300">
<Link href={`/projects/${myIssue.project}/issues/${myIssue.id}`}>
<a>{myIssue.name}</a>
</Link>
</td>
<td className="px-3 py-4 max-w-[15rem]">{myIssue.description}</td>
<td className="px-3 py-4">

View File

@ -136,7 +136,6 @@ const ProjectIssues: NextPage = () => {
isOpen={!!deleteIssue}
data={projectIssues?.results.find((issue) => issue.id === deleteIssue)}
/>
<div className="w-full">
{!projectIssues ? (
<div className="h-full w-full flex justify-center items-center">
<Spinner />
@ -178,7 +177,7 @@ const ProjectIssues: NextPage = () => {
</div>
<Menu as="div" className="relative inline-block w-40">
<div className="w-full">
<Menu.Button className="inline-flex justify-between items-center w-full rounded-md shadow-sm p-2 bg-white border border-gray-300 text-xs font-semibold text-gray-700 hover:bg-gray-50 focus:outline-none">
<Menu.Button className="inline-flex justify-between items-center w-full rounded-md shadow-sm p-2 border border-gray-300 text-xs font-semibold text-gray-700 hover:bg-gray-100 focus:outline-none">
<span className="flex gap-x-1 items-center">
{groupByOptions.find((option) => option.key === groupByProperty)?.name ??
"No Grouping"}
@ -237,7 +236,7 @@ const ProjectIssues: NextPage = () => {
<Popover className="relative">
{({ open }) => (
<>
<Popover.Button className="inline-flex justify-between items-center rounded-md shadow-sm p-2 bg-white border border-gray-300 text-xs font-semibold text-gray-700 hover:bg-gray-50 focus:outline-none w-40">
<Popover.Button className="inline-flex justify-between items-center rounded-md shadow-sm p-2 border border-gray-300 text-xs font-semibold text-gray-700 hover:bg-gray-100 focus:outline-none w-40">
<span>Properties</span>
<ChevronDownIcon className="h-4 w-4" />
</Popover.Button>
@ -328,7 +327,6 @@ const ProjectIssues: NextPage = () => {
</EmptySpace>
</div>
)}
</div>
</AdminLayout>
);
};

View File

@ -444,6 +444,15 @@ const ProjectSettings: NextPage = () => {
</div>
</div>
</section>
<section className="space-y-5">
<div>
<h3 className="text-lg font-medium leading-6 text-gray-900">Labels</h3>
<p className="mt-1 text-sm text-gray-500">
Manage the labels of this project.
</p>
</div>
<div></div>
</section>
</div>
</form>
</div>

View File

@ -1,4 +1,4 @@
@import url("https://fonts.googleapis.com/css2?family=Lexend:wght@200;300;400;500;600;700;800&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@200;300;400;500;600;700;800&display=swap");
@tailwind base;
@tailwind components;
@ -6,7 +6,7 @@
@layer base {
html {
font-family: "Lexend", sans-serif;
font-family: "Inter", sans-serif;
}
}

View File

@ -64,7 +64,7 @@ const CustomListbox: React.FC<Props> = ({
leaveTo="opacity-0"
>
<Listbox.Options
className={`absolute mt-1 bg-white shadow-lg ${
className={`absolute mt-1 bg-white shadow-lg max-h-32 overflow-auto ${
width === "sm"
? "w-32"
: width === "md"

View File

@ -35,7 +35,7 @@ const Input: React.FC<Props> = ({
onChange && onChange(e);
}}
className={classNames(
"mt-1 block w-full px-3 py-2 text-base focus:outline-none sm:text-sm rounded-md",
"mt-1 block w-full px-3 py-2 text-base focus:outline-none sm:text-sm rounded-md bg-transparent",
mode === "primary" ? "border border-gray-300 rounded-md" : "",
mode === "transparent"
? "bg-transparent border-none transition-all ring-0 focus:ring-1 focus:ring-indigo-500 rounded"

View File

@ -82,7 +82,7 @@ const SearchListbox: React.FC<Props> = ({
leaveTo="opacity-0"
>
<Combobox.Options
className={`absolute mt-1 bg-white shadow-lg rounded-md py-1 ring-1 ring-black ring-opacity-5 focus:outline-none z-10 ${
className={`absolute mt-1 bg-white shadow-lg rounded-md py-1 ring-1 ring-black ring-opacity-5 focus:outline-none max-h-32 overflow-auto z-10 ${
width === "sm"
? "w-32"
: width === "md"
@ -109,11 +109,12 @@ const SearchListbox: React.FC<Props> = ({
} ${optionsClassName || ""}`}
>
<Combobox.Input
className="w-full bg-transparent border-b py-2 pl-3 mb-1 focus:outline-none sm:text-sm"
className="w-full bg-transparent border-b p-2 mb-1 focus:outline-none sm:text-sm"
onChange={(event) => setQuery(event.target.value)}
placeholder="Search"
displayValue={(assigned: any) => assigned?.name}
/>
<div className="p-1">
{filteredOptions ? (
filteredOptions.length > 0 ? (
filteredOptions.map((option) => (
@ -122,15 +123,11 @@ const SearchListbox: React.FC<Props> = ({
className={({ active }) =>
`${
active ? "text-white bg-theme" : "text-gray-900"
} cursor-pointer select-none relative p-2 rounded-md`
} cursor-pointer select-none truncate font-medium relative p-2 rounded-md`
}
value={option.value}
>
<div className="flex items-center">
<span className="ml-3 block truncate font-medium">
{option.element ?? option.display}
</span>
</div>
</Combobox.Option>
))
) : (
@ -139,6 +136,7 @@ const SearchListbox: React.FC<Props> = ({
) : (
<p className="text-sm text-gray-500">Loading...</p>
)}
</div>
</Combobox.Options>
</Transition>
</div>

View File

@ -27,7 +27,7 @@ const Select: React.FC<Props> = ({
value={value}
{...(register && register(name, validations))}
disabled={disabled}
className="mt-1 block w-full px-3 py-2 text-base border border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md"
className="mt-1 block w-full px-3 py-2 text-base border border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md bg-transparent"
>
{options.map((option, index) => (
<option value={option.value} key={index}>

View File

@ -54,7 +54,7 @@ const TextArea: React.FC<Props> = ({
setTextareaValue(e.target.value);
}}
className={classNames(
"w-full outline-none px-3 py-2",
"w-full outline-none px-3 py-2 bg-transparent",
mode === "primary" ? "border border-gray-300 rounded-md" : "",
mode === "transparent"
? "bg-transparent border-none transition-all ring-0 focus:ring-1 focus:ring-indigo-600 rounded"