forked from github/plane
feat: list and kanban view group by header icon (#665)
This commit is contained in:
parent
c940641ba1
commit
9f34f41982
@ -9,9 +9,11 @@ import issuesService from "services/issues.service";
|
|||||||
import projectService from "services/project.service";
|
import projectService from "services/project.service";
|
||||||
// hooks
|
// hooks
|
||||||
import useIssuesView from "hooks/use-issues-view";
|
import useIssuesView from "hooks/use-issues-view";
|
||||||
|
// component
|
||||||
|
import { Avatar } from "components/ui";
|
||||||
// icons
|
// icons
|
||||||
import { ArrowsPointingInIcon, ArrowsPointingOutIcon, PlusIcon } from "@heroicons/react/24/outline";
|
import { ArrowsPointingInIcon, ArrowsPointingOutIcon, PlusIcon } from "@heroicons/react/24/outline";
|
||||||
import { getStateGroupIcon } from "components/icons";
|
import { getPriorityIcon, getStateGroupIcon } from "components/icons";
|
||||||
// helpers
|
// helpers
|
||||||
import { addSpaceIfCamelCase } from "helpers/string.helper";
|
import { addSpaceIfCamelCase } from "helpers/string.helper";
|
||||||
// types
|
// types
|
||||||
@ -89,9 +91,39 @@ export const BoardHeader: React.FC<Props> = ({
|
|||||||
return title;
|
return title;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getGroupIcon = () => {
|
||||||
|
let icon;
|
||||||
|
|
||||||
|
switch (selectedGroup) {
|
||||||
|
case "state":
|
||||||
|
icon = currentState && getStateGroupIcon(currentState.group, "18", "18", bgColor);
|
||||||
|
break;
|
||||||
|
case "priority":
|
||||||
|
icon = getPriorityIcon(groupTitle, "h-[18px] w-[18px] flex items-center");
|
||||||
|
break;
|
||||||
|
case "labels":
|
||||||
|
const labelColor =
|
||||||
|
issueLabels?.find((label) => label.id === groupTitle)?.color ?? "#000000";
|
||||||
|
icon = (
|
||||||
|
<span
|
||||||
|
className="h-[18px] w-[18px] flex-shrink-0 rounded-full"
|
||||||
|
style={{ backgroundColor: labelColor }}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case "created_by":
|
||||||
|
const member = members?.find((member) => member.member.id === groupTitle)?.member;
|
||||||
|
icon = <Avatar user={member} height="24px" width="24px" fontSize="12px" />;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return icon;
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`flex justify-between px-1 ${
|
className={`flex justify-between items-center px-1 ${
|
||||||
!isCollapsed ? "flex-col rounded-md border bg-gray-50" : ""
|
!isCollapsed ? "flex-col rounded-md border bg-gray-50" : ""
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
@ -101,7 +133,7 @@ export const BoardHeader: React.FC<Props> = ({
|
|||||||
!isCollapsed ? "mb-2 flex-col gap-y-2 py-2" : ""
|
!isCollapsed ? "mb-2 flex-col gap-y-2 py-2" : ""
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{currentState && getStateGroupIcon(currentState.group, "18", "18", bgColor)}
|
<span className="flex items-center">{getGroupIcon()}</span>
|
||||||
<h2
|
<h2
|
||||||
className="text-lg font-semibold capitalize"
|
className="text-lg font-semibold capitalize"
|
||||||
style={{
|
style={{
|
||||||
|
@ -12,10 +12,10 @@ import useIssuesProperties from "hooks/use-issue-properties";
|
|||||||
// components
|
// components
|
||||||
import { SingleListIssue } from "components/core";
|
import { SingleListIssue } from "components/core";
|
||||||
// ui
|
// ui
|
||||||
import { CustomMenu } from "components/ui";
|
import { Avatar, CustomMenu } from "components/ui";
|
||||||
// icons
|
// icons
|
||||||
import { PlusIcon } from "@heroicons/react/24/outline";
|
import { PlusIcon } from "@heroicons/react/24/outline";
|
||||||
import { getStateGroupIcon } from "components/icons";
|
import { getPriorityIcon, getStateGroupIcon } from "components/icons";
|
||||||
// helpers
|
// helpers
|
||||||
import { addSpaceIfCamelCase } from "helpers/string.helper";
|
import { addSpaceIfCamelCase } from "helpers/string.helper";
|
||||||
// types
|
// types
|
||||||
@ -99,6 +99,36 @@ export const SingleList: React.FC<Props> = ({
|
|||||||
return title;
|
return title;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getGroupIcon = () => {
|
||||||
|
let icon;
|
||||||
|
|
||||||
|
switch (selectedGroup) {
|
||||||
|
case "state":
|
||||||
|
icon = currentState && getStateGroupIcon(currentState.group, "18", "18", bgColor);
|
||||||
|
break;
|
||||||
|
case "priority":
|
||||||
|
icon = getPriorityIcon(groupTitle, "h-[18px] w-[18px] flex items-center");
|
||||||
|
break;
|
||||||
|
case "labels":
|
||||||
|
const labelColor =
|
||||||
|
issueLabels?.find((label) => label.id === groupTitle)?.color ?? "#000000";
|
||||||
|
icon = (
|
||||||
|
<span
|
||||||
|
className="h-[18px] w-[18px] flex-shrink-0 rounded-full"
|
||||||
|
style={{ backgroundColor: labelColor }}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case "created_by":
|
||||||
|
const member = members?.find((member) => member.member.id === groupTitle)?.member;
|
||||||
|
icon = <Avatar user={member} height="24px" width="24px" fontSize="12px" />;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return icon;
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Disclosure key={groupTitle} as="div" defaultOpen>
|
<Disclosure key={groupTitle} as="div" defaultOpen>
|
||||||
{({ open }) => (
|
{({ open }) => (
|
||||||
@ -110,12 +140,8 @@ export const SingleList: React.FC<Props> = ({
|
|||||||
>
|
>
|
||||||
<Disclosure.Button>
|
<Disclosure.Button>
|
||||||
<div className="flex items-center gap-x-3">
|
<div className="flex items-center gap-x-3">
|
||||||
{selectedGroup !== null && selectedGroup === "state" ? (
|
{selectedGroup !== null && (
|
||||||
<span>
|
<span className="flex items-center">{getGroupIcon()}</span>
|
||||||
{currentState && getStateGroupIcon(currentState.group, "16", "16", bgColor)}
|
|
||||||
</span>
|
|
||||||
) : (
|
|
||||||
""
|
|
||||||
)}
|
)}
|
||||||
{selectedGroup !== null ? (
|
{selectedGroup !== null ? (
|
||||||
<h2 className="text-base font-semibold capitalize leading-6 text-gray-800">
|
<h2 className="text-base font-semibold capitalize leading-6 text-gray-800">
|
||||||
|
Loading…
Reference in New Issue
Block a user