Skip to content

Commit 4fa358a

Browse files
authored
Merge pull request #2551 from Open-Earth-Foundation/feat/navigation-related-improvements
Feat/navigation related improvements
2 parents 301f3cc + b1519d6 commit 4fa358a

11 files changed

Lines changed: 159 additions & 45 deletions

File tree

app/src/app/[lng]/[inventory]/data/[step]/[subsector]/page.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,20 +258,30 @@ function SubSectorPage(props: {
258258
<BreadcrumbLink
259259
href={pathname.replace(`/${step}/${subsector}`, "")}
260260
color="content.tertiary"
261+
textDecoration="none"
262+
_hover={{
263+
textDecoration: "underline",
264+
textUnderlineOffset: "4px",
265+
}}
261266
truncate
262267
>
263268
{t("all-sectors")}
264269
</BreadcrumbLink>
265270
<BreadcrumbLink
266271
href={pathname.replace(`/${subsector}`, "")}
267272
color="content.tertiary"
273+
textDecoration="none"
274+
_hover={{
275+
textDecoration: "underline",
276+
textUnderlineOffset: "4px",
277+
}}
268278
truncate
269279
>
270280
{t(getSectorName(step))}
271281
</BreadcrumbLink>
272282
<BreadcrumbCurrentLink
273283
color="content.link"
274-
textDecoration="underline"
284+
textDecoration="none"
275285
>
276286
<Text truncate lineClamp={1}>
277287
{!subSectorData ? (

app/src/app/[lng]/[inventory]/data/[step]/page.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,13 +676,18 @@ export default function AddDataSteps() {
676676
<BreadcrumbLink
677677
href={`/${inventory}/data`}
678678
color="content.tertiary"
679+
textDecoration="none"
680+
_hover={{
681+
textDecoration: "underline",
682+
textUnderlineOffset: "4px",
683+
}}
679684
>
680685
{t("all-sectors")}
681686
</BreadcrumbLink>
682687

683688
<BreadcrumbCurrentLink
684689
color="content.link"
685-
textDecoration="underline"
690+
textDecoration="none"
686691
>
687692
{t(kebab(currentStep.name || ""))}
688693
</BreadcrumbCurrentLink>

app/src/components/GHGIHomePage/Hero.tsx

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { Box, Heading, Icon, Spinner, Text } from "@chakra-ui/react";
1212
import { CircleFlag } from "react-circle-flags";
1313
import {
1414
MdArrowOutward,
15+
MdChevronRight,
1516
MdGroup,
1617
MdInfoOutline,
1718
MdOutlineAspectRatio,
@@ -22,6 +23,12 @@ import { getShortenNumberUnit, shortenNumber } from "@/util/helpers";
2223
import Link from "next/link";
2324
import { hasFeatureFlag, FeatureFlags } from "@/util/feature-flags";
2425
import { useTranslation } from "@/i18n/client";
26+
import {
27+
BreadcrumbCurrentLink,
28+
BreadcrumbLink,
29+
BreadcrumbRoot,
30+
} from "@/components/ui/breadcrumb";
31+
import { usePathname } from "next/navigation";
2532

2633
const CityMap = dynamic(() => import("@/components/CityMap"), { ssr: false });
2734

@@ -47,6 +54,7 @@ export function Hero({
4754
city,
4855
}: HeroProps) {
4956
const { t } = useTranslation(lng, "dashboard");
57+
const pathname = usePathname();
5058
const activeCity = inventory?.city?.name ?? city?.name;
5159
const activeProject = (() => {
5260
const projectName = inventory?.city?.project?.name ?? city?.project?.name;
@@ -72,15 +80,60 @@ export function Hero({
7280
[cityData?.population, population?.population, population?.year],
7381
);
7482

83+
const moduleLabel = useMemo(() => {
84+
if (pathname.includes("/HIAP")) return t("breadcrumb-hiap");
85+
if (pathname.includes("/dashboard")) return t("dashboard");
86+
return t("ghg-inventories");
87+
}, [pathname, t]);
88+
89+
const cityId = inventory?.cityId ?? city?.cityId;
90+
const breadcrumbsHomeHref = cityId ? `/${lng}/cities/${cityId}` : `/${lng}`;
91+
7592
return (
76-
<Box bg="content.alternative" w="full" h="491px" pt="150px" px={8}>
77-
<Box display="flex" mx="auto" maxW="full" w="1090px">
93+
<Box bg="content.alternative" w="full" h="491px" pt="80px" px={8}>
94+
<Box
95+
display="flex"
96+
flexDirection="column"
97+
gap="24px"
98+
mx="auto"
99+
maxW="full"
100+
w="1090px"
101+
>
102+
<Box>
103+
<BreadcrumbRoot
104+
separator={
105+
<Icon as={MdChevronRight} boxSize={4} color="base.light" />
106+
}
107+
separatorGap="8px"
108+
fontFamily="body"
109+
>
110+
<BreadcrumbLink href={breadcrumbsHomeHref} asChild>
111+
<Link href={breadcrumbsHomeHref} color="base.light">
112+
<Text
113+
fontSize="body.md"
114+
color="base.light"
115+
lineHeight="20px"
116+
_hover={{ textDecoration: "underline" }}
117+
textUnderlineOffset="8px"
118+
>
119+
{t("citycatalyst")}
120+
</Text>
121+
</Link>
122+
</BreadcrumbLink>
123+
<BreadcrumbCurrentLink>
124+
<Text fontSize="body.md" color="border.neutral">
125+
{moduleLabel}
126+
</Text>
127+
</BreadcrumbCurrentLink>
128+
</BreadcrumbRoot>
129+
</Box>
78130
<Box
79131
w="full"
80132
h="240px"
81133
display="flex"
82134
flexDirection="column"
83135
justifyContent="center"
136+
pt="36px"
84137
>
85138
<Box display="flex" h="240px">
86139
<Box
@@ -98,6 +151,7 @@ export function Hero({
98151
>
99152
{!inventory ? t("welcome") : null}
100153
</Text>
154+
101155
<Box display="flex" flexDirection="column" gap={2}>
102156
{!isPublic &&
103157
hasFeatureFlag(FeatureFlags.PROJECT_OVERVIEW_ENABLED) ? (

app/src/components/HomePageJN/ModuleCard.tsx

Lines changed: 62 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ import React from "react";
55
import type { TFunction } from "i18next";
66
import { ButtonMedium } from "@/components/package/Texts/Button";
77
import { BodyMedium, BodySmall } from "@/components/package/Texts/Body";
8-
import { MdArrowForward } from "react-icons/md";
8+
import { MdArrowForward, MdOpenInNew } from "react-icons/md";
99
import { MdInfoOutline } from "react-icons/md";
1010
import { TitleLarge } from "@/components/package/Texts/Title";
1111
import { ModuleAttributes } from "@/models/Module";
1212
import NextLink from "next/link";
13+
import { Modules } from "@/util/constants";
14+
15+
const GHGI_START_HERE_HIDDEN_KEY = "ghgi-start-here-hidden";
1316

1417
export function ModuleCard({
1518
module,
@@ -43,6 +46,18 @@ export function ModuleCard({
4346
};
4447

4548
const { name, author, description, tagline, url, logo, status } = module;
49+
const isGhgi = module.id === Modules.GHGI.id;
50+
const [hideStartHereTag, setHideStartHereTag] = React.useState(false);
51+
52+
React.useEffect(() => {
53+
if (!isGhgi) return;
54+
55+
const isHidden =
56+
localStorage.getItem(GHGI_START_HERE_HIDDEN_KEY) === "true";
57+
if (isHidden) {
58+
setHideStartHereTag(true);
59+
}
60+
}, [isGhgi]);
4661

4762
const getTranslationInLanguage = (
4863
obj: { [lng: string]: string } | undefined,
@@ -57,6 +72,11 @@ export function ModuleCard({
5772
const resolvedUrl = isExternal ? url : `${baseUrl}${url}`;
5873

5974
const handleModuleLaunch = (e: React.MouseEvent) => {
75+
if (isGhgi) {
76+
setHideStartHereTag(true);
77+
localStorage.setItem(GHGI_START_HERE_HIDDEN_KEY, "true");
78+
}
79+
6080
if (isExternal) {
6181
e.preventDefault();
6282
window.open(url, "_blank", "noopener,noreferrer");
@@ -84,39 +104,55 @@ export function ModuleCard({
84104
<Card.Body gap={2} flex="1">
85105
<VStack w="full" align="start" gap={2}>
86106
<HStack justify="space-between" w="full">
87-
<HStack gap={2}>
107+
<HStack gap={2} justifyContent="space-between">
88108
<Image
89109
src={logo || "/assets/icon_inverted.svg"}
90110
boxSize={8}
91111
alt={`${name} module logo`}
92112
/>
113+
93114
{status && status !== "active" && (
94115
<Tag size="sm" colorPalette={statusColorMap[status] || "gray"}>
95116
{t(statusLabelMap[status] || status)}
96117
</Tag>
97118
)}
98119
</HStack>
99-
100-
<Tooltip
101-
content={getTranslationInLanguage(description)}
102-
showArrow
103-
closeDelay={8000}
104-
contentProps={{
105-
bg: "content.secondary",
106-
color: "background.default",
107-
borderRadius: "md",
108-
p: 3,
109-
maxW: "300px",
110-
fontSize: "sm",
111-
}}
112-
>
113-
<Icon
114-
as={MdInfoOutline}
115-
boxSize={6}
116-
color="interactive.control"
117-
cursor="pointer"
118-
/>
119-
</Tooltip>
120+
<HStack gap={2} justifyContent="flex-end">
121+
{isGhgi && !hideStartHereTag && (
122+
<Tag
123+
size="sm"
124+
colorPalette="gray"
125+
p={2}
126+
borderRadius={"8px"}
127+
bg="border.neutral"
128+
color="content.secondary"
129+
fontWeight="semibold"
130+
textTransform="uppercase"
131+
>
132+
{t("start-here")}
133+
</Tag>
134+
)}
135+
<Tooltip
136+
content={getTranslationInLanguage(description)}
137+
showArrow
138+
closeDelay={8000}
139+
contentProps={{
140+
bg: "content.secondary",
141+
color: "background.default",
142+
borderRadius: "md",
143+
p: 3,
144+
maxW: "300px",
145+
fontSize: "sm",
146+
}}
147+
>
148+
<Icon
149+
as={MdInfoOutline}
150+
boxSize={6}
151+
color="interactive.control"
152+
cursor="pointer"
153+
/>
154+
</Tooltip>
155+
</HStack>
120156
</HStack>
121157
<Card.Title
122158
mt={2}
@@ -151,11 +187,11 @@ export function ModuleCard({
151187
<NextLink
152188
href={resolvedUrl}
153189
onClick={handleModuleLaunch}
154-
target={isExternal ? "_blank" : undefined}
155-
rel={isExternal ? "noopener noreferrer" : undefined}
190+
target={"_blank"}
191+
rel={"noopener noreferrer"}
156192
>
157193
<ButtonMedium>{t("launch")}</ButtonMedium>
158-
<MdArrowForward />
194+
<Icon as={MdOpenInNew} boxSize={5} />
159195
</NextLink>
160196
</Button>
161197
</Card.Footer>

app/src/components/navigation-bar.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
MdArrowDropUp,
2626
MdAspectRatio,
2727
MdLogout,
28+
MdOpenInNew,
2829
MdOutlineMenu,
2930
} from "react-icons/md";
3031
import Cookies from "js-cookie";
@@ -245,17 +246,15 @@ export function NavigationBar({
245246
</Link>
246247
<Link
247248
rel="help noopener"
249+
target="_blank"
248250
href="https://citycatalyst.openearth.org/learning-hub"
249251
>
250-
<Heading
251-
color="base.light"
252-
size="md"
253-
opacity={0.75}
254-
whiteSpace="nowrap"
255-
ml={6}
256-
>
257-
{t("learning-hub")}
258-
</Heading>
252+
<HStack ml={6} gap={2} color="base.light" opacity={0.75}>
253+
<Heading size="md" whiteSpace="nowrap">
254+
{t("learning-hub")}
255+
</Heading>
256+
<Icon as={MdOpenInNew} boxSize={4} />
257+
</HStack>
259258
</Link>
260259
<Separator
261260
orientation="vertical"

app/src/i18n/locales/de/dashboard.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,5 +298,7 @@
298298
"status-beta": "Betaversion",
299299
"status-active": "Aktiv",
300300
"legend": "Legende",
301-
"citycatalyst": "CityCatalyst"
301+
"citycatalyst": "CityCatalyst",
302+
"breadcrumb-hiap": "Actions & Plans",
303+
"start-here": "Hier starten"
302304
}

app/src/i18n/locales/en/dashboard.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,5 +304,7 @@
304304
"subcategory": "Sub-category",
305305
"inventory-versions-restore-failed": "Failed to restore version",
306306
"legend": "Legend",
307-
"citycatalyst": "CityCatalyst"
307+
"citycatalyst": "CityCatalyst",
308+
"breadcrumb-hiap": "Actions & Plans",
309+
"start-here": "Start here"
308310
}

app/src/i18n/locales/en/navigation.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"learning-hub": "Learn",
2+
"learning-hub": "Learning hub",
33
"admin": "Admin",
44
"cities": "cities",
55
"settings": "Settings",

app/src/i18n/locales/es/dashboard.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,5 +301,7 @@
301301
"status-beta": "Beta",
302302
"status-active": "Activo",
303303
"legend": "Leyenda",
304-
"citycatalyst": "CityCatalyst"
304+
"citycatalyst": "CityCatalyst",
305+
"breadcrumb-hiap": "Actions & Plans",
306+
"start-here": "Empieza aquí"
305307
}

app/src/i18n/locales/fr/dashboard.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,5 +298,7 @@
298298
"status-beta": "Bêta",
299299
"status-active": "Actif",
300300
"legend": "Légende",
301-
"citycatalyst": "CityCatalyst"
301+
"citycatalyst": "CityCatalyst",
302+
"breadcrumb-hiap": "Actions & Plans",
303+
"start-here": "Commencer ici"
302304
}

0 commit comments

Comments
 (0)