diff --git a/src/gdpr/createGdprApi.ts b/src/gdpr/createGdprApi.ts index d798f8076..912fc3fe5 100644 --- a/src/gdpr/createGdprApi.ts +++ b/src/gdpr/createGdprApi.ts @@ -9,6 +9,8 @@ import { useRerenderOnChange } from "../tools/StatefulObservable/hooks"; import { createConsentBannerAndConsentManagement } from "./ConsentBannerAndConsentManagement"; import { isBrowser } from "../tools/isBrowser"; +export const localStorageKey = "@codegouvfr/react-dsfr gdpr finalityConsent"; + export function createGdprApi< FinalityDescription extends Record< string, @@ -26,8 +28,6 @@ export function createGdprApi< const { finalityDescription, personalDataPolicyLinkProps, consentCallback } = params; - const localStorageKey = "@codegouvfr/react-dsfr gdpr finalityConsent"; - const $finalityConsent = createStatefulObservable | undefined>(() => { if (!isBrowser) { return undefined; diff --git a/stories/ConsentBanner.stories.tsx b/stories/ConsentBanner.stories.tsx index f608bf893..5fd79c5ac 100644 --- a/stories/ConsentBanner.stories.tsx +++ b/stories/ConsentBanner.stories.tsx @@ -1,121 +1,131 @@ -import * as React from "react"; -import { ConsentBanner, ConsentBannerProps, consentModalButtonProps } from "../dist/ConsentBanner"; +import React from "react"; import { sectionName } from "./sectionName"; import { getStoryFactory } from "./getStory"; -import { symToStr } from "tsafe/symToStr"; -import { ConsentBannerContent } from "../dist/ConsentBanner/ConsentBannerContent"; +import { createGdprApi } from "../dist/gdpr"; +import { localStorageKey } from "../dist/gdpr/createGdprApi"; +import { Footer } from "../dist/Footer"; +import { Button } from "../dist/Button"; +import { fr } from "../dist/fr"; const { meta, getStory } = getStoryFactory({ sectionName, "wrappedComponent": { - [symToStr({ ConsentBanner })]: Story + "ConsentBanner": Story }, "description": ` - - WARNING: This is [a temporary implementation](https://github.com/codegouvfr/react-dsfr/pull/107#issuecomment-1517538228). - -Manage cookies and consent with a banner and a dedicated modal. - - [See DSFR documentation](https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/gestionnaire-de-consentement), -- [See source code](https://github.com/codegouvfr/react-dsfr/blob/main/src/ConsentBanner/index.tsx) - -Optionally, you can also use \`import { useGdprStore } from "@codegouvfr/react-dsfr/gdpr"\` to manually monitor and controls -the consent state. - -## Usage example - -\`\`\`tsx -import { Footer } from "@codegouvfr/react-dsfr/Footer"; -import { ConsentBanner, consentModalButtonProps } from "@codegouvfr/react-dsfr/ConsentBanner"; - -// You can augment the service registry to have autocomplete when using useGdprStore -declare module "@codegouvfr/react-dsfr/gdpr" { - interface RegisterGdprServices { - // the value can be anything (or never), but you can set true - // as a reminder that this service is mandatory - mandatory-cookie-consumer: true; - cookie-consumer: never; - } -} - -function App(){ +- [See source code](https://github.com/codegouvfr/react-dsfr/blob/main/src/gdpr) - return ( - <> - {/* must be on root level */} - - {/* ... Header ...*/} - {/* ... your app ...*/} -