|
1 | 1 | import { Meta } from "@storybook/addon-docs"; |
2 | 2 | import { Alert } from "../dist/Alert"; |
| 3 | +import { Tabs } from "../dist/Tabs"; |
3 | 4 | import ReactMarkdown from "react-markdown"; |
4 | 5 |
|
5 | 6 |
|
@@ -36,3 +37,79 @@ _Setup `@codegouvfr/react-dsfr` in your project_ |
36 | 37 | yarn add @codegouvfr/react-dsfr # Or: 'npm install --save @codegouvfr/react-dsfr' |
37 | 38 | ``` |
38 | 39 |
|
| 40 | +export const craContent = |
| 41 | +`# The content |
| 42 | + |
| 43 | +\`\`\`diff |
| 44 | + "scripts": { |
| 45 | ++ "postinstall": "copy-dsfr-to-public" |
| 46 | ++ "prestart": "only-include-used-icons", |
| 47 | ++ "prebuild": "only-include-used-icons" |
| 48 | + } |
| 49 | +\`\`\` |
| 50 | +\`\`\`tsx |
| 51 | +const node =(<div>ok</div>); |
| 52 | +\`\`\` |
| 53 | + |
| 54 | +`; |
| 55 | + |
| 56 | + |
| 57 | +<Tabs |
| 58 | + tabs={[ |
| 59 | + { "label": "Create React App", "content": <ReactMarkdown>{craContent}</ReactMarkdown> }, |
| 60 | + { "label": "Tab 2", "iconId": "fr-icon-ball-pen-fill", "content": <p>Content of tab2</p> }, |
| 61 | + { "label": "Tab 3", "content": <p>Content of tab3</p> } |
| 62 | + ]} |
| 63 | +/> |
| 64 | + |
| 65 | +#### package.json |
| 66 | + |
| 67 | +```diff |
| 68 | + "scripts": { |
| 69 | ++ "postinstall": "copy-dsfr-to-public" |
| 70 | ++ "prestart": "only-include-used-icons", |
| 71 | ++ "prebuild": "only-include-used-icons" |
| 72 | + } |
| 73 | +``` |
| 74 | + |
| 75 | +`update_dsfr_static_resources` is a `bin` script of `@codegouvfr/react-dsfr` that copies `@gouvfr/dsfr/dist` into `public/dsfr` |
| 76 | + |
| 77 | +#### .gitignore |
| 78 | + |
| 79 | +```diff |
| 80 | ++ /public/dsfr |
| 81 | +``` |
| 82 | + |
| 83 | +#### public/index.html |
| 84 | + |
| 85 | +Add the following code in the `<head />`  |
| 86 | + |
| 87 | +```ejs |
| 88 | +<link rel="apple-touch-icon" href="%PUBLIC_URL%/dsfr/favicon/apple-touch-icon.png" /> |
| 89 | +<link rel="icon" href="%PUBLIC_URL%/dsfr/favicon/favicon.svg" type="image/svg+xml" /> |
| 90 | +<link rel="shortcut icon" href="%PUBLIC_URL%/dsfr/favicon/favicon.ico" type="image/x-icon" /> |
| 91 | +<link rel="manifest" href="%PUBLIC_URL%/dsfr/favicon/manifest.webmanifest" crossorigin="use-credentials" /> |
| 92 | +<link rel="stylesheet" href="%PUBLIC_URL%/dsfr/dsfr.min.css" /> |
| 93 | +<link rel="stylesheet" href="%PUBLIC_URL%/dsfr/utility/icons/icons.min.css" /> |
| 94 | +``` |
| 95 | + |
| 96 | +#### src/index.tsx |
| 97 | + |
| 98 | +```diff |
| 99 | + import React from 'react'; |
| 100 | + import ReactDOM from 'react-dom/client'; |
| 101 | + import App from './App'; |
| 102 | ++import { startDsfrReact } from "@codegouvfr/react-dsfr"; |
| 103 | ++startDsfrReact({ "defaultColorScheme": "system" }); |
| 104 | + const root = ReactDOM.createRoot( |
| 105 | + document.getElementById('root') as HTMLElement |
| 106 | + ); |
| 107 | + root.render( |
| 108 | + <React.StrictMode> |
| 109 | + <App /> |
| 110 | + </React.StrictMode> |
| 111 | + ); |
| 112 | +``` |
| 113 | + |
| 114 | +You can find an example setup [here](https://github.com/codegouvfr/dsfr-react/tree/main/src/test/frameworks/cra). |
| 115 | + |
0 commit comments