Skip to content

Commit 3cf5352

Browse files
authored
docs: add toc to docs-mode only stories (#4347)
1 parent 79d5e05 commit 3cf5352

File tree

6 files changed

+30
-7
lines changed

6 files changed

+30
-7
lines changed

.storybook/components/TableOfContent.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ function makeIds(headingSelector) {
2525
});
2626
}
2727

28-
export function TableOfContent({ headingSelector = 'h2:not(.noAnchor), h3:not(.noAnchor), h4:not(.noAnchor)' }) {
28+
export function TableOfContent({
29+
headingSelector = 'h2:not(.noAnchor), h3:not(.noAnchor), h4:not(.noAnchor)',
30+
onlyDisplaySideNav = false
31+
}) {
2932
useEffect(() => {
3033
makeIds(headingSelector);
3134

@@ -47,8 +50,10 @@ export function TableOfContent({ headingSelector = 'h2:not(.noAnchor), h3:not(.n
4750

4851
return (
4952
<>
50-
<h3 className={`${classes.header} noAnchor`}>Contents</h3>
51-
<div className={classes.fixedContainer}>
53+
<h3 className={`${classes.header} noAnchor`} data-show-small={!onlyDisplaySideNav}>
54+
Contents
55+
</h3>
56+
<div className={classes.fixedContainer} data-show-small={!onlyDisplaySideNav}>
5257
<div className={`js-toc ${classes.toc}`} id="toc-container" />
5358
</div>
5459
</>

.storybook/components/ToC.module.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
}
3232

3333
@media (max-width: 1329px) {
34+
.header[data-show-small='false'] {
35+
display: none;
36+
}
37+
.fixedContainer[data-show-small='false'] {
38+
display: none;
39+
}
3440
.toc {
3541
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
3642
}

docs/Changelog.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { Meta, Markdown } from '@storybook/blocks';
2-
import { Footer } from '../.storybook/components/Footer';
32
import Changelog from '../CHANGELOG.md?raw';
3+
import { Footer, TableOfContent } from '@sb/components';
44

55
<Meta title="Change Log" />
66

7+
<TableOfContent headingSelector="h2:not(.noAnchor)" onlyDisplaySideNav />
8+
79
<Markdown>{Changelog}</Markdown>
810

911
<Footer />

docs/Welcome.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Footer } from '@sb/components';
1+
import { Footer, TableOfContent } from '@sb/components';
22
import { Meta } from '@storybook/blocks';
33
import { Link, MessageStrip } from '@ui5/webcomponents-react';
44
import { VersionTable } from '@sb/components/VersionTable';
@@ -21,6 +21,8 @@ UI5 Web Components for React is a Fiori compliant React library built on top of
2121
With the help of UI5 Web Components for React, you can use UI5 Web Components as if they were native React components.
2222
In addition to that, UI5 Web Components for React is providing complex components and layouts on top of the UI5 Web Components.
2323

24+
<TableOfContent />
25+
2426
## Requirements
2527

2628
- [React](https://www.npmjs.com/package/react) and [React-DOM](https://www.npmjs.com/package/react-dom) (**16.14.0 or higher**)

docs/knowledge-base/Internationalization.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import { Meta } from '@storybook/addon-docs';
22
import { MessageStrip, MessageStripDesign } from '@ui5/webcomponents-react';
3-
import { Footer } from '@sb/components';
3+
import { Footer, TableOfContent } from '@sb/components';
44

55
<Meta title="Internationalization" />
66

7+
<TableOfContent />
8+
79
# Setup Internationalization (i18n)
810

911
UI5 Web Components (for React) aim to be feature rich and with a minimal code footprint at the same time.
1012
In order to achieve this, most UI5 Web Components packages ship their assets as `.json` files while also providing a public module import for them.
1113

1214
**Prerequisite: This guide requires `@ui5/webcomponents-react@^0.14.0` and `@ui5/webcomponents@^1.0.0-rc.12` or newer.**
1315

16+
## Make your App translatable
17+
1418
In order to make your app translatable into various languages, you need to import the following asset:
1519

1620
```js

docs/knowledge-base/Styling.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import { Meta } from '@storybook/addon-docs';
22
import { MyCustomElement } from '../styling/MyCustomElement';
33
import { MessageStrip, MessageStripDesign, ThemeProvider } from '@ui5/webcomponents-react';
4-
import { Footer } from '@sb/components';
4+
import { Footer, TableOfContent } from '@sb/components';
55

66
<Meta title="Styling" />
77

88
# Styling
99

10+
<TableOfContent />
11+
12+
## Styling UI5 Web Components for React components
13+
1014
You can change the appearance of the Web Components by using [CSS Variables](https://www.w3schools.com/Css/css3_variables.asp).
1115
Per default, we are injecting the Fiori 3 theme parameters as CSS Variables into the `<head>`.
1216
For example, if you want to change the color of all texts that use the `--sapTextColor` variable, you can create an additional `style` tag with the following content:

0 commit comments

Comments
 (0)