Skip to content

Commit d1d2133

Browse files
committed
Object notation, dynamic classes, global config
1 parent 5a968d6 commit d1d2133

File tree

7 files changed

+180
-13
lines changed

7 files changed

+180
-13
lines changed

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,59 @@ You can specify the tooltip position as a modifier:
6767

6868
See the available positions in the [tether-tooltip documentation](http://github.hubspot.com/tooltip/#changing-the-positioning).
6969

70+
## Dynamic CSS classes
71+
72+
You can set the tooltip css classes dynamically with the object notation:
73+
74+
```html
75+
<button v-tooltip="{ content: 'You have ' + count + ' new messages.', classes: ['a', 'b'] }">
76+
```
77+
78+
This will replace the default CSS classe with 'a b' on the tooltip element.
79+
80+
You can also use the standard class notation:
81+
82+
```html
83+
<button v-tooltip="{ content: 'You have ' + count + ' new messages.', classes: 'a b' }">
84+
```
85+
86+
Or a reactive property:
87+
88+
```html
89+
<button v-tooltip="{ content: 'You have ' + count + ' new messages.', classes: tooltipClasses }">
90+
```
91+
92+
## Global options
93+
94+
The default global options are:
95+
96+
```javascript
97+
{
98+
defaultClass: 'vue-tooltip-theme',
99+
tetherOptions: {
100+
constraints: [
101+
{
102+
to: 'window',
103+
attachment: 'together',
104+
pin: true,
105+
},
106+
],
107+
},
108+
}
109+
```
110+
111+
You can change the options during install with the arguments:
112+
113+
```javascript
114+
Vue.use(VTooltip, options)
115+
```
116+
117+
Or directly on the directive definition:
118+
119+
```javascript
120+
VTooltip.options.defaultClass = 'my-tooltip'
121+
```
122+
70123
# Example Style
71124

72125
## Sass / Less

dist/v-tooltip.browser.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/v-tooltip.common.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "v-tooltip",
3-
"version": "1.0.6",
3+
"version": "1.1.1",
44
"description": "Easy tooltips with Vue 2.x",
55
"main": "dist/v-tooltip.common.js",
66
"unpkg": "dist/v-tooltip.browser.js",
@@ -41,7 +41,7 @@
4141
"eslint-loader": "^1.6.1",
4242
"eslint-plugin-promise": "^3.4.0",
4343
"eslint-plugin-standard": "^2.0.1",
44-
"webpack": "^2.1.0-beta.25",
44+
"webpack": "^2.2",
4545
"webpack-merge": "^1.1.2"
4646
}
4747
}

src/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import vtooltip from './v-tooltip'
1+
import vtooltip, { defaultOptions } from './v-tooltip'
22

3-
export function install (Vue) {
3+
export function install (Vue, options) {
4+
options = Object.assign({}, defaultOptions, options || {})
5+
vtooltip.options = options
46
Vue.directive('tooltip', vtooltip)
57
}
68

0 commit comments

Comments
 (0)