Skip to content

Commit

Permalink
GitBook: [codegouvfr#115] No subject
Browse files Browse the repository at this point in the history
  • Loading branch information
garronej authored and gitbook-bot committed Dec 1, 2022
1 parent 910122b commit d39e584
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 59 deletions.
62 changes: 4 additions & 58 deletions integration-with-routing-libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,71 +68,17 @@ Example [here](https://github.com/codegouvfr/react-dsfr/blob/ae8b3319a15064160b9
{% tab title="trype-route" %}
type-route is an exeption amongs routing library in the sence that it dosen't require to use a Link component. As a result you only need to implement module augmentation

{% code title="index.tsx" %}
```tsx
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { startDsfrReact } from "@codegouvfr/react-dsfr";
import { Home } from "./Home";
import { Mui } from "./Mui";
import { useRoute, RouteProvider } from "./router";
import { Header } from "@codegouvfr/react-dsfr/Header";
import { fr } from "@codegouvfr/react-dsfr";
import type { Link as TypeRouteLink } from "type-route";
import { routes } from "./router";

declare module "@codegouvfr/react-dsfr" {
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface LinkProps extends TypeRouteLink { }

}

startDsfrReact({
"defaultColorScheme": "system"
});

createRoot(document.getElementById("root")!).render(
<StrictMode>
<RouteProvider>
<Header
intituléOfficiel="Intitulé officiel"
baselinePrécisionsSurLorganisation="baseline - Précision sur l'organisation"
nomDuSiteSlashService="Nom du site / service"
links={[
{
"text": "Home",
"iconId": "fr-icon-home-4-fill",
"linkProps": routes.home().link
},
{
"text": "Mui playground",
"iconId": "ri-play-circle-fill",
"linkProps": routes.mui().link
}
]}
/>
<div style={{
"margin": "auto",
"maxWidth": 1000,
...fr.spacing("padding", { "topBottom": "10v" })
}}>
<Router />
</div>
</RouteProvider>
</StrictMode>
);

function Router() {

const route = useRoute();

switch (route.name) {
case "mui": return <Mui />;
case "home": return <Home />;
case false: return <h1>404</h1>
}

}
```
{% endcode %}

Example [here](https://github.com/codegouvfr/react-dsfr/blob/e8b78dd5ad069a322fbcc34b34b25d4ac8214e34/test/integration/cra/src/index.tsx#L33).
{% endtab %}

{% tab title="other" %}
Expand Down
2 changes: 1 addition & 1 deletion internationalisation.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Example setup [in Next.js](https://github.com/etalab/etalab-website/blob/b427049
{% hint style="warning" %}
DISLAMER: I'm the author of i18nifty.

While I can confidently recommend it for SPAs I have to warn you that using i18nifty in Next.js will force you to opt out from[ Automatic Static Optimization](https://nextjs.org/docs/messages/opt-out-auto-static-optimization) and bundle all your translations in the JavaScript bundle. SSR, SSO will work fine though.
While I confidently recommend it for SPAs I have to warn you that using i18nifty in Next.js will force you to opt out from[ Automatic Static Optimization](https://nextjs.org/docs/messages/opt-out-auto-static-optimization) and bundle all your translations in the JavaScript bundle. SSR, SSO will work fine though.
{% endhint %}
{% endtab %}

Expand Down

0 comments on commit d39e584

Please sign in to comment.