Skip to content

Commit 3a64ead

Browse files
committed
migrate DocsHeader
1 parent e01e598 commit 3a64ead

File tree

109 files changed

+113
-127
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+113
-127
lines changed

.storybook/components/DocsHeader.tsx

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,7 @@ import { GitHubLogo } from './GitHub-Mark';
2121
import { Import } from './Import';
2222
import { TableOfContent } from './TableOfContent';
2323

24-
const Links = () => {
25-
//todo: context is not available anymore like this
26-
// const docsContext = useContext(DocsContext);
27-
return null;
28-
const docsContext = {};
29-
const isChart = docsContext.componentStories().at(0).id.startsWith('charts-');
30-
31-
// const filePath = docsContext.parameters.fileName.replace(/^\.\//, '');
32-
// const folderPath = filePath.substr(0, filePath.lastIndexOf('/'));
33-
34-
// const githubUrl = `https://github.com/SAP/ui5-webcomponents-react/tree/main/${folderPath}`;
24+
const Links = ({ isChart }: { isChart?: boolean }) => {
3525
const githubUrl = `https://github.com/SAP/ui5-webcomponents-react`;
3626

3727
const packageName = `@ui5/webcomponents-react${isChart ? '-charts' : ''}`;
@@ -60,11 +50,9 @@ interface InfoTableProps {
6050
export const InfoTable = ({ of, since, subComponents, mergeSubComponents }: InfoTableProps) => {
6151
const context = useOf<'meta'>(of);
6252
const { csfFile, preparedMeta } = context;
63-
console.log(context);
6453
const moduleName = csfFile.meta.component.displayName;
6554

6655
const wcSubComponents = useGetSubComponentsOfModule(moduleName.replace('V2', ''), preparedMeta.tags);
67-
console.log(moduleName);
6856
const subComps = mergeSubComponents
6957
? [...(subComponents ?? []), ...(wcSubComponents ?? [])]
7058
: (subComponents ?? wcSubComponents);
@@ -88,7 +76,7 @@ export const InfoTable = ({ of, since, subComponents, mergeSubComponents }: Info
8876
<Label>Usage</Label>
8977
</th>
9078
<td data-import-cell={supportsClipboardApi}>
91-
<Import componentName={moduleName} componentId={preparedMeta.componentId} />
79+
<Import moduleNames={[moduleName]} componentId={preparedMeta.componentId} />
9280
{supportsClipboardApi && (
9381
<Button
9482
design={ButtonDesign.Transparent}
@@ -117,7 +105,7 @@ export const InfoTable = ({ of, since, subComponents, mergeSubComponents }: Info
117105
<Label>Subcomponents</Label>
118106
</th>
119107
<td data-import-cell={supportsClipboardApi}>
120-
<Import moduleNames={subComps} />
108+
<Import moduleNames={subComps} componentId={preparedMeta.componentId} />
121109
{supportsClipboardApi && (
122110
<Button
123111
design={ButtonDesign.Transparent}
@@ -143,7 +131,7 @@ export const DocsHeader = ({ of, since, subComponents, mergeSubComponents, isCha
143131
<Title />
144132
{experimental && <Label className={classes.experimentalLabel}>experimental</Label>}
145133
<span style={{ flexGrow: 1 }} />
146-
<Links />
134+
<Links isChart={isChart} />
147135
</FlexBox>
148136
<Subtitle />
149137
<InfoTable of={of} since={since} subComponents={subComponents} mergeSubComponents={mergeSubComponents} />

.storybook/components/Import.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,14 @@ interface ImportProps {
118118
/**
119119
* Names of module/component (e.g. "Button")
120120
*/
121-
moduleNames?: ImportStatementPropTypes['moduleNames'];
121+
moduleNames: ImportStatementPropTypes['moduleNames'];
122122
componentId: string;
123-
componentName: string;
124123
}
125124

126125
export const Import = (props: ImportProps) => {
127-
const { componentId, componentName } = props;
126+
const { componentId, moduleNames } = props;
128127
const isChart = componentId.startsWith('charts-');
129128
const isCompat = componentId.startsWith('legacy-');
130-
const moduleNames = props.moduleNames ?? [componentName];
131129

132130
return (
133131
<ImportStatement

packages/ai/src/components/Button/Button.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { excludePropsForAbstract } from '@sb/utils';
77

88
<Meta of={ComponentStories} />
99

10-
<DocsHeader experimental />
10+
<DocsHeader of={ComponentStories} experimental />
1111

1212
<br />
1313

packages/ai/src/components/PromptInput/PromptInput.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { excludePropsForAbstract } from '@sb/utils';
77

88
<Meta of={ComponentStories} />
99

10-
<DocsHeader experimental />
10+
<DocsHeader of={ComponentStories} experimental />
1111

1212
<br />
1313

packages/charts/src/components/BarChart/BarChart.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as ComponentStories from './BarChart.stories';
77

88
<Meta of={ComponentStories} />
99

10-
<DocsHeader isChart />
10+
<DocsHeader of={ComponentStories} isChart />
1111

1212
## Example
1313

packages/charts/src/components/BulletChart/BulletChart.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as ComponentStories from './BulletChart.stories';
66

77
<Meta of={ComponentStories} />
88

9-
<DocsHeader isChart />
9+
<DocsHeader of={ComponentStories} isChart />
1010

1111
## Example
1212

packages/charts/src/components/ColumnChart/ColumnChart.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as ComponentStories from './ColumnChart.stories';
77

88
<Meta of={ComponentStories} />
99

10-
<DocsHeader isChart />
10+
<DocsHeader of={ComponentStories} isChart />
1111

1212
## Example
1313

packages/charts/src/components/ColumnChartWithTrend/ColumnChartWithTrend.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import LegendStory from '../../resources/LegendConfig.mdx';
55

66
<Meta of={ComponentStories} />
77

8-
<DocsHeader isChart />
8+
<DocsHeader of={ComponentStories} isChart />
99

1010
## Example
1111

packages/charts/src/components/ComposedChart/ComposedChart.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as ComponentStories from './ComposedChart.stories';
66

77
<Meta of={ComponentStories} />
88

9-
<DocsHeader isChart />
9+
<DocsHeader of={ComponentStories} isChart />
1010

1111
## Example
1212

packages/charts/src/components/DonutChart/DonutChart.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import LegendStory from '../../resources/LegendConfig.mdx';
66

77
<Meta of={ComponentStories} />
88

9-
<DocsHeader isChart />
9+
<DocsHeader of={ComponentStories} isChart />
1010

1111
## Example
1212

0 commit comments

Comments
 (0)