Skip to content

Commit 0592b30

Browse files
committed
doc
1 parent 528ac63 commit 0592b30

File tree

6 files changed

+26
-24
lines changed

6 files changed

+26
-24
lines changed

src/ConsentBanner/ConsentBannerContent.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
1-
import React, { ElementType, PropsWithChildren } from "react";
1+
import React from "react";
2+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- used in doc
3+
import { FooterProps } from "../Footer";
24
import { fr } from "../fr";
5+
import { getLink } from "../link";
36
import { ConsentBannerActions, ConsentBannerActionsProps } from "./ConsentBannerActions";
47

58
export interface ConsentBannerContentProps extends ConsentBannerActionsProps {
9+
/** Usually the same as {@link FooterProps.personalDataLinkProps} */
610
gdprPageLink: string;
7-
gdprPageLinkAs?: ElementType<PropsWithChildren<{ href: any }>> | string;
11+
/** Current website name */
812
siteName: string;
913
}
1014

1115
export const ConsentBannerContent = ({
1216
gdprPageLink,
13-
gdprPageLinkAs: GdprPageLinkAs = "a",
1417
siteName,
1518
services,
1619
consentModalButtonProps
1720
}: ConsentBannerContentProps) => {
21+
const { Link } = getLink();
1822
return (
1923
<div className={fr.cx("fr-consent-banner")}>
2024
<h2 className={fr.cx("fr-h6")}>À propos des cookies sur {siteName}</h2>
2125
<div className="fr-consent-banner__content">
2226
<p className="fr-text--sm">
2327
Bienvenue ! Nous utilisons des cookies pour améliorer votre expérience et les
2428
services disponibles sur ce site. Pour en savoir plus, visitez la page{" "}
25-
<GdprPageLinkAs href={gdprPageLink}>
26-
Données personnelles et cookies
27-
</GdprPageLinkAs>
28-
. Vous pouvez, à tout moment, avoir le contrôle sur les cookies que vous
29-
souhaitez activer.
29+
<Link href={gdprPageLink}>Données personnelles et cookies</Link>. Vous pouvez, à
30+
tout moment, avoir le contrôle sur les cookies que vous souhaitez activer.
3031
</p>
3132
</div>
3233
<ConsentBannerActions

src/ConsentBanner/ConsentManager.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { useState, useEffect } from "react";
22
import ButtonsGroup from "../ButtonsGroup";
33
import { fr } from "../fr";
44
import { GdprService } from "../gdpr";
5+
import { getLink } from "../link";
56
import { useGdprStore } from "../useGdprStore";
67
import { ConsentBannerContentProps } from "./ConsentBannerContent";
78

@@ -14,9 +15,9 @@ type ConsentManagerProps = Required<Omit<ConsentBannerContentProps, "siteName">>
1415
export const ConsentManager = ({
1516
gdprPageLink,
1617
services,
17-
gdprPageLinkAs: GdprPageLinkAs,
1818
consentModalButtonProps
1919
}: ConsentManagerProps) => {
20+
const { Link } = getLink();
2021
const setConsent = useGdprStore(state => state.setConsent);
2122
const setFirstChoiceMade = useGdprStore(state => state.setFirstChoiceMade);
2223
const consents = useGdprStore(state => state.consents);
@@ -70,9 +71,7 @@ export const ConsentManager = ({
7071
>
7172
Préférences pour tous les services.
7273
<br />
73-
<GdprPageLinkAs href={gdprPageLink}>
74-
Données personnelles et cookies
75-
</GdprPageLinkAs>
74+
<Link href={gdprPageLink}>Données personnelles et cookies</Link>
7675
</legend>
7776
<div className={fr.cx("fr-consent-service__radios")}>
7877
<ButtonsGroup

src/ConsentBanner/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export { consentModalButtonProps };
1919
export type ConsentBannerProps = Omit<ConsentBannerContentProps, "consentModalButtonProps">;
2020

2121
export const ConsentBanner = memo((props: ConsentBannerProps) => {
22-
const { gdprPageLink, gdprPageLinkAs: GdprPageLinkAs = "a", services } = props;
22+
const { gdprPageLink, services } = props;
2323

2424
const firstChoiceMade = useGdprStore(state => state.firstChoiceMade);
2525
const __inited = useGdprStore(state => state.__inited);
@@ -34,7 +34,6 @@ export const ConsentBanner = memo((props: ConsentBannerProps) => {
3434
<ConsentModal title="Panneau de gestion des cookies" size="large">
3535
<ConsentManager
3636
gdprPageLink={gdprPageLink}
37-
gdprPageLinkAs={GdprPageLinkAs}
3837
services={services}
3938
consentModalButtonProps={consentModalButtonProps}
4039
/>

src/gdpr/GdprStore.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export const GdprStoreProvider = ({ children }: PropsWithChildren) => {
3333
const [__inited, setInited] = useState(defaultStore.__inited);
3434

3535
const setConsentImpl: GdprStore["setConsent"] = (serviceName, consent) => {
36-
console.log("In provider setConsent", consents, serviceName, consent);
3736
setConsents({ ...consents, [serviceName]: consent });
3837
};
3938

src/gdpr/types.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
type UnknownMapping = string & {
2-
_?: never & symbol;
3-
};
4-
51
/**
6-
* format: `<serviceName>: <isMandatory>`
2+
* format: `<serviceName>: never`
73
* @example
84
* ```ts
95
* declare module "@codegouvfr/react-dsfr/gdpr" {
106
* interface RegisterGdprServices {
11-
* matomo: true;
12-
* youtube: false;
7+
* matomo: never;
8+
* youtube: never;
139
* }
1410
* }
1511
* ```
@@ -18,12 +14,20 @@ type UnknownMapping = string & {
1814
export interface RegisterGdprServices {}
1915
export type GdprServiceName = keyof RegisterGdprServices extends never
2016
? string
21-
: keyof RegisterGdprServices | UnknownMapping;
17+
:
18+
| keyof RegisterGdprServices
19+
| (string & {
20+
_?: never & symbol;
21+
});
2222
export type Consents = Record<GdprServiceName, boolean | undefined>;
2323

2424
export interface GdprService {
25+
/** Will be displayed in consent modal. */
2526
description: string;
27+
/** If true, consent for this service will always be true and not switchable. */
2628
mandatory?: boolean;
29+
/** Technical name. Not displayed. */
2730
name: GdprServiceName;
31+
/** Displayed name. */
2832
title: string;
2933
}

test/integration/next-appdir/app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default function RootLayout({ children }: { children: JSX.Element; }) {
5454
}}
5555
>
5656
<DsfrProvider defaultColorScheme={defaultColorScheme}>
57-
<ConsentBanner gdprPageLinkAs={Link} gdprPageLink="/mui" siteName='Next Test App' services={[
57+
<ConsentBanner gdprPageLink="/mui" siteName='Next Test App' services={[
5858
{
5959
name: "matomo",
6060
title: "Matomo",

0 commit comments

Comments
 (0)