Skip to content

Commit

Permalink
feat(alert): add a tooltip to show the CCN title (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-maillot committed Mar 1, 2021
1 parent 8b1346a commit 724dc08
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions targets/frontend/src/pages/alerts/[[...params]].js
Expand Up @@ -4,6 +4,7 @@ import slugify from "@socialgouv/cdtn-slugify";
import { getRouteBySource } from "@socialgouv/cdtn-sources";
import { useRouter } from "next/router";
import { useMemo } from "react";
import { IoIosInformationCircleOutline } from "react-icons/io";
import { AlertTabs } from "src/components/alerts/AlertTabs";
import { AlertTitle } from "src/components/alerts/AlertTitle";
import { DiffChange } from "src/components/changes";
Expand Down Expand Up @@ -94,13 +95,27 @@ export function AlertPage() {

function getTitle(alert) {
if (alert.info.num) {
return `IDCC ${alert.info.num} - ${new Date(
alert.created_at
).toLocaleDateString()} (${alert.ref})`;
return (
<span title={alert.info.title}>
IDCC {alert.info.num}
<IoIosInformationCircleOutline
style={{ verticalAlign: "super" }}
sx={{
height: "iconsXSmall",
mx: "0.1rem",
width: "iconsXSmall",
}}
/>
- {new Date(alert.created_at).toLocaleDateString()} ({alert.ref})
</span>
);
} else {
return `${alert.info.title} - ${new Date(
alert.created_at
).toLocaleDateString()} (${alert.ref})`;
return (
<>
{alert.info.title} - {new Date(alert.created_at).toLocaleDateString()}{" "}
({alert.ref})
</>
);
}
}

Expand Down Expand Up @@ -228,6 +243,7 @@ export function AlertPage() {
</Layout>
);
}

/**
* This getInitialProps ensure useState to reset while page url change
* @see https://github.com/vercel/next.js/issues/9992
Expand Down

0 comments on commit 724dc08

Please sign in to comment.