style: app sidebar revamp (#1120)

* style: app sidebar, sidebar workspace dropdown and help section styling

* style: consistent  padding and spacing

* feat: material icon global component

* style: icons updated and tooltip added

* style: project list spacing and project name truncate

* style: sidebar padding and theming

---------

Co-authored-by: Aaryan Khandelwal <aaryankhandu123@gmail.com>
This commit is contained in:
Anmol Singh Bhatia 2023-07-13 18:35:43 +05:30 committed by GitHub
parent 3f3fb373cc
commit 60e96bcb72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 305 additions and 329 deletions

View file

@ -151,11 +151,11 @@ export const ProjectSidebarList: FC = () => {
data={projectToDelete}
user={user}
/>
<div className="mt-2.5 h-full overflow-y-auto border-t border-custom-sidebar-border-100 bg-custom-sidebar-background-100 pt-2.5">
<div className="h-full overflow-y-auto mt-5 px-4">
{favoriteProjects && favoriteProjects.length > 0 && (
<div className="mt-3 flex flex-col space-y-2 px-3">
<div className="flex flex-col space-y-2">
{!sidebarCollapse && (
<h5 className="text-sm font-semibold text-custom-sidebar-text-200">Favorites</h5>
<h5 className="text-sm font-medium text-custom-sidebar-text-200">Favorites</h5>
)}
{favoriteProjects.map((favoriteProject) => {
const project = favoriteProject.project_detail;
@ -173,9 +173,9 @@ export const ProjectSidebarList: FC = () => {
})}
</div>
)}
<div className="flex flex-col space-y-2 p-3">
<div className="flex flex-col space-y-2 mt-5">
{!sidebarCollapse && (
<h5 className="text-sm font-semibold text-custom-sidebar-text-200">Projects</h5>
<h5 className="text-sm font-medium text-custom-sidebar-text-200">Projects</h5>
)}
{projects ? (
<>

View file

@ -4,22 +4,9 @@ import { useRouter } from "next/router";
// headless ui
import { Disclosure, Transition } from "@headlessui/react";
// ui
import { CustomMenu, Icon } from "components/ui";
import { CustomMenu, Icon, Tooltip } from "components/ui";
// icons
import {
ChevronDownIcon,
DocumentTextIcon,
LinkIcon,
StarIcon,
TrashIcon,
} from "@heroicons/react/24/outline";
import {
ContrastIcon,
LayerDiagonalIcon,
PeopleGroupIcon,
SettingIcon,
ViewListIcon,
} from "components/icons";
import { LinkIcon, StarIcon, TrashIcon } from "@heroicons/react/24/outline";
// helpers
import { truncateText } from "helpers/string.helper";
import { renderEmoji } from "helpers/emoji.helper";
@ -39,32 +26,32 @@ const navigation = (workspaceSlug: string, projectId: string) => [
{
name: "Issues",
href: `/${workspaceSlug}/projects/${projectId}/issues`,
icon: LayerDiagonalIcon,
icon: "stack",
},
{
name: "Cycles",
href: `/${workspaceSlug}/projects/${projectId}/cycles`,
icon: ContrastIcon,
icon: "contrast",
},
{
name: "Modules",
href: `/${workspaceSlug}/projects/${projectId}/modules`,
icon: PeopleGroupIcon,
icon: "dataset",
},
{
name: "Views",
href: `/${workspaceSlug}/projects/${projectId}/views`,
icon: ViewListIcon,
icon: "photo_filter",
},
{
name: "Pages",
href: `/${workspaceSlug}/projects/${projectId}/pages`,
icon: DocumentTextIcon,
icon: "article",
},
{
name: "Settings",
href: `/${workspaceSlug}/projects/${projectId}/settings`,
icon: SettingIcon,
icon: "settings",
},
];
@ -84,44 +71,56 @@ export const SingleSidebarProject: React.FC<Props> = ({
{({ open }) => (
<>
<div className="flex items-center gap-x-1 text-custom-sidebar-text-100">
<Disclosure.Button
as="div"
className={`flex w-full cursor-pointer select-none items-center rounded-md py-2 text-left text-sm font-medium ${
sidebarCollapse ? "justify-center" : "justify-between"
}`}
<Tooltip
tooltipContent={`${project?.name}`}
position="right"
className="ml-2"
disabled={!sidebarCollapse}
>
<div className="flex items-center gap-x-2">
{project.emoji ? (
<span className="grid h-7 w-7 flex-shrink-0 place-items-center rounded uppercase">
{renderEmoji(project.emoji)}
</span>
) : project.icon_prop ? (
<div className="h-7 w-7 grid place-items-center">
<span
style={{ color: project.icon_prop.color }}
className="material-symbols-rounded text-lg"
>
{project.icon_prop.name}
<Disclosure.Button
as="div"
className={`flex w-full cursor-pointer select-none items-center rounded-sm py-1 text-left text-sm font-medium ${
sidebarCollapse ? "justify-center" : "justify-between"
}`}
>
<div className="flex items-center gap-x-2">
{project.emoji ? (
<span className="grid h-7 w-7 flex-shrink-0 place-items-center rounded uppercase">
{renderEmoji(project.emoji)}
</span>
</div>
) : (
<span className="grid h-7 w-7 flex-shrink-0 place-items-center rounded bg-gray-700 uppercase text-white">
{project?.name.charAt(0)}
</span>
)}
) : project.icon_prop ? (
<div className="h-7 w-7 grid place-items-center">
<span
style={{ color: project.icon_prop.color }}
className="material-symbols-rounded text-lg"
>
{project.icon_prop.name}
</span>
</div>
) : (
<span className="grid h-7 w-7 flex-shrink-0 place-items-center rounded bg-gray-700 uppercase text-white">
{project?.name.charAt(0)}
</span>
)}
{!sidebarCollapse && (
<p
className={`overflow-hidden text-ellipsis ${
open ? "" : "text-custom-sidebar-text-200"
}`}
>
{truncateText(project?.name, 14)}
</p>
)}
</div>
{!sidebarCollapse && (
<h5 className={`overflow-hidden text-sm ${open ? "" : "text-custom-text-200"}`}>
{truncateText(project?.name, 20)}
</h5>
<Icon
iconName="expand_more"
className={`${open ? "rotate-180" : ""} text-custom-text-200 duration-300`}
/>
)}
</div>
{!sidebarCollapse && (
<span>
<ChevronDownIcon className={`h-4 w-4 duration-300 ${open ? "rotate-180" : ""}`} />
</span>
)}
</Disclosure.Button>
</Disclosure.Button>
</Tooltip>
{!sidebarCollapse && (
<CustomMenu ellipsis>
@ -177,9 +176,7 @@ export const SingleSidebarProject: React.FC<Props> = ({
leaveFrom="transform scale-100 opacity-100"
leaveTo="transform scale-95 opacity-0"
>
<Disclosure.Panel
className={`${sidebarCollapse ? "" : "ml-[2.25rem]"} flex flex-col gap-y-1`}
>
<Disclosure.Panel className={`space-y-2 ${sidebarCollapse ? "" : "ml-[2.25rem]"}`}>
{navigation(workspaceSlug as string, project?.id).map((item) => {
if (
(item.name === "Cycles" && !project.cycle_view) ||
@ -191,25 +188,24 @@ export const SingleSidebarProject: React.FC<Props> = ({
return (
<Link key={item.name} href={item.href}>
<a
className={`group flex items-center rounded-md p-2 text-xs font-medium outline-none ${
router.asPath.includes(item.href)
? "bg-custom-sidebar-background-90 text-custom-sidebar-text-100"
: "text-custom-sidebar-text-200 hover:bg-custom-sidebar-background-90 focus:bg-custom-sidebar-background-90"
} ${sidebarCollapse ? "justify-center" : ""}`}
>
<div className="grid place-items-center">
<item.icon
className={`h-5 w-5 flex-shrink-0 ${!sidebarCollapse ? "mr-3" : ""}`}
color={
<a className="block w-full">
<Tooltip
tooltipContent={`${project?.name}: ${item.name}`}
position="right"
className="ml-2"
disabled={!sidebarCollapse}
>
<div
className={`group flex items-center rounded-md px-2 py-1.5 gap-2 text-xs font-medium outline-none ${
router.asPath.includes(item.href)
? "rgb(var(--color-sidebar-text-100))"
: "rgb(var(--color-sidebar-text-200))"
}
aria-hidden="true"
/>
</div>
{!sidebarCollapse && item.name}
? "bg-custom-primary-100/10 text-custom-primary-100"
: "text-custom-sidebar-text-200 hover:bg-custom-sidebar-background-80 focus:bg-custom-sidebar-background-80"
} ${sidebarCollapse ? "justify-center" : ""}`}
>
<Icon iconName={item.icon} />
{!sidebarCollapse && item.name}
</div>
</Tooltip>
</a>
</Link>
);