Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES-659/ES-661: fix truncated icons and popover content #12

Merged
merged 8 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
1 change: 1 addition & 0 deletions signup-ui/src/app/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
UNDER_CONSTRUCTION,
} from "~constants/routes";
import { lazyRetry } from "~utils/lazyRetry";
import { setupResponseInterceptor } from "~services/api.service";

const SignUpPage = lazy(() => lazyRetry(() => import("~pages/SignUpPage")));
const ResetPasswordPage = lazy(() =>
Expand Down
36 changes: 36 additions & 0 deletions signup-ui/src/components/label-popover.tsx
aranaravi marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {
Popover,
PopoverArrow,
PopoverContent,
PopoverTrigger,
} from "./ui/popover";

interface LabelPopoverProps {
icon: React.ReactNode;
children: React.ReactNode;
}

export const LabelPopover = ({ icon, children }: LabelPopoverProps) => {
return (
<>
<div className="flex items-center sm:hidden">
<Popover>
<PopoverTrigger>{icon}</PopoverTrigger>
<PopoverContent side="right" className="text-xs">
{children}
<PopoverArrow className="fill-[#FFFFFF] stroke-[#BCBCBC]" />
</PopoverContent>
</Popover>
</div>
<div className="hidden items-center sm:flex">
<Popover>
<PopoverTrigger>{icon}</PopoverTrigger>
<PopoverContent side="bottom" className="text-xs">
{children}
<PopoverArrow className="fill-[#FFFFFF] stroke-[#BCBCBC]" />
</PopoverContent>
</Popover>
</div>
</>
);
};
9 changes: 7 additions & 2 deletions signup-ui/src/components/ui/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ReactComponent as ChevronDown } from "~assets/svg/chevron-down.svg";
import { ReactComponent as ChevronUp } from "~assets/svg/chevron-up.svg";
import { ReactComponent as EyeOff } from "~assets/svg/eye-off.svg";
import { ReactComponent as Eye } from "~assets/svg/eye.svg";
import { ReactComponent as Info } from "~assets/svg/info.svg";
import InfoSvg from "~assets/svg/info.svg";
import { ReactComponent as Loader } from "~assets/svg/loader.svg";
import { ReactComponent as X } from "~assets/svg/x.svg";

Expand All @@ -18,7 +18,12 @@ export const Icons = {
close: X,
eye: Eye,
eyeOff: EyeOff,
info: Info,
info: React.forwardRef<
HTMLImageElement,
React.ImgHTMLAttributes<HTMLImageElement>
>(({ alt, ...props }, ref) => (
<img ref={ref} src={InfoSvg} alt={alt} {...props} />
)),
loader: Loader,
arrow: React.forwardRef<SVGSVGElement, React.SVGAttributes<SVGSVGElement>>(
(props, ref) => (
Expand Down
6 changes: 4 additions & 2 deletions signup-ui/src/components/ui/popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { cn } from "~utils/cn";

const Popover = PopoverPrimitive.Root;

const PopoverAnchor = PopoverPrimitive.Anchor;

const PopoverTrigger = PopoverPrimitive.Trigger;

const PopoverContent = React.forwardRef<
Expand All @@ -17,7 +19,7 @@ const PopoverContent = React.forwardRef<
align={align}
sideOffset={sideOffset}
className={cn(
"z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
"z-50 w-[175px] rounded-md border bg-popover px-3 py-2 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 md:w-[220px] sm:w-[200px]",
className
)}
{...props}
Expand All @@ -37,4 +39,4 @@ const PopoverArrow = React.forwardRef<
/>
));

export { Popover, PopoverTrigger, PopoverArrow, PopoverContent };
export { Popover, PopoverAnchor, PopoverTrigger, PopoverArrow, PopoverContent };
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useFormContext, UseFormReturn } from "react-hook-form";
import { Trans, useTranslation } from "react-i18next";
import { useLocation } from "react-router-dom";

