Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dsfr): ajout des premières pages et composants en DSFR #6078

Merged
merged 76 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
5d0bee3
fix: dsfr
maxgfr Aug 22, 2024
26c096b
fix: dsfr
maxgfr Aug 22, 2024
26fda93
fix: dsfr
maxgfr Aug 22, 2024
3de62c3
fix: tests
maxgfr Aug 23, 2024
519c2b8
fix: build
maxgfr Aug 23, 2024
584430c
fix: build
maxgfr Aug 23, 2024
e72900e
fix: build
maxgfr Aug 23, 2024
e7e9d9d
feat(dsfr): ajout du footer (#6079)
maxgfr Aug 27, 2024
9b5940d
fix: tests
maxgfr Aug 28, 2024
6b8bbc3
fix: tests
maxgfr Aug 29, 2024
39725b4
fix: tests
maxgfr Aug 29, 2024
fa27e26
fix: dernier titi
maxgfr Aug 29, 2024
730c547
fix: autoclick
maxgfr Aug 29, 2024
8959e95
fix: bug
maxgfr Aug 29, 2024
5e70276
feat(css): ajout de la lib `panda-css` (zero-runtime) (#6085)
maxgfr Sep 2, 2024
84fd66c
feat(dsfr): ajout de la page stats (#6090)
maxgfr Sep 2, 2024
a1bc36f
fix: tests
maxgfr Sep 2, 2024
205f24d
fix: tests
maxgfr Sep 2, 2024
9fa7db2
Update packages/code-du-travail-frontend/src/modules/mentions-legales…
carolineBda Sep 3, 2024
34ad3a4
fix(recherche): remonter les pré-qualifiés dans la recherche (#6082)
m-maillot Aug 30, 2024
811d51c
chore(release): version 4.151.1
SocialGroovyBot Aug 30, 2024
3a18228
fix(csp): remove reporting on sentry (#6092)
maxgfr Sep 3, 2024
632ad2d
fix: config
maxgfr Sep 3, 2024
dc60c8a
fix: config
maxgfr Sep 3, 2024
3c964c6
fix: config
maxgfr Sep 3, 2024
49e3218
empty
maxgfr Sep 3, 2024
66af4ac
fix: config
maxgfr Sep 3, 2024
b89df9e
empty
maxgfr Sep 3, 2024
7d74e34
Update packages/code-du-travail-frontend/src/modules/mentions-legales…
maxgfr Sep 3, 2024
50029c0
Update packages/code-du-travail-frontend/src/modules/mentions-legales…
maxgfr Sep 3, 2024
4cf46ee
fix: config
maxgfr Sep 3, 2024
4422345
Merge branch 'dev' into maxgfr/dsfr-header
maxgfr Sep 3, 2024
56bde01
chore(dsfr): mise à jour de la version DSFR
m-maillot Sep 5, 2024
0dcdb11
fix(dsfr): ignore les exceptions d'hydratation
m-maillot Sep 10, 2024
eb9af7a
Merge branch 'dev' into maxgfr/dsfr-header
m-maillot Sep 10, 2024
f7ccd02
feat(tests): ajout du module de testing (#6096)
maxgfr Sep 10, 2024
f146a58
fix(dsfr): ignore les exceptions d'hydratation
m-maillot Sep 10, 2024
1ab139e
empty
maxgfr Sep 10, 2024
b9ae448
Merge branch 'dev' into maxgfr/dsfr-header
maxgfr Sep 10, 2024
e43a732
fix: readme
maxgfr Sep 10, 2024
222395d
feat(DSFR): migration de la page article du code du travail (#6099)
carolineBda Sep 16, 2024
e1b2b85
feat: 6093 dsfr page politique de confidentialit (#6094)
Viczei Sep 16, 2024
c4033af
Merge branch 'dev' into maxgfr/dsfr-header
m-maillot Sep 16, 2024
9c7536b
feat(dsfr): ajout des liens d'évitement (#6120)
m-maillot Sep 16, 2024
75b9216
feat(dsfr): migration de la page plan du site (#6097)
m-maillot Sep 16, 2024
13ba1aa
feat(dsfr): mise à jour des snapshots
m-maillot Sep 16, 2024
aee0955
feat(dsfr): mise à jour des snapshots
m-maillot Sep 16, 2024
abecbd2
chore(dsfr): mise à jour de la lib DSFR
m-maillot Sep 17, 2024
a5c5bdc
feat(dsfr): ajout du composant "Avez-vous trouvé une réponse à votre …
maxgfr Sep 18, 2024
6709c1e
fix: tests
maxgfr Sep 18, 2024
919318a
fix: retours
maxgfr Sep 19, 2024
1f81741
fix: tests
maxgfr Sep 19, 2024
75cddcf
feat: nouvelle API pour les articles du code du travail (#6132)
m-maillot Sep 19, 2024
e830c52
fix: merge date
maxgfr Sep 20, 2024
1935bcf
fix(spec) : fix de la spec article-code-du-travail.spec.ts
carolineBda Sep 23, 2024
b250d45
fix(dsfr): ajout de la config pour supprimer le `insafe-inline` des `…
maxgfr Sep 26, 2024
3d0967c
feat(dsfr): ajout de matomo pour tracker les events (#6157)
maxgfr Sep 26, 2024
177b731
Merge branch 'dev' into maxgfr/dsfr-header
m-maillot Sep 26, 2024
f87c8ad
fix(feedback): ajout d'une logique de caractères restants (#6156)
maxgfr Sep 26, 2024
c4c92cb
feat(dsfr): ajout du nouveau logo (#6159)
carolineBda Sep 30, 2024
29ec0d6
feat(dsfr): ajout des pages d'erreurs (404 + 500) (#6146)
maxgfr Oct 3, 2024
70c41a0
feat: séparation des anciennes API et des nouvelles (#6183)
m-maillot Oct 3, 2024
16ed3e8
fix(article code du travail): retrait du tag Code du travail (#6182)
carolineBda Oct 3, 2024
7f329e0
feat(config): correction de `husky`, ajout de `prettier` pour le form…
maxgfr Oct 9, 2024
68ea2cf
Merge branch 'dev' into maxgfr/dsfr-header
maxgfr Oct 9, 2024
0ebc402
fix: branch
maxgfr Oct 9, 2024
6cefcfb
merge dev
carolineBda Oct 10, 2024
36697b3
merge dev
carolineBda Oct 10, 2024
7e4685a
fix: crash lors de la sélection d'une suggestion (#6202)
m-maillot Oct 10, 2024
3f0a3ca
merge dev
carolineBda Oct 10, 2024
11a3292
fix: crash lors de la sélection d'une suggestion (#6209)
carolineBda Oct 14, 2024
000c2cc
Merge branch 'maxgfr/dsfr-header' of https://github.com/SocialGouv/co…
carolineBda Oct 14, 2024
4e128a4
Merge branch 'dev' into maxgfr/dsfr-header
carolineBda Oct 14, 2024
1f64d85
fix(suggestion): style + move feedback into RichComponent (#6210)
carolineBda Oct 14, 2024
67b7b7e
Merge branch 'dev' into maxgfr/dsfr-header
m-maillot Oct 15, 2024
76c626b
fix: format
m-maillot Oct 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/code-du-travail-frontend/app/[...not-found]/page.tsx
maxgfr marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function Index() {
return <div>Erreur 404 todo</div>;
}

export default Index;
46 changes: 46 additions & 0 deletions packages/code-du-travail-frontend/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { DsfrHead } from "@codegouvfr/react-dsfr/next-appdir/DsfrHead";
import { DsfrProvider } from "@codegouvfr/react-dsfr/next-appdir/DsfrProvider";
import { getHtmlAttributes } from "@codegouvfr/react-dsfr/next-appdir/getHtmlAttributes";
import Link from "next/link";
import { defaultColorScheme } from "../src/dsfr/config/defaultColorScheme";
import { StartDsfr } from "../src/dsfr/config/StartDsfr";

export const metadata = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c'est normal qu'on est un title et description dans le layout ? C'est spécifique à chaque page non ?

title: "Code du travail numérique - Ministère du Travail",
description:
"Posez votre question sur le droit du travail et obtenez une réponse personnalisée à vos questions (contrat de travail, congés payés, formation, démission, indemnités).",
};

export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
const lang = "fr";

return (
<html {...getHtmlAttributes({ defaultColorScheme, lang })}>
<head>
<StartDsfr />
<DsfrHead
Link={Link}
preloadFonts={[
//"Marianne-Light",
//"Marianne-Light_Italic",
"Marianne-Regular",
//"Marianne-Regular_Italic",
"Marianne-Medium",
//"Marianne-Medium_Italic",
"Marianne-Bold",
//"Marianne-Bold_Italic",
//"Spectral-Regular",
//"Spectral-ExtraBold"
]}
/>
</head>
<body>
<DsfrProvider lang={lang}>{children}</DsfrProvider>
</body>
</html>
);
}
32 changes: 32 additions & 0 deletions packages/code-du-travail-frontend/app/test-header/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"use client";

import Link from "next/link";
import { useRouter } from "next/navigation";
import { fr } from "@codegouvfr/react-dsfr";
import { DsfrLayout } from "../../src/dsfr/layout";

function Index() {
const router = useRouter();
return (
<DsfrLayout>
<section>
<Link href="/">Accueil with link</Link>
<button
onClick={() => {
console.log("ok");
router.push("/");
}}
>
Accueil with router
</button>
<br />
<a href="/">Accueil without router</a>
</section>
<section>
example icon :<i className={fr.cx("fr-icon-account-pin-circle-line")} />
</section>
</DsfrLayout>
);
}

export default Index;
1 change: 1 addition & 0 deletions packages/code-du-travail-frontend/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference types="next/navigation-types/compat/navigation" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
11 changes: 9 additions & 2 deletions packages/code-du-travail-frontend/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { withSentryConfig } from "@sentry/nextjs";
import MappingReplacement from "./redirects.json" assert { type: "json" };

const ContentSecurityPolicy = `
img-src 'self' https://travail-emploi.gouv.fr https://www.service-public.fr https://cdtn-prod-public.s3.gra.io.cloud.ovh.net https://matomo.fabrique.social.gouv.fr;
script-src 'self' https://mon-entreprise.urssaf.fr https://matomo.fabrique.social.gouv.fr ${
img-src 'self' https://travail-emploi.gouv.fr https://www.service-public.fr https://cdtn-prod-public.s3.gra.io.cloud.ovh.net https://matomo.fabrique.social.gouv.fr data:;
m-maillot marked this conversation as resolved.
Show resolved Hide resolved
script-src 'self' https://mon-entreprise.urssaf.fr https://matomo.fabrique.social.gouv.fr 'unsafe-inline' ${
carolineBda marked this conversation as resolved.
Show resolved Hide resolved
process.env.NEXT_PUBLIC_APP_ENV !== "production" && "'unsafe-eval'"
};
frame-src 'self' https://mon-entreprise.urssaf.fr https://matomo.fabrique.social.gouv.fr *.dailymotion.com;
Expand Down Expand Up @@ -50,6 +50,13 @@ const nextConfig = {
},
staticPageGenerationTimeout: 60 * 5, // 5 minutes
experimental: { instrumentationHook: true },
webpack: (config) => {
config.module.rules.push({
test: /\.woff2$/,
type: "asset/resource",
});
return config;
},
};

const moduleExports = {
Expand Down
7 changes: 5 additions & 2 deletions packages/code-du-travail-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
"keywords": [],
"main": "src/index.js",
"scripts": {
"dev": "next dev",
"dev": "yarn predev && next dev",
"predev": "react-dsfr update-icons",
"lint:js": "next lint --quiet",
"lint:css": "stylelint './{src,pages}/**/*.{js,ts,tsx,jsx,css}' --quiet",
"lint": "yarn lint:css && next lint",
"precommit": "lint-staged",
"start": "next start",
"prebuild": "node -r @swc-node/register scripts/prebuild.ts",
"prebuild": "node -r @swc-node/register scripts/prebuild.ts && react-dsfr update-icons",
"build": "yarn prebuild && next build",
"build:analyze": "yarn prebuild && ANALYZE=true next build",
"pretest:api": "NEXT_PUBLIC_ES_INDEX_PREFIX=cdtn_test NEXT_PUBLIC_APP_ENV=test NODE_ENV=test node -r @swc-node/register scripts/generate-data.ts",
Expand All @@ -30,6 +31,7 @@
"type-check:watch": "npm run type-check -- --watch"
},
"dependencies": {
"@codegouvfr/react-dsfr": "^1.11.4",
"@elastic/elasticsearch": "^8.13.1",
"@matejmazur/react-katex": "^3.1.3",
"@opentelemetry/instrumentation-generic-pool": "^0.37.0",
Expand Down Expand Up @@ -101,6 +103,7 @@
"mockdate": "^3.0.5",
"nextjs-http-supertest": "^1.0.6",
"postcss": "^8.4.19",
"sass": "^1.77.8",
maxgfr marked this conversation as resolved.
Show resolved Hide resolved
"stylelint": "^14.16.0",
"stylelint-config-rational-order": "^0.1.2",
"stylelint-config-standard-scss": "^6.1.0",
Expand Down
9 changes: 2 additions & 7 deletions packages/code-du-travail-frontend/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ import "react-image-lightbox/style.css";
import "../public/static/modeles.css";

import * as Sentry from "@sentry/nextjs";
import { GlobalStyles, ThemeProvider } from "@socialgouv/cdtn-ui";
import { AppProps } from "next/app";
import { init, push } from "@socialgouv/matomo-next";
import React, { useEffect } from "react";

import { A11y } from "../src/a11y";
import { getSourceUrlFromPath } from "../src/lib";
import { useRouter } from "next/router";
import { PIWIK_SITE_ID, PIWIK_URL, SITE_URL } from "../src/config";
Expand Down Expand Up @@ -40,6 +38,7 @@ const WIDGETS_PATH = /\/widgets\/.*/;

function MyApp({ Component, pageProps }: AppProps) {
const router = useRouter();

useEffect(() => {
init({
siteId: PIWIK_SITE_ID,
Expand All @@ -60,11 +59,7 @@ function MyApp({ Component, pageProps }: AppProps) {

return (
<React.StrictMode>
<ThemeProvider>
maxgfr marked this conversation as resolved.
Show resolved Hide resolved
<GlobalStyles />
<A11y />
<Component {...pageProps} />
</ThemeProvider>
<Component {...pageProps} />
</React.StrictMode>
);
}
Expand Down
3 changes: 2 additions & 1 deletion packages/code-du-travail-frontend/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ process.on("unhandledRejection", (err) => {
process.on("uncaughtException", (err) => {
Sentry.captureException(err);
});

export default class MyDocument extends Document {
static async getInitialProps(ctx) {
const sheet = new ServerStyleSheet();
Expand Down Expand Up @@ -39,7 +40,7 @@ export default class MyDocument extends Document {

render() {
return (
<Html lang="fr" prefix="og: http://ogp.me/ns#">
<Html>
<Head>
<link
key="rel-stylesheet"
Expand Down
3 changes: 2 additions & 1 deletion packages/code-du-travail-frontend/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ export async function getStaticProps() {
tools: data?.tools.map(({ _id, _source }) => ({ ..._source, _id })) ?? [],
contributions: data?.contributions ?? [],
modeles: data?.modeles ?? [],
agreements: data?.agreements.map((v) => ({ ...v, title: v.shortTitle })) ?? [],
agreements:
data?.agreements.map((v) => ({ ...v, title: v.shortTitle })) ?? [],
},
revalidate: REVALIDATE_TIME,
};
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions packages/code-du-travail-frontend/src/dsfr/config/StartDsfr.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"use client";

import { startReactDsfr } from "@codegouvfr/react-dsfr/next-appdir";
import { defaultColorScheme } from "./defaultColorScheme";
import Link from "next/link";

declare module "@codegouvfr/react-dsfr/next-appdir" {
interface RegisterLink {
Link: typeof Link;
}
}

startReactDsfr({ defaultColorScheme, Link, doCheckNonce: true });

export function StartDsfr() {
//Yes, leave null here.
return null;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { DefaultColorScheme } from "@codegouvfr/react-dsfr/next-appdir";

export const defaultColorScheme: DefaultColorScheme = "system";
85 changes: 85 additions & 0 deletions packages/code-du-travail-frontend/src/dsfr/layout/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
"use client";
maxgfr marked this conversation as resolved.
Show resolved Hide resolved

import { Header as HeaderDsfr } from "@codegouvfr/react-dsfr/Header";
import { headerFooterDisplayItem } from "@codegouvfr/react-dsfr/Display";
import { usePathname, useRouter } from "next/navigation";
import { SearchInput } from "./SearchInput";
import { useState } from "react";

export const Header = () => {
const currentPath = usePathname();
const router = useRouter();

const [search, onSearchChange] = useState("");

const onSearchSubmit = () => {
router.push(`/recherche?q=${encodeURIComponent(search)}`);
};

return (
<HeaderDsfr
serviceTitle="Code du travail numérique"
serviceTagline="Toutes les réponses à vos questions sur le droit du travail"
brandTop={
<>
RÉPUBLIQUE
<br />
FRANÇAISE
</>
}
homeLinkProps={{
href: "/",
title: "Accueil - Code du travail numérique, Ministère du Travail",
}}
navigation={[
{
text: "Boîte à outils",
linkProps: {
href: "/outils",
},
isActive: currentPath === "/outils",
},
{
text: "Modèles de documents",
linkProps: {
href: "/modeles-de-courriers",
},
isActive: currentPath === "/modeles-de-courriers",
},
{
text: "Vos fiches pratiques",
linkProps: {
href: "/contribution",
},
isActive: currentPath === "/contribution",
},
{
text: "Votre convention collective",
linkProps: {
href: "/convention-collective",
},
isActive: currentPath === "/convention-collective",
},
{
text: "Thèmes",
linkProps: {
href: "/themes",
},
isActive: currentPath === "/themes",
},
]}
quickAccessItems={[headerFooterDisplayItem]}
renderSearchInput={({ className, id, placeholder, type }) => (
<SearchInput
className={className}
id={id}
placeholder={placeholder}
type={type}
search={search}
onSearchChange={onSearchChange}
onSearchSubmit={onSearchSubmit}
/>
)}
/>
);
};
Loading
Loading