Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 7 additions & 37 deletions apps/app/components/issues/select/assignee.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { useState, FC, Fragment } from "react";

import Image from "next/image";
import { useRouter } from "next/router";

import useSWR from "swr";

// headless ui
import { Transition, Combobox } from "@headlessui/react";
// services
import projectServices from "services/project.service";
// ui
import { Avatar } from "components/ui";
// icons
import { UserIcon } from "@heroicons/react/24/outline";
// service
import projectServices from "services/project.service";
// types
import type { IProjectMember } from "types";
// fetch keys
import { PROJECT_MEMBERS } from "constants/fetch-keys";

Expand All @@ -22,35 +21,6 @@ export type IssueAssigneeSelectProps = {
onChange: (value: string[]) => void;
};

type AssigneeAvatarProps = {
user: IProjectMember | undefined;
};

export const AssigneeAvatar: FC<AssigneeAvatarProps> = ({ user }) => {
if (!user) return <></>;

if (user.member.avatar && user.member.avatar !== "") {
return (
<div className="relative h-4 w-4">
<Image
src={user.member.avatar}
alt="avatar"
className="rounded-full"
layout="fill"
objectFit="cover"
/>
</div>
);
} else
return (
<div className="grid h-4 w-4 flex-shrink-0 place-items-center rounded-full bg-gray-700 capitalize text-white">
{user.member.first_name && user.member.first_name !== ""
? user.member.first_name.charAt(0)
: user.member.email.charAt(0)}
</div>
);
};