import { LabelPopover } from "~components/label-popover";
import { ActionMessage } from "~components/ui/action-message";
import { Button } from "~components/ui/button";
import {
Expand All @@ -14,12 +15,6 @@ import {
} from "~components/ui/form";
import { Icons } from "~components/ui/icons";
import { Input } from "~components/ui/input";
import {
Popover,
PopoverArrow,
PopoverContent,
PopoverTrigger,
} from "~components/ui/popover";
import {
Step,
StepAlert,
Expand Down Expand Up @@ -172,21 +167,24 @@ export const ResetPassword = ({ methods, settings }: ResetPasswordProps) => {
<div className="space-y-2">
<div className="flex items-center gap-1">
<FormLabel>{t("new_password")}</FormLabel>
<Popover>
<PopoverTrigger asChild>
<Icons.info className="h-4 w-4 cursor-pointer" />
</PopoverTrigger>
<PopoverContent side="right" className="w-full">
<Trans
i18nKey="password_rules"
components={{
ul: <ul className="list-inside list-disc" />,
li: <li />,
}}
<LabelPopover
icon={
<Icons.info
className="m-1 h-4 w-4 cursor-pointer sm:h-3 sm:w-3"
alt="info icon"
width="100%"
height="100%"
/>
<PopoverArrow className="fill-[#FFFFFF] stroke-[#BCBCBC]" />
</PopoverContent>
</Popover>
}
>
<Trans
i18nKey="password_rules"
components={{
ul: <ul className="list-inside list-disc" />,
li: <li />,
}}
/>
</LabelPopover>
</div>
<FormControl>
<Input
Expand Down
6 changes: 0 additions & 6 deletions signup-ui/src/pages/ResetPasswordPage/UserInfo/UserInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ import {
} from "~components/ui/form";
import { Icons } from "~components/ui/icons";
import { Input } from "~components/ui/input";
import {
Popover,
PopoverArrow,
PopoverContent,
PopoverTrigger,
} from "~components/ui/popover";
import {
Step,
StepAlert,
Expand Down
77 changes: 44 additions & 33 deletions signup-ui/src/pages/SignUpPage/AccountSetup/AccountSetup.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { KeyboardEvent, useCallback, useMemo, useState } from "react";
import { PopoverTrigger } from "@radix-ui/react-popover";
import { UseFormReturn } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { Trans, useTranslation } from "react-i18next";

import { LabelPopover } from "~components/label-popover";
import { Button } from "~components/ui/button";
import { Checkbox } from "~components/ui/checkbox";
import {
Expand All @@ -14,7 +14,6 @@ import {
} from "~components/ui/form";
import { Icons } from "~components/ui/icons";
import { Input } from "~components/ui/input";
import { Popover, PopoverArrow, PopoverContent } from "~components/ui/popover";
import {
Step,
StepContent,
Expand Down Expand Up @@ -63,7 +62,7 @@ export const AccountSetup = ({ settings, methods }: AccountSetupProps) => {

const { registerMutation } = useRegister();
const [openTermConditionModal, setOpenTermConditionModal] = useState(false);
const [modalData, setModalData] = useState({title: "", content: ""});
const [modalData, setModalData] = useState({ title: "", content: "" });

const disabledContinue =
!isValid ||
Expand Down Expand Up @@ -121,20 +120,26 @@ export const AccountSetup = ({ settings, methods }: AccountSetupProps) => {

const onModalToggle = () => {
setOpenTermConditionModal(false);
setModalData({title: "", content: ""});
}
setModalData({ title: "", content: "" });
};

const onOpenTerm = (e: any) => {
e.preventDefault();
setModalData({title: t("terms_and_conditions_title"), content: t("terms_and_conditions_content")});
setModalData({
title: t("terms_and_conditions_title"),
content: t("terms_and_conditions_content"),
});
setOpenTermConditionModal(true);
}
};

const onOpenPrivacy = (e: any) => {
e.preventDefault();
setModalData({title: t("privacy_and_policy_title"), content: t("privacy_and_policy_content")});
setModalData({
title: t("privacy_and_policy_title"),
content: t("privacy_and_policy_content"),
});
setOpenTermConditionModal(true);
}
};

const handleFullNameInput = (event: KeyboardEvent<HTMLInputElement>) =>
handleInputFilter(
Expand Down Expand Up @@ -183,15 +188,18 @@ export const AccountSetup = ({ settings, methods }: AccountSetupProps) => {
<div className="space-y-2">
<div className="flex items-center gap-1">
<FormLabel>{t("full_name")}</FormLabel>
<Popover>
<PopoverTrigger asChild>
<Icons.info className="h-4 w-4 cursor-pointer" />
</PopoverTrigger>
<PopoverContent side="right">
{t("full_name_tooltip")}
<PopoverArrow className="fill-[#FFFFFF] stroke-[#BCBCBC]" />
</PopoverContent>
</Popover>
<LabelPopover
icon={
<Icons.info
className="m-1 h-4 w-4 cursor-pointer sm:h-3 sm:w-3"
alt="info icon"
width="100%"
height="100%"
/>
}
>
<span>{t("full_name_tooltip")}</span>
</LabelPopover>
</div>
<FormControl>
<Input
Expand Down Expand Up @@ -223,21 +231,24 @@ export const AccountSetup = ({ settings, methods }: AccountSetupProps) => {
<div className="space-y-2">
<div className="flex items-center gap-1">
<FormLabel>{t("password")}</FormLabel>
<Popover>
<PopoverTrigger asChild>
<Icons.info className="h-4 w-4 cursor-pointer" />
</PopoverTrigger>
<PopoverContent side="right" className="w-full">
<Trans
i18nKey="password_rules"
components={{
ul: <ul className="list-inside list-disc" />,
li: <li />,
}}
<LabelPopover
icon={
<Icons.info
className="m-1 h-4 w-4 cursor-pointer sm:h-3 sm:w-3"
alt="info icon"
width="100%"
height="100%"
/>
<PopoverArrow className="fill-[#FFFFFF] stroke-[#BCBCBC]" />
</PopoverContent>
</Popover>
}
>
<Trans
i18nKey="password_rules"
components={{
ul: <ul className="list-inside list-disc" />,
li: <li />,
}}
/>
</LabelPopover>
</div>
<FormControl>
<Input
Expand Down