@erain20029/tooltips 0.1.0 → 1.1.0
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/dist/tooltip-overlay.umd.cjs +12 -35
- package/dist/tooltip.css +36 -36
- package/package.json +2 -2
|
@@ -1,39 +1,16 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
<div class="
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
id="tooltip-image"
|
|
7
|
-
src="${n}${e.image}"
|
|
8
|
-
>
|
|
9
|
-
</div>
|
|
10
|
-
`:""}
|
|
11
|
-
<div class="text-container">
|
|
12
|
-
${r.image==="left"?`
|
|
13
|
-
<img
|
|
14
|
-
id="tooltip-image"
|
|
15
|
-
src="${n}${e.image}"
|
|
16
|
-
>
|
|
17
|
-
`:""}
|
|
18
|
-
<div class="text-content">
|
|
19
|
-
<div>
|
|
20
|
-
<span style="font-size: ${i.title}px; text-align: ${r.title}">
|
|
21
|
-
${e.title}
|
|
22
|
-
</span>
|
|
23
|
-
</div>
|
|
1
|
+
(function(d){typeof define=="function"&&define.amd?define(d):d()})((function(){"use strict";const d=".overlay{background:#fff;color:#111;position:fixed;border-radius:10px;z-index:99999;box-shadow:0 0 34px #223c5033;overflow:hidden}.tooltip-card{display:flex;gap:16px;padding:16px 20px;max-width:500px;box-sizing:border-box}.tooltip-media{flex:0 0 120px;display:flex;align-items:flex-start}.tooltip-image{width:120px;height:120px;object-fit:cover;border-radius:8px}.tooltip-text{flex:1;min-width:0;display:flex;flex-direction:column;gap:8px}.tooltip-title{font-weight:600;line-height:1.3}.tooltip-desc{line-height:1.5;overflow-wrap:anywhere}",p={tooltips:[],ready:!1},g=new Set;function x(t){return g.has(t)?Promise.resolve():new Promise((e,o)=>{const i=document.createElement("script");i.src=t,i.async=!0,i.onload=()=>{g.add(t),e()},i.onerror=()=>o(new Error(`Failed to load script: ${t}`)),document.head.appendChild(i)})}async function w(){if(p.ready)return;const t=localStorage.getItem("product");if(!t)return;const e=JSON.parse(t).id;await x(`http://localhost:3000/documentation/${e}/tooltip.js`),p.tooltips=await window.tooltipGetter(),p.ready=!0}document.addEventListener("mouseenter",async t=>{await w();const e=t.target;if(!e||!(e instanceof Element))return;const o=p.tooltips.find(E=>e.matches(E.selector));if(!o)return;const i=e.getBoundingClientRect(),l=S(i),{x:n,y:a}=b(l,i.left,i.top);C({tooltip:o,rect:i,x:n,y:a})},!0),document.addEventListener("mouseleave",t=>{r&&(t.target===r||t.target===m)&&h()},!0);function v({title:t,description:e,image:o}){const i=n=>n==="center"||n==="right"?n:"left",l=n=>n==="top"||n==="right"?n:"left";return{title:i(t),description:i(e),image:l(o)}}function y({title:t,description:e}){const o={small:14,medium:16,large:20};return{title:o[t]??16,description:o[e]??14}}const f=500,u=200;let s=0,c=0,r=null,m=null;function h(){r&&(r.remove(),r=null,m=null)}function b(t,e,o){switch(t){case"left-bottom":s=e,c=o+36;break;case"right-bottom":s=e-f+45,c=o+36;break;case"left-top":s=e,c=o-u-18;break;case"right-top":s=e-f+45,c=o-u-18;break}return{x:s,y:c}}function T(){const t=document.createElement("style");t.textContent=d,document.body.appendChild(t)}function $(t){const e=document.createElement("div");return e.className=t,e}function C(t){if(!t?.tooltip)return null;h();const e=t.tooltip,o=$("overlay");o.style.position="fixed",o.style.width=`${f}px`,o.style.height=`${u}px`,o.style.left=`${t.x}px`,o.style.top=`${t.y}px`,y({title:e.size.title,description:e.size.description}),v({title:e.position.title,description:e.position.description,image:e.position.image}),console.log(e);const l=e.image?`<img class="tooltip-image" src="http://localhost:3000${e.image}" alt="" />`:"";return o.innerHTML=`
|
|
2
|
+
<div class="tooltip-card">
|
|
3
|
+
<div class="tooltip-media">
|
|
4
|
+
${l}
|
|
5
|
+
</div>
|
|
24
6
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
7
|
+
<div class="tooltip-text">
|
|
8
|
+
<div class="tooltip-title">
|
|
9
|
+
${e.title}
|
|
10
|
+
</div>
|
|
11
|
+
<div class="tooltip-desc">
|
|
12
|
+
${e.description}
|
|
30
13
|
</div>
|
|
31
|
-
${r.image==="right"?`
|
|
32
|
-
<img
|
|
33
|
-
id="tooltip-image"
|
|
34
|
-
src="${n}${e.image}"
|
|
35
|
-
>
|
|
36
|
-
`:""}
|
|
37
14
|
</div>
|
|
38
15
|
</div>
|
|
39
|
-
`,document.body.appendChild(o)
|
|
16
|
+
`,document.body.appendChild(o),T(),r=o,m=t.rect,o}function S(t){const e=window.innerWidth/2,o=window.innerHeight/2,i=t.left+t.width/2,l=t.top+t.height/2,n=i<e,a=l<o;return n&&a?"left-bottom":!n&&a?"right-bottom":n&&!a?"left-top":"right-top"}}));
|
package/dist/tooltip.css
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
1
|
.overlay {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
box-shadow: 0px 0px 34px 0px rgba(34, 60, 80, 0.2);
|
|
2
|
+
background: white;
|
|
3
|
+
color: #111;
|
|
4
|
+
position: fixed;
|
|
5
|
+
border-radius: 10px;
|
|
6
|
+
z-index: 99999;
|
|
7
|
+
box-shadow: 0 0 34px rgba(34, 60, 80, 0.2);
|
|
8
|
+
overflow: hidden;
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
padding: 0 24px;
|
|
11
|
+
.tooltip-card {
|
|
12
|
+
display: flex;
|
|
13
|
+
gap: 16px;
|
|
14
|
+
padding: 16px 20px;
|
|
15
|
+
max-width: 500px;
|
|
16
|
+
box-sizing: border-box;
|
|
19
17
|
}
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
/* КАРТИНКА */
|
|
20
|
+
.tooltip-media {
|
|
21
|
+
flex: 0 0 120px; /* фикс */
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: flex-start; /* ❗ не center */
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
.
|
|
26
|
-
|
|
26
|
+
.tooltip-image {
|
|
27
|
+
width: 120px;
|
|
28
|
+
height: 120px;
|
|
29
|
+
object-fit: cover;
|
|
30
|
+
border-radius: 8px;
|
|
27
31
|
}
|
|
28
32
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
.tooltip-text {
|
|
34
|
+
flex: 1;
|
|
35
|
+
min-width: 0;
|
|
36
|
+
display: flex;
|
|
37
|
+
flex-direction: column;
|
|
38
|
+
gap: 8px;
|
|
33
39
|
}
|
|
34
40
|
|
|
35
|
-
.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
font-weight: 300;
|
|
39
|
-
display: block;
|
|
40
|
-
text-align-last: "center";
|
|
41
|
-
line-height: 1.5;
|
|
42
|
-
letter-spacing: .2px;
|
|
43
|
-
hyphens: auto;
|
|
44
|
-
overflow-wrap: break-word
|
|
41
|
+
.tooltip-title {
|
|
42
|
+
font-weight: 600;
|
|
43
|
+
line-height: 1.3;
|
|
45
44
|
}
|
|
46
45
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
.tooltip-desc {
|
|
47
|
+
line-height: 1.5;
|
|
48
|
+
overflow-wrap: anywhere;
|
|
49
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@erain20029/tooltips",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "1.1.0",
|
|
5
5
|
"description": "Universal tooltip overlay for any HTML project",
|
|
6
6
|
"main": "dist/tooltip-overlay.js",
|
|
7
7
|
"style": "dist/tooltip.css",
|
|
@@ -41,4 +41,4 @@
|
|
|
41
41
|
"typescript-eslint": "^8.46.4",
|
|
42
42
|
"vite": "^7.2.4"
|
|
43
43
|
}
|
|
44
|
-
}
|
|
44
|
+
}
|