|
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'; |
4 | 4 |
|
5 |
| -<Meta of={ToggleTip} /> |
| 5 | +<Meta of={ToggleTipStories} /> |
6 | 6 |
|
7 | 7 | # Toggletip
|
8 | 8 |
|
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 | + | |
| 11 | +[Usage guidelines](https://www.carbondesignsystem.com/components/toggletip/usage) |
12 | 12 |
|
13 |
| -[](https://stackblitz.com/github/carbon-design-system/carbon/tree/main/packages/web-components/examples/components/toggletip) |
| 13 | +## Table of Contents |
14 | 14 |
|
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) |
18 | 19 |
|
19 |
| -## Getting started |
| 20 | +## Overview |
20 | 21 |
|
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"` |
22 | 28 |
|
23 |
| -### JS (via import) |
| 29 | +<Canvas of={ToggleTipStories.Default} /> |
24 | 30 |
|
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. |
30 | 53 |
|
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. |
33 | 56 |
|
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: |
35 | 61 |
|
36 | 62 | ```html
|
37 | 63 | <cds-toggletip>
|
38 |
| - Toggletip label |
39 |
| - |
40 | 64 | <p slot="body-text">
|
41 | 65 | Lorem ipsum dolor sit amet, di os consectetur adipiscing elit, sed do
|
42 | 66 | eiusmod tempor incididunt ut fsil labore et dolore magna aliqua.
|
43 | 67 | </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> |
46 | 70 | </cds-toggletip>
|
47 | 71 | ```
|
48 | 72 |
|
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 |
54 | 74 |
|
55 | 75 | <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). |
0 commit comments