Skip to content

Commit

Permalink
Move on with the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
garronej committed Nov 21, 2022
1 parent 0cc8276 commit 2aa04d0
Show file tree
Hide file tree
Showing 4 changed files with 193 additions and 52 deletions.
2 changes: 2 additions & 0 deletions docs/Markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import typescript from "react-syntax-highlighter/dist/cjs/languages/prism/typesc
import bash from "react-syntax-highlighter/dist/cjs/languages/prism/bash";
import json from "react-syntax-highlighter/dist/cjs/languages/prism/json";
import diff from "react-syntax-highlighter/dist/cjs/languages/prism/diff";
import ejs from "react-syntax-highlighter/dist/cjs/languages/prism/ejs";
import rangeParser from "parse-numeric-range";
import oneDark from "react-syntax-highlighter/dist/esm/styles/prism/one-dark";
import oneLight from "react-syntax-highlighter/dist/esm/styles/prism/one-light";
Expand All @@ -24,6 +25,7 @@ SyntaxHighlighter.registerLanguage("typescript", typescript);
SyntaxHighlighter.registerLanguage("bash", bash);
SyntaxHighlighter.registerLanguage("json", json);
SyntaxHighlighter.registerLanguage("diff", diff);
SyntaxHighlighter.registerLanguage("ejs", ejs);

//SEE: https://amirardalan.com/blog/syntax-highlight-code-in-markdown

Expand Down
53 changes: 53 additions & 0 deletions docs/quick-start-2.stories.mdx
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" />





100 changes: 100 additions & 0 deletions docs/quick-start.stories copy.mdx.2.disabled
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> }
]}
/>
90 changes: 38 additions & 52 deletions docs/quick-start.stories.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meta } from "@storybook/addon-docs";
import { Alert } from "../dist/Alert";
import { Tabs } from "../dist/Tabs";
import ReactMarkdown from "react-markdown";
import { Markdown } from "./Markdown";


<Meta
Expand All @@ -19,83 +19,59 @@ import ReactMarkdown from "react-markdown";


# 🔧 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.
description={<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.`
}</ReactMarkdown>}
}</Markdown>}
/>

```bash
yarn add @codegouvfr/react-dsfr # Or: 'npm install --save @codegouvfr/react-dsfr'
```

export const craContent =
`# The content
export const craContent = <Markdown>{`
#### package.json
\`\`\`diff
\`\`\`diff {0}
"scripts": {
+ "postinstall": "copy-dsfr-to-public"
+ "prestart": "only-include-used-icons",
+ "prebuild": "only-include-used-icons"
+ "postinstall": "copy-dsfr-to-public"
+ "prestart": "only-include-used-icons",
+ "prebuild": "only-include-used-icons"
}
\`\`\`
\`\`\`tsx
const node =(<div>ok</div>);
\`\`\`
`;


<Tabs
tabs={[
{ "label": "Create React App", "content": <ReactMarkdown>{craContent}</ReactMarkdown> },
{ "label": "Tab 2", "iconId": "fr-icon-ball-pen-fill", "content": <p>Content of tab2</p> },
{ "label": "Tab 3", "content": <p>Content of tab3</p> }
]}
/>

#### 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`

\`copy-dsfr-to-public\` is a \`bin\` script of \`@codegouvfr/react-dsfr\` that copies \`@gouvfr/dsfr/dist\` into \`public/dsfr\`
#### .gitignore

```diff
\`\`\`diff {0}
+ /public/dsfr
```

\`\`\`
#### public/index.html

Add the following code in the `<head />`&#x20;

```ejs
Add the following code in the \`<head />\`
\`\`\`ejs {0}
<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
\`\`\`diff {0}
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
Expand All @@ -109,7 +85,17 @@ Add the following code in the `<head />`&#x20;
<App />
</React.StrictMode>
);
```

\`\`\`
You can find an example setup [here](https://github.com/codegouvfr/dsfr-react/tree/main/src/test/frameworks/cra).
`}</Markdown>;


<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> }
]}
/>

0 comments on commit 2aa04d0

Please sign in to comment.