Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
garronej committed Jun 4, 2023
1 parent ab37e14 commit 8a46988
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 37 deletions.
2 changes: 0 additions & 2 deletions src/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ export namespace HeaderProps {
}
}



/** @see <https://react-dsfr-components.etalab.studio/?path=/docs/components-header> */
export const Header = memo(
forwardRef<HTMLDivElement, HeaderProps>((props, ref) => {
Expand Down
2 changes: 1 addition & 1 deletion src/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type RegisteredLinkProps = RegisterLink extends {

let Link: (
props: RegisteredLinkProps & { children: ReactNode }
) => ReturnType<React.FC> = props=> <a {...props} />;
) => ReturnType<React.FC> = props => <a {...props} />;

export function setLink(params: { Link: typeof Link }): void {
Link = props => {
Expand Down
2 changes: 1 addition & 1 deletion src/next-appdir/DsfrHead.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function DsfrHead(props: DsfrHeadProps) {
if (Link !== undefined) {
setLink({ Link });
}
},[Link]);
}, [Link]);

return (
<>
Expand Down
7 changes: 2 additions & 5 deletions src/next-appdir/DsfrProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,16 @@ export function DsfrProvider(props: DsfrProviderProps) {
dsfrEffect();
}, []);

useMemo(()=> {
useMemo(() => {
if (lang === undefined) {
return;
}

setUseLang({ "useLang": () => lang });

}, [lang]);

if (isBrowser) {
return (
<GdprStoreProvider>{children}</GdprStoreProvider>
);
return <GdprStoreProvider>{children}</GdprStoreProvider>;
}

const defaultColorScheme = getDefaultColorSchemeClientSide();
Expand Down
13 changes: 7 additions & 6 deletions src/next-appdir/getHtmlAttributes.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { data_fr_scheme, data_fr_theme } from "../useIsDark/constants";
import type { ColorScheme } from "../useIsDark";
import { type DefaultColorScheme, setDefaultColorSchemeServerSide } from "./zz_internal/defaultColorScheme";
import {
type DefaultColorScheme,
setDefaultColorSchemeServerSide
} from "./zz_internal/defaultColorScheme";
import { setUseLang } from "../i18n";

const suppressHydrationWarning = true;

export function getHtmlAttributes(params: {
defaultColorScheme: DefaultColorScheme;
lang?: string;
}): { suppressHydrationWarning: true; lang?: string; } & (
}): { suppressHydrationWarning: true; lang?: string } & (
| Record<typeof data_fr_scheme | typeof data_fr_theme, ColorScheme>
| {}
) {

const { defaultColorScheme, lang } = params;

setDefaultColorSchemeServerSide({ defaultColorScheme });
Expand All @@ -22,9 +24,9 @@ export function getHtmlAttributes(params: {
}

if (defaultColorScheme === "system") {
return {
return {
lang,
suppressHydrationWarning
suppressHydrationWarning
};
}

Expand All @@ -35,4 +37,3 @@ export function getHtmlAttributes(params: {
[data_fr_theme]: defaultColorScheme
};
}

17 changes: 6 additions & 11 deletions src/next-appdir/zz_internal/defaultColorScheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ export function getDefaultColorSchemeServerSide(): DefaultColorScheme {
return defaultColorSchemeServerSide;
}

export function setDefaultColorSchemeServerSide(
params: { defaultColorScheme: DefaultColorScheme }
): void {

export function setDefaultColorSchemeServerSide(params: {
defaultColorScheme: DefaultColorScheme;
}): void {
const { defaultColorScheme } = params;

defaultColorSchemeServerSide = defaultColorScheme;
Expand All @@ -27,14 +26,10 @@ export function getDefaultColorSchemeClientSide(): DefaultColorScheme {
return defaultColorSchemeClientSide;
}

export function setDefaultColorSchemeClientSide(
params: { defaultColorScheme: DefaultColorScheme }
): void {

export function setDefaultColorSchemeClientSide(params: {
defaultColorScheme: DefaultColorScheme;
}): void {
const { defaultColorScheme } = params;

defaultColorSchemeClientSide = defaultColorScheme;
}



15 changes: 7 additions & 8 deletions src/zz_internal/brandTopAndHomeLinkProps.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@

import type { ReactNode } from "react";
import type { RegisteredLinkProps } from "../link";


let wrap: {
brandTop: ReactNode;
homeLinkProps: RegisteredLinkProps & { title: string };
} | undefined = undefined;
let wrap:
| {
brandTop: ReactNode;
homeLinkProps: RegisteredLinkProps & { title: string };
}
| undefined = undefined;

export function setBrandTopAndHomeLinkProps(params: {
brandTop: ReactNode;
homeLinkProps: RegisteredLinkProps & { title: string }
homeLinkProps: RegisteredLinkProps & { title: string };
}) {
wrap = params;
}

export function getBrandTopAndHomeLinkProps() {

if (wrap === undefined) {
throw new Error("The footer should be used in conjunction with the header.");
}
Expand Down
8 changes: 5 additions & 3 deletions stories/Footer.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import placeholder_16x9ImgUrl from "./assets/placeholder.16x9.png";
import { setBrandTopAndHomeLinkProps } from "../dist/zz_internal/brandTopAndHomeLinkProps";

setBrandTopAndHomeLinkProps({
"brandTop": <>
"brandTop": (
<>
INTITULE
<br />
OFFICIEL
</>,
</>
),
"homeLinkProps": {
"href": "/",
"title": "Accueil - Nom de l’entité (ministère, secrétariat d‘état, gouvernement)"
Expand Down Expand Up @@ -93,7 +95,7 @@ export const Default = getStory({
},
"cookiesManagementLinkProps": {
"href": "#"
},
}
});

export const FooterWithVerticalOperatorLogo = getStory({
Expand Down

0 comments on commit 8a46988

Please sign in to comment.