Skip to content

Commit 0c93902

Browse files
committed
#300: Make dsfr-chart an optional dev depencency
1 parent bc2c2be commit 0c93902

12 files changed

+82
-9
lines changed

package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,19 @@
6363
],
6464
"homepage": "https://github.com/codegouvfr/react-dsfr",
6565
"dependencies": {
66-
"@gouvfr/dsfr-chart": "^1.0.0",
6766
"tsafe": "^1.7.2",
6867
"yargs-parser": "^21.1.1"
6968
},
69+
"peerDependencies": {
70+
"@gouvfr/dsfr-chart": "^1.0.0"
71+
},
72+
"peerDependenciesMeta": {
73+
"@gouvfr/dsfr-chart": {
74+
"optional": true
75+
}
76+
},
7077
"devDependencies": {
78+
"@gouvfr/dsfr-chart": "^1.0.0",
7179
"@babel/core": "^7.20.2",
7280
"@emotion/react": "^11.10.4",
7381
"@emotion/styled": "^11.10.4",

src/Chart/BarChart.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,5 @@ export const BarChart = chartWrapper((props: BarChartBaseProps) => {
4141
BarChart.displayName = symToStr({ BarChart });
4242

4343
export default BarChart;
44+
45+
// Just so that the icon is included: "fr-icon-arrow-go-back-fill"

src/bin/only-include-used-icons.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,12 @@ async function getCommandContext(args: string[]): Promise<CommandContext> {
336336
return false;
337337
}
338338

339+
console.log(relativeDirPath);
340+
341+
if (parsedPackageJson["name"] === "@gouvfr/dsfr-chart") {
342+
return false;
343+
}
344+
339345
for (const packageName of [
340346
CODEGOUV_REACT_DSFR,
341347
"@gouvfr/dsfr",

stories/charts/BarChart.stories.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ const { meta, getStory } = getStoryFactory<BarChartProps>({
77
"wrappedComponent": { BarChart },
88
"description": `
99
- [See DSFR documentation](https://www.systeme-de-design.gouv.fr/composants-et-modeles/composants-beta/graphiques-charts/)
10-
- [See source code](https://github.com/codegouvfr/react-dsfr/blob/main/src/Chart/BarChart.tsx)`,
10+
- [See source code](https://github.com/codegouvfr/react-dsfr/blob/main/src/Chart/BarChart.tsx)
11+
12+
To use this component you need to add \`@gouvfr/dsfr-chart\` to your dependencies.
13+
14+
Note for Next users: Chart components are not SSR compatible. You need to import them dynamically with [\`next/dynamic\`](https://nextjs.org/docs/pages/building-your-application/optimizing/lazy-loading#nextdynamic).
15+
You can find an example [here](https://github.com/codegouvfr/react-dsfr/blob/bc2c2be290b09684711c53176b7a379cebed08a8/test/integration/next-appdir/app/dsfr-chart/page.tsx#L8-L9).
16+
17+
`,
1118
"argTypes": {
1219
"x": {
1320
"description": "Array of value for the x axis"

stories/charts/BarLineChart.stories.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ const { meta, getStory } = getStoryFactory<BarLineChartProps>({
77
"wrappedComponent": { BarLineChart },
88
"description": `
99
- [See DSFR documentation](https://www.systeme-de-design.gouv.fr/composants-et-modeles/composants-beta/graphiques-charts/)
10-
- [See source code](https://github.com/codegouvfr/react-dsfr/blob/main/src/Chart/BarChart.tsx)`,
10+
- [See source code](https://github.com/codegouvfr/react-dsfr/blob/main/src/Chart/BarChart.tsx)
11+
12+
To use this component you need to add \`@gouvfr/dsfr-chart\` to your dependencies.
13+
14+
Note for Next users: Chart components are not SSR compatible. You need to import them dynamically with [\`next/dynamic\`](https://nextjs.org/docs/pages/building-your-application/optimizing/lazy-loading#nextdynamic).
15+
You can find an example [here](https://github.com/codegouvfr/react-dsfr/blob/bc2c2be290b09684711c53176b7a379cebed08a8/test/integration/next-appdir/app/dsfr-chart/page.tsx#L8-L9).
16+
17+
`,
1118
"argTypes": {
1219
"x": {
1320
"description": "Array of value for the x axis"

stories/charts/GaugeChart.stories.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ const { meta, getStory } = getStoryFactory<GaugeChartProps>({
77
"wrappedComponent": { GaugeChart },
88
"description": `
99
- [See DSFR documentation](https://www.systeme-de-design.gouv.fr/composants-et-modeles/composants-beta/graphiques-charts/)
10-
- [See source code](https://github.com/codegouvfr/react-dsfr/blob/main/src/Chart/BarChart.tsx)`,
10+
- [See source code](https://github.com/codegouvfr/react-dsfr/blob/main/src/Chart/BarChart.tsx)
11+
12+
To use this component you need to add \`@gouvfr/dsfr-chart\` to your dependencies.
13+
14+
Note for Next users: Chart components are not SSR compatible. You need to import them dynamically with [\`next/dynamic\`](https://nextjs.org/docs/pages/building-your-application/optimizing/lazy-loading#nextdynamic).
15+
You can find an example [here](https://github.com/codegouvfr/react-dsfr/blob/bc2c2be290b09684711c53176b7a379cebed08a8/test/integration/next-appdir/app/dsfr-chart/page.tsx#L8-L9).
16+
17+
`,
1118
"argTypes": {
1219
"value": {
1320
"description": "Current value"

stories/charts/LineChart.stories.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ const { meta, getStory } = getStoryFactory<LineChartProps>({
77
"wrappedComponent": { LineChart },
88
"description": `
99
- [See DSFR documentation](https://www.systeme-de-design.gouv.fr/composants-et-modeles/composants-beta/graphiques-charts/)
10-
- [See source code](https://github.com/codegouvfr/react-dsfr/blob/main/src/Chart/BarChart.tsx)`,
10+
- [See source code](https://github.com/codegouvfr/react-dsfr/blob/main/src/Chart/BarChart.tsx)
11+
12+
To use this component you need to add \`@gouvfr/dsfr-chart\` to your dependencies.
13+
14+
Note for Next users: Chart components are not SSR compatible. You need to import them dynamically with [\`next/dynamic\`](https://nextjs.org/docs/pages/building-your-application/optimizing/lazy-loading#nextdynamic).
15+
You can find an example [here](https://github.com/codegouvfr/react-dsfr/blob/bc2c2be290b09684711c53176b7a379cebed08a8/test/integration/next-appdir/app/dsfr-chart/page.tsx#L8-L9).
16+
17+
`,
1118
"argTypes": {
1219
"x": {
1320
"description": "Array of value for the x axis"

stories/charts/MultiLineChart.stories.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ const { meta, getStory } = getStoryFactory<MultiLineChartProps>({
77
"wrappedComponent": { MultiLineChart },
88
"description": `
99
- [See DSFR documentation](https://www.systeme-de-design.gouv.fr/composants-et-modeles/composants-beta/graphiques-charts/)
10-
- [See source code](https://github.com/codegouvfr/react-dsfr/blob/main/src/Chart/BarChart.tsx)`,
10+
- [See source code](https://github.com/codegouvfr/react-dsfr/blob/main/src/Chart/BarChart.tsx)
11+
12+
To use this component you need to add \`@gouvfr/dsfr-chart\` to your dependencies.
13+
14+
Note for Next users: Chart components are not SSR compatible. You need to import them dynamically with [\`next/dynamic\`](https://nextjs.org/docs/pages/building-your-application/optimizing/lazy-loading#nextdynamic).
15+
You can find an example [here](https://github.com/codegouvfr/react-dsfr/blob/bc2c2be290b09684711c53176b7a379cebed08a8/test/integration/next-appdir/app/dsfr-chart/page.tsx#L8-L9).
16+
17+
`,
1118
"argTypes": {
1219
"x": {
1320
"description": "Array of value for the x axis"

stories/charts/PieChart.stories.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ const { meta, getStory } = getStoryFactory<PieChartProps>({
77
"wrappedComponent": { PieChart },
88
"description": `
99
- [See DSFR documentation](https://www.systeme-de-design.gouv.fr/composants-et-modeles/composants-beta/graphiques-charts/)
10-
- [See source code](https://github.com/codegouvfr/react-dsfr/blob/main/src/Chart/BarChart.tsx)`,
10+
- [See source code](https://github.com/codegouvfr/react-dsfr/blob/main/src/Chart/BarChart.tsx)
11+
12+
To use this component you need to add \`@gouvfr/dsfr-chart\` to your dependencies.
13+
14+
Note for Next users: Chart components are not SSR compatible. You need to import them dynamically with [\`next/dynamic\`](https://nextjs.org/docs/pages/building-your-application/optimizing/lazy-loading#nextdynamic).
15+
You can find an example [here](https://github.com/codegouvfr/react-dsfr/blob/bc2c2be290b09684711c53176b7a379cebed08a8/test/integration/next-appdir/app/dsfr-chart/page.tsx#L8-L9).
16+
17+
`,
1118
"argTypes": {
1219
"x": {
1320
"description": "Array of value for the x axis"

stories/charts/RadarChart.stories.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ const { meta, getStory } = getStoryFactory<RadarChartProps>({
77
"wrappedComponent": { RadarChart },
88
"description": `
99
- [See DSFR documentation](https://www.systeme-de-design.gouv.fr/composants-et-modeles/composants-beta/graphiques-charts/)
10-
- [See source code](https://github.com/codegouvfr/react-dsfr/blob/main/src/Chart/BarChart.tsx)`,
10+
- [See source code](https://github.com/codegouvfr/react-dsfr/blob/main/src/Chart/BarChart.tsx)
11+
12+
To use this component you need to add \`@gouvfr/dsfr-chart\` to your dependencies.
13+
14+
Note for Next users: Chart components are not SSR compatible. You need to import them dynamically with [\`next/dynamic\`](https://nextjs.org/docs/pages/building-your-application/optimizing/lazy-loading#nextdynamic).
15+
You can find an example [here](https://github.com/codegouvfr/react-dsfr/blob/bc2c2be290b09684711c53176b7a379cebed08a8/test/integration/next-appdir/app/dsfr-chart/page.tsx#L8-L9).
16+
17+
`,
1118
"argTypes": {
1219
"x": {
1320
"description": "Array of value for the x axis"

0 commit comments

Comments
 (0)