From a4d231b39ac25ef7af7fe314ea1fdea26c3f234a Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia <121005188+anmolsinghbhatia@users.noreply.github.com> Date: Tue, 5 Dec 2023 16:07:25 +0530 Subject: [PATCH] chore: space ui component revamp and bug fixes (#2980) * chore: replace space ui component with plane ui component * fix: space project icon and user pic bug * chore: code refactor * fix: profile section navbar fix --- space/components/accounts/email-code-form.tsx | 24 ++++--- .../accounts/email-password-form.tsx | 15 ++-- .../accounts/email-reset-password-form.tsx | 9 ++- space/components/accounts/onboarding-form.tsx | 6 +- space/components/issues/navbar/index.tsx | 41 +++++------ .../comment/comment-reactions.tsx | 3 +- .../peek-overview/full-screen-peek-view.tsx | 2 +- .../issues/peek-overview/issue-activity.tsx | 7 +- .../peek-overview/issue-emoji-reactions.tsx | 3 +- .../peek-overview/issue-vote-reactions.tsx | 3 +- .../issues/peek-overview/side-peek-view.tsx | 2 +- space/components/ui/index.ts | 5 -- space/components/ui/input.tsx | 37 ---------- space/components/ui/loader.tsx | 25 ------- space/components/ui/primary-button.tsx | 35 ---------- space/components/ui/secondary-button.tsx | 35 ---------- space/components/ui/tooltip.tsx | 70 ------------------- web/components/profile/navbar.tsx | 2 +- 18 files changed, 62 insertions(+), 262 deletions(-) delete mode 100644 space/components/ui/input.tsx delete mode 100644 space/components/ui/loader.tsx delete mode 100644 space/components/ui/primary-button.tsx delete mode 100644 space/components/ui/secondary-button.tsx delete mode 100644 space/components/ui/tooltip.tsx diff --git a/space/components/accounts/email-code-form.tsx b/space/components/accounts/email-code-form.tsx index b760ccfbb..5b1a15434 100644 --- a/space/components/accounts/email-code-form.tsx +++ b/space/components/accounts/email-code-form.tsx @@ -11,7 +11,7 @@ import useToast from "hooks/use-toast"; import useTimer from "hooks/use-timer"; // ui -import { Input, PrimaryButton } from "components/ui"; +import { Button, Input } from "@plane/ui"; // types type EmailCodeFormValues = { @@ -133,7 +133,7 @@ export const EmailCodeForm = ({ handleSignIn }: any) => { id="email" type="email" placeholder="Enter your email address..." - className="border-custom-border-300 h-[46px]" + className="border-custom-border-300 h-[46px] w-full" {...register("email", { required: "Email address is required", validate: (value) => @@ -154,7 +154,7 @@ export const EmailCodeForm = ({ handleSignIn }: any) => { required: "Code is required", })} placeholder="Enter code..." - className="border-custom-border-300 h-[46px]" + className="border-custom-border-300 h-[46px] w-full" /> {errors.token &&
{errors.token.message}
} ) : ( - { handleSubmit(onSubmit)().then(() => { setResendCodeTimer(30); @@ -208,7 +210,7 @@ export const EmailCodeForm = ({ handleSignIn }: any) => { loading={isSubmitting} > {isSubmitting ? "Sending code..." : "Send sign in code"} - + )} diff --git a/space/components/accounts/email-password-form.tsx b/space/components/accounts/email-password-form.tsx index 775f1a3c2..b07a26956 100644 --- a/space/components/accounts/email-password-form.tsx +++ b/space/components/accounts/email-password-form.tsx @@ -5,7 +5,8 @@ import { useForm } from "react-hook-form"; // components import { EmailResetPasswordForm } from "./email-reset-password-form"; // ui -import { Input, PrimaryButton } from "components/ui"; +import { Button, Input } from "@plane/ui"; + // types type EmailPasswordFormValues = { email: string; @@ -58,7 +59,7 @@ export const EmailPasswordForm: React.FC = ({ onSubmit }) => { ) || "Email address is not valid", })} placeholder="Enter your email address..." - className="border-custom-border-300 h-[46px]" + className="border-custom-border-300 h-[46px] w-full" /> {errors.email &&
{errors.email.message}
} @@ -70,7 +71,7 @@ export const EmailPasswordForm: React.FC = ({ onSubmit }) => { required: "Password is required", })} placeholder="Enter your password..." - className="border-custom-border-300 h-[46px]" + className="border-custom-border-300 h-[46px] w-full" /> {errors.password &&
{errors.password.message}
} @@ -92,14 +93,16 @@ export const EmailPasswordForm: React.FC = ({ onSubmit }) => { )}
- {isSignUpPage ? (isSubmitting ? "Signing up..." : "Sign up") : isSubmitting ? "Signing in..." : "Sign in"} - + {!isSignUpPage && ( diff --git a/space/components/accounts/email-reset-password-form.tsx b/space/components/accounts/email-reset-password-form.tsx index e7752a00f..dc4c32775 100644 --- a/space/components/accounts/email-reset-password-form.tsx +++ b/space/components/accounts/email-reset-password-form.tsx @@ -1,8 +1,7 @@ import React from "react"; import { useForm } from "react-hook-form"; // ui -import { Input } from "components/ui"; -import { Button } from "@plane/ui"; +import { Button, Input } from "@plane/ui"; // types type Props = { setIsResettingPassword: React.Dispatch>; @@ -66,15 +65,15 @@ export const EmailResetPasswordForm: React.FC = ({ setIsResettingPassword ) || "Email address is not valid", })} placeholder="Enter registered email address.." - className="h-[46px] border-custom-border-300" + className="h-[46px] border-custom-border-300 w-full" /> {errors.email &&
{errors.email.message}
}
- -
diff --git a/space/components/accounts/onboarding-form.tsx b/space/components/accounts/onboarding-form.tsx index c3cb972b2..e372ac1e5 100644 --- a/space/components/accounts/onboarding-form.tsx +++ b/space/components/accounts/onboarding-form.tsx @@ -13,7 +13,7 @@ import useToast from "hooks/use-toast"; // services import UserService from "services/user.service"; // ui -import { Input, PrimaryButton } from "components/ui"; +import { Button, Input } from "@plane/ui"; const defaultValues = { first_name: "", @@ -173,9 +173,9 @@ export const OnBoardingForm: React.FC = observer(({ user }) => { - + ); }); diff --git a/space/components/issues/navbar/index.tsx b/space/components/issues/navbar/index.tsx index 220991bd9..e4ce36050 100644 --- a/space/components/issues/navbar/index.tsx +++ b/space/components/issues/navbar/index.tsx @@ -1,7 +1,6 @@ import { useEffect } from "react"; import Link from "next/link"; -import Image from "next/image"; import { useRouter } from "next/router"; // mobx @@ -11,7 +10,8 @@ import { observer } from "mobx-react-lite"; import { NavbarIssueBoardView } from "./issue-board-view"; import { NavbarTheme } from "./theme"; // ui -import { PrimaryButton } from "components/ui"; +import { Avatar, Button } from "@plane/ui"; +import { Briefcase } from "lucide-react"; // lib import { useMobxStore } from "lib/mobx/store-provider"; // store @@ -87,10 +87,24 @@ const IssueNavbar = observer(() => { {/* project detail */}
- {projectStore?.project && projectStore?.project?.emoji ? ( - renderEmoji(projectStore?.project?.emoji) + {projectStore.project ? ( + projectStore.project?.emoji ? ( + + {renderEmoji(projectStore.project.emoji)} + + ) : projectStore.project?.icon_prop ? ( +
+ {renderEmoji(projectStore.project.icon_prop)} +
+ ) : ( + + {projectStore.project?.name.charAt(0)} + + ) ) : ( - plane logo + + + )}
@@ -113,26 +127,13 @@ const IssueNavbar = observer(() => { {user ? (
- {user.avatar && user.avatar !== "" ? ( -
- {/* eslint-disable-next-line @next/next/no-img-element */} - {user.display_name -
- ) : ( -
- {(user.display_name ?? "A")[0]} -
- )} +
{user.display_name}
) : (
- - - Sign in - - +
)} diff --git a/space/components/issues/peek-overview/comment/comment-reactions.tsx b/space/components/issues/peek-overview/comment/comment-reactions.tsx index 4045d3edf..d53ae4936 100644 --- a/space/components/issues/peek-overview/comment/comment-reactions.tsx +++ b/space/components/issues/peek-overview/comment/comment-reactions.tsx @@ -6,7 +6,8 @@ import { useRouter } from "next/router"; import { observer } from "mobx-react-lite"; import { useMobxStore } from "lib/mobx/store-provider"; // ui -import { ReactionSelector, Tooltip } from "components/ui"; +import { ReactionSelector } from "components/ui"; +import { Tooltip } from "@plane/ui"; // helpers import { groupReactions, renderEmoji } from "helpers/emoji.helper"; diff --git a/space/components/issues/peek-overview/full-screen-peek-view.tsx b/space/components/issues/peek-overview/full-screen-peek-view.tsx index 3a66c9abe..e07620c05 100644 --- a/space/components/issues/peek-overview/full-screen-peek-view.tsx +++ b/space/components/issues/peek-overview/full-screen-peek-view.tsx @@ -7,7 +7,7 @@ import { PeekOverviewIssueProperties, } from "components/issues/peek-overview"; // types -import { Loader } from "components/ui/loader"; +import { Loader } from "@plane/ui"; import { IIssue } from "types/issue"; type Props = { diff --git a/space/components/issues/peek-overview/issue-activity.tsx b/space/components/issues/peek-overview/issue-activity.tsx index 2d173487c..cbb27679b 100644 --- a/space/components/issues/peek-overview/issue-activity.tsx +++ b/space/components/issues/peek-overview/issue-activity.tsx @@ -10,7 +10,8 @@ import { useMobxStore } from "lib/mobx/store-provider"; // components import { CommentCard, AddComment } from "components/issues/peek-overview"; // ui -import { Icon, PrimaryButton } from "components/ui"; +import { Icon } from "components/ui"; +import { Button } from "@plane/ui"; // types import { IIssue } from "types/issue"; @@ -55,9 +56,7 @@ export const PeekOverviewIssueActivity: React.FC = observer(() => { Sign in to add your comment

- - Sign in - +
)} diff --git a/space/components/issues/peek-overview/issue-emoji-reactions.tsx b/space/components/issues/peek-overview/issue-emoji-reactions.tsx index b0c5b0361..dfd45f62b 100644 --- a/space/components/issues/peek-overview/issue-emoji-reactions.tsx +++ b/space/components/issues/peek-overview/issue-emoji-reactions.tsx @@ -6,7 +6,8 @@ import { useMobxStore } from "lib/mobx/store-provider"; // helpers import { groupReactions, renderEmoji } from "helpers/emoji.helper"; // components -import { ReactionSelector, Tooltip } from "components/ui"; +import { ReactionSelector } from "components/ui"; +import { Tooltip } from "@plane/ui"; export const IssueEmojiReactions: React.FC = observer(() => { // router diff --git a/space/components/issues/peek-overview/issue-vote-reactions.tsx b/space/components/issues/peek-overview/issue-vote-reactions.tsx index ac20565ea..8d619681a 100644 --- a/space/components/issues/peek-overview/issue-vote-reactions.tsx +++ b/space/components/issues/peek-overview/issue-vote-reactions.tsx @@ -6,7 +6,8 @@ import { useRouter } from "next/router"; import { observer } from "mobx-react-lite"; // lib import { useMobxStore } from "lib/mobx/store-provider"; -import { Tooltip } from "components/ui"; +// ui +import { Tooltip } from "@plane/ui"; export const IssueVotes: React.FC = observer(() => { const [isSubmitting, setIsSubmitting] = useState(false); diff --git a/space/components/issues/peek-overview/side-peek-view.tsx b/space/components/issues/peek-overview/side-peek-view.tsx index bacf83420..f0fc3d83e 100644 --- a/space/components/issues/peek-overview/side-peek-view.tsx +++ b/space/components/issues/peek-overview/side-peek-view.tsx @@ -7,7 +7,7 @@ import { PeekOverviewIssueProperties, } from "components/issues/peek-overview"; -import { Loader } from "components/ui/loader"; +import { Loader } from "@plane/ui"; import { IIssue } from "types/issue"; type Props = { diff --git a/space/components/ui/index.ts b/space/components/ui/index.ts index e44096909..1e523d5dd 100644 --- a/space/components/ui/index.ts +++ b/space/components/ui/index.ts @@ -1,8 +1,3 @@ export * from "./dropdown"; -export * from "./input"; -export * from "./loader"; -export * from "./primary-button"; -export * from "./secondary-button"; export * from "./icon"; export * from "./reaction-selector"; -export * from "./tooltip"; diff --git a/space/components/ui/input.tsx b/space/components/ui/input.tsx deleted file mode 100644 index b6be82ae5..000000000 --- a/space/components/ui/input.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import React, { forwardRef, Ref } from "react"; - -// types -interface Props extends React.InputHTMLAttributes { - mode?: "primary" | "transparent" | "trueTransparent"; - error?: boolean; - inputSize?: "rg" | "lg"; - fullWidth?: boolean; -} - -export const Input = forwardRef((props: Props, ref: Ref) => { - const { mode = "primary", error, className = "", type, fullWidth = true, id, inputSize = "rg", ...rest } = props; - - return ( - - ); -}); - -Input.displayName = "Input"; - -export default Input; diff --git a/space/components/ui/loader.tsx b/space/components/ui/loader.tsx deleted file mode 100644 index b9d13883a..000000000 --- a/space/components/ui/loader.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import React from "react"; - -type Props = { - children: React.ReactNode; - className?: string; -}; - -const Loader = ({ children, className = "" }: Props) => ( -
- {children} -
-); - -type ItemProps = { - height?: string; - width?: string; -}; - -const Item: React.FC = ({ height = "auto", width = "auto" }) => ( -
-); - -Loader.Item = Item; - -export { Loader }; diff --git a/space/components/ui/primary-button.tsx b/space/components/ui/primary-button.tsx deleted file mode 100644 index b3e1b82ee..000000000 --- a/space/components/ui/primary-button.tsx +++ /dev/null @@ -1,35 +0,0 @@ -interface ButtonProps extends React.ButtonHTMLAttributes { - size?: "sm" | "md" | "lg"; - outline?: boolean; - loading?: boolean; -} - -export const PrimaryButton: React.FC = ({ - children, - className = "", - onClick, - type = "button", - disabled = false, - loading = false, - size = "sm", - outline = false, -}) => ( - -); diff --git a/space/components/ui/secondary-button.tsx b/space/components/ui/secondary-button.tsx deleted file mode 100644 index 2a9b3d528..000000000 --- a/space/components/ui/secondary-button.tsx +++ /dev/null @@ -1,35 +0,0 @@ -interface ButtonProps extends React.ButtonHTMLAttributes { - size?: "sm" | "md" | "lg"; - outline?: boolean; - loading?: boolean; -} - -export const SecondaryButton: React.FC = ({ - children, - className = "", - onClick, - type = "button", - disabled = false, - loading = false, - size = "sm", - outline = false, -}) => ( - -); diff --git a/space/components/ui/tooltip.tsx b/space/components/ui/tooltip.tsx deleted file mode 100644 index 64876ffc0..000000000 --- a/space/components/ui/tooltip.tsx +++ /dev/null @@ -1,70 +0,0 @@ -import React from "react"; -// next-themes -import { useTheme } from "next-themes"; -// tooltip2 -import { Tooltip2 } from "@blueprintjs/popover2"; - -type Props = { - tooltipHeading?: string; - tooltipContent: string | React.ReactNode; - position?: - | "top" - | "right" - | "bottom" - | "left" - | "auto" - | "auto-end" - | "auto-start" - | "bottom-left" - | "bottom-right" - | "left-bottom" - | "left-top" - | "right-bottom" - | "right-top" - | "top-left" - | "top-right"; - children: JSX.Element; - disabled?: boolean; - className?: string; - openDelay?: number; - closeDelay?: number; -}; - -export const Tooltip: React.FC = ({ - tooltipHeading, - tooltipContent, - position = "top", - children, - disabled = false, - className = "", - openDelay = 200, - closeDelay, -}) => { - const { theme } = useTheme(); - - return ( - - {tooltipHeading && ( -
- {tooltipHeading} -
- )} - {tooltipContent} -
- } - position={position} - renderTarget={({ isOpen: isTooltipOpen, ref: eleReference, ...tooltipProps }) => - React.cloneElement(children, { ref: eleReference, ...tooltipProps, ...children.props }) - } - /> - ); -}; diff --git a/web/components/profile/navbar.tsx b/web/components/profile/navbar.tsx index 23eea6222..7c9b3b922 100644 --- a/web/components/profile/navbar.tsx +++ b/web/components/profile/navbar.tsx @@ -51,7 +51,7 @@ export const ProfileNavbar: React.FC = (props) => { {tabsList.map((tab) => (