2019-10-07 11:39:21 +00:00
|
|
|
# Tooltip
|
|
|
|
|
|
|
|
#### Description
|
|
|
|
|
|
|
|
Custom tooltip
|
|
|
|
|
2019-10-08 08:42:12 +00:00
|
|
|
#### Usage with IconButton
|
2019-10-07 11:39:21 +00:00
|
|
|
|
|
|
|
```js
|
2019-10-08 08:42:12 +00:00
|
|
|
import { Tooltip, IconButton, Text } from "asc-web-components";
|
2019-10-07 11:39:21 +00:00
|
|
|
|
2019-10-08 08:42:12 +00:00
|
|
|
<div
|
|
|
|
style={BodyStyle}
|
|
|
|
data-for="tooltipContent"
|
|
|
|
data-tip="You tooltip content"
|
|
|
|
data-event="click focus"
|
|
|
|
>
|
|
|
|
<IconButton isClickable={true} size={20} iconName="QuestionIcon" />
|
|
|
|
</div>
|
2019-10-07 11:39:21 +00:00
|
|
|
<Tooltip
|
|
|
|
id="tooltipContent"
|
|
|
|
getContent={dataTip => <Text.Body fontSize={13}>{dataTip}</Text.Body>}
|
2019-10-08 08:42:12 +00:00
|
|
|
effect={select("effect", arrayEffects, "float")}
|
|
|
|
place={select("place", arrayPlaces, "top")}
|
|
|
|
maxWidth={number("maxWidth", 320)}
|
|
|
|
/>
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
#### Usage with array
|
|
|
|
|
|
|
|
```js
|
|
|
|
import { Tooltip, Link, Text } from "asc-web-components";
|
|
|
|
|
|
|
|
const arrayUsers = [
|
|
|
|
{ key: "user_1", name: "Bob", email: "Bob@gmail.com", position: "developer" },
|
|
|
|
{ key: "user_2", name: "John", email: "John@gmail.com", position: "developer" },
|
|
|
|
{ key: "user_3", name: "Kevin", email: "Kevin@gmail.com", position: "developer" },
|
|
|
|
{ key: "user_4", name: "Alex", email: "Alex@gmail.com", position: "developer" },
|
|
|
|
{ key: "user_5", name: "Tomas", email: "Tomas@gmail.com", position: "developer" }
|
|
|
|
];
|
|
|
|
|
|
|
|
<h5 style={{ marginLeft: -5 }}>Hover group</h5>
|
|
|
|
<Link data-for="group" data-tip={0}>Bob</Link><br />
|
|
|
|
<Link data-for="group" data-tip={1}>John</Link><br />
|
|
|
|
<Link data-for="group" data-tip={2}>Kevin</Link><br />
|
|
|
|
<Link data-for="group" data-tip={3}>Alex</Link><br />
|
|
|
|
<Link data-for="group" data-tip={4}>Tomas</Link>
|
|
|
|
|
|
|
|
<Tooltip
|
|
|
|
id="group"
|
|
|
|
offset={{ right: 90 }}
|
|
|
|
getContent={dataTip =>
|
|
|
|
dataTip ? (
|
|
|
|
<div>
|
|
|
|
<Text.Body isBold={true} fontSize={16}>{arrayUsers[dataTip].name}</Text.Body>
|
|
|
|
<Text.Body color="#A3A9AE" fontSize={13}>{arrayUsers[dataTip].email}</Text.Body>
|
|
|
|
<Text.Body fontSize={13}>{arrayUsers[dataTip].position}</Text.Body>
|
|
|
|
</div>
|
|
|
|
) : null
|
|
|
|
}
|
|
|
|
|
2019-10-07 11:39:21 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
#### YouComponent Properties
|
|
|
|
|
|
|
|
| Props | Type | Required | Values | Default | Description |
|
|
|
|
| ------------ | -------- | :------: | ------ | ------- | --------------------------------- |
|
2019-10-08 08:42:12 +00:00
|
|
|
| `data-tip` | `string` | - | - | - | Required if you need to component |
|
2019-10-07 11:39:21 +00:00
|
|
|
| `data-event` | `string` | - | - | - | Custom event to trigger tooltip |
|
2019-10-08 08:42:12 +00:00
|
|
|
| `data-for` | `string` | ✅ | - | - | Corresponds to the id of Tooltip |
|
2019-10-07 11:39:21 +00:00
|
|
|
|
|
|
|
#### ReactTooltip Properties
|
|
|
|
|
|
|
|
| Props | Type | Required | Values | Default | Description |
|
|
|
|
| ------------ | -------- | :------: | -------------------------------------- | ------- | ------------------------------------ |
|
|
|
|
| `id` | `string` | ✅ | - | - | Used as HTML id property |
|
2019-10-08 08:42:12 +00:00
|
|
|
| `getContent` | `func` | - | | - | Generate the tip content dynamically |
|
2019-10-07 11:39:21 +00:00
|
|
|
| `effect` | `string` | - | `float, solid` | `float` | Behaviour of tooltip |
|
2019-10-08 08:42:12 +00:00
|
|
|
| `offset` | `object` | - | `top, left, right, bottom` | - | Offset of tooltip |
|
|
|
|
| `maxWidth` | `number` | - | - | `340` | Set max width of tooltip |
|