Skip to content

Commit 32f1066

Browse files
chore(docs): update misc web component Storybook docs (#19175)
* chore(docs): update misc web component Storybook docs * chore(cleanup): more * chore(comments): fix * fix(toggle): missing cdn link
1 parent f37d572 commit 32f1066

File tree

11 files changed

+245
-439
lines changed

11 files changed

+245
-439
lines changed
Lines changed: 59 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,83 @@
1-
import { ArgTypes, Markdown, Meta } from '@storybook/blocks';
2-
import { cdnJs, cdnCss } from '../../globals/internal/storybook-cdn';
3-
import * as ToggleTip from './toggletip.stories';
1+
import { ArgTypes, Canvas, Markdown, Meta } from '@storybook/blocks';
2+
import { cdnJs } from '../../globals/internal/storybook-cdn';
3+
import * as ToggleTipStories from './toggletip.stories';
44

5-
<Meta of={ToggleTip} />
5+
<Meta of={ToggleTipStories} />
66

77
# Toggletip
88

9-
> 💡 Check our
10-
> [Stackblitz](https://stackblitz.com/github/carbon-design-system/carbon/tree/main/packages/web-components/examples/components/toggletip)
11-
> example implementation.
9+
[Source code](https://github.com/carbon-design-system/carbon/tree/main/packages/web-components/src/components/toogle-tip)
10+
&nbsp;|&nbsp;
11+
[Usage guidelines](https://www.carbondesignsystem.com/components/toggletip/usage)
1212

13-
[![Edit carbon-web-components](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/carbon-design-system/carbon/tree/main/packages/web-components/examples/components/toggletip)
13+
## Table of Contents
1414

15-
The Toggletip component provides an accessible way to render interactive content
16-
within a popover. If you do not have any interactive content inside of your
17-
Toggletip, consider using Tooltip instead.
15+
- [Overview](#overview)
16+
- [Toggletips vs Tooltips](#toggletips-vs-tooltips)
17+
- [Component API](#component-api)
18+
- [Feedback](#feedback)
1819

19-
## Getting started
20+
## Overview
2021

21-
Here's a quick example to get you started.
22+
The `cds-toggletip` component provides an accessible way to render interactive
23+
content within a popover. If you do not have any interactive content inside of
24+
your `cds-toggletip`, consider using `cds-tooltip` instead. To use this
25+
component, you can provide the label by passing it in as a child, include
26+
actions by using `slot="action"` in a `cds-button`, and to include the content
27+
you can use the `slot="body-text"`
2228

23-
### JS (via import)
29+
<Canvas of={ToggleTipStories.Default} />
2430

25-
```javascript
26-
import '@carbon/web-components/es/components/toggle-tip/index.js';
27-
import '@carbon/web-components/es/components/link/index.js';
28-
import '@carbon/web-components/es/components/button/index.js';
29-
```
31+
### Toggletips vs Tooltips
32+
33+
Toggletips and tooltips are similar visually and both contain a popover and
34+
interactive trigger element. The two components differ in the way they are
35+
invoked and dismissed and if the user must interact with the contents. A tooltip
36+
is exposed on hover or focus when you need to expose brief, supplemental
37+
information that is not interactive. A toggletip is used on click or enter when
38+
you need to expose interactive elements, such as button, that a user needs to
39+
interact with.
40+
41+
## Alignment
42+
43+
The toggletip component provides four options for alignment: `top`, `bottom`,
44+
`left`, and `right`. These options will correspond to where the popover will
45+
render relative to the toggletip button. For example, when choosing `align="top"`
46+
the toggletip content will render above the toggletip button.
47+
48+
## Customizing content
49+
50+
You can customize the contents of a toggletip with the toggletip content
51+
component. You can render any kind of child element or component inside of this
52+
component.
3053

31-
<Markdown>{`${cdnJs({ components: ['toggle-tip'] })}`}</Markdown>
32-
<Markdown>{`${cdnCss()}`}</Markdown>
54+
You can customize the contents of a toggletip with using the `slot="body-text"`
55+
on any kind of child element or component.
3356

34-
### HTML
57+
## Actions
58+
59+
If your toggletip includes actions, you can make use of the `slot="actions"` to
60+
render them underneath the content of your content. For example:
3561

3662
```html
3763
<cds-toggletip>
38-
Toggletip label
39-
4064
<p slot="body-text">
4165
Lorem ipsum dolor sit amet, di os consectetur adipiscing elit, sed do
4266
eiusmod tempor incididunt ut fsil labore et dolore magna aliqua.
4367
</p>
44-
<cds-link slot="actions">Test</cds-link>
45-
<cds-button slot="actions">Button</cds-button>
68+
<cds-link href="custom-link" slot="actions">Custom link</cds-link>
69+
<cds-button size="sm" slot="actions">Custom action</cds-button>
4670
</cds-toggletip>
4771
```
4872

49-
### `<cds-toggletip>` attributes and properties
50-
51-
Note: For `boolean` attributes, `true` means simply setting the attribute (e.g.
52-
`<cds-toggletip open>`) and `false` means not setting the attribute (e.g.
53-
`<cds-toggletip>` without `open` attribute).
73+
## Component API
5474

5575
<ArgTypes of="cds-toggletip" />
76+
77+
<Markdown>{`${cdnJs({ components: ['toggletip'] })}`}</Markdown>
78+
79+
## Feedback
80+
81+
Help us improve this component by providing feedback, asking questions on Slack,
82+
or updating this file on
83+
[GitHub](https://github.com/carbon-design-system/carbon/edit/main/packages/web-components/src/components/toggle-tip/toggletip.mdx).

packages/web-components/src/components/toggle-tip/toggletip.stories.ts

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -44,33 +44,17 @@ const controls = {
4444

4545
export const Default = {
4646
render: () => html`
47-
<div>
48-
<div style="display: flex; align-items: center">
49-
<cds-toggletip alignment="bottom">
50-
Toggletip label
47+
<div style="display: flex; align-items: center">
48+
<cds-toggletip alignment="bottom">
49+
Toggletip label
5150
52-
<p slot="body-text">
53-
Lorem ipsum dolor sit amet, di os consectetur adipiscing elit, sed
54-
do eiusmod tempor incididunt ut fsil labore et dolore magna aliqua.
55-
</p>
56-
<cds-link slot="actions">Test</cds-link>
57-
<cds-button slot="actions">Button</cds-button>
58-
</cds-toggletip>
59-
</div>
60-
<br />
61-
<br />
62-
<div style="display: flex; align-items: center">
63-
<cds-toggletip alignment="bottom" open>
64-
Toggletip label -- using <code>open</code> prop
65-
66-
<p slot="body-text">
67-
Lorem ipsum dolor sit amet, di os consectetur adipiscing elit, sed
68-
do eiusmod tempor incididunt ut fsil labore et dolore magna aliqua.
69-
</p>
70-
<cds-link slot="actions">Test</cds-link>
71-
<cds-button slot="actions">Button</cds-button>
72-
</cds-toggletip>
73-
</div>
51+
<p slot="body-text">
52+
Lorem ipsum dolor sit amet, di os consectetur adipiscing elit, sed do
53+
eiusmod tempor incididunt ut fsil labore et dolore magna aliqua.
54+
</p>
55+
<cds-link slot="actions">Test</cds-link>
56+
<cds-button slot="actions">Button</cds-button>
57+
</cds-toggletip>
7458
</div>
7559
`,
7660
};

packages/web-components/src/components/toggle/docs/overview.mdx

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,41 @@
1-
import { ArgTypes, Markdown, Meta } from '@storybook/blocks';
2-
import { cdnJs, cdnCss } from '../../globals/internal/storybook-cdn';
3-
import * as Toggle from './toggle.stories';
1+
import { ArgTypes, Canvas, Markdown, Meta } from '@storybook/blocks';
2+
import { cdnJs } from '../../globals/internal/storybook-cdn';
3+
import * as ToggleStories from './toggle.stories';
44

5-
<Meta of={Toggle} />
5+
<Meta of={ToggleStories} />
66

77
# Toggle
88

9-
> 💡 Check our
10-
> [Stackblitz](https://stackblitz.com/github/carbon-design-system/carbon/tree/main/packages/web-components/examples/components/toggle)
11-
> example implementation.
9+
[Source code](https://github.com/carbon-design-system/carbon/tree/main/packages/web-components/src/components/toggle)
10+
&nbsp;|&nbsp;
11+
[Usage guidelines](https://www.carbondesignsystem.com/components/toggle/usage)
12+
&nbsp;|&nbsp;
13+
[Accessibility](https://www.carbondesignsystem.com/components/toggle/accessibility)
1214

13-
[![Edit carbon-web-components](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/carbon-design-system/carbon/tree/main/packages/web-components/examples/components/toggle)
15+
## Table of Contents
1416

15-
Toggle is a control that is used to quickly switch between two possible states.
16-
Toggles are only used for these binary actions that occur immediately after the
17-
user “flips” the toggle switch. They are commonly used for “on/off” switches.
17+
- [Overview](#overview)
18+
- [Small Toggle](#small-toggle)
19+
- [Component API](#component-api)
20+
- [CDN](#cdn)
21+
- [Feedback](#feedback)
1822

19-
Use `small` property/attribute to make it more compact in size, so they can be
20-
used in use cases such as data tables.
23+
## Overview
2124

22-
## Getting started
25+
<Canvas of={ToggleStories.Default} />
2326

24-
Here's a quick example to get you started.
27+
## Small Toggle
2528

26-
### JS (via import)
29+
<Canvas of={ToggleStories.SmallToggle} />
2730

28-
```javascript
29-
import '@carbon/web-components/es/components/toggle/index.js';
30-
```
31+
## Component API
3132

32-
<Markdown>{`${cdnJs({ components: ['toggle'] })}`}</Markdown>
33-
<Markdown>{`${cdnCss()}`}</Markdown>
34-
35-
### HTML
36-
37-
```html
38-
<cds-toggle label-a="On" label-text="Toggle" label-b="Off"></cds-toggle>
39-
```
40-
41-
## Small toggle
33+
<ArgTypes of="cds-toggle" />
4234

43-
```html
44-
<cds-toggle
45-
size="sm"
46-
label-a="On"
47-
label-text="Toggle"
48-
label-b="Off"></cds-toggle>
49-
```
35+
<Markdown>{`${cdnJs({ components: ['toggle'] })}`}</Markdown>
5036

51-
## `<cds-toggle>` attributes, properties and events
37+
## Feedback
5238

53-
<ArgTypes of="cds-toggle" />
39+
Help us improve this component by providing feedback, asking questions on Slack,
40+
or updating this file on
41+
[GitHub](https://github.com/carbon-design-system/carbon/edit/main/packages/web-components/src/components/toggle/toggle.mdx).

packages/web-components/src/components/tooltip/docs/overview.mdx

Lines changed: 0 additions & 20 deletions
This file was deleted.

packages/web-components/src/components/tooltip/tooltip-content.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { carbonElement as customElement } from '../../globals/decorators/carbon-
1212

1313
/**
1414
* Tooltip content.
15+
*
16+
* @element cds-tooltip-content
1517
*/
1618
@customElement(`${prefix}-tooltip-content`)
1719
class CDSTooltipContent extends CDSPopoverContent {

0 commit comments

Comments
 (0)