export const IssueAssigneeSelect: FC<IssueAssigneeSelectProps> = ({
projectId,
value = [],
Expand Down Expand Up @@ -136,14 +106,14 @@ export const IssueAssigneeSelect: FC<IssueAssigneeSelectProps> = ({
className={({ active, selected }) =>
`${active ? "bg-indigo-50" : ""} ${
selected ? "bg-indigo-50 font-medium" : ""
} flex cursor-pointer select-none items-center gap-2 truncate p-2 text-gray-900`
} flex cursor-pointer select-none items-center gap-2 truncate px-2 py-1 text-gray-900`
}
value={option.value}
>
{people && (
<>
<AssigneeAvatar
user={people?.find((p) => p.member.id === option.value)}
<Avatar
user={people?.find((p) => p.member.id === option.value)?.member}
/>
{option.display}
</>
Expand Down
4 changes: 2 additions & 2 deletions apps/app/components/issues/sidebar-select/assignee.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ export const SidebarAssigneeSelect: React.FC<Props> = ({ control, submitChanges,
<Listbox.Option
key={option.member.id}
className={({ active, selected }) =>
`${
active || selected ? "bg-indigo-50" : ""
`${active || selected ? "bg-indigo-50" : ""} ${
selected ? "font-medium" : ""
} flex cursor-pointer select-none items-center gap-2 truncate p-2 text-gray-900`
}
value={option.member.id}
Expand Down
94 changes: 35 additions & 59 deletions apps/app/components/issues/view-select/priority.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";

// ui
import { Listbox, Transition } from "@headlessui/react";
import { CustomSelect } from "components/ui";
// icons
import { getPriorityIcon } from "components/icons/priority-icon";
// types
Expand All @@ -22,67 +22,43 @@ export const ViewPrioritySelect: React.FC<Props> = ({
position = "right",
isNotAllowed,
}) => (
<Listbox
as="div"
value={issue.priority}
<CustomSelect
label={
<span>
{getPriorityIcon(
issue.priority && issue.priority !== "" ? issue.priority ?? "" : "None",
"text-sm"
)}
</span>
}
value={issue.state}
onChange={(data: string) => {
partialUpdateIssue({ priority: data });
}}
className="group relative flex-shrink-0"
maxHeight="md"
buttonClassName={`flex ${
isNotAllowed ? "cursor-not-allowed" : "cursor-pointer"
} items-center gap-x-2 rounded px-2 py-0.5 capitalize shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500 ${
issue.priority === "urgent"
? "bg-red-100 text-red-600 hover:bg-red-100"
: issue.priority === "high"
? "bg-orange-100 text-orange-500 hover:bg-orange-100"
: issue.priority === "medium"
? "bg-yellow-100 text-yellow-500 hover:bg-yellow-100"
: issue.priority === "low"
? "bg-green-100 text-green-500 hover:bg-green-100"
: "bg-gray-100"
} border-none`}
noChevron
disabled={isNotAllowed}
>
{({ open }) => (
<div>
<Listbox.Button
className={`flex ${
isNotAllowed ? "cursor-not-allowed" : "cursor-pointer"
} items-center gap-x-2 rounded px-2 py-0.5 capitalize shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500 ${
issue.priority === "urgent"
? "bg-red-100 text-red-600"
: issue.priority === "high"
? "bg-orange-100 text-orange-500"
: issue.priority === "medium"
? "bg-yellow-100 text-yellow-500"
: issue.priority === "low"
? "bg-green-100 text-green-500"
: "bg-gray-100"
}`}
>
{getPriorityIcon(
issue.priority && issue.priority !== "" ? issue.priority ?? "" : "None",
"text-sm"
)}
</Listbox.Button>

<Transition
show={open}
as={React.Fragment}
leave="transition ease-in duration-100"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<Listbox.Options
className={`absolute z-10 mt-1 max-h-48 w-36 overflow-auto rounded-md bg-white py-1 text-xs shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none ${
position === "left" ? "left-0" : "right-0"
}`}
>
{PRIORITIES?.map((priority) => (
<Listbox.Option
key={priority}
className={({ active, selected }) =>
`${active || selected ? "bg-indigo-50" : ""} ${
selected ? "font-medium" : ""
} flex cursor-pointer select-none items-center gap-x-2 px-3 py-2 capitalize`
}
value={priority}
>
{getPriorityIcon(priority, "text-sm")}
{priority ?? "None"}
</Listbox.Option>
))}
</Listbox.Options>
</Transition>
</div>
)}
</Listbox>
{PRIORITIES?.map((priority) => (
<CustomSelect.Option key={priority} value={priority} className="capitalize">
<>
{getPriorityIcon(priority, "text-sm")}
{priority ?? "None"}
</>
</CustomSelect.Option>
))}
</CustomSelect>
);
2 changes: 1 addition & 1 deletion apps/app/components/issues/view-select/state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Props = {
export const ViewStateSelect: React.FC<Props> = ({
issue,
partialUpdateIssue,
position,
position = "right",
isNotAllowed,
}) => {
const router = useRouter();
Expand Down
3 changes: 1 addition & 2 deletions apps/app/components/onboarding/invite-members.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import useToast from "hooks/use-toast";
import workspaceService from "services/workspace.service";
import { IUser } from "types";
// ui components
import MultiInput from "components/ui/multi-input";
import OutlineButton from "components/ui/outline-button";
import { MultiInput, OutlineButton } from "components/ui";

type Props = {
setStep: React.Dispatch<React.SetStateAction<number>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,19 @@ import React from "react";

// headless ui
import { Listbox, Transition } from "@headlessui/react";
// types
import { Props } from "./types";

type Props = {
title?: string;
label?: string;
options?: Array<{ display: string; value: any; color?: string; icon?: JSX.Element }>;
icon?: JSX.Element;
value: any;
onChange: (value: any) => void;
multiple?: boolean;
optionsFontsize?: "sm" | "md" | "lg" | "xl" | "2xl";
className?: string;
footerOption?: JSX.Element;
};

export const CustomListbox: React.FC<Props> = ({
title = "",
Expand Down
12 changes: 0 additions & 12 deletions apps/app/components/ui/custom-listbox/types.d.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,25 @@ import Link from "next/link";
import { Menu, Transition } from "@headlessui/react";
// icons
import { ChevronDownIcon, EllipsisHorizontalIcon } from "@heroicons/react/24/outline";
// types
import { MenuItemProps, Props } from "./types";
// constants

type Props = {
children: React.ReactNode;
label?: string | JSX.Element;
className?: string;
ellipsis?: boolean;
width?: "sm" | "md" | "lg" | "xl" | "auto";
textAlignment?: "left" | "center" | "right";
noBorder?: boolean;
optionsPosition?: "left" | "right";
};

type MenuItemProps = {
children: JSX.Element | string;
renderAs?: "button" | "a";
href?: string;
onClick?: () => void;
className?: string;
};

const CustomMenu = ({
children,
Expand Down
18 changes: 0 additions & 18 deletions apps/app/components/ui/custom-menu/types.d.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type CustomSelectProps = {
width?: "auto" | string;
input?: boolean;
noChevron?: boolean;
buttonClassName?: string;
disabled?: boolean;
};

Expand All @@ -27,6 +28,7 @@ const CustomSelect = ({
width = "auto",
input = false,
noChevron = false,
buttonClassName = "",
disabled = false,
}: CustomSelectProps) => (
<Listbox
Expand All @@ -38,7 +40,7 @@ const CustomSelect = ({
>
<div>
<Listbox.Button
className={`flex w-full ${
className={`${buttonClassName} flex w-full ${
disabled ? "cursor-not-allowed" : "cursor-pointer hover:bg-gray-100"
} items-center justify-between gap-1 rounded-md border shadow-sm duration-300 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500 ${
input ? "border-gray-300 px-3 py-2 text-sm" : "px-2 py-1 text-xs"
Expand Down Expand Up @@ -95,8 +97,8 @@ const Option: React.FC<OptionProps> = ({ children, value, className }) => (
<Listbox.Option
value={value}
className={({ active, selected }) =>
`${selected ? "bg-indigo-50 font-medium" : ""} ${
active ? "bg-indigo-50" : ""
`${active || selected ? "bg-indigo-50" : ""} ${
selected ? "font-medium" : ""
} relative flex cursor-pointer select-none items-center gap-2 truncate p-2 text-gray-900 ${className}`
}
>
Expand Down
10 changes: 6 additions & 4 deletions apps/app/components/ui/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
export * from "./input";
export * from "./text-area";
export * from "./avatar";
export * from "./button";
export * from "./custom-listbox";
export * from "./custom-menu";
export * from "./custom-select";
export * from "./datepicker";
export * from "./empty-space";
export * from "./header-button";
export * from "./input";
export * from "./loader";
export * from "./multi-input";
export * from "./outline-button";
export * from "./progress-bar";
export * from "./select";
export * from "./spinner";
export * from "./text-area";
export * from "./avatar";
export * from "./datepicker";
export * from "./tooltip";
Loading