@avakhula/ui 0.0.24 → 0.0.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avakhula/ui",
3
- "version": "0.0.24",
3
+ "version": "0.0.25",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.umd.cjs",
6
6
  "source": "src/index.js",
package/src/App.vue CHANGED
@@ -21,9 +21,16 @@
21
21
  <button @click="changeValueInProps">Change value in props</button>
22
22
 
23
23
  <ib-checkbox @input="test1" class="hello" />
24
+
25
+ <ib-button style="margin-bottom: 20px;" v-tooltip="'test'" >HOVER ME</ib-button>
26
+ <ib-button style="margin-bottom: 20px;" v-tooltip="'second test'" >HOVER ME</ib-button>
27
+
24
28
  </template>
25
29
 
26
30
  <script>
31
+ import IbButton from "./components/Button/Button.vue"
32
+ import { TooltipDirective as Tooltip} from "./directives/tooltip/tooltip"
33
+
27
34
  import IbSelect from "./components/TreeSelect/Select.vue";
28
35
  import IbCheckbox from "./components/Form/Checkbox/Checkbox.vue";
29
36
  import IbPagination from "./components/Pagination/Pagination.vue";
@@ -85,12 +92,16 @@ export default {
85
92
  test: testData[0].id,
86
93
  };
87
94
  },
95
+ directives: {
96
+ Tooltip,
97
+ },
88
98
  watch: {
89
99
  test(val) {
90
100
  console.log("test", val);
91
101
  },
92
102
  },
93
103
  components: {
104
+ IbButton,
94
105
  IbSelect,
95
106
  IbCheckbox,
96
107
  IbPagination,
@@ -0,0 +1,50 @@
1
+ // import { createApp, h } from "vue";
2
+ import IbTooltip from "../../components/Tooltip/Tooltip.vue";
3
+ import { createApp } from "vue";
4
+
5
+ export const TooltipDirective = {
6
+ mounted(el, binding) {
7
+ let tooltipInstance = null;
8
+ const tooltipContainer = document.createElement("div");
9
+
10
+ el.addEventListener("mouseenter", () => {
11
+ const tooltipContainerStyles = `
12
+ position: absolute;
13
+ top: 0px;
14
+ left: 0px;
15
+ `;
16
+ tooltipContainer.setAttribute("style", tooltipContainerStyles);
17
+
18
+ document.body.appendChild(tooltipContainer);
19
+ tooltipInstance = createApp(IbTooltip, {
20
+ text: binding.value,
21
+ });
22
+
23
+ tooltipInstance.mount(tooltipContainer);
24
+ tooltipContainer.firstChild.setAttribute("style", "display: block");
25
+
26
+ setTimeout(() => {
27
+ if (tooltipContainer.firstChild) {
28
+ const { top, left, width } = el.getBoundingClientRect();
29
+ const { width: tooltipWidth, height: tooltipHeight } =
30
+ tooltipContainer.firstChild.getBoundingClientRect();
31
+
32
+ const tooltipStyles = `
33
+ left: ${left + width / 2 - tooltipWidth / 2}px!important;
34
+ top: ${top - tooltipHeight - 5}px!important;
35
+ bottom: auto!important;
36
+ right: auto!important;
37
+ transform: none!important;
38
+ `;
39
+
40
+ tooltipContainer.firstChild.setAttribute("style", tooltipStyles);
41
+ }
42
+ }, 100);
43
+ });
44
+
45
+ el.addEventListener("mouseleave", () => {
46
+ tooltipInstance.unmount();
47
+ document.body.removeChild(tooltipContainer);
48
+ });
49
+ },
50
+ };
package/src/index.js CHANGED
@@ -47,3 +47,4 @@ export { default as IbCheckboxCell } from "./components/Table/Cells/CheckboxCell
47
47
 
48
48
  // Directives
49
49
  export { OutsideDirective } from "./directives/outside/outside";
50
+ export { TooltipDirective } from "./directives/tooltip/tooltip";