-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(Toc): add component docs (#1024)
- Loading branch information
Showing
4 changed files
with
45 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!--GITHUB_BLOCK--> | ||
|
||
# Toc | ||
|
||
<!--/GITHUB_BLOCK--> | ||
|
||
```tsx | ||
import {Toc} from '@gravity-ui/uikit'; | ||
``` | ||
|
||
The `Toc` component is designed to represent table of contents of the page, displaying a set items with two levels of hierarchy. | ||
|
||
## Usage | ||
|
||
You can use `Toc` in two ways: | ||
|
||
1. Items are links | ||
2. Items are clickable buttons | ||
|
||
To use the first method, pass the corresponding link to each item of the `Toc` via `href` property. You will still be able to use a click handler to control active element of the `Toc`. | ||
|
||
If you don't do this, the component will work in the second way. | ||
|
||
## Properties | ||
|
||
| Name | Description | Type | Default | | ||
| :-------- | :------------------------------------------------------------------- | :---------: | :-----: | | ||
| className | CSS class | `string` | | | ||
| items | Elements of the table of contents | `TocItem[]` | | | ||
| value | Current active item | `string` | | | ||
| onUpdate | Item click handler | `Function` | | | ||
| qa | The value to be passed to `data-qa` attribute of the `Toc` container | `string` | | | ||
|
||
#### TocItem | ||
|
||
| Name | Description | Type | Default | | ||
| :------ | :----------------------------------------------------------------------------- | :-----------------: | :-----: | | ||
| value | Value of the item | `string` | | | ||
| content | Content of the item that will be displayed | `React.ReactNode[]` | | | ||
| href | `href` property of the `<a>` element to which item will be converted if passed | `string` | | | ||
| items | Children items | `TocItem[]` | | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,5 @@ $block: '.#{variables.$ns-new}toc-stories'; | |
#{$block} { | ||
$class: &; | ||
|
||
max-width: 156px; | ||
max-width: 416px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters