Skip to content

Commit

Permalink
fix: review metier
Browse files Browse the repository at this point in the history
  • Loading branch information
victor committed Jan 27, 2025
1 parent 633a64b commit 3fa6cc9
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import Html from "../common/Html";
import Link from "../common/Link";
import Accordion from "@codegouvfr/react-dsfr/Accordion";
import { ListWithArrow } from "../common/ListWithArrow";
import { ElasticSearchContributionConventionnelle } from "@socialgouv/cdtn-types";
import { RelatedItems } from "../common/RelatedItems";
import { RelatedItem } from "../documents";
import { Share } from "../common/Share";
import { Contribution } from "./type";

type Props = {
contribution: ElasticSearchContributionConventionnelle;
contribution: Contribution;
relatedItems: {
items: RelatedItem[];
title: string;
Expand Down Expand Up @@ -42,7 +42,7 @@ export function ContributionAgreementContent({
items={contribution.references.map(({ title, url }) => {
if (!url) return <></>;
return (
<Link key={title} href={url}>
<Link key={title} href={url} target="_blank">
{title}
</Link>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
import {
ElasticSearchContributionConventionnelle,
ElasticSearchContributionGeneric,
} from "@socialgouv/cdtn-types";
import React from "react";

import DisplayContentContribution, {
ContentSP,
numberLevel,
} from "./DisplayContentContribution";
import { Contribution } from "./type";

type Props = {
contribution:
| ElasticSearchContributionGeneric
| ElasticSearchContributionConventionnelle;
contribution: Contribution;
titleLevel: numberLevel;
};

export const ContributionContent = ({ contribution, titleLevel }: Props) => {
if (contribution.type === "generic-no-cdt") return <></>;
const isFicheSP = "raw" in contribution;

return (
<section>
{isFicheSP ? (
{contribution.isFicheSP ? (
<>
<div>
<ContentSP raw={contribution.raw} titleLevel={titleLevel - 2} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import React, { ReactNode, useEffect, useRef, useState } from "react";
import { Button } from "@codegouvfr/react-dsfr/Button";
import { fr } from "@codegouvfr/react-dsfr";
import { css } from "@styled-system/css";
import { Share } from "../common/Share";
import { ElasticSearchContributionGeneric } from "@socialgouv/cdtn-types";
import { ContributionContent } from "./ContributionContent";
Expand Down Expand Up @@ -71,21 +72,18 @@ export function ContributionGenericContent({
displayContent ? "fr-unhidden" : "fr-hidden"
)}
>
<div id="cdt">
<div id="cdt" className={w100}>
<p className={fr.cx("fr-h5")} ref={titleRef}>
Que dit le code du travail&nbsp;?
</p>
{alertText}
<ContributionContent
contribution={contribution as ElasticSearchContributionGeneric}
titleLevel={2}
/>
<ContributionContent contribution={contribution} titleLevel={2} />
{contribution.references.length && (
<Accordion label="Références" className={fr.cx("fr-mt-6w")}>
<ListWithArrow
items={contribution.references.map(({ title, url }) => {
return (
<Link key={title} href={url ?? ""}>
<Link key={title} href={url ?? ""} target="_blank">
{title}
</Link>
);
Expand Down Expand Up @@ -120,3 +118,8 @@ export function ContributionGenericContent({
</>
);
}

const w100 = css({
w: "100%!",
justifyContent: "center",
});
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,7 @@ export function ContributionLayout({ contribution }: Props) {
)}
{!isGeneric && (
<ContributionAgreementContent
contribution={
contribution as ElasticSearchContributionConventionnelle
}
contribution={contribution}
relatedItems={relatedItems}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const mapTbody = (tbody: Element) => {
}

return (
<div className={"fr-table--md fr-table"}>
<div className={fr.cx("fr-table", "fr-mb-2w")}>
<div className="fr-table__wrapper">
<div className="fr-table__container">
<div className="fr-table__content">
Expand Down Expand Up @@ -191,9 +191,11 @@ function renderChildrenWithNoTrim(domNode) {
const getHeadingElement = (titleLevel: numberLevel, domNode) => {
const Tag = ("h" + titleLevel) as ElementType;
return titleLevel <= 6 ? (
<Tag>{renderChildrenWithNoTrim(domNode)}</Tag>
<Tag className={fr.cx("fr-mt-2w")}>{renderChildrenWithNoTrim(domNode)}</Tag>
) : (
<strong>{renderChildrenWithNoTrim(domNode)}</strong>
<strong className={fr.cx("fr-mt-2w")}>
{renderChildrenWithNoTrim(domNode)}
</strong>
);
};

Expand Down Expand Up @@ -251,6 +253,7 @@ const options = (titleLevel: numberLevel): HTMLReactParserOptions => {
description={domToReact(domNode.children as DOMNode[], {
trim: true,
})}
className={fr.cx("fr-mt-2w")}
></Alert>
);
}
Expand All @@ -272,7 +275,7 @@ const options = (titleLevel: numberLevel): HTMLReactParserOptions => {
className={
(domNode.parentNode as Element | undefined)?.name === "li"
? fr.cx("fr-mb-0")
: undefined
: fr.cx("fr-mt-2w")
}
>
{renderChildrenWithNoTrim(domNode)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Sentry from "@sentry/nextjs";
import { elasticDocumentsIndex, elasticsearchClient } from "../../api/utils";
import { SOURCES } from "@socialgouv/cdtn-utils";
import { slugify, SOURCES } from "@socialgouv/cdtn-utils";
import { DocumentElasticResult, fetchDocument, isSource } from "../documents";
import { Contribution, ContributionElasticDocument } from "./type";

Expand Down Expand Up @@ -64,7 +64,7 @@ const formatContribution = (
...arr,
{
title: linked.title,
url: linked.slug,
url: `/${slugify(linked.source)}/${linked.slug}`,
source: linked.source,
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type ContributionElasticDocumentBase = Omit<
ExportContributionInfo & {
raw: string;
url: string;
content: string;
};

export type ContributionElasticDocument = ContributionElasticDocumentBase &
Expand Down

0 comments on commit 3fa6cc9

Please sign in to comment.