Added back to portfolio button with tooltip

This commit is contained in:
Khalim Conn-Kowlessar 2023-11-29 11:04:50 +00:00
parent 1a2bfca9af
commit 3b259d7611
6 changed files with 219 additions and 24 deletions

117
package-lock.json generated
View file

@ -20,6 +20,7 @@
"@radix-ui/react-select": "^1.2.2",
"@radix-ui/react-separator": "^1.0.3",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-tooltip": "^1.0.7",
"@tanstack/react-query": "^4.29.12",
"@tanstack/react-table": "^8.9.3",
"@types/node": "20.2.3",
@ -2141,6 +2142,122 @@
}
}
},
"node_modules/@radix-ui/react-tooltip": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/@radix-ui/react-tooltip/-/react-tooltip-1.0.7.tgz",
"integrity": "sha512-lPh5iKNFVQ/jav/j6ZrWq3blfDJ0OH9R6FlNUHPMqdLuQ9vwDgFsRxvl8b7Asuy5c8xmoojHUxKHQSOAvMHxyw==",
"dependencies": {
"@babel/runtime": "^7.13.10",
"@radix-ui/primitive": "1.0.1",
"@radix-ui/react-compose-refs": "1.0.1",
"@radix-ui/react-context": "1.0.1",
"@radix-ui/react-dismissable-layer": "1.0.5",
"@radix-ui/react-id": "1.0.1",
"@radix-ui/react-popper": "1.1.3",
"@radix-ui/react-portal": "1.0.4",
"@radix-ui/react-presence": "1.0.1",
"@radix-ui/react-primitive": "1.0.3",
"@radix-ui/react-slot": "1.0.2",
"@radix-ui/react-use-controllable-state": "1.0.1",
"@radix-ui/react-visually-hidden": "1.0.3"
},
"peerDependencies": {
"@types/react": "*",
"@types/react-dom": "*",
"react": "^16.8 || ^17.0 || ^18.0",
"react-dom": "^16.8 || ^17.0 || ^18.0"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
},
"@types/react-dom": {
"optional": true
}
}
},
"node_modules/@radix-ui/react-tooltip/node_modules/@radix-ui/react-dismissable-layer": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/@radix-ui/react-dismissable-layer/-/react-dismissable-layer-1.0.5.tgz",
"integrity": "sha512-aJeDjQhywg9LBu2t/At58hCvr7pEm0o2Ke1x33B+MhjNmmZ17sy4KImo0KPLgsnc/zN7GPdce8Cnn0SWvwZO7g==",
"dependencies": {
"@babel/runtime": "^7.13.10",
"@radix-ui/primitive": "1.0.1",
"@radix-ui/react-compose-refs": "1.0.1",
"@radix-ui/react-primitive": "1.0.3",
"@radix-ui/react-use-callback-ref": "1.0.1",
"@radix-ui/react-use-escape-keydown": "1.0.3"
},
"peerDependencies": {
"@types/react": "*",
"@types/react-dom": "*",
"react": "^16.8 || ^17.0 || ^18.0",
"react-dom": "^16.8 || ^17.0 || ^18.0"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
},
"@types/react-dom": {
"optional": true
}
}
},
"node_modules/@radix-ui/react-tooltip/node_modules/@radix-ui/react-popper": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/@radix-ui/react-popper/-/react-popper-1.1.3.tgz",
"integrity": "sha512-cKpopj/5RHZWjrbF2846jBNacjQVwkP068DfmgrNJXpvVWrOvlAmE9xSiy5OqeE+Gi8D9fP+oDhUnPqNMY8/5w==",
"dependencies": {
"@babel/runtime": "^7.13.10",
"@floating-ui/react-dom": "^2.0.0",
"@radix-ui/react-arrow": "1.0.3",
"@radix-ui/react-compose-refs": "1.0.1",
"@radix-ui/react-context": "1.0.1",
"@radix-ui/react-primitive": "1.0.3",
"@radix-ui/react-use-callback-ref": "1.0.1",
"@radix-ui/react-use-layout-effect": "1.0.1",
"@radix-ui/react-use-rect": "1.0.1",
"@radix-ui/react-use-size": "1.0.1",
"@radix-ui/rect": "1.0.1"
},
"peerDependencies": {
"@types/react": "*",
"@types/react-dom": "*",
"react": "^16.8 || ^17.0 || ^18.0",
"react-dom": "^16.8 || ^17.0 || ^18.0"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
},
"@types/react-dom": {
"optional": true
}
}
},
"node_modules/@radix-ui/react-tooltip/node_modules/@radix-ui/react-portal": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@radix-ui/react-portal/-/react-portal-1.0.4.tgz",
"integrity": "sha512-Qki+C/EuGUVCQTOTD5vzJzJuMUlewbzuKyUy+/iHM2uwGiru9gZeBJtHAPKAEkB5KWGi9mP/CHKcY0wt1aW45Q==",
"dependencies": {
"@babel/runtime": "^7.13.10",
"@radix-ui/react-primitive": "1.0.3"
},
"peerDependencies": {
"@types/react": "*",
"@types/react-dom": "*",
"react": "^16.8 || ^17.0 || ^18.0",
"react-dom": "^16.8 || ^17.0 || ^18.0"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
},
"@types/react-dom": {
"optional": true
}
}
},
"node_modules/@radix-ui/react-use-callback-ref": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@radix-ui/react-use-callback-ref/-/react-use-callback-ref-1.0.1.tgz",

