Skip to content

Commit 239551d

Browse files
committed
Test integration with react-router
1 parent 5bbea88 commit 239551d

File tree

7 files changed

+591
-42
lines changed

7 files changed

+591
-42
lines changed

src/lib/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export type { SpacingToken } from "./spacing";
88
import { cx } from "./cx";
99
export type { FrCxArg } from "./cx";
1010
export { DsfrLangProvider } from "./i18n";
11-
export { createLinkProvider } from "./routing";
11+
export { createDsfrLinkProvider } from "./routing";
1212
export type { LinkProps, HTMLAnchorProps } from "./routing";
1313

1414
export const fr = {

src/lib/routing.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@ export type HTMLAnchorProps = DetailedHTMLProps<
1717
const context = createContext<CreateLinkProviderPrams["Link"]>(props => <a {...props} />);
1818

1919
type CreateLinkProviderPrams = {
20-
Link: (props: LinkProps) => JSX.Element;
20+
Link: (props: LinkProps) => ReturnType<React.FC>;
2121
};
2222

23-
export function createLinkProvider(params: CreateLinkProviderPrams) {
23+
export function createDsfrLinkProvider(params: CreateLinkProviderPrams) {
2424
const { Link } = params;
2525

2626
type Props = {
2727
children: ReactNode;
2828
};
2929

30-
function LinkProvider(props: Props) {
30+
function DsfrLinkProvider(props: Props) {
3131
const { children } = props;
3232

3333
return <context.Provider value={Link}>{children}</context.Provider>;
3434
}
3535

36-
return { LinkProvider };
36+
return { DsfrLinkProvider };
3737
}
3838

3939
export function useLink() {

test/integration/vite/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
},
1515
"dependencies": {
1616
"react": "18.2.0",
17-
"react-dom": "18.2.0",
17+
"react-dom": "18.2.0",
18+
"react-router-dom": "^6.4.3",
19+
"@mui/x-date-pickers": "^5.0.9",
20+
"@mui/icons-material": "^5.10.16",
21+
"dayjs": "^1.11.6",
1822
"@codegouvfr/react-dsfr": "file:../../../dist"
1923
},
2024
"devDependencies": {
@@ -24,4 +28,4 @@
2428
"typescript": "^4.6.4",
2529
"vite": "^3.1.0"
2630
}
27-
}
31+
}

test/integration/vite/src/App.tsx renamed to test/integration/vite/src/Home.tsx

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,12 @@
1-
import { Header } from "@codegouvfr/react-dsfr/Header";
21
import { Alert } from "@codegouvfr/react-dsfr/Alert";
32
import { useIsDark, fr } from "@codegouvfr/react-dsfr";
43
import { DarkModeSwitch } from "@codegouvfr/react-dsfr/DarkModeSwitch";
54

6-
export function App() {
5+
export function Home() {
76
const { isDark, setIsDark } = useIsDark();
87

98
return (
109
<>
11-
<Header
12-
intituléOfficiel="Intitulé officiel"
13-
baselinePrécisionsSurLorganisation="baseline - Précision sur l'organisation"
14-
nomDuSiteSlashService="Nom du site / service"
15-
links={[
16-
{
17-
"text": "Créer un espace",
18-
"iconId": "fr-icon-add-circle-line",
19-
"href": "#"
20-
},
21-
{
22-
"text": "Se connecter",
23-
"iconId": "fr-icon-lock-line",
24-
"href": "#"
25-
},
26-
{
27-
"text": "S'enregistrer",
28-
"iconId": "fr-icon-account-line",
29-
"href": "#"
30-
}
31-
]}
32-
/>
3310

3411
<Alert
3512
isClosable={true}

0 commit comments

Comments
 (0)