diff --git a/src/Donations/LeftPanel/LeftPanel.module.scss b/src/Donations/LeftPanel/LeftPanel.module.scss index 7681eeb2..8dd4d7cf 100644 --- a/src/Donations/LeftPanel/LeftPanel.module.scss +++ b/src/Donations/LeftPanel/LeftPanel.module.scss @@ -103,6 +103,33 @@ color: $light; } +.project-title { + display: flex; + align-items: stretch; + flex-wrap: wrap; + column-gap: 10px; + margin-top: 10px; + + a, + h1 { + color: $light; + } +} + +.verified-badge { + display: flex; + align-items: center; + height: 1.43em; //hack to match line height of h1 tag +} + +.verified-badge-popup { + max-width: 800px; + padding: 0.5rem; + margin-right: 20px; + margin-left: 10px; + pointer-events: none; +} + @include smTabletView { .left-panel-container { padding: 30px; diff --git a/src/Donations/LeftPanel/LeftPanelInfo.tsx b/src/Donations/LeftPanel/LeftPanelInfo.tsx index 4661db89..05bae8d2 100644 --- a/src/Donations/LeftPanel/LeftPanelInfo.tsx +++ b/src/Donations/LeftPanel/LeftPanelInfo.tsx @@ -1,8 +1,6 @@ -import { ReactElement, useState, MouseEvent } from "react"; -import { Typography, Popover } from "@mui/material"; +import { ReactElement } from "react"; import { useTranslation } from "next-i18next"; import { useRouter } from "next/router"; -import VerifiedIcon from "@mui/icons-material/Verified"; import { ContactDetails, NoGift } from "@planet-sdk/common"; import { FetchedProjectDetails, @@ -13,6 +11,7 @@ import { } from "src/Common/Types"; import Avatar from "./Avatar"; import TransactionSummary from "./TransactionSummary"; +import ProjectTitle from "./ProjectTitle"; interface Props { isMobile: boolean; @@ -51,23 +50,13 @@ const LeftPanelInfo = ({ tenant, country, }: Props): ReactElement | null => { - const [anchorElement, setAnchorElement] = useState(null); - const open = Boolean(anchorElement); - const { t, i18n } = useTranslation("common"); const router = useRouter(); const canShowAvatar = donationStep !== null && donationStep > 0; const canShowTransactionSummary = paymentSetup !== null && (donationStep === 2 || donationStep === 3); - - const handlePopoverOpen = (event: MouseEvent) => { - setAnchorElement(event.currentTarget); - }; - - const handlePopoverClose = () => { - setAnchorElement(null); - }; + const canShowProject = donationStep !== null && donationStep > 0; return projectDetails ? (
@@ -80,90 +69,9 @@ const LeftPanelInfo = ({ paymentSetup={paymentSetup} /> )} - {donationStep && donationStep > 0 ? ( + {canShowProject ? ( <> - {projectDetails.purpose === "trees" || - projectDetails.purpose === "conservation" ? ( -
- - {projectDetails.name} - - {projectDetails?.isApproved && ( -
- - - - - {t("verifiedIconInfo")} - -
- )} -
- ) : ( -

- {projectDetails.name ? projectDetails.name : ""} - {projectDetails.name && projectDetails?.isApproved && ( -
- - - - - {t("verifiedIconInfo")} - -
- )} -

- )} + {projectDetails.purpose === "funds" || projectDetails.purpose === "bouquet" ? ( diff --git a/src/Donations/LeftPanel/ProjectTitle.tsx b/src/Donations/LeftPanel/ProjectTitle.tsx new file mode 100644 index 00000000..d4c7ec42 --- /dev/null +++ b/src/Donations/LeftPanel/ProjectTitle.tsx @@ -0,0 +1,39 @@ +import { ReactElement } from "react"; +import { + FetchedProjectDetails, + PlanetCashSignupDetails, +} from "src/Common/Types"; +import VerifiedBadge from "./VerifiedBadge"; +import styles from "./LeftPanel.module.scss"; + +interface Props { + projectDetails: FetchedProjectDetails | PlanetCashSignupDetails; + isMobile: boolean; +} + +const ProjectTitle = ({ projectDetails, isMobile }: Props): ReactElement => { + const isLinked = + projectDetails.purpose === "trees" || + projectDetails.purpose === "conservation"; + + return ( +
+ {isLinked ? ( + +

{projectDetails.name}

+
+ ) : ( +

{projectDetails.name}

+ )} + {projectDetails.name && projectDetails?.isApproved && ( + + )} +
+ ); +}; + +export default ProjectTitle; diff --git a/src/Donations/LeftPanel/VerifiedBadge.tsx b/src/Donations/LeftPanel/VerifiedBadge.tsx new file mode 100644 index 00000000..2190a671 --- /dev/null +++ b/src/Donations/LeftPanel/VerifiedBadge.tsx @@ -0,0 +1,59 @@ +import { ReactElement, useState, MouseEvent } from "react"; +import { useTranslation } from "next-i18next"; +import VerifiedIcon from "@mui/icons-material/Verified"; +import { Typography, Popover } from "@mui/material"; +import styles from "./LeftPanel.module.scss"; + +interface Props { + isMobile: boolean; +} + +const VerifiedBadge = ({ isMobile }: Props): ReactElement => { + const { t } = useTranslation("common"); + + const [anchorElement, setAnchorElement] = useState(null); + const isPopoverOpen = anchorElement !== null; + + const handlePopoverOpen = (event: MouseEvent) => { + setAnchorElement(event.currentTarget); + }; + + const handlePopoverClose = () => { + setAnchorElement(null); + }; + + return ( + <> +
+ +
+ + {t("verifiedIconInfo")} + + + ); +}; + +export default VerifiedBadge; diff --git a/styles/donations.scss b/styles/donations.scss index 3191743e..82866169 100644 --- a/styles/donations.scss +++ b/styles/donations.scss @@ -83,10 +83,6 @@ } } -.project-title-container { - display: flex; -} - .donations-transaction-details { font-size: 12px; color: $light; @@ -974,17 +970,3 @@ text-align: left; } } - -.verified-icon-popup { - max-width: 800px; - padding: 0.5rem; - margin-right: 20px; - pointer-events: none; -} - -.MuiTypography-root { - display: inline; -} -.MuiPaper-root { - padding: 10px; -} diff --git a/styles/muiTheme.ts b/styles/muiTheme.ts index 6c87503c..376ee6cc 100644 --- a/styles/muiTheme.ts +++ b/styles/muiTheme.ts @@ -24,6 +24,20 @@ const MuiTheme = createTheme({ }, }, }, + MuiPaper: { + styleOverrides: { + root: { + padding: "10px", + }, + }, + }, + MuiPopover: { + styleOverrides: { + paper: { + minWidth: "240px", + }, + }, + }, }, });