chore: drop-downs improvements and bug fixes (#3433)

* chore: dropdowns should close on selecting an option

* style: @plane/ui dropdown styling

* refactor: @plane/ui dropdowns

* fix: build errors

* fix: list layout dropdowns positioning

* fix: priority dropdown text in dark mode
This commit is contained in:
Aaryan Khandelwal 2024-01-23 14:25:09 +05:30 committed by GitHub
parent f88109ef04
commit 801f75f406
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
52 changed files with 308 additions and 394 deletions

View File

@ -1,17 +1,15 @@
import * as React from "react"; import * as React from "react";
import ReactDOM from "react-dom"; import ReactDOM from "react-dom";
// react-popper import { Menu } from "@headlessui/react";
import { usePopper } from "react-popper"; import { usePopper } from "react-popper";
import { ChevronDown, MoreHorizontal } from "lucide-react";
// hooks // hooks
import { useDropdownKeyDown } from "../hooks/use-dropdown-key-down"; import { useDropdownKeyDown } from "../hooks/use-dropdown-key-down";
import useOutsideClickDetector from "../hooks/use-outside-click-detector"; import useOutsideClickDetector from "../hooks/use-outside-click-detector";
// headless ui // helpers
import { Menu } from "@headlessui/react";
// type
import { ICustomMenuDropdownProps, ICustomMenuItemProps } from "./helper";
// icons
import { ChevronDown, MoreHorizontal } from "lucide-react";
import { cn } from "../../helpers"; import { cn } from "../../helpers";
// types
import { ICustomMenuDropdownProps, ICustomMenuItemProps } from "./helper";
const CustomMenu = (props: ICustomMenuDropdownProps) => { const CustomMenu = (props: ICustomMenuDropdownProps) => {
const { const {
@ -29,7 +27,6 @@ const CustomMenu = (props: ICustomMenuDropdownProps) => {
noChevron = false, noChevron = false,
optionsClassName = "", optionsClassName = "",
verticalEllipsis = false, verticalEllipsis = false,
width = "auto",
portalElement, portalElement,
menuButtonOnClick, menuButtonOnClick,
tabIndex, tabIndex,
@ -63,17 +60,16 @@ const CustomMenu = (props: ICustomMenuDropdownProps) => {
static static
> >
<div <div
className={`my-1 overflow-y-scroll rounded-md border-[0.5px] border-custom-border-300 bg-custom-background-100 px-2 py-2.5 text-xs shadow-custom-shadow-rg focus:outline-none ${ className={cn(
maxHeight === "lg" "my-1 overflow-y-scroll rounded-md border-[0.5px] border-custom-border-300 bg-custom-background-100 px-2 py-2.5 text-xs shadow-custom-shadow-rg focus:outline-none min-w-[12rem] whitespace-nowrap",
? "max-h-60" {
: maxHeight === "md" "max-h-60": maxHeight === "lg",
? "max-h-48" "max-h-48": maxHeight === "md",
: maxHeight === "rg" "max-h-36": maxHeight === "rg",
? "max-h-36" "max-h-28": maxHeight === "sm",
: maxHeight === "sm" },
? "max-h-28" optionsClassName
: "" )}
} ${width === "auto" ? "min-w-[12rem] whitespace-nowrap" : width} ${optionsClassName}`}
ref={setPopperElement} ref={setPopperElement}
style={styles.popper} style={styles.popper}
{...attributes.popper} {...attributes.popper}
@ -92,7 +88,7 @@ const CustomMenu = (props: ICustomMenuDropdownProps) => {
as="div" as="div"
ref={dropdownRef} ref={dropdownRef}
tabIndex={tabIndex} tabIndex={tabIndex}
className={`relative w-min text-left ${className}`} className={cn("relative w-min text-left", className)}
onKeyDown={handleKeyDown} onKeyDown={handleKeyDown}
> >
{({ open }) => ( {({ open }) => (

View File

@ -1,14 +1,12 @@
import React, { useRef, useState } from "react"; import React, { useRef, useState } from "react";
// react-popper
import { usePopper } from "react-popper"; import { usePopper } from "react-popper";
import { Combobox } from "@headlessui/react";
import { Check, ChevronDown, Search } from "lucide-react";
// hooks // hooks
import { useDropdownKeyDown } from "../hooks/use-dropdown-key-down"; import { useDropdownKeyDown } from "../hooks/use-dropdown-key-down";
import useOutsideClickDetector from "../hooks/use-outside-click-detector"; import useOutsideClickDetector from "../hooks/use-outside-click-detector";
// headless ui // helpers
import { Combobox } from "@headlessui/react"; import { cn } from "../../helpers";
// icons
import { Check, ChevronDown, Search } from "lucide-react";
// types // types
import { ICustomSearchSelectProps } from "./helper"; import { ICustomSearchSelectProps } from "./helper";
@ -31,7 +29,6 @@ export const CustomSearchSelect = (props: ICustomSearchSelectProps) => {
onOpen, onOpen,
optionsClassName = "", optionsClassName = "",
value, value,
width = "auto",
tabIndex, tabIndex,
} = props; } = props;
const [query, setQuery] = useState(""); const [query, setQuery] = useState("");
@ -70,7 +67,7 @@ export const CustomSearchSelect = (props: ICustomSearchSelectProps) => {
as="div" as="div"
ref={dropdownRef} ref={dropdownRef}
tabIndex={tabIndex} tabIndex={tabIndex}
className={`relative flex-shrink-0 text-left ${className}`} className={cn("relative flex-shrink-0 text-left", className)}
onKeyDown={handleKeyDown} onKeyDown={handleKeyDown}
{...comboboxProps} {...comboboxProps}
> >
@ -114,37 +111,33 @@ export const CustomSearchSelect = (props: ICustomSearchSelectProps) => {
</Combobox.Button> </Combobox.Button>
)} )}
{isOpen && ( {isOpen && (
<Combobox.Options as={React.Fragment} static> <Combobox.Options className="fixed z-10" static>
<div <div
className={`z-10 my-1 min-w-[10rem] rounded-md border border-custom-border-300 bg-custom-background-90 p-2 text-xs shadow-custom-shadow-rg focus:outline-none ${ className={cn(
width === "auto" ? "min-w-[8rem] whitespace-nowrap" : width "my-1 overflow-y-scroll rounded-md border-[0.5px] border-custom-border-300 bg-custom-background-100 px-2 py-2.5 text-xs shadow-custom-shadow-rg focus:outline-none w-48 whitespace-nowrap",
} ${optionsClassName}`} optionsClassName
)}
ref={setPopperElement} ref={setPopperElement}
style={styles.popper} style={styles.popper}
{...attributes.popper} {...attributes.popper}
> >
<div className="flex w-full items-center justify-start rounded-sm border-[0.6px] border-custom-border-200 bg-custom-background-90 px-2"> <div className="flex items-center gap-1.5 rounded border border-custom-border-100 bg-custom-background-90 px-2">
<Search className="h-3 w-3 text-custom-text-200" /> <Search className="h-3.5 w-3.5 text-custom-text-400" strokeWidth={1.5} />
<Combobox.Input <Combobox.Input
className="w-full bg-transparent px-2 py-1 text-xs text-custom-text-200 placeholder:text-custom-text-400 focus:outline-none" className="w-full bg-transparent py-1 text-xs text-custom-text-200 placeholder:text-custom-text-400 focus:outline-none"
value={query} value={query}
onChange={(e) => setQuery(e.target.value)} onChange={(e) => setQuery(e.target.value)}
placeholder="Type to search..." placeholder="Search"
displayValue={(assigned: any) => assigned?.name} displayValue={(assigned: any) => assigned?.name}
/> />
</div> </div>
<div <div
className={`mt-2 space-y-1 ${ className={cn("mt-2 space-y-1 overflow-y-scroll", {
maxHeight === "lg" "max-h-60": maxHeight === "lg",
? "max-h-60" "max-h-48": maxHeight === "md",
: maxHeight === "md" "max-h-36": maxHeight === "rg",
? "max-h-48" "max-h-28": maxHeight === "sm",
: maxHeight === "rg" })}
? "max-h-36"
: maxHeight === "sm"
? "max-h-28"
: ""
} overflow-y-scroll`}
> >
{filteredOptions ? ( {filteredOptions ? (
filteredOptions.length > 0 ? ( filteredOptions.length > 0 ? (
@ -152,37 +145,31 @@ export const CustomSearchSelect = (props: ICustomSearchSelectProps) => {
<Combobox.Option <Combobox.Option
key={option.value} key={option.value}
value={option.value} value={option.value}
className={({ active, selected }) => className={({ active }) =>
`flex cursor-pointer select-none items-center justify-between gap-2 truncate rounded px-1 py-1.5 ${ cn(
active || selected ? "bg-custom-background-80" : "" "w-full truncate flex items-center justify-between gap-2 rounded px-1 py-1.5 cursor-pointer select-none",
} ${selected ? "text-custom-text-100" : "text-custom-text-200"}` {
"bg-custom-background-80": active,
}
)
} }
onClick={() => {
if (!multiple) closeDropdown();
}}
> >
{({ active, selected }) => ( {({ selected }) => (
<> <>
{option.content} <span className="flex-grow truncate">{option.content}</span>
{multiple ? ( {selected && <Check className="h-3.5 w-3.5 flex-shrink-0" />}
<div
className={`flex items-center justify-center rounded border border-custom-border-400 p-0.5 ${
active || selected ? "opacity-100" : "opacity-0"
}`}
>
<Check className={`h-3 w-3 ${selected ? "opacity-100" : "opacity-0"}`} />
</div>
) : (
<Check className={`h-3 w-3 ${selected ? "opacity-100" : "opacity-0"}`} />
)}
</> </>
)} )}
</Combobox.Option> </Combobox.Option>
)) ))
) : ( ) : (
<span className="flex items-center gap-2 p-1"> <p className="text-custom-text-400 italic py-1 px-1.5">No matches found</p>
<p className="text-left text-custom-text-200 ">No matching results</p>
</span>
) )
) : ( ) : (
<p className="text-center text-custom-text-200">Loading...</p> <p className="text-custom-text-400 italic py-1 px-1.5">Loading...</p>
)} )}
</div> </div>
{footerOption} {footerOption}

View File

@ -1,14 +1,12 @@
import React, { useRef, useState } from "react"; import React, { useRef, useState } from "react";
// react-popper
import { usePopper } from "react-popper"; import { usePopper } from "react-popper";
import { Listbox } from "@headlessui/react";
import { Check, ChevronDown } from "lucide-react";
// hooks // hooks
import { useDropdownKeyDown } from "../hooks/use-dropdown-key-down"; import { useDropdownKeyDown } from "../hooks/use-dropdown-key-down";
import useOutsideClickDetector from "../hooks/use-outside-click-detector"; import useOutsideClickDetector from "../hooks/use-outside-click-detector";
// headless ui // helpers
import { Listbox } from "@headlessui/react"; import { cn } from "../../helpers";
// icons
import { Check, ChevronDown } from "lucide-react";
// types // types
import { ICustomSelectItemProps, ICustomSelectProps } from "./helper"; import { ICustomSelectItemProps, ICustomSelectProps } from "./helper";
@ -28,7 +26,6 @@ const CustomSelect = (props: ICustomSelectProps) => {
onChange, onChange,
optionsClassName = "", optionsClassName = "",
value, value,
width = "auto",
tabIndex, tabIndex,
} = props; } = props;
// states // states
@ -57,7 +54,7 @@ const CustomSelect = (props: ICustomSelectProps) => {
tabIndex={tabIndex} tabIndex={tabIndex}
value={value} value={value}
onChange={onChange} onChange={onChange}
className={`relative flex-shrink-0 text-left ${className}`} className={cn("relative flex-shrink-0 text-left", className)}
onKeyDown={handleKeyDown} onKeyDown={handleKeyDown}
disabled={disabled} disabled={disabled}
> >
@ -94,24 +91,23 @@ const CustomSelect = (props: ICustomSelectProps) => {
)} )}
</> </>
{isOpen && ( {isOpen && (
<Listbox.Options static> <Listbox.Options className="fixed z-10" onClick={() => closeDropdown()} static>
<div <div
className={`z-10 my-1 overflow-y-auto rounded-md border border-custom-border-300 bg-custom-background-90 text-xs shadow-custom-shadow-rg focus:outline-none ${ className={cn(
maxHeight === "lg" "my-1 overflow-y-scroll rounded-md border-[0.5px] border-custom-border-300 bg-custom-background-100 px-2 py-2.5 text-xs shadow-custom-shadow-rg focus:outline-none min-w-[12rem] whitespace-nowrap",
? "max-h-60" {
: maxHeight === "md" "max-h-60": maxHeight === "lg",
? "max-h-48" "max-h-48": maxHeight === "md",
: maxHeight === "rg" "max-h-36": maxHeight === "rg",
? "max-h-36" "max-h-28": maxHeight === "sm",
: maxHeight === "sm" },
? "max-h-28" optionsClassName
: "" )}
} ${width === "auto" ? "min-w-[8rem] whitespace-nowrap" : width} ${optionsClassName}`}
ref={setPopperElement} ref={setPopperElement}
style={styles.popper} style={styles.popper}
{...attributes.popper} {...attributes.popper}
> >
<div className="space-y-1 p-2">{children}</div> {children}
</div> </div>
</Listbox.Options> </Listbox.Options>
)} )}
@ -124,16 +120,20 @@ const Option = (props: ICustomSelectItemProps) => {
return ( return (
<Listbox.Option <Listbox.Option
value={value} value={value}
className={({ active, selected }) => className={({ active }) =>
`cursor-pointer select-none truncate rounded px-1 py-1.5 ${ cn(
active || selected ? "bg-custom-background-80" : "" "cursor-pointer select-none truncate rounded px-1 py-1.5 text-custom-text-200",
} ${selected ? "text-custom-text-100" : "text-custom-text-200"} ${className}` {
"bg-custom-background-80": active,
},
className
)
} }
> >
{({ selected }) => ( {({ selected }) => (
<div className="flex items-center justify-between gap-2"> <div className="flex items-center justify-between gap-2">
<div className="flex items-center gap-2">{children}</div> <div className="flex items-center gap-2">{children}</div>
{selected && <Check className="h-4 w-4 flex-shrink-0" />} {selected && <Check className="h-3.5 w-3.5 flex-shrink-0" />}
</div> </div>
)} )}
</Listbox.Option> </Listbox.Option>

View File

@ -13,7 +13,6 @@ export interface IDropdownProps {
noChevron?: boolean; noChevron?: boolean;
onOpen?: () => void; onOpen?: () => void;
optionsClassName?: string; optionsClassName?: string;
width?: "auto" | string;
placement?: Placement; placement?: Placement;
tabIndex?: number; tabIndex?: number;
} }

View File

@ -21,9 +21,9 @@ export const SelectProject: React.FC<Props> = observer((props) => {
value: projectDetails?.id, value: projectDetails?.id,
query: `${projectDetails?.name} ${projectDetails?.identifier}`, query: `${projectDetails?.name} ${projectDetails?.identifier}`,
content: ( content: (
<div className="flex items-center gap-2"> <div className="flex items-center gap-2 truncate">
<span className="text-[0.65rem] text-custom-text-200">{projectDetails?.identifier}</span> <span className="text-[0.65rem] text-custom-text-200 flex-shrink-0">{projectDetails?.identifier}</span>
{projectDetails?.name} <span className="flex-grow truncate">{projectDetails?.name}</span>
</div> </div>
), ),
}; };
@ -42,7 +42,6 @@ export const SelectProject: React.FC<Props> = observer((props) => {
.join(", ") .join(", ")
: "All projects" : "All projects"
} }
optionsClassName="min-w-full max-w-[20rem]"
multiple multiple
/> />
); );

View File

@ -28,7 +28,6 @@ export const SelectSegment: React.FC<Props> = ({ value, onChange, params }) => {
</span> </span>
} }
onChange={onChange} onChange={onChange}
width="w-full"
maxHeight="lg" maxHeight="lg"
> >
<CustomSelect.Option value={null}>No value</CustomSelect.Option> <CustomSelect.Option value={null}>No value</CustomSelect.Option>

View File

@ -24,7 +24,6 @@ export const SelectXAxis: React.FC<Props> = (props) => {
value={value} value={value}
label={<span>{ANALYTICS_X_AXIS_VALUES.find((v) => v.value === value)?.label}</span>} label={<span>{ANALYTICS_X_AXIS_VALUES.find((v) => v.value === value)?.label}</span>}
onChange={onChange} onChange={onChange}
width="w-full"
maxHeight="lg" maxHeight="lg"
> >
{ANALYTICS_X_AXIS_VALUES.map((item) => { {ANALYTICS_X_AXIS_VALUES.map((item) => {

View File

@ -15,7 +15,7 @@ export const SelectYAxis: React.FC<Props> = ({ value, onChange }) => (
value={value} value={value}
label={<span>{ANALYTICS_Y_AXIS_VALUES.find((v) => v.value === value)?.label ?? "None"}</span>} label={<span>{ANALYTICS_Y_AXIS_VALUES.find((v) => v.value === value)?.label ?? "None"}</span>}
onChange={onChange} onChange={onChange}
width="w-full" maxHeight="lg"
> >
{ANALYTICS_Y_AXIS_VALUES.map((item) => ( {ANALYTICS_Y_AXIS_VALUES.map((item) => (
<CustomSelect.Option key={item.value} value={item.value}> <CustomSelect.Option key={item.value} value={item.value}>

View File

@ -79,7 +79,6 @@ export const AutoArchiveAutomation: React.FC<Props> = observer((props) => {
handleChange({ archive_in: val }); handleChange({ archive_in: val });
}} }}
input input
width="w-full"
disabled={!isAdmin} disabled={!isAdmin}
> >
<> <>

View File

@ -106,7 +106,6 @@ export const AutoCloseAutomation: React.FC<Props> = observer((props) => {
handleChange({ close_in: val }); handleChange({ close_in: val });
}} }}
input input
width="w-full"
disabled={!isAdmin} disabled={!isAdmin}
> >
<> <>
@ -161,7 +160,6 @@ export const AutoCloseAutomation: React.FC<Props> = observer((props) => {
}} }}
options={options} options={options}
disabled={!multipleOptions} disabled={!multipleOptions}
width="w-full"
input input
/> />
</div> </div>

View File

@ -43,7 +43,7 @@ const IssueLink = ({ activity }: { activity: IIssueActivity }) => {
}`} }`}
target={activity.issue === null ? "_self" : "_blank"} target={activity.issue === null ? "_self" : "_blank"}
rel={activity.issue === null ? "" : "noopener noreferrer"} rel={activity.issue === null ? "" : "noopener noreferrer"}
className="inline-flex items-center gap-1 font-medium text-custom-text-100 hover:underline" className="inline-flex items-center gap-1 font-medium text-custom-text-100 hover:underline whitespace-nowrap"
> >
{activity.issue_detail ? `${activity.project_detail.identifier}-${activity.issue_detail.sequence_id}` : "Issue"}{" "} {activity.issue_detail ? `${activity.project_detail.identifier}-${activity.issue_detail.sequence_id}` : "Issue"}{" "}
<span className="font-normal">{activity.issue_detail?.name}</span> <span className="font-normal">{activity.issue_detail?.name}</span>
@ -123,7 +123,6 @@ const activityDetails: {
to <IssueLink activity={activity} /> to <IssueLink activity={activity} />
</> </>
)} )}
.
</> </>
); );
else else
@ -136,7 +135,6 @@ const activityDetails: {
from <IssueLink activity={activity} /> from <IssueLink activity={activity} />
</> </>
)} )}
.
</> </>
); );
}, },
@ -181,7 +179,6 @@ const activityDetails: {
from <IssueLink activity={activity} /> from <IssueLink activity={activity} />
</> </>
)} )}
.
</> </>
); );
}, },
@ -197,7 +194,6 @@ const activityDetails: {
of <IssueLink activity={activity} /> of <IssueLink activity={activity} />
</> </>
)} )}
.
</> </>
), ),
icon: <MessageSquareIcon size={12} color="#6b7280" aria-hidden="true" />, icon: <MessageSquareIcon size={12} color="#6b7280" aria-hidden="true" />,
@ -214,7 +210,6 @@ const activityDetails: {
from <IssueLink activity={activity} /> from <IssueLink activity={activity} />
</> </>
)} )}
.
</> </>
); );
else else
@ -227,7 +222,6 @@ const activityDetails: {
for <IssueLink activity={activity} /> for <IssueLink activity={activity} />
</> </>
)} )}
.
</> </>
); );
}, },
@ -297,7 +291,6 @@ const activityDetails: {
to <IssueLink activity={activity} /> to <IssueLink activity={activity} />
</> </>
)} )}
.
</> </>
); );
else if (activity.verb === "updated") else if (activity.verb === "updated")
@ -318,7 +311,6 @@ const activityDetails: {
from <IssueLink activity={activity} /> from <IssueLink activity={activity} />
</> </>
)} )}
.
</> </>
); );
else else
@ -339,7 +331,6 @@ const activityDetails: {
from <IssueLink activity={activity} /> from <IssueLink activity={activity} />
</> </>
)} )}
.
</> </>
); );
}, },
@ -449,7 +440,6 @@ const activityDetails: {
of <IssueLink activity={activity} /> of <IssueLink activity={activity} />
</> </>
)} )}
.
</> </>
), ),
icon: <MessageSquareIcon size={12} color="#6b7280" aria-hidden="true" />, icon: <MessageSquareIcon size={12} color="#6b7280" aria-hidden="true" />,
@ -466,7 +456,6 @@ const activityDetails: {
from <IssueLink activity={activity} /> from <IssueLink activity={activity} />
</> </>
)} )}
.
</> </>
); );
else else
@ -479,7 +468,6 @@ const activityDetails: {
for <IssueLink activity={activity} /> for <IssueLink activity={activity} />
</> </>
)} )}
.
</> </>
); );
}, },
@ -498,7 +486,6 @@ const activityDetails: {
for <IssueLink activity={activity} /> for <IssueLink activity={activity} />
</> </>
)} )}
.
</> </>
), ),
icon: <SignalMediumIcon size={12} color="#6b7280" aria-hidden="true" />, icon: <SignalMediumIcon size={12} color="#6b7280" aria-hidden="true" />,
@ -587,7 +574,6 @@ const activityDetails: {
for <IssueLink activity={activity} /> for <IssueLink activity={activity} />
</> </>
)} )}
.
</> </>
), ),
icon: <LayoutGridIcon size={12} color="#6b7280" aria-hidden="true" />, icon: <LayoutGridIcon size={12} color="#6b7280" aria-hidden="true" />,
@ -604,7 +590,6 @@ const activityDetails: {
from <IssueLink activity={activity} /> from <IssueLink activity={activity} />
</> </>
)} )}
.
</> </>
); );
else else
@ -618,7 +603,6 @@ const activityDetails: {
for <IssueLink activity={activity} /> for <IssueLink activity={activity} />
</> </>
)} )}
.
</> </>
); );
}, },
@ -636,7 +620,6 @@ const activityDetails: {
from <IssueLink activity={activity} /> from <IssueLink activity={activity} />
</> </>
)} )}
.
</> </>
); );
else else
@ -650,7 +633,6 @@ const activityDetails: {
for <IssueLink activity={activity} /> for <IssueLink activity={activity} />
</> </>
)} )}
.
</> </>
); );
}, },