View file

@ -26,6 +26,7 @@
"@radix-ui/react-select": "^1.2.2",
"@radix-ui/react-separator": "^1.0.3",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-tooltip": "^1.0.7",
"@tanstack/react-query": "^4.29.12",
"@tanstack/react-table": "^8.9.3",
"@types/node": "20.2.3",

View file

@ -0,0 +1,38 @@
"use client";
import { useRouter } from "next/navigation";
import { ArrowLeftIcon } from "@heroicons/react/24/outline";
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "@/app/shadcn_components/ui/tooltip";
const BackToPortfolioButton = ({ portfolioId }: { portfolioId: string }) => {
const router = useRouter();
const handleBackClick = () => {
router.push(`/portfolio/${portfolioId}`);
};
return (
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
<button
onClick={handleBackClick}
className="bg-white hover:bg-gray-200 text-brandblue font-bold py-2 px-4 rounded-full"
>
<ArrowLeftIcon className="w-5 h-5 mr-1" />
</button>
</TooltipTrigger>
<TooltipContent className="bg-brandblue text-gray-100">
Back to Portfolio
</TooltipContent>
</Tooltip>
</TooltipProvider>
);
};
export default BackToPortfolioButton;

View file

@ -129,84 +129,88 @@ function SummaryBox({
return (
<div className="p-6 bg-white rounded-lg leading-relaxed">
<h2 className="text-2xl font-bold mb-4 text-gray-700 text-center">
<h2 className="text-2xl font-bold mb-4 text-brandblue text-center">
Portfolio Summary
</h2>
<div className="grid grid-cols-1 md:grid-cols-1 gap-6">
<div className="p-4 bg-brandblue rounded-lg">
<h3 className="text-lg font-semibold text-gray-200 mb-2">
<div className="p-4 bg-gray-50 rounded-lg">
<h3 className="text-lg font-semibold text-brandblue mb-2">
Work Package
</h3>
<table className="w-full">
<tbody>
<tr>
<td className="text-gray-200 ">Total Budget</td>
<td className="text-gray-200 text-end">{budgetFormatted}</td>
<td className="text-brandblue ">Total Budget</td>
<td className="text-brandblue text-end">{budgetFormatted}</td>
</tr>
<tr>
<td className="text-gray-200 ">Total Cost</td>
<td className="text-gray-200 text-end">{totalCostFormatted}</td>
<td className="text-brandblue ">Total Cost</td>
<td className="text-brandblue text-end">
{totalCostFormatted}
</td>
</tr>
<tr>
<td className="text-gray-200">Estimated Duration</td>
<td className="text-gray-200 text-end">
<td className="text-brandblue">Estimated Duration</td>
<td className="text-brandblue text-end">
{estimatedDurationFormatted}
</td>
</tr>
<tr>
<td className="text-gray-200">Total properties</td>
<td className="text-gray-200 text-end">{numProperties}</td>
<td className="text-brandblue">Total properties</td>
<td className="text-brandblue text-end">{numProperties}</td>
</tr>
</tbody>
</table>
</div>
<div className="p-4 bg-brandblue rounded-lg">
<div className="p-4 bg-gray-50 rounded-lg">
{/* Environmental Impact */}
<h3 className="text-lg font-semibold text-gray-200 mb-2">
<h3 className="text-lg font-semibold text-brandblue mb-2">
Environmental Impact
</h3>
<table className="w-full">
<tbody>
<tr>
<td className="text-gray-200">
<td className="text-brandblue">
Annual{" "}
<span>
CO<sub>2</sub>
</span>{" "}
Savings
</td>
<td className="text-gray-200 text-end">
<td className="text-brandblue text-end">
{co2EquivalentSavingsFormatted}
</td>
</tr>
<tr>
<td className="text-gray-200">Annual Energy Savings</td>
<td className="text-gray-200 text-end">
<td className="text-brandblue">Annual Energy Savings</td>
<td className="text-brandblue text-end">
{energySavingsFormatted}
</td>
</tr>
</tbody>
</table>
</div>
<div className="p-4 bg-brandblue rounded-lg">
<div className="p-4 bg-gray-50 rounded-lg">
{/* Financial Impact table */}
<h3 className="text-lg font-semibold text-gray-200 mb-2">
<h3 className="text-lg font-semibold text-brandblue mb-2">
Financial Impact
</h3>
<table className="w-full">
<tbody>
<tr>
<td className="text-gray-200 ">Annual Energy Bill Reduction</td>
<td className="text-gray-200 text-end">
<td className="text-brandblue ">
Annual Energy Bill Reduction
</td>
<td className="text-brandblue text-end">
{energyCostSavingsFormatted}
</td>
</tr>
<tr>
<td className="text-gray-200 ">Total Value Increase</td>
<td className="text-gray-200 text-end">
<td className="text-brandblue ">Total Value Increase</td>
<td className="text-brandblue text-end">
{totalValueIncreaseFormatted}
</td>
</tr>

View file

@ -1,5 +1,6 @@
import { Toolbar } from "@/app/components/building-passport/Toolbar";
import { getPropertyMeta } from "./utils";
import BackToPortfolioButton from "@/app/components/building-passport/BackToPortfolioButton";
export default async function DashboardLayout({
children, // will be a page or nested layout
@ -25,7 +26,11 @@ export default async function DashboardLayout({
return (
<section>
<div className="mx-auto w-full max-w-6xl mb-10">
<div className="flex justify-start items-end p-8">
<div className="flex justify-start items-end pr-8 py-8">
<div className="mr-2">
<BackToPortfolioButton portfolioId={portfolioId} />
</div>
<h1 className="text-3xl font-bold mr-3 text-gray-900">
{propertyMeta.address}
</h1>

View file

@ -0,0 +1,30 @@
"use client"
import * as React from "react"
import * as TooltipPrimitive from "@radix-ui/react-tooltip"
import { cn } from "@/lib/utils"
const TooltipProvider = TooltipPrimitive.Provider
const Tooltip = TooltipPrimitive.Root
const TooltipTrigger = TooltipPrimitive.Trigger
const TooltipContent = React.forwardRef<
React.ElementRef<typeof TooltipPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
>(({ className, sideOffset = 4, ...props }, ref) => (
<TooltipPrimitive.Content
ref={ref}
sideOffset={sideOffset}
className={cn(
"z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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",
className
)}
{...props}
/>
))
TooltipContent.displayName = TooltipPrimitive.Content.displayName
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }