-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: quick add * style: made text color muted
- Loading branch information
1 parent
daa0b16
commit 771ca58
Showing
17 changed files
with
847 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
web/components/core/views/board-view/inline-create-issue-form.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { useEffect } from "react"; | ||
|
||
// react hook form | ||
import { useFormContext } from "react-hook-form"; | ||
|
||
// components | ||
import { InlineCreateIssueFormWrapper } from "components/core"; | ||
|
||
// hooks | ||
import useProjectDetails from "hooks/use-project-details"; | ||
|
||
// types | ||
import { IIssue } from "types"; | ||
|
||
type Props = { | ||
isOpen: boolean; | ||
handleClose: () => void; | ||
onSuccess?: (data: IIssue) => Promise<void> | void; | ||
prePopulatedData?: Partial<IIssue>; | ||
}; | ||
|
||
const InlineInput = () => { | ||
const { projectDetails } = useProjectDetails(); | ||
|
||
const { register, setFocus } = useFormContext(); | ||
|
||
useEffect(() => { | ||
setFocus("name"); | ||
}, [setFocus]); | ||
|
||
return ( | ||
<div> | ||
<h4 className="text-sm font-medium leading-5 text-custom-text-300"> | ||
{projectDetails?.identifier ?? "..."} | ||
</h4> | ||
<input | ||
autoComplete="off" | ||
placeholder="Issue Title" | ||
{...register("name", { | ||
required: "Issue title is required.", | ||
})} | ||
className="w-full px-2 pl-0 py-1.5 rounded-md bg-transparent text-sm font-medium leading-5 text-custom-text-200 outline-none" | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export const BoardInlineCreateIssueForm: React.FC<Props> = (props) => ( | ||
<> | ||
<InlineCreateIssueFormWrapper | ||
className="flex flex-col justify-between gap-1.5 group/card relative select-none px-3.5 py-3 h-[118px] mb-3 rounded bg-custom-background-100 shadow" | ||
{...props} | ||
> | ||
<InlineInput /> | ||
</InlineCreateIssueFormWrapper> | ||
{props.isOpen && ( | ||
<p className="text-xs ml-3 italic text-custom-text-200"> | ||
Press {"'"}Enter{"'"} to add another issue | ||
</p> | ||
)} | ||
</> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
web/components/core/views/calendar-view/inline-create-issue-form.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import { useEffect, useRef, useState } from "react"; | ||
|
||
// react hook form | ||
import { useFormContext } from "react-hook-form"; | ||
|
||
import { InlineCreateIssueFormWrapper } from "components/core"; | ||
|
||
// hooks | ||
import useProjectDetails from "hooks/use-project-details"; | ||
|
||
// types | ||
import { IIssue } from "types"; | ||
|
||
type Props = { | ||
isOpen: boolean; | ||
handleClose: () => void; | ||
onSuccess?: (data: IIssue) => Promise<void> | void; | ||
prePopulatedData?: Partial<IIssue>; | ||
}; | ||
|
||
const useCheckIfThereIsSpaceOnRight = (ref: React.RefObject<HTMLDivElement>) => { | ||
const [isThereSpaceOnRight, setIsThereSpaceOnRight] = useState(true); | ||
|
||
useEffect(() => { | ||
if (!ref.current) return; | ||
|
||
const { right } = ref.current.getBoundingClientRect(); | ||
|
||
const width = right + 250; | ||
|
||
if (width > window.innerWidth) setIsThereSpaceOnRight(false); | ||
else setIsThereSpaceOnRight(true); | ||
}, [ref]); | ||
|
||
return isThereSpaceOnRight; | ||
}; | ||
|
||
const InlineInput = () => { | ||
const { projectDetails } = useProjectDetails(); | ||
|
||
const { register, setFocus } = useFormContext(); | ||
|
||
useEffect(() => { | ||
setFocus("name"); | ||
}, [setFocus]); | ||
|
||
return ( | ||
<> | ||
<h4 className="text-sm font-medium leading-5 text-custom-text-400"> | ||
{projectDetails?.identifier ?? "..."} | ||
</h4> | ||
<input | ||
type="text" | ||
autoComplete="off" | ||
placeholder="Issue Title" | ||
{...register("name", { | ||
required: "Issue title is required.", | ||
})} | ||
className="w-full px-2 py-1.5 rounded-md bg-transparent text-sm font-medium leading-5 text-custom-text-200 outline-none" | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
export const CalendarInlineCreateIssueForm: React.FC<Props> = (props) => { | ||
const { isOpen } = props; | ||
|
||
const ref = useRef<HTMLDivElement>(null); | ||
|
||
const isSpaceOnRight = useCheckIfThereIsSpaceOnRight(ref); | ||
|
||
return ( | ||
<> | ||
<div | ||
ref={ref} | ||
className={`absolute -translate-x-1 top-5 transition-all z-20 ${ | ||
isOpen ? "opacity-100 scale-100" : "opacity-0 pointer-events-none scale-95" | ||
} ${isSpaceOnRight ? "left-full" : "right-0"}`} | ||
> | ||
<InlineCreateIssueFormWrapper | ||
{...props} | ||
className="flex w-60 p-1 px-1.5 rounded items-center gap-x-3 bg-custom-background-100 shadow-custom-shadow-md transition-opacity" | ||
> | ||
<InlineInput /> | ||
</InlineCreateIssueFormWrapper> | ||
</div> | ||
{/* Added to make any other element as outside click. This will make input also to be outside. */} | ||
{isOpen && <div className="w-screen h-screen fixed inset-0 z-10" />} | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
771ca58
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
plane-dev – ./web/
plane-dev.vercel.app
plane-dev-git-develop-plane.vercel.app
plane-dev-plane.vercel.app
771ca58
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
plane-sh-dev – ./space/
plane-sh-dev-plane.vercel.app
plane-sh-dev-git-develop-plane.vercel.app
plane-space-dev.vercel.app