View File

@ -46,7 +46,6 @@ export const ThemeSwitch: FC<Props> = (props) => {
} }
onChange={onChange} onChange={onChange}
input input
width="w-full z-20"
> >
{THEME_OPTIONS.map((themeOption) => ( {THEME_OPTIONS.map((themeOption) => (
<CustomSelect.Option key={themeOption.value} value={themeOption}> <CustomSelect.Option key={themeOption.value} value={themeOption}>

View File

@ -246,7 +246,7 @@ export const CyclesBoardCard: FC<ICyclesBoardCard> = (props) => {
<Star className="h-3.5 w-3.5 text-custom-text-200" /> <Star className="h-3.5 w-3.5 text-custom-text-200" />
</button> </button>
))} ))}
<CustomMenu width="auto" ellipsis className="z-10"> <CustomMenu ellipsis className="z-10">
{!isCompleted && isEditingAllowed && ( {!isCompleted && isEditingAllowed && (
<> <>
<CustomMenu.MenuItem onClick={handleEditCycle}> <CustomMenu.MenuItem onClick={handleEditCycle}>

View File

@ -240,7 +240,7 @@ export const CyclesListItem: FC<TCyclesListItem> = (props) => {
</button> </button>
))} ))}
<CustomMenu width="auto" ellipsis> <CustomMenu ellipsis>
{!isCompleted && isEditingAllowed && ( {!isCompleted && isEditingAllowed && (
<> <>
<CustomMenu.MenuItem onClick={handleEditCycle}> <CustomMenu.MenuItem onClick={handleEditCycle}>

View File

@ -341,7 +341,7 @@ export const CycleDetailsSidebar: React.FC<Props> = observer((props) => {
<LinkIcon className="h-3 w-3 text-custom-text-300" /> <LinkIcon className="h-3 w-3 text-custom-text-300" />
</button> </button>
{!isCompleted && isEditingAllowed && ( {!isCompleted && isEditingAllowed && (
<CustomMenu width="lg" placement="bottom-end" ellipsis> <CustomMenu placement="bottom-end" ellipsis>
<CustomMenu.MenuItem <CustomMenu.MenuItem
onClick={() => { onClick={() => {
setTrackElement("CYCLE_PAGE_SIDEBAR"); setTrackElement("CYCLE_PAGE_SIDEBAR");

View File

@ -2,7 +2,6 @@ import { Fragment, ReactNode, useEffect, useRef, useState } from "react";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
import { Combobox } from "@headlessui/react"; import { Combobox } from "@headlessui/react";
import { usePopper } from "react-popper"; import { usePopper } from "react-popper";
import { Placement } from "@popperjs/core";
import { Check, ChevronDown, Search } from "lucide-react"; import { Check, ChevronDown, Search } from "lucide-react";
// hooks // hooks
import { useApplication, useCycle } from "hooks/store"; import { useApplication, useCycle } from "hooks/store";
@ -14,21 +13,14 @@ import { ContrastIcon } from "@plane/ui";
import { cn } from "helpers/common.helper"; import { cn } from "helpers/common.helper";
// types // types
import { ICycle } from "@plane/types"; import { ICycle } from "@plane/types";
import { TButtonVariants } from "./types"; import { TDropdownProps } from "./types";
type Props = { type Props = TDropdownProps & {
button?: ReactNode; button?: ReactNode;
buttonClassName?: string;
buttonContainerClassName?: string;
buttonVariant: TButtonVariants;
className?: string;
disabled?: boolean;
dropdownArrow?: boolean; dropdownArrow?: boolean;
onChange: (val: string | null) => void; onChange: (val: string | null) => void;
placement?: Placement;
projectId: string; projectId: string;
value: string | null; value: string | null;
tabIndex?: number;
}; };
type ButtonProps = { type ButtonProps = {
@ -291,6 +283,7 @@ export const CycleDropdown: React.FC<Props> = observer((props) => {
active ? "bg-custom-background-80" : "" active ? "bg-custom-background-80" : ""
} ${selected ? "text-custom-text-100" : "text-custom-text-200"}` } ${selected ? "text-custom-text-100" : "text-custom-text-200"}`
} }
onClick={closeDropdown}
> >
{({ selected }) => ( {({ selected }) => (
<> <>

View File

@ -3,7 +3,6 @@ import { Popover } from "@headlessui/react";
import DatePicker from "react-datepicker"; import DatePicker from "react-datepicker";
import { usePopper } from "react-popper"; import { usePopper } from "react-popper";
import { CalendarDays, X } from "lucide-react"; import { CalendarDays, X } from "lucide-react";
// import "react-datepicker/dist/react-datepicker.css";
// hooks // hooks
import { useDropdownKeyDown } from "hooks/use-dropdown-key-down"; import { useDropdownKeyDown } from "hooks/use-dropdown-key-down";
import useOutsideClickDetector from "hooks/use-outside-click-detector"; import useOutsideClickDetector from "hooks/use-outside-click-detector";
@ -11,24 +10,17 @@ import useOutsideClickDetector from "hooks/use-outside-click-detector";
import { renderFormattedDate } from "helpers/date-time.helper"; import { renderFormattedDate } from "helpers/date-time.helper";
import { cn } from "helpers/common.helper"; import { cn } from "helpers/common.helper";
// types // types
import { TButtonVariants } from "./types"; import { TDropdownProps } from "./types";
import { Placement } from "@popperjs/core";
type Props = { type Props = TDropdownProps & {
buttonClassName?: string;
buttonContainerClassName?: string;
buttonVariant: TButtonVariants;
disabled?: boolean;
icon?: React.ReactNode; icon?: React.ReactNode;
isClearable?: boolean; isClearable?: boolean;
minDate?: Date; minDate?: Date;
maxDate?: Date; maxDate?: Date;
onChange: (val: Date | null) => void; onChange: (val: Date | null) => void;
placeholder: string; placeholder: string;
placement?: Placement;
value: Date | string | null; value: Date | string | null;
closeOnSelect?: boolean; closeOnSelect?: boolean;
tabIndex?: number;
}; };
type ButtonProps = { type ButtonProps = {
@ -118,6 +110,7 @@ export const DateDropdown: React.FC<Props> = (props) => {
buttonClassName = "", buttonClassName = "",
buttonContainerClassName, buttonContainerClassName,
buttonVariant, buttonVariant,
className = "",
disabled = false, disabled = false,
icon = <CalendarDays className="h-3 w-3 flex-shrink-0" />, icon = <CalendarDays className="h-3 w-3 flex-shrink-0" />,
isClearable = true, isClearable = true,
@ -160,102 +153,103 @@ export const DateDropdown: React.FC<Props> = (props) => {
useOutsideClickDetector(dropdownRef, closeDropdown); useOutsideClickDetector(dropdownRef, closeDropdown);
return ( return (
<Popover ref={dropdownRef} tabIndex={tabIndex} className="h-full flex-shrink-0" onKeyDown={handleKeyDown}> <Popover
{({ close }) => ( ref={dropdownRef}
<> tabIndex={tabIndex}
<Popover.Button as={React.Fragment}> className={cn("h-full flex-shrink-0", className)}
<button onKeyDown={handleKeyDown}
ref={setReferenceElement} >
type="button" <Popover.Button as={React.Fragment}>
className={cn( <button
"block h-full max-w-full outline-none", ref={setReferenceElement}
{ type="button"
"cursor-not-allowed text-custom-text-200": disabled, className={cn(
"cursor-pointer": !disabled, "block h-full max-w-full outline-none",
}, {
buttonContainerClassName "cursor-not-allowed text-custom-text-200": disabled,
)} "cursor-pointer": !disabled,
onClick={openDropdown} },
> buttonContainerClassName
{buttonVariant === "border-with-text" ? (
<BorderButton
date={value}
className={buttonClassName}
icon={icon}
placeholder={placeholder}
isClearable={isClearable && isDateSelected}
onClear={() => onChange(null)}
/>
) : buttonVariant === "border-without-text" ? (
<BorderButton
date={value}
className={buttonClassName}
icon={icon}
placeholder={placeholder}
isClearable={isClearable && isDateSelected}
onClear={() => onChange(null)}
hideText
/>
) : buttonVariant === "background-with-text" ? (
<BackgroundButton
date={value}
className={buttonClassName}
icon={icon}
placeholder={placeholder}
isClearable={isClearable && isDateSelected}
onClear={() => onChange(null)}
/>
) : buttonVariant === "background-without-text" ? (
<BackgroundButton
date={value}
className={buttonClassName}
icon={icon}
placeholder={placeholder}
isClearable={isClearable && isDateSelected}
onClear={() => onChange(null)}
hideText
/>
) : buttonVariant === "transparent-with-text" ? (
<TransparentButton
date={value}
className={buttonClassName}
icon={icon}
placeholder={placeholder}
isClearable={isClearable && isDateSelected}
onClear={() => onChange(null)}
/>
) : buttonVariant === "transparent-without-text" ? (
<TransparentButton
date={value}
className={buttonClassName}
icon={icon}
placeholder={placeholder}
isClearable={isClearable && isDateSelected}
onClear={() => onChange(null)}
hideText
/>
) : null}
</button>
</Popover.Button>
{isOpen && (
<Popover.Panel className="fixed z-10" static>
<div className="my-1" ref={setPopperElement} style={styles.popper} {...attributes.popper}>
<DatePicker
selected={value ? new Date(value) : null}
onChange={(val) => {
onChange(val);
if (closeOnSelect) close();
}}
dateFormat="dd-MM-yyyy"
minDate={minDate}
maxDate={maxDate}
calendarClassName="shadow-custom-shadow-rg rounded"
inline
/>
</div>
</Popover.Panel>
)} )}
</> onClick={openDropdown}
>
{buttonVariant === "border-with-text" ? (
<BorderButton
date={value}
className={buttonClassName}
icon={icon}
placeholder={placeholder}
isClearable={isClearable && isDateSelected}
onClear={() => onChange(null)}
/>
) : buttonVariant === "border-without-text" ? (
<BorderButton
date={value}
className={buttonClassName}
icon={icon}
placeholder={placeholder}
isClearable={isClearable && isDateSelected}
onClear={() => onChange(null)}
hideText
/>
) : buttonVariant === "background-with-text" ? (
<BackgroundButton
date={value}
className={buttonClassName}
icon={icon}
placeholder={placeholder}
isClearable={isClearable && isDateSelected}
onClear={() => onChange(null)}
/>
) : buttonVariant === "background-without-text" ? (
<BackgroundButton
date={value}
className={buttonClassName}
icon={icon}
placeholder={placeholder}
isClearable={isClearable && isDateSelected}
onClear={() => onChange(null)}
hideText
/>
) : buttonVariant === "transparent-with-text" ? (
<TransparentButton
date={value}
className={buttonClassName}
icon={icon}
placeholder={placeholder}
isClearable={isClearable && isDateSelected}
onClear={() => onChange(null)}
/>
) : buttonVariant === "transparent-without-text" ? (
<TransparentButton
date={value}
className={buttonClassName}
icon={icon}
placeholder={placeholder}
isClearable={isClearable && isDateSelected}
onClear={() => onChange(null)}
hideText
/>
) : null}
</button>
</Popover.Button>
{isOpen && (
<Popover.Panel className="fixed z-10" static>
<div className="my-1" ref={setPopperElement} style={styles.popper} {...attributes.popper}>
<DatePicker
selected={value ? new Date(value) : null}
onChange={(val) => {
onChange(val);
if (closeOnSelect) closeDropdown();
}}
dateFormat="dd-MM-yyyy"
minDate={minDate}
maxDate={maxDate}
calendarClassName="shadow-custom-shadow-rg rounded"
inline
/>
</div>
</Popover.Panel>
)} )}
</Popover> </Popover>
); );

View File

@ -2,7 +2,6 @@ import { Fragment, ReactNode, useEffect, useRef, useState } from "react";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
import { Combobox } from "@headlessui/react"; import { Combobox } from "@headlessui/react";
import { usePopper } from "react-popper"; import { usePopper } from "react-popper";
import { Placement } from "@popperjs/core";
import { Check, ChevronDown, Search, Triangle } from "lucide-react"; import { Check, ChevronDown, Search, Triangle } from "lucide-react";
import sortBy from "lodash/sortBy"; import sortBy from "lodash/sortBy";
// hooks // hooks
@ -12,21 +11,14 @@ import useOutsideClickDetector from "hooks/use-outside-click-detector";
// helpers // helpers
import { cn } from "helpers/common.helper"; import { cn } from "helpers/common.helper";
// types // types
import { TButtonVariants } from "./types"; import { TDropdownProps } from "./types";
type Props = { type Props = TDropdownProps & {
button?: ReactNode; button?: ReactNode;
buttonClassName?: string;
buttonContainerClassName?: string;
buttonVariant: TButtonVariants;
className?: string;
disabled?: boolean;
dropdownArrow?: boolean; dropdownArrow?: boolean;
onChange: (val: number | null) => void; onChange: (val: number | null) => void;
placement?: Placement;
projectId: string; projectId: string;
value: number | null; value: number | null;
tabIndex?: number;
}; };
type ButtonProps = { type ButtonProps = {
@ -280,6 +272,7 @@ export const EstimateDropdown: React.FC<Props> = observer((props) => {
active ? "bg-custom-background-80" : "" active ? "bg-custom-background-80" : ""
} ${selected ? "text-custom-text-100" : "text-custom-text-200"}` } ${selected ? "text-custom-text-100" : "text-custom-text-200"}`
} }
onClick={closeDropdown}
> >
{({ selected }) => ( {({ selected }) => (
<> <>

View File

@ -217,6 +217,9 @@ export const ProjectMemberDropdown: React.FC<Props> = observer((props) => {
active ? "bg-custom-background-80" : "" active ? "bg-custom-background-80" : ""
} ${selected ? "text-custom-text-100" : "text-custom-text-200"}` } ${selected ? "text-custom-text-100" : "text-custom-text-200"}`
} }
onClick={() => {
if (!multiple) closeDropdown();
}}
> >
{({ selected }) => ( {({ selected }) => (
<> <>

View File

@ -1,26 +1,18 @@
import { Placement } from "@popperjs/core"; import { TDropdownProps } from "../types";
import { TButtonVariants } from "../types";
export type MemberDropdownProps = { export type MemberDropdownProps = TDropdownProps & {
button?: ReactNode; button?: ReactNode;
buttonClassName?: string;
buttonContainerClassName?: string;
buttonVariant: TButtonVariants;
className?: string;
disabled?: boolean;
dropdownArrow?: boolean; dropdownArrow?: boolean;
placeholder?: string; placeholder?: string;
placement?: Placement;
tabIndex?: number;
} & ( } & (
| { | {
multiple: false; multiple: false;
onChange: (val: string | null) => void; onChange: (val: string | null) => void;
value: string | null; value: string | null;
} }
| { | {
multiple: true; multiple: true;
onChange: (val: string[]) => void; onChange: (val: string[]) => void;
value: string[]; value: string[];
} }
); );

View File

@ -1,4 +1,4 @@
import { Fragment, useState } from "react"; import { Fragment, useRef, useState } from "react";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
import { Combobox } from "@headlessui/react"; import { Combobox } from "@headlessui/react";
import { usePopper } from "react-popper"; import { usePopper } from "react-popper";
@ -13,6 +13,8 @@ import { Avatar } from "@plane/ui";
import { cn } from "helpers/common.helper"; import { cn } from "helpers/common.helper";
// types // types
import { MemberDropdownProps } from "./types"; import { MemberDropdownProps } from "./types";
import { useDropdownKeyDown } from "hooks/use-dropdown-key-down";
import useOutsideClickDetector from "hooks/use-outside-click-detector";
export const WorkspaceMemberDropdown: React.FC<MemberDropdownProps> = observer((props) => { export const WorkspaceMemberDropdown: React.FC<MemberDropdownProps> = observer((props) => {
const { const {
@ -28,9 +30,13 @@ export const WorkspaceMemberDropdown: React.FC<MemberDropdownProps> = observer((
placeholder = "Members", placeholder = "Members",
placement, placement,
value, value,
tabIndex,
} = props; } = props;
// states // states
const [query, setQuery] = useState(""); const [query, setQuery] = useState("");
const [isOpen, setIsOpen] = useState(false);
// refs
const dropdownRef = useRef<HTMLDivElement | null>(null);
// popper-js refs // popper-js refs
const [referenceElement, setReferenceElement] = useState<HTMLButtonElement | null>(null); const [referenceElement, setReferenceElement] = useState<HTMLButtonElement | null>(null);
const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(null); const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(null);
@ -78,13 +84,24 @@ export const WorkspaceMemberDropdown: React.FC<MemberDropdownProps> = observer((
}; };
if (multiple) comboboxProps.multiple = true; if (multiple) comboboxProps.multiple = true;
const openDropdown = () => {
setIsOpen(true);
if (referenceElement) referenceElement.focus();
};
const closeDropdown = () => setIsOpen(false);
const handleKeyDown = useDropdownKeyDown(openDropdown, closeDropdown, isOpen);
useOutsideClickDetector(dropdownRef, closeDropdown);
return ( return (
<Combobox <Combobox
as="div" as="div"
ref={dropdownRef}
tabIndex={tabIndex}
className={cn("h-full flex-shrink-0", { className={cn("h-full flex-shrink-0", {
className, className,
})} })}
{...comboboxProps} {...comboboxProps}
handleKeyDown={handleKeyDown}
> >
<Combobox.Button as={Fragment}> <Combobox.Button as={Fragment}>
{button ? ( {button ? (
@ -186,6 +203,9 @@ export const WorkspaceMemberDropdown: React.FC<MemberDropdownProps> = observer((
active ? "bg-custom-background-80" : "" active ? "bg-custom-background-80" : ""
} ${selected ? "text-custom-text-100" : "text-custom-text-200"}` } ${selected ? "text-custom-text-100" : "text-custom-text-200"}`
} }
onClick={() => {
if (!multiple) closeDropdown();
}}
> >
{({ selected }) => ( {({ selected }) => (
<> <>

View File

@ -2,7 +2,6 @@ import { Fragment, ReactNode, useEffect, useRef, useState } from "react";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
import { Combobox } from "@headlessui/react"; import { Combobox } from "@headlessui/react";
import { usePopper } from "react-popper"; import { usePopper } from "react-popper";
import { Placement } from "@popperjs/core";
import { Check, ChevronDown, Search } from "lucide-react"; import { Check, ChevronDown, Search } from "lucide-react";
// hooks // hooks
import { useApplication, useModule } from "hooks/store"; import { useApplication, useModule } from "hooks/store";
@ -14,21 +13,14 @@ import { DiceIcon } from "@plane/ui";
import { cn } from "helpers/common.helper"; import { cn } from "helpers/common.helper";
// types // types
import { IModule } from "@plane/types"; import { IModule } from "@plane/types";
import { TButtonVariants } from "./types"; import { TDropdownProps } from "./types";
type Props = { type Props = TDropdownProps & {
button?: ReactNode; button?: ReactNode;
buttonClassName?: string;
buttonContainerClassName?: string;
buttonVariant: TButtonVariants;
className?: string;
disabled?: boolean;
dropdownArrow?: boolean; dropdownArrow?: boolean;
onChange: (val: string | null) => void; onChange: (val: string | null) => void;
placement?: Placement;
projectId: string; projectId: string;
value: string | null; value: string | null;
tabIndex?: number;
}; };
type DropdownOptions = type DropdownOptions =
@ -186,9 +178,7 @@ export const ModuleDropdown: React.FC<Props> = observer((props) => {
as="div" as="div"
ref={dropdownRef} ref={dropdownRef}
tabIndex={tabIndex} tabIndex={tabIndex}
className={cn("h-full flex-shrink-0", { className={cn("h-full flex-shrink-0", className)}
className,
})}
value={value} value={value}
onChange={onChange} onChange={onChange}
disabled={disabled} disabled={disabled}
@ -291,6 +281,7 @@ export const ModuleDropdown: React.FC<Props> = observer((props) => {
active ? "bg-custom-background-80" : "" active ? "bg-custom-background-80" : ""
} ${selected ? "text-custom-text-100" : "text-custom-text-200"}` } ${selected ? "text-custom-text-100" : "text-custom-text-200"}`
} }
onClick={closeDropdown}
> >
{({ selected }) => ( {({ selected }) => (
<> <>

View File

@ -1,7 +1,6 @@
import { Fragment, ReactNode, useRef, useState } from "react"; import { Fragment, ReactNode, useRef, useState } from "react";
import { Combobox } from "@headlessui/react"; import { Combobox } from "@headlessui/react";
import { usePopper } from "react-popper"; import { usePopper } from "react-popper";
import { Placement } from "@popperjs/core";
import { Check, ChevronDown, Search } from "lucide-react"; import { Check, ChevronDown, Search } from "lucide-react";
// hooks // hooks
import { useDropdownKeyDown } from "hooks/use-dropdown-key-down"; import { useDropdownKeyDown } from "hooks/use-dropdown-key-down";
@ -12,23 +11,17 @@ import { PriorityIcon } from "@plane/ui";
import { cn } from "helpers/common.helper"; import { cn } from "helpers/common.helper";
// types // types
import { TIssuePriorities } from "@plane/types"; import { TIssuePriorities } from "@plane/types";
import { TButtonVariants } from "./types"; import { TDropdownProps } from "./types";
// constants // constants
import { ISSUE_PRIORITIES } from "constants/issue"; import { ISSUE_PRIORITIES } from "constants/issue";
import { useTheme } from "next-themes";
type Props = { type Props = TDropdownProps & {
button?: ReactNode; button?: ReactNode;
buttonClassName?: string;
buttonContainerClassName?: string;
buttonVariant: TButtonVariants;
className?: string;
disabled?: boolean;
dropdownArrow?: boolean; dropdownArrow?: boolean;
highlightUrgent?: boolean; highlightUrgent?: boolean;
onChange: (val: TIssuePriorities) => void; onChange: (val: TIssuePriorities) => void;
placement?: Placement;
value: TIssuePriorities; value: TIssuePriorities;
tabIndex?: number;
}; };
type ButtonProps = { type ButtonProps = {
@ -236,43 +229,20 @@ export const PriorityDropdown: React.FC<Props> = (props) => {
}, },
], ],
}); });
// next-themes
// TODO: remove this after new theming implementation
const { resolvedTheme } = useTheme();
const options = ISSUE_PRIORITIES.map((priority) => { const options = ISSUE_PRIORITIES.map((priority) => ({
const priorityClasses = { value: priority.key,
urgent: "bg-red-500/20 text-red-950 border-red-500", query: priority.key,
high: "bg-orange-500/20 text-orange-950 border-orange-500", content: (
medium: "bg-yellow-500/20 text-yellow-950 border-yellow-500", <div className="flex items-center gap-2">
low: "bg-custom-primary-100/20 text-custom-primary-950 border-custom-primary-100", <PriorityIcon priority={priority.key} size={14} withContainer />
none: "bg-custom-background-80 border-custom-border-300", <span className="flex-grow truncate">{priority.title}</span>
}; </div>
),
return { }));
value: priority.key,
query: priority.key,
content: (
<div className="flex items-center gap-2">
<div
className={cn("grid place-items-center border rounded p-0.5 flex-shrink-0", priorityClasses[priority.key], {
"bg-red-500 border-red-500": priority.key === "urgent" && highlightUrgent,
})}
>
<PriorityIcon
priority={priority.key}
size={14}
className={cn({
"text-white": priority.key === "urgent" && highlightUrgent,
// centre align the icons if text is hidden
"translate-x-[0.0625rem]": priority.key === "high",
"translate-x-0.5": priority.key === "medium",
"translate-x-1": priority.key === "low",
})}
/>
</div>
<span className="flex-grow truncate">{priority.title}</span>
</div>
),
};
});
const filteredOptions = const filteredOptions =
query === "" ? options : options.filter((o) => o.query.toLowerCase().includes(query.toLowerCase())); query === "" ? options : options.filter((o) => o.query.toLowerCase().includes(query.toLowerCase()));
@ -325,14 +295,18 @@ export const PriorityDropdown: React.FC<Props> = (props) => {
{buttonVariant === "border-with-text" ? ( {buttonVariant === "border-with-text" ? (
<BorderButton <BorderButton
priority={value} priority={value}
className={buttonClassName} className={cn(buttonClassName, {
"text-white": resolvedTheme === "dark",
})}
highlightUrgent={highlightUrgent} highlightUrgent={highlightUrgent}
dropdownArrow={dropdownArrow && !disabled} dropdownArrow={dropdownArrow && !disabled}
/> />
) : buttonVariant === "border-without-text" ? ( ) : buttonVariant === "border-without-text" ? (
<BorderButton <BorderButton
priority={value} priority={value}
className={buttonClassName} className={cn(buttonClassName, {
"text-white": resolvedTheme === "dark",
})}
highlightUrgent={highlightUrgent} highlightUrgent={highlightUrgent}
dropdownArrow={dropdownArrow && !disabled} dropdownArrow={dropdownArrow && !disabled}
hideText hideText
@ -340,14 +314,18 @@ export const PriorityDropdown: React.FC<Props> = (props) => {
) : buttonVariant === "background-with-text" ? ( ) : buttonVariant === "background-with-text" ? (
<BackgroundButton <BackgroundButton
priority={value} priority={value}
className={buttonClassName} className={cn(buttonClassName, {
"text-white": resolvedTheme === "dark",
})}
highlightUrgent={highlightUrgent} highlightUrgent={highlightUrgent}
dropdownArrow={dropdownArrow && !disabled} dropdownArrow={dropdownArrow && !disabled}
/> />
) : buttonVariant === "background-without-text" ? ( ) : buttonVariant === "background-without-text" ? (
<BackgroundButton <BackgroundButton
priority={value} priority={value}
className={buttonClassName} className={cn(buttonClassName, {
"text-white": resolvedTheme === "dark",
})}
highlightUrgent={highlightUrgent} highlightUrgent={highlightUrgent}
dropdownArrow={dropdownArrow && !disabled} dropdownArrow={dropdownArrow && !disabled}
hideText hideText
@ -355,14 +333,18 @@ export const PriorityDropdown: React.FC<Props> = (props) => {
) : buttonVariant === "transparent-with-text" ? ( ) : buttonVariant === "transparent-with-text" ? (
<TransparentButton <TransparentButton
priority={value} priority={value}
className={buttonClassName} className={cn(buttonClassName, {
"text-white": resolvedTheme === "dark",
})}
highlightUrgent={highlightUrgent} highlightUrgent={highlightUrgent}
dropdownArrow={dropdownArrow && !disabled} dropdownArrow={dropdownArrow && !disabled}
/> />
) : buttonVariant === "transparent-without-text" ? ( ) : buttonVariant === "transparent-without-text" ? (
<TransparentButton <TransparentButton
priority={value} priority={value}
className={buttonClassName} className={cn(buttonClassName, {
"text-white": resolvedTheme === "dark",
})}
highlightUrgent={highlightUrgent} highlightUrgent={highlightUrgent}
dropdownArrow={dropdownArrow && !disabled} dropdownArrow={dropdownArrow && !disabled}
hideText hideText
@ -400,6 +382,7 @@ export const PriorityDropdown: React.FC<Props> = (props) => {
active ? "bg-custom-background-80" : "" active ? "bg-custom-background-80" : ""
} ${selected ? "text-custom-text-100" : "text-custom-text-200"}` } ${selected ? "text-custom-text-100" : "text-custom-text-200"}`
} }
onClick={closeDropdown}
> >
{({ selected }) => ( {({ selected }) => (
<> <>

View File

@ -2,7 +2,6 @@ import { Fragment, ReactNode, useRef, useState } from "react";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
import { Combobox } from "@headlessui/react"; import { Combobox } from "@headlessui/react";
import { usePopper } from "react-popper"; import { usePopper } from "react-popper";
import { Placement } from "@popperjs/core";
import { Check, ChevronDown, Search } from "lucide-react"; import { Check, ChevronDown, Search } from "lucide-react";
// hooks // hooks
import { useProject } from "hooks/store"; import { useProject } from "hooks/store";
@ -13,20 +12,13 @@ import { cn } from "helpers/common.helper";
import { renderEmoji } from "helpers/emoji.helper"; import { renderEmoji } from "helpers/emoji.helper";
// types // types
import { IProject } from "@plane/types"; import { IProject } from "@plane/types";
import { TButtonVariants } from "./types"; import { TDropdownProps } from "./types";
type Props = { type Props = TDropdownProps & {
button?: ReactNode; button?: ReactNode;
buttonClassName?: string;
buttonContainerClassName?: string;
buttonVariant: TButtonVariants;
className?: string;
disabled?: boolean;
dropdownArrow?: boolean; dropdownArrow?: boolean;
onChange: (val: string) => void; onChange: (val: string) => void;
placement?: Placement;
value: string | null; value: string | null;
tabIndex?: number;
}; };
type ButtonProps = { type ButtonProps = {
@ -166,9 +158,7 @@ export const ProjectDropdown: React.FC<Props> = observer((props) => {
as="div" as="div"
ref={dropdownRef} ref={dropdownRef}
tabIndex={tabIndex} tabIndex={tabIndex}
className={cn("h-full flex-shrink-0", { className={cn("h-full flex-shrink-0", className)}
className,
})}
value={value} value={value}
onChange={onChange} onChange={onChange}
disabled={disabled} disabled={disabled}
@ -271,6 +261,7 @@ export const ProjectDropdown: React.FC<Props> = observer((props) => {
active ? "bg-custom-background-80" : "" active ? "bg-custom-background-80" : ""
} ${selected ? "text-custom-text-100" : "text-custom-text-200"}` } ${selected ? "text-custom-text-100" : "text-custom-text-200"}`
} }
onClick={closeDropdown}
> >
{({ selected }) => ( {({ selected }) => (
<> <>

View File

@ -2,7 +2,6 @@ import { Fragment, ReactNode, useEffect, useRef, useState } from "react";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
import { Combobox } from "@headlessui/react"; import { Combobox } from "@headlessui/react";
import { usePopper } from "react-popper"; import { usePopper } from "react-popper";
import { Placement } from "@popperjs/core";
import { Check, ChevronDown, Search } from "lucide-react"; import { Check, ChevronDown, Search } from "lucide-react";
// hooks // hooks
import { useApplication, useProjectState } from "hooks/store"; import { useApplication, useProjectState } from "hooks/store";
@ -14,21 +13,14 @@ import { StateGroupIcon } from "@plane/ui";
import { cn } from "helpers/common.helper"; import { cn } from "helpers/common.helper";
// types // types
import { IState } from "@plane/types"; import { IState } from "@plane/types";
import { TButtonVariants } from "./types"; import { TDropdownProps } from "./types";
type Props = { type Props = TDropdownProps & {
button?: ReactNode; button?: ReactNode;
buttonClassName?: string;
buttonContainerClassName?: string;
buttonVariant: TButtonVariants;
className?: string;
disabled?: boolean;
dropdownArrow?: boolean; dropdownArrow?: boolean;
onChange: (val: string) => void; onChange: (val: string) => void;
placement?: Placement;
projectId: string; projectId: string;
value: string; value: string;
tabIndex?: number;
}; };
type ButtonProps = { type ButtonProps = {
@ -159,9 +151,7 @@ export const StateDropdown: React.FC<Props> = observer((props) => {
as="div" as="div"
ref={dropdownRef} ref={dropdownRef}
tabIndex={tabIndex} tabIndex={tabIndex}
className={cn("h-full flex-shrink-0", { className={cn("h-full flex-shrink-0", className)}
className,
})}
value={value} value={value}
onChange={onChange} onChange={onChange}
disabled={disabled} disabled={disabled}
@ -264,6 +254,7 @@ export const StateDropdown: React.FC<Props> = observer((props) => {
active ? "bg-custom-background-80" : "" active ? "bg-custom-background-80" : ""
} ${selected ? "text-custom-text-100" : "text-custom-text-200"}` } ${selected ? "text-custom-text-100" : "text-custom-text-200"}`
} }
onClick={closeDropdown}
> >
{({ selected }) => ( {({ selected }) => (
<> <>

View File

@ -1,3 +1,5 @@
import { Placement } from "@popperjs/core";
export type TButtonVariants = export type TButtonVariants =
| "border-with-text" | "border-with-text"
| "border-without-text" | "border-without-text"
@ -5,3 +7,13 @@ export type TButtonVariants =
| "background-without-text" | "background-without-text"
| "transparent-with-text" | "transparent-with-text"
| "transparent-without-text"; | "transparent-without-text";
export type TDropdownProps = {
buttonClassName?: string;
buttonContainerClassName?: string;
buttonVariant: TButtonVariants;
className?: string;
disabled?: boolean;
placement?: Placement;
tabIndex?: number;
};

View File

@ -180,7 +180,6 @@ export const CycleIssuesHeader: React.FC = observer(() => {
</> </>
} }
className="ml-1.5 flex-shrink-0" className="ml-1.5 flex-shrink-0"
width="auto"
placement="bottom-start" placement="bottom-start"
> >
{currentProjectCycleIds?.map((cycleId) => ( {currentProjectCycleIds?.map((cycleId) => (

View File

@ -183,7 +183,6 @@ export const ModuleIssuesHeader: React.FC = observer(() => {
</> </>
} }
className="ml-1.5 flex-shrink-0" className="ml-1.5 flex-shrink-0"
width="auto"
placement="bottom-start" placement="bottom-start"
> >
{projectModuleIds?.map((moduleId) => ( {projectModuleIds?.map((moduleId) => (

View File

@ -161,7 +161,6 @@ export const JiraGetImportDetail: React.FC = observer(() => {
<CustomSelect <CustomSelect
value={value} value={value}
input input
width="w-full"
onChange={onChange} onChange={onChange}
label={ label={
<span> <span>
@ -172,6 +171,7 @@ export const JiraGetImportDetail: React.FC = observer(() => {
)} )}
</span> </span>
} }
optionsClassName="w-full"
> >
{workspaceProjectIds && workspaceProjectIds.length > 0 ? ( {workspaceProjectIds && workspaceProjectIds.length > 0 ? (
workspaceProjectIds.map((projectId) => { workspaceProjectIds.map((projectId) => {

View File

@ -82,7 +82,7 @@ export const JiraImportUsers: FC = () => {
input input
value={value} value={value}
onChange={onChange} onChange={onChange}
width="w-full" optionsClassName="w-full"
label={<span className="capitalize">{Boolean(value) ? value : ("Ignore" as any)}</span>} label={<span className="capitalize">{Boolean(value) ? value : ("Ignore" as any)}</span>}
> >
<CustomSelect.Option value="invite">Invite by email</CustomSelect.Option> <CustomSelect.Option value="invite">Invite by email</CustomSelect.Option>

View File

@ -93,7 +93,6 @@ export const IssueCycleSelect: React.FC<TIssueCycleSelect> = observer((props) =>
</Tooltip> </Tooltip>
</div> </div>
} }
width="max-w-[10rem]"
noChevron noChevron
disabled={disableSelect} disabled={disableSelect}
/> />

View File

@ -93,7 +93,6 @@ export const IssueModuleSelect: React.FC<TIssueModuleSelect> = observer((props)
</Tooltip> </Tooltip>
</div> </div>
} }
width="max-w-[10rem]"
noChevron noChevron
disabled={disableSelect} disabled={disableSelect}
/> />

View File

@ -135,7 +135,6 @@ export const HeaderGroupByCard: FC<IHeaderGroupByCard> = observer((props) => {
{!disableIssueCreation && {!disableIssueCreation &&
(renderExistingIssueModal ? ( (renderExistingIssueModal ? (
<CustomMenu <CustomMenu
width="auto"
customButton={ customButton={
<span className="flex h-[20px] w-[20px] flex-shrink-0 cursor-pointer items-center justify-center overflow-hidden rounded-sm transition-all hover:bg-custom-background-80"> <span className="flex h-[20px] w-[20px] flex-shrink-0 cursor-pointer items-center justify-center overflow-hidden rounded-sm transition-all hover:bg-custom-background-80">
<Plus height={14} width={14} strokeWidth={2} /> <Plus height={14} width={14} strokeWidth={2} />

View File

@ -73,7 +73,7 @@ export const IssueBlock: React.FC<IssueBlockProps> = observer((props: IssueBlock
{!issue?.tempId ? ( {!issue?.tempId ? (
<> <>
<IssueProperties <IssueProperties
className="relative flex items-center gap-2 overflow-x-auto whitespace-nowrap" className="relative flex items-center gap-2 whitespace-nowrap"
issue={issue} issue={issue}
isReadOnly={!canEditIssueProperties} isReadOnly={!canEditIssueProperties}
handleIssues={updateIssue} handleIssues={updateIssue}

View File

@ -70,7 +70,6 @@ export const HeaderGroupByCard = observer(
{!disableIssueCreation && {!disableIssueCreation &&
(renderExistingIssueModal ? ( (renderExistingIssueModal ? (
<CustomMenu <CustomMenu
width="auto"
customButton={ customButton={
<span className="flex h-5 w-5 flex-shrink-0 cursor-pointer items-center justify-center overflow-hidden rounded-sm transition-all hover:bg-custom-background-80"> <span className="flex h-5 w-5 flex-shrink-0 cursor-pointer items-center justify-center overflow-hidden rounded-sm transition-all hover:bg-custom-background-80">
<Plus className="h-3.5 w-3.5" strokeWidth={2} /> <Plus className="h-3.5 w-3.5" strokeWidth={2} />

View File

@ -62,7 +62,6 @@ export const SpreadsheetHeaderColumn = (props: Props) => {
</div> </div>
</div> </div>
} }
width="xl"
placement="bottom-end" placement="bottom-end"
> >
<CustomMenu.MenuItem onClick={() => handleOrderBy(propertyDetails.ascendingOrderKey, property)}> <CustomMenu.MenuItem onClick={() => handleOrderBy(propertyDetails.ascendingOrderKey, property)}>

View File

@ -134,7 +134,7 @@ export const IssueListItem: React.FC<ISubIssues> = observer((props) => {
</div> </div>
<div className="flex-shrink-0 text-sm"> <div className="flex-shrink-0 text-sm">
<CustomMenu width="auto" placement="bottom-end" ellipsis> <CustomMenu placement="bottom-end" ellipsis>
{disabled && ( {disabled && (
<CustomMenu.MenuItem onClick={() => handleIssueCrudState("update", parentIssueId, issue)}> <CustomMenu.MenuItem onClick={() => handleIssueCrudState("update", parentIssueId, issue)}>
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">

View File

@ -42,7 +42,7 @@ export const ViewEstimateSelect: React.FC<Props> = observer((props) => {
maxHeight="md" maxHeight="md"
noChevron noChevron
disabled={disabled} disabled={disabled}
width="w-full min-w-[8rem]" optionsClassName="w-full"
> >
<CustomSelect.Option value={null}> <CustomSelect.Option value={null}>
<> <>

View File

@ -232,7 +232,7 @@ export const ModuleCardItem: React.FC<Props> = observer((props) => {
</button> </button>
))} ))}
<CustomMenu width="auto" ellipsis className="z-10"> <CustomMenu ellipsis className="z-10">
{isEditingAllowed && ( {isEditingAllowed && (
<> <>
<CustomMenu.MenuItem onClick={handleEditModule}> <CustomMenu.MenuItem onClick={handleEditModule}>

View File

@ -209,7 +209,7 @@ export const ModuleListItem: React.FC<Props> = observer((props) => {
</button> </button>
))} ))}
<CustomMenu width="auto" verticalEllipsis buttonClassName="z-[1]"> <CustomMenu verticalEllipsis buttonClassName="z-[1]">
{isEditingAllowed && ( {isEditingAllowed && (
<> <>
<CustomMenu.MenuItem onClick={handleEditModule}> <CustomMenu.MenuItem onClick={handleEditModule}>

View File

@ -291,7 +291,7 @@ export const ModuleDetailsSidebar: React.FC<Props> = observer((props) => {
<LinkIcon className="h-3 w-3 text-custom-text-300" /> <LinkIcon className="h-3 w-3 text-custom-text-300" />
</button> </button>
{isEditingAllowed && ( {isEditingAllowed && (
<CustomMenu width="lg" placement="bottom-end" ellipsis> <CustomMenu placement="bottom-end" ellipsis>
<CustomMenu.MenuItem onClick={() => setModuleDeleteModal(true)}> <CustomMenu.MenuItem onClick={() => setModuleDeleteModal(true)}>
<span className="flex items-center justify-start gap-2"> <span className="flex items-center justify-start gap-2">
<Trash2 className="h-3 w-3" /> <Trash2 className="h-3 w-3" />

View File

@ -200,7 +200,7 @@ export const SnoozeNotificationModal: FC<SnoozeModalProps> = (props) => {
)} )}
</div> </div>
} }
width="w-full" optionsClassName="w-full"
input input
> >
<div className="mb-2 flex h-9 w-full overflow-hidden rounded"> <div className="mb-2 flex h-9 w-full overflow-hidden rounded">

View File

@ -235,7 +235,7 @@ export const PagesListItem: FC<IPagesListItem> = observer(({ pageId, projectId }
> >
<AlertCircle className="h-3.5 w-3.5" /> <AlertCircle className="h-3.5 w-3.5" />
</Tooltip> </Tooltip>
<CustomMenu width="auto" placement="bottom-end" className="!-m-1" verticalEllipsis> <CustomMenu placement="bottom-end" className="!-m-1" verticalEllipsis>
{archived_at ? ( {archived_at ? (
<> <>
{userCanArchive && ( {userCanArchive && (

View File

@ -69,7 +69,6 @@ export const MemberSelect: React.FC<Props> = observer((props) => {
] ]
} }
maxHeight="md" maxHeight="md"
width="w-full"
onChange={onChange} onChange={onChange}
disabled={isDisabled} disabled={isDisabled}
/> />

View File

@ -236,7 +236,7 @@ export const SendProjectInvitationModal: React.FC<Props> = observer((props) => {
onChange(val); onChange(val);
}} }}
options={options} options={options}
width="w-full min-w-[12rem]" optionsClassName="w-full"
/> />
); );
}} }}
@ -266,7 +266,7 @@ export const SendProjectInvitationModal: React.FC<Props> = observer((props) => {
</div> </div>
} }
input input
width="w-full" optionsClassName="w-full"
> >
{Object.entries(ROLE).map(([key, label]) => { {Object.entries(ROLE).map(([key, label]) => {
if (parseInt(key) > (currentProjectRole ?? EUserProjectRoles.GUEST)) return null; if (parseInt(key) > (currentProjectRole ?? EUserProjectRoles.GUEST)) return null;

View File

@ -160,7 +160,7 @@ export const CreateStateModal: React.FC<Props> = observer((props) => {
value={value} value={value}
label={GROUP_CHOICES[value as keyof typeof GROUP_CHOICES]} label={GROUP_CHOICES[value as keyof typeof GROUP_CHOICES]}
onChange={onChange} onChange={onChange}
width="w-full" optionsClassName="w-full"
input input
> >
{Object.keys(GROUP_CHOICES).map((key) => ( {Object.keys(GROUP_CHOICES).map((key) => (

View File

@ -123,7 +123,7 @@ export const ProjectViewListItem: React.FC<Props> = observer((props) => {
</button> </button>
))} ))}
<CustomMenu width="auto" ellipsis> <CustomMenu ellipsis>
{isEditingAllowed && ( {isEditingAllowed && (
<> <>
<CustomMenu.MenuItem <CustomMenu.MenuItem

View File

@ -201,7 +201,7 @@ export const CreateWorkspaceForm: FC<Props> = observer((props) => {
} }
buttonClassName="!border-[0.5px] !border-custom-border-200 !shadow-none" buttonClassName="!border-[0.5px] !border-custom-border-200 !shadow-none"
input input
width="w-full" optionsClassName="w-full"
> >
{ORGANIZATION_SIZE.map((item) => ( {ORGANIZATION_SIZE.map((item) => (
<CustomSelect.Option key={item} value={item}> <CustomSelect.Option key={item} value={item}>

View File

@ -165,7 +165,7 @@ export const SendWorkspaceInvitationModal: React.FC<Props> = observer((props) =>
value={value} value={value}
label={<span className="text-xs sm:text-sm">{ROLE[value]}</span>} label={<span className="text-xs sm:text-sm">{ROLE[value]}</span>}
onChange={onChange} onChange={onChange}
width="w-full" optionsClassName="w-full"
input input
> >
{Object.entries(ROLE).map(([key, value]) => { {Object.entries(ROLE).map(([key, value]) => {

View File

@ -247,7 +247,7 @@ export const WorkspaceDetails: FC = observer(() => {
value={value} value={value}
onChange={onChange} onChange={onChange}
label={ORGANIZATION_SIZE.find((c) => c === value) ?? "Select organization size"} label={ORGANIZATION_SIZE.find((c) => c === value) ?? "Select organization size"}
width="w-full" optionsClassName="w-full"
buttonClassName="!border-[0.5px] !border-custom-border-200 !shadow-none" buttonClassName="!border-[0.5px] !border-custom-border-200 !shadow-none"
input input
disabled={!isAdmin} disabled={!isAdmin}

View File

@ -54,7 +54,7 @@ export const GlobalViewListItem: React.FC<Props> = observer((props) => {
<p className="hidden rounded bg-custom-background-80 px-2 py-1 text-xs text-custom-text-200 group-hover:block"> <p className="hidden rounded bg-custom-background-80 px-2 py-1 text-xs text-custom-text-200 group-hover:block">
{totalFilters} {totalFilters === 1 ? "filter" : "filters"} {totalFilters} {totalFilters === 1 ? "filter" : "filters"}
</p> </p>
<CustomMenu width="auto" ellipsis> <CustomMenu ellipsis>
<CustomMenu.MenuItem <CustomMenu.MenuItem
onClick={(e) => { onClick={(e) => {
e.preventDefault(); e.preventDefault();

View File

@ -284,7 +284,9 @@ const ProfileSettingsPage: NextPageWithLayout = observer(() => {
ref={ref} ref={ref}
hasError={Boolean(errors.email)} hasError={Boolean(errors.email)}
placeholder="Enter your email" placeholder="Enter your email"
className={`w-full rounded-md cursor-not-allowed !bg-custom-background-80 ${errors.email ? "border-red-500" : ""}`} className={`w-full rounded-md cursor-not-allowed !bg-custom-background-80 ${
errors.email ? "border-red-500" : ""
}`}
disabled disabled
/> />
)} )}
@ -306,7 +308,7 @@ const ProfileSettingsPage: NextPageWithLayout = observer(() => {
label={value ? value.toString() : "Select your role"} label={value ? value.toString() : "Select your role"}
buttonClassName={errors.role ? "border-red-500" : "border-none"} buttonClassName={errors.role ? "border-red-500" : "border-none"}
className="rounded-md border-[0.5px] !border-custom-border-200" className="rounded-md border-[0.5px] !border-custom-border-200"
width="w-full" optionsClassName="w-full"
input input
> >
{USER_ROLES.map((item) => ( {USER_ROLES.map((item) => (