Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore (refs T33323): add storybook documentation to DpTabs. #344

Merged
merged 13 commits into from
Jul 4, 2023
Merged
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Since v0.0.10, this Changelog is formatted according to the [Common Changelog][c

### Added

- ([#344](https://github.com/demos-europe/demosplan-ui/pull/344)) docs: add documentation for DpTabs ([@@ahmad-demos](https://github.com/@ahmad-demos))
ahmad-demos marked this conversation as resolved.
Show resolved Hide resolved

### Added
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An "Added" section already exists!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 6fb4106


- ([#333](https://github.com/demos-europe/demosplan-ui/pull/333)) Add "rounded" prop to DpButton, add "arrow-up" and "arrow-down" icons to DpIcon ([@spiess-demos](https://github.com/spiess-demos))

## v0.1.7 - 2023-06-27
Expand Down
61 changes: 61 additions & 0 deletions src/components/DpTabs/DpTabs.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { Meta } from '@storybook/addon-docs'
import DpTabs from './DpTabs'

<Meta
title="Components/Tabs"
component={DpTabs} />

# DpTabs

The DpTabs component provides a structured and interactive way to organize and navigate related content, allowing users to switch between different views while keeping context.

DpTabs and DpTab both provide a default slot. For each tab, a `DpTab` instance is placed inside the default slot of `DpTabs`, while the content of each tab is placed inside the default slot of the respective `DpTab` instance.

The `DpTab` instances are then aligned horizontally, and each tab is associated with its header.

## Default usage

```html
<dp-tabs
tab-size="medium"
:active-id="activeTabId"
use-url-fragment
@change="setActiveTabId"> <!-- call a method -->
<dp-tab
id="idTab1"
label="Tab Title 1">
<slot>
Tab content 1.
</slot>
</dp-tab>
<dp-tab
id="idTab2"
label="Tab Title 2">
<slot>
Tab content 2.
</slot>
</dp-tab>
</dp-tabs>
```

## DpTabs Props:

```
- activeId: is a String type, belongs to data.

- tabSize: `medium` or `large`, default is `large`

- useUrlFragment: Active tab state may be persisted via an Url fragment.
Also, ab clicks are pushed to the browser history to enable state change when browser navigation is used.
```

## DpTab Props:

```
- id: Tab ID.

- label: The label is passed to the DpTab child component, but then it is used in the parent component DpTabs.

- suffix: A html string may be passed here which is appended to the tab label.
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vue component props are typically "auto-documented" by storybook using vue-docgen-api and vue-docgen-loader. At the moment the Storybook docs integraton is broken so that the props are not showing up as expected, however there is no need to document them by hand. Rather we could fill in the blanks by adding docblocks directly above the props themselves.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 59b2c5b