-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
193 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { Meta } from "@storybook/addon-docs"; | ||
import { Markdown } from "./Markdown"; | ||
//import { Markdown } from "./tools/Markdown"; | ||
import { Alert } from "../dist/Alert"; | ||
|
||
<Meta | ||
title="Guides/🔧 Initial setup 2" | ||
parameters={{ | ||
"viewMode": "docs", | ||
"previewTabs": { | ||
"canvas": { "hidden": true }, | ||
"zoom": { "hidden": true }, | ||
"storybook/background": { "hidden": true }, | ||
"storybook/viewport": { "hidden": true }, | ||
}, | ||
}} | ||
/> | ||
|
||
|
||
export const node = <Markdown>{` | ||
* Remove [@gouvfr/dsfr](https://www.npmjs.com/package/@gouvfr/dsfr) from your dependencies. | ||
* Remove all imports: \`dsfr.css\`, \`dsfr.module.js\` the favicon and the fonts. | ||
* Remove the \`data-fr-scheme\` (and \`data-fr-theme\` ) attribude from your \`<html/>\` tag. | ||
\`\`\`diff {0} | ||
+ new line | ||
- removed line | ||
- removed line | ||
- removed line | ||
- removed line | ||
nothing | ||
+ added | ||
sdf | ||
sdf | ||
sdf | ||
sdf | ||
\`\`\` | ||
\`\`\`tsx {1} | ||
const node = <div>{cool}</div>; | ||
\`\`\` | ||
This is the end of the _markdown_ | ||
`}</Markdown> | ||
|
||
<>{node}</> | ||
|
||
<Alert title="This is the title" description={node} severity="success" /> | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { Meta } from "@storybook/addon-docs"; | ||
import { Alert } from "../dist/Alert"; | ||
import { Tabs } from "../dist/Tabs"; | ||
import ReactMarkdown from "react-markdown"; | ||
|
||
|
||
<Meta | ||
title="Guides/🔧 Initial setup" | ||
parameters={{ | ||
"viewMode": "docs", | ||
"previewTabs": { | ||
"canvas": { "hidden": true }, | ||
"zoom": { "hidden": true }, | ||
"storybook/background": { "hidden": true }, | ||
"storybook/viewport": { "hidden": true }, | ||
}, | ||
}} | ||
/> | ||
|
||
|
||
# 🔧 Initial setup | ||
|
||
_Setup `@codegouvfr/react-dsfr` in your project_ | ||
|
||
<Alert | ||
severity="warning" | ||
title="Warning: If you already had the DSFR installed in your project" | ||
isClosable | ||
description={<ReactMarkdown>{` | ||
* Remove [\`@gouvfr/dsfr\`](https://www.npmjs.com/package/@gouvfr/dsfr) from your dependencies. | ||
* Remove all imports: \`dsfr.css\`, \`dsfr.module.js\` the favicon and the fonts. | ||
* Remove the \`data-fr-scheme\` (and \`data-fr-theme\` ) attribude from your \`<html/>\` tag.` | ||
}</ReactMarkdown>} | ||
/> | ||
|
||
```bash | ||
yarn add @codegouvfr/react-dsfr # Or: 'npm install --save @codegouvfr/react-dsfr' | ||
``` | ||
|
||
export const craContent = <ReactMarkdown>{` | ||
#### package.json | ||
|
||
\`\`\`diff | ||
"scripts": { | ||
+ "postinstall": "copy-dsfr-to-public" | ||
+ "prestart": "only-include-used-icons", | ||
+ "prebuild": "only-include-used-icons" | ||
} | ||
\`\`\` | ||
|
||
\`update_dsfr_static_resources\` is a \`bin\` script of \`@codegouvfr/react-dsfr\` that copies \`@gouvfr/dsfr/dist\` into \`public/dsfr\` | ||
|
||
#### .gitignore | ||
|
||
\`\`\`diff | ||
+ /public/dsfr | ||
\`\`\` | ||
|
||
#### public/index.html | ||
|
||
Add the following code in the \`<head />\` | ||
|
||
\`\`\`ejs | ||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/dsfr/favicon/apple-touch-icon.png" /> | ||
<link rel="icon" href="%PUBLIC_URL%/dsfr/favicon/favicon.svg" type="image/svg+xml" /> | ||
<link rel="shortcut icon" href="%PUBLIC_URL%/dsfr/favicon/favicon.ico" type="image/x-icon" /> | ||
<link rel="manifest" href="%PUBLIC_URL%/dsfr/favicon/manifest.webmanifest" crossorigin="use-credentials" /> | ||
<link rel="stylesheet" href="%PUBLIC_URL%/dsfr/dsfr.min.css" /> | ||
<link rel="stylesheet" href="%PUBLIC_URL%/dsfr/utility/icons/icons.min.css" /> | ||
\`\`\` | ||
|
||
#### src/index.tsx | ||
|
||
\`\`\`diff | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom/client'; | ||
import App from './App'; | ||
+import { startDsfrReact } from "@codegouvfr/react-dsfr"; | ||
+startDsfrReact({ "defaultColorScheme": "system" }); | ||
const root = ReactDOM.createRoot( | ||
document.getElementById('root') as HTMLElement | ||
); | ||
root.render( | ||
<React.StrictMode> | ||
<App /> | ||
</React.StrictMode> | ||
); | ||
\`\`\` | ||
|
||
You can find an example setup [here](https://github.com/codegouvfr/dsfr-react/tree/main/src/test/frameworks/cra). | ||
|
||
`}</ReactMarkdown>; | ||
|
||
<Tabs | ||
tabs={[ | ||
{ "label": "Create React App", "content": craContent }, | ||
{ "label": "Tab 2", "iconId": "fr-icon-ball-pen-fill", "content": <p>Content of tab2</p> }, | ||
{ "label": "Tab 3", "content": <p>Content of tab3</p> } | ||
]} | ||
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters