zero-tooltip 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1 +1,93 @@
|
|
|
1
|
-
|
|
1
|
+
## zero-tooltip [](https://www.npmjs.com/package/zero-tooltip)
|
|
2
|
+
|
|
3
|
+
**zero-tooltip** is a Vue 3 simple tooltip component for displaying information text when hovering over element.
|
|
4
|
+
|
|
5
|
+
## About
|
|
6
|
+
The component is designed to enhance user interactions by providing informative tooltips when hovering over specific element by rendering overlay with given text next to it. Components settings are fully customizable.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
# npm
|
|
12
|
+
npm install zero-tooltip
|
|
13
|
+
# yarn
|
|
14
|
+
yarn add zero-tooltip
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Add globally in `main.ts`:
|
|
18
|
+
```ts
|
|
19
|
+
import ZeroTooltip from 'zero-tooltip'
|
|
20
|
+
// import default styles
|
|
21
|
+
import '../node_modules/zero-tooltip/dist/styles.css'
|
|
22
|
+
// register directive
|
|
23
|
+
const app = createApp(App)
|
|
24
|
+
app.directive('tooltip', ZeroTooltip())
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
Use it just like any other Vue.js directive on elements.
|
|
30
|
+
The given value is displayed as tooltip's text:
|
|
31
|
+
|
|
32
|
+
```html
|
|
33
|
+
<button v-tooltip="'Submits this form'">Submit</button>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Zero dependencies
|
|
37
|
+
This component does not depend on any other package, except Vue 3
|
|
38
|
+
|
|
39
|
+
## Customization
|
|
40
|
+
Default position for tooltip is above/on top of the element that is being hovered. You can change position by passing argument to directive:
|
|
41
|
+
|
|
42
|
+
```html
|
|
43
|
+
<button v-tooltip:right="'Submits this form'">Submit</button>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Acceptable arguments are: `left` | `top` | `right` | `bottom`
|
|
47
|
+
|
|
48
|
+
You can also define default position globally when registering directive at the app level:
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
app.directive('tooltip', ZeroTooltip({
|
|
52
|
+
defaultPosition: 'right'
|
|
53
|
+
}))
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Tooltip component is fully customizable by giving config object:
|
|
57
|
+
```ts
|
|
58
|
+
app.directive('tooltip', ZeroTooltip({
|
|
59
|
+
defaultPosition: ... ,
|
|
60
|
+
positions: ... ,
|
|
61
|
+
offsetFromSource: ... ,
|
|
62
|
+
offsetFromViewport: ... ,
|
|
63
|
+
minWidth: ... ,
|
|
64
|
+
maxWidth: ... ,
|
|
65
|
+
tooltipBorderWidth: ... ,
|
|
66
|
+
tooltipClasses: ... ,
|
|
67
|
+
textClasses: ... ,
|
|
68
|
+
arrowSize: ... ,
|
|
69
|
+
arrowClasses: ... ,
|
|
70
|
+
arrowMinOffsetFromTooltipCorner: ... ,
|
|
71
|
+
}))
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
All above settings are optional.
|
|
75
|
+
|
|
76
|
+
## Config
|
|
77
|
+
| Property | <div style="width:260px">Default value</div> | Type | Details |
|
|
78
|
+
|---|---|---|---|
|
|
79
|
+
| defaultPosition | *top* | TooltipPosition | Postion of tooltip component relative to element that is being hovered |
|
|
80
|
+
| positions | *{ <br>   'left': ['left', 'right', 'top', 'bottom'], <br>   'top': ['top', 'bottom', 'right', 'left'], <br>   'right': ['right', 'left', 'top', 'bottom'], <br>   'bottom': ['bottom', 'top', 'right', 'left'], <br> }* | TooltipPositions | Ordered list of fallback positions in case tooltip does not have enough space in default position. If none of given positions will have enough space for tooltip, then it will not be rendered. |
|
|
81
|
+
| offsetFromSource | *10* | number | Tooltip offset in `px` from element that's being hovered *(arrow size is not added to this value)* |
|
|
82
|
+
| offsetFromViewport | *20* | number | Minimal allowed tooltip offset in `px` from viewports sides |
|
|
83
|
+
| minWidth | *100* | number | Minimal tooltip width in `px` that will be allowed to render |
|
|
84
|
+
| maxWidth | *250* | number | Maximal tooltip width in `px` that will be allowed to render |
|
|
85
|
+
| tooltipBorderWidth | *0* | number | Tooltip container border width in `px` |
|
|
86
|
+
| tooltipClasses | *undefined* | string | List of classes that will be added to tooltip element |
|
|
87
|
+
| textClasses | *undefined* | string | List of classes that will be added to text element |
|
|
88
|
+
| arrowSize | *5* | number | Lenght of arrow hypotenuse in `px` (arrow is generated using border width property, creating square which gets divided in four triangles, thus `arrowSize` is lenght of square side) |
|
|
89
|
+
| arrowClasses | *undefined* | string | List of classes that will be added to arrow element |
|
|
90
|
+
| arrowMinOffsetFromTooltipCorner | *6* | number | Minimal allowed arrow offset in `px` from tooltip corner. Used in situations when tooltip does not have enough space to be centered relative to element that is being hover, thus arrow is rendered closer to one of the tooltip corners |
|
|
91
|
+
|
|
92
|
+
## Licence
|
|
93
|
+
The licence is MIT, so any extension, forking is welcome. `zero-tooltip` is designed as fully customizable, zero dependency, simple tooltip for Vue.js.
|