Skip to content

Commit f34b41f

Browse files
committed
[2.1.3] Finish release
1 parent c3a724d commit f34b41f

16 files changed

+209
-101
lines changed

README.md

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ Add dependencies to your `main.ts`:
2626

2727
```js
2828
import { createApp } from 'vue'
29-
import { TooltipDirective, TooltipComponent } from 'vue3-tooltip'
29+
import { TooltipDirective, TooltipComponent } from 'vue3-tooltip';
30+
import 'vue3-tooltip/tooltip.css';
3031

3132
const app = createApp({...})
3233
app.directive('tooltip', TooltipDirective)
@@ -91,7 +92,16 @@ The component has the following props *(default values are highlighted in bold)*
9192
`clickable` *(true | **false**)* - do not hide the tooltip when hovering over it
9293

9394
## Style customization
94-
To customize tooltip directive, you need to create a global style file using `CSS` or `Sass`. My example demonstrates this process:
95+
To customize styles, you need to paste your CSS file into `main.ts` after importing the basic tooltip styles `(vue3-tooltip/tooltip.css)`:
96+
97+
```js
98+
import { TooltipDirective, TooltipComponent } from 'vue3-tooltip';
99+
import 'vue3-tooltip/tooltip.css';
100+
// After this line you need to do your import
101+
import './assets/my-tooltip.scss';
102+
```
103+
104+
To customize tooltip **directive**, you need to create a global style file using `CSS` or `Sass`. My example demonstrates this process:
95105

96106
```scss
97107
.vue-tooltip {
@@ -110,7 +120,74 @@ To customize tooltip directive, you need to create a global style file using `CS
110120
}
111121
```
112122

113-
If you want to explore customization in more detail and change all the classes in the module, you should check them out at [this link](https://github.com/neluckoff/vue3-tooltip/blob/master/src/assets/directive.css).
123+
*If you want to explore customization in more detail and change all the classes in the module, you should check them out at [this link](https://github.com/neluckoff/vue3-tooltip/blob/master/src/assets/_directive.css).*
124+
125+
To customize the **component**, you can also override the standard styles:
126+
127+
```scss
128+
.vue-tooltip {
129+
&.disable {
130+
// ... //
131+
}
132+
&--component {
133+
/*
134+
* font-size, line-height, max-width, padding, border-radius, box-shadow, transition
135+
*/
136+
}
137+
}
138+
```
139+
140+
*You can go deeper into component styles at [this link](https://github.com/neluckoff/vue3-tooltip/blob/master/src/assets/_component.css).*
141+
142+
Or, instead of redefining classes, you can use variables, on which the entire tooltip design is based. If you want to add new variables, you can write to [Issues on GitHub](https://github.com/neluckoff/vue3-tooltip/issues).
143+
144+
```css
145+
:root {
146+
/* Directive Variables */
147+
--tooltip-d-transition-duration: 0.4s;
148+
--tooltip-d-border-radius: 4px;
149+
--tooltip-d-padding: 2px 4px;
150+
--tooltip-d-position-x: calc(100% + 10px);
151+
--tooltip-d-position-y: calc(100% + 2px);
152+
--tooltip-d-box-shadow: 0px 3.2px 7.2px 0px rgba(0, 0, 0, 0.14),
153+
0px 0.6px 1.8px 0px rgba(0, 0, 0, 0.1),
154+
0px -1.5px 6px 0px rgba(0, 0, 0, 0.06);
155+
--tooltip-d-z-index: 10;
156+
--tooltip-d-max-width: 200px;
157+
--tooltip-d-font-size: 14px;
158+
--tooltip-d-width: max-content;
159+
--tooltip-d-height: max-content;
160+
--tooltip-d-outline: none;
161+
--tooltip-d-border: none;
162+
163+
/* Component Variables */
164+
--tooltip-c-transition-duration: 0.4s;
165+
--tooltip-c-border-radius: 4px;
166+
--tooltip-c-padding: 2px 4px;
167+
--tooltip-c-position-x: calc(100% + 10px);
168+
--tooltip-c-position-y: 100%;
169+
--tooltip-c-box-shadow: 0px 3.2px 7.2px 0px rgba(0, 0, 0, 0.14),
170+
0px 0.6px 1.8px 0px rgba(0, 0, 0, 0.1),
171+
0px -1.5px 6px 0px rgba(0, 0, 0, 0.06);
172+
--tooltip-c-z-index: 10;
173+
--tooltip-c-max-width: max-content;
174+
--tooltip-c-width: max-content;
175+
--tooltip-c-height: max-content;
176+
--tooltip-c-outline: none;
177+
--tooltip-c-border: none;
178+
179+
/* Colors */
180+
--tooltip-primary-color: #212121;
181+
--tooltip-primary-background: #fff;
182+
--tooltip-seconary-color: #fff;
183+
--tooltip-seconary-background: #475DEB;
184+
--tooltip-accent-color: #fff;
185+
--tooltip-accent-background: #212121;
186+
187+
--tooltip-component-color: #212121;
188+
--tooltip-component-background: #fff;
189+
}
190+
```
114191

115192
## Contributing
116193
I have a positive attitude towards PR and pull requests. Glad to see that people like the package.

dist/index.d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import { PublicProps } from 'vue';
66
import { Ref } from 'vue';
77

88
declare module 'vue3-tooltip' {
9-
declare const _default: {
9+
const _default: {
1010
install: (app: any) => void;
1111
};
1212
export default _default;
1313

14-
export declare const install: (app: any) => void;
14+
export const install: (app: any) => void;
1515

16-
export declare const TooltipComponent: DefineComponent<{
16+
export const TooltipComponent: DefineComponent<{
1717
disable: {
1818
type: BooleanConstructor;
1919
required: false;
@@ -55,9 +55,9 @@ declare module 'vue3-tooltip' {
5555
clickable: boolean;
5656
}, {}>;
5757

58-
export declare const TooltipDirective: Directive<HTMLElement, string>;
58+
export const TooltipDirective: Directive<HTMLElement, string>;
5959

60-
declare type TooltipPosition = 'bottom' | 'top' | 'left' | 'right';
60+
type TooltipPosition = 'bottom' | 'top' | 'left' | 'right';
6161

6262
export { }
63-
}
63+
}

dist/style.css

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

dist/vue3-tooltip.es.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
(function(){"use strict";var o;try{if(typeof document<"u"){var t=document.createElement("style");t.nonce=(o=document.head.querySelector("meta[property=csp-nonce]"))==null?void 0:o.content,t.appendChild(document.createTextNode('.vue-tooltip[data-v-5991ce00]:after{content:"";display:none}.vue-tooltip__pointer-event[data-v-5991ce00]{pointer-events:none}.vue-tooltip__hover-left[data-v-5991ce00]{right:var(--tooltip-position-x);left:auto}.left-enter-active[data-v-5991ce00],.left-leave-active[data-v-5991ce00]{transition:var(--tooltip-transition-duration);right:var(--tooltip-position-x)}.left-enter-from[data-v-5991ce00],.left-leave-to[data-v-5991ce00]{opacity:0;right:50%}.vue-tooltip__left[data-v-5991ce00]{top:50%;bottom:50%;transform:translateY(-50%)}.vue-tooltip__hover-right[data-v-5991ce00]{left:var(--tooltip-position-x);right:auto}.right-enter-active[data-v-5991ce00],.right-leave-active[data-v-5991ce00]{transition:var(--tooltip-transition-duration);left:var(--tooltip-position-x)}.right-enter-from[data-v-5991ce00],.right-leave-to[data-v-5991ce00]{opacity:0;left:50%}.vue-tooltip__right[data-v-5991ce00]{top:50%;bottom:50%;transform:translateY(-50%)}.vue-tooltip__hover-bottom[data-v-5991ce00]{top:100%;bottom:auto}.bottom-enter-active[data-v-5991ce00],.bottom-leave-active[data-v-5991ce00]{transition:var(--tooltip-transition-duration);top:100%}.bottom-enter-from[data-v-5991ce00],.bottom-leave-to[data-v-5991ce00]{opacity:0;top:50%}.vue-tooltip__bottom[data-v-5991ce00]{right:50%;left:50%;transform:translate(-50%)}.vue-tooltip__hover-top[data-v-5991ce00]{bottom:100%;top:auto}.top-enter-active[data-v-5991ce00],.top-leave-active[data-v-5991ce00]{transition:var(--tooltip-transition-duration);bottom:100%}.top-enter-from[data-v-5991ce00],.top-leave-to[data-v-5991ce00]{opacity:0;bottom:50%}.vue-tooltip__top[data-v-5991ce00]{right:50%;left:50%;transform:translate(-50%)}.vue-tooltip{position:relative;cursor:pointer;z-index:1}.vue-tooltip__primary:after{background:var(--tooltip-primary-background);color:var(--tooltip-primary-color)}.vue-tooltip__secondary:after{background:var(--tooltip-seconary-background);color:var(--tooltip-seconary-color)}.vue-tooltip__accent:after{background:var(--tooltip-accent-background);color:var(--tooltip-accent-color)}.vue-tooltip:after{content:attr(data-tooltip);font-size:14px;position:absolute;width:max-content;max-width:200px;height:max-content;z-index:10;padding:var(--tooltip-padding);border-radius:var(--tooltip-border-radius);box-shadow:var(--tooltip-box-shadow);pointer-events:none;opacity:0;transition:var(--tooltip-transition-duration)}.vue-tooltip:hover:after{opacity:1}.vue-tooltip__bottom:after{top:50%;bottom:auto;right:50%;left:50%;transform:translate(-50%)}.vue-tooltip__bottom:hover:after{top:calc(100% + 2px)}.vue-tooltip__top:after{top:auto;bottom:50%;right:50%;left:50%;transform:translate(-50%)}.vue-tooltip__top:hover:after{bottom:calc(100% + 2px)}.vue-tooltip__right:after{top:50%;bottom:50%;left:14px;right:auto;transform:translateY(-50%)}.vue-tooltip__right:hover:after{left:var(--tooltip-position-x)}.vue-tooltip__left:after{top:50%;bottom:50%;right:14px;left:auto;transform:translateY(-50%)}.vue-tooltip__left:hover:after{right:var(--tooltip-position-x)}.vue-tooltip-body{z-index:10;background:var(--tooltip-component-background);color:var(--tooltip-component-color);border-radius:var(--tooltip-border-radius);box-shadow:var(--tooltip-box-shadow);padding:var(--tooltip-padding);width:max-content;height:max-content;position:absolute}.vue-tooltip.disable{opacity:.5;cursor:not-allowed}:root{--tooltip-transition-duration: .4s;--tooltip-border-radius: 4px;--tooltip-padding: 2px 4px;--tooltip-position-x: calc(100% + 10px) ;--tooltip-box-shadow: 0px 3.2px 7.2px 0px rgba(0, 0, 0, .14), 0px .6px 1.8px 0px rgba(0, 0, 0, .1), 0px -1.5px 6px 0px rgba(0, 0, 0, .06);--tooltip-primary-color: #212121;--tooltip-primary-background: #fff;--tooltip-seconary-color: #fff;--tooltip-seconary-background: #475DEB;--tooltip-accent-color: #fff;--tooltip-accent-background: #212121;--tooltip-component-color: #212121;--tooltip-component-background: #fff}')),document.head.appendChild(t)}}catch(a){console.error("vite-plugin-css-injected-by-js",a)}})();
2-
import { ref as d, openBlock as s, createElementBlock as a, normalizeClass as i, renderSlot as n, createVNode as p, Transition as f, withCtx as v, createCommentVNode as m } from "vue";
1+
import { ref as d, openBlock as r, createElementBlock as s, normalizeClass as a, renderSlot as i, createVNode as p, Transition as f, withCtx as v, createCommentVNode as m } from "vue";
32
const _ = {
43
name: "TooltipComponent",
54
props: {
@@ -23,8 +22,8 @@ const _ = {
2322
const e = d(!1);
2423
return {
2524
isShowTooltip: e,
26-
afterEnter: (r) => {
27-
r.classList.add(`vue-tooltip__hover-${t.position}`);
25+
afterEnter: (n) => {
26+
n.classList.add(`vue-tooltip__hover-${t.position}`);
2827
},
2928
hideTooltip: () => {
3029
e.value = !1;
@@ -33,34 +32,34 @@ const _ = {
3332
}
3433
}, y = (t, e) => {
3534
const o = t.__vccOpts || t;
36-
for (const [l, r] of e)
37-
o[l] = r;
35+
for (const [l, n] of e)
36+
o[l] = n;
3837
return o;
3938
};
40-
function T(t, e, o, l, r, b) {
41-
return s(), a("div", {
39+
function T(t, e, o, l, n, b) {
40+
return r(), s("div", {
4241
onMouseenter: e[0] || (e[0] = (u) => l.isShowTooltip = !0),
4342
onMouseleave: e[1] || (e[1] = (u) => l.isShowTooltip = !1),
44-
class: i(["vue-tooltip", { disable: o.disable }])
43+
class: a(["vue-tooltip", { disable: o.disable }])
4544
}, [
46-
n(t.$slots, "text", {}, void 0, !0),
45+
i(t.$slots, "text", {}, void 0, !0),
4746
p(f, {
4847
name: o.position,
4948
onAfterEnter: l.afterEnter
5049
}, {
5150
default: v(() => [
52-
!o.disable && l.isShowTooltip ? (s(), a("div", {
51+
!o.disable && l.isShowTooltip ? (r(), s("div", {
5352
key: 0,
54-
class: i(["vue-tooltip-body", [{ "vue-tooltip__pointer-event": !o.clickable }, `vue-tooltip__${o.position}`]])
53+
class: a(["vue-tooltip--component", [{ "vue-tooltip__pointer-event": !o.clickable }, `vue-tooltip__${o.position}`]])
5554
}, [
56-
n(t.$slots, "tooltip", {}, void 0, !0)
55+
i(t.$slots, "tooltip", {}, void 0, !0)
5756
], 2)) : m("", !0)
5857
]),
5958
_: 3
6059
}, 8, ["name", "onAfterEnter"])
6160
], 34);
6261
}
63-
const S = /* @__PURE__ */ y(_, [["render", T], ["__scopeId", "data-v-5991ce00"]]), k = {
62+
const S = /* @__PURE__ */ y(_, [["render", T], ["__scopeId", "data-v-69eec82b"]]), k = {
6463
mounted: (t, e) => {
6564
c(t, e);
6665
},

0 commit comments

Comments
 (0)