Skip to content

Commit d6707cb

Browse files
authored
Add folder Chart in path when the component is a chart (#379)
1 parent 9597534 commit d6707cb

9 files changed

+22
-10
lines changed

stories/charts/BarChart.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ You can find an example [here](https://github.com/codegouvfr/react-dsfr/blob/bc2
3737
"vlinecolor": { "description": "Color of the horizontal lines", control: "object" },
3838
"hlinecolor": { "description": "Color of the vertical lines", control: "object" }
3939
},
40-
"disabledProps": ["lang"]
40+
"disabledProps": ["lang"],
41+
isChartComponent: true
4142
});
4243

4344
export default meta;

stories/charts/BarLineChart.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ You can find an example [here](https://github.com/codegouvfr/react-dsfr/blob/bc2
3434
"vlinecolor": { "description": "Color of the horizontal lines", control: "object" },
3535
"hlinecolor": { "description": "Color of the vertical lines", control: "object" }
3636
},
37-
"disabledProps": ["lang"]
37+
"disabledProps": ["lang"],
38+
isChartComponent: true
3839
});
3940

4041
export default meta;

stories/charts/GaugeChart.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ You can find an example [here](https://github.com/codegouvfr/react-dsfr/blob/bc2
2929
"description": "Color"
3030
}
3131
},
32-
"disabledProps": ["lang"]
32+
"disabledProps": ["lang"],
33+
isChartComponent: true
3334
});
3435

3536
export default meta;

stories/charts/LineChart.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ You can find an example [here](https://github.com/codegouvfr/react-dsfr/blob/bc2
3131
"vlinecolor": { "description": "Color of the horizontal lines", control: "object" },
3232
"hlinecolor": { "description": "Color of the vertical lines", control: "object" }
3333
},
34-
"disabledProps": ["lang"]
34+
"disabledProps": ["lang"],
35+
isChartComponent: true
3536
});
3637

3738
export default meta;

stories/charts/MultiLineChart.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ You can find an example [here](https://github.com/codegouvfr/react-dsfr/blob/bc2
3131
"vlinecolor": { "description": "Color of the horizontal lines", control: "object" },
3232
"hlinecolor": { "description": "Color of the vertical lines", control: "object" }
3333
},
34-
"disabledProps": ["lang"]
34+
"disabledProps": ["lang"],
35+
isChartComponent: true
3536
});
3637

3738
export default meta;

stories/charts/PieChart.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ You can find an example [here](https://github.com/codegouvfr/react-dsfr/blob/bc2
2626
"color": { "description": "Array of color", control: "object" },
2727
"fill": { control: "boolean" }
2828
},
29-
"disabledProps": ["lang"]
29+
"disabledProps": ["lang"],
30+
isChartComponent: true
3031
});
3132

3233
export default meta;

stories/charts/RadarChart.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ You can find an example [here](https://github.com/codegouvfr/react-dsfr/blob/bc2
2525
"name": { "description": "Array of name", control: "object" },
2626
"color": { "description": "Array of color", control: "object" }
2727
},
28-
"disabledProps": ["lang"]
28+
"disabledProps": ["lang"],
29+
isChartComponent: true
2930
});
3031

3132
export default meta;

stories/charts/ScatterChart.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ You can find an example [here](https://github.com/codegouvfr/react-dsfr/blob/bc2
3131
"vlinecolor": { "description": "Color of the horizontal lines", control: "object" },
3232
"hlinecolor": { "description": "Color of the vertical lines", control: "object" }
3333
},
34-
"disabledProps": ["lang"]
34+
"disabledProps": ["lang"],
35+
isChartComponent: true
3536
});
3637

3738
export default meta;

stories/getStory.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export function getStoryFactory<Props extends Record<string, any>>(params: {
2929
disabledProps?: ("containerWidth" | "lang" | "darkMode")[];
3030
/** Default false */
3131
doHideImportInstruction?: boolean;
32+
isChartComponent?: boolean;
3233
}) {
3334
const {
3435
sectionName,
@@ -37,7 +38,8 @@ export function getStoryFactory<Props extends Record<string, any>>(params: {
3738
argTypes = {},
3839
defaultContainerWidth,
3940
disabledProps = [],
40-
doHideImportInstruction = false
41+
doHideImportInstruction = false,
42+
isChartComponent = false
4143
} = params;
4244

4345
const Component: any = Object.entries(wrappedComponent).map(([, component]) => component)[0];
@@ -138,6 +140,8 @@ export function getStoryFactory<Props extends Record<string, any>>(params: {
138140

139141
const componentName = symToStr(wrappedComponent);
140142

143+
const pathComponent = isChartComponent ? `Chart/${componentName}` : componentName;
144+
141145
return {
142146
"meta": id<Meta>({
143147
"title": `${sectionName}/${componentName}`,
@@ -151,7 +155,7 @@ export function getStoryFactory<Props extends Record<string, any>>(params: {
151155
: [
152156
`\`\`\`tsx `,
153157
` `,
154-
`import { ${componentName} } from "@codegouvfr/react-dsfr/${componentName}";`,
158+
`import { ${componentName} } from "@codegouvfr/react-dsfr/${pathComponent}";`,
155159
` `,
156160
`\`\`\``
157161
]),

0 commit comments

Comments
 (0)