@tiennm99/aboutme 1.0.1 → 1.2.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/aboutme.js CHANGED
@@ -1,18 +1,19 @@
1
- (()=>{var P="aboutme:hiddenUntil";var q=["home","blog","github","facebook","linkedin","x","youtube","email","link"],Q={m:6e4,h:36e5,d:864e5,w:6048e5},ee={m:"minute",h:"hour",d:"day",w:"week"},F=/^(\d{1,4})\s*([mhdw])$/i,te=/^[a-z0-9-]{1,32}$/;function H(t){let n=F.exec(String(t??"").trim());return!n||Number(n[1])===0?H("7d"):Number(n[1])*Q[n[2].toLowerCase()]}function N(t){let n=F.exec(String(t??"").trim());if(!n||Number(n[1])===0)return N("7d");let i=Number(n[1]),a=ee[n[2].toLowerCase()];return`${i} ${a}${i===1?"":"s"}`}function W(t,n){try{let i=Number(t?.getItem(P));return Number.isFinite(i)&&i>n}catch{return!1}}function X(t,n,i){try{t?.setItem(P,String(n+i))}catch{}}function I(t,n){if(typeof t!="string")return null;try{let i=new URL(t);return n.includes(i.protocol)?i.href:null}catch{return null}}function D(t,n){return typeof t=="string"?t.trim().slice(0,n):""}function j(t,n){if(!t||typeof t!="object"||t.schemaVersion!==1)return null;let i=D(t.name,60);if(!i)return null;let a=[],f=new Set;for(let s of Array.isArray(t.links)?t.links.slice(0,12):[]){let p=typeof s?.id=="string"&&te.test(s.id)?s.id:null,y=D(s?.label,40),o=I(s?.url,["https:","http:","mailto:"]);!p||!y||!o||f.has(p)||(f.add(p),a.push({id:p,label:y,url:o,icon:q.includes(s.icon)?s.icon:"link"}))}if(a.length===0)return null;let u=null;if(typeof t.events=="string")try{u=I(new URL(t.events,n).href,["https:","http:"])}catch{u=null}return{name:i,tagline:D(t.tagline,120),avatar:I(t.avatar,["https:"]),links:a,events:u}}var m=52,l=16,ne=6,oe=72,B={person:'<circle cx="12" cy="8" r="4"/><path d="M4 21c0-4 4-7 8-7s8 3 8 7"/>',close:'<path d="M6 6l12 12M18 6L6 18"/>',home:'<path d="M3 11l9-7 9 7v9a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z"/>',blog:'<path d="M4 20h4L19 9l-4-4L4 16z"/><path d="M14 6l4 4"/>',github:'<path d="M8 8l-4 4 4 4M16 8l4 4-4 4"/>',facebook:'<circle cx="9" cy="8" r="3"/><path d="M3 20c0-3 3-5 6-5s6 2 6 5"/><circle cx="17" cy="9" r="2.5"/><path d="M15 15c3 0 6 1.5 6 4.5"/>',linkedin:'<rect x="3" y="7" width="18" height="13" rx="2"/><path d="M9 7V5h6v2"/>',x:'<path d="M4 5h16v11H9l-5 4z"/>',youtube:'<rect x="3" y="6" width="18" height="12" rx="3"/><path d="M10 9l5 3-5 3z"/>',email:'<rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 7l9 6 9-6"/>',link:'<path d="M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1"/><path d="M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1"/>'},ie=`
1
+ (()=>{var ge="aboutme:hiddenUntil";var He=["home","blog","github","facebook","linkedin","x","youtube","email","telegram","cv","link"],Ie={m:6e4,h:36e5,d:864e5,w:6048e5},Te={m:"minute",h:"hour",d:"day",w:"week"},be=/^(\d{1,4})\s*([mhdw])$/i,_e=/^[a-z0-9-]{1,32}$/;function J(e){let n=be.exec(String(e??"").trim());return!n||Number(n[1])===0?J("7d"):Number(n[1])*Ie[n[2].toLowerCase()]}function Z(e){let n=be.exec(String(e??"").trim());if(!n||Number(n[1])===0)return Z("7d");let o=Number(n[1]),r=Te[n[2].toLowerCase()];return`${o} ${r}${o===1?"":"s"}`}function ve(e,n){try{let o=Number(e?.getItem(ge));return Number.isFinite(o)&&o>n}catch{return!1}}function xe(e,n,o){try{e?.setItem(ge,String(n+o))}catch{}}function K(e,n){if(typeof e!="string")return null;try{let o=new URL(e);return n.includes(o.protocol)?o.href:null}catch{return null}}function q(e,n){return typeof e=="string"?e.trim().slice(0,n):""}function we(e,n){if(!e||typeof e!="object"||e.schemaVersion!==1)return null;let o=q(e.name,60);if(!o)return null;let r=[],d=new Set;for(let i of Array.isArray(e.links)?e.links.slice(0,12):[]){let m=typeof i?.id=="string"&&_e.test(i.id)?i.id:null,g=q(i?.label,40),w=K(i?.url,["https:","http:","mailto:"]);!m||!g||!w||d.has(m)||(d.add(m),r.push({id:m,label:g,url:w,icon:He.includes(i.icon)?i.icon:"link"}))}if(r.length===0)return null;let h=null;if(typeof e.events=="string")try{h=K(new URL(e.events,n).href,["https:","http:"])}catch{h=null}return{name:o,tagline:q(e.tagline,120),avatar:K(e.avatar,["https:"]),links:r,events:h}}var Ce=/^(rgba?|oklch|oklab|lab|lch|color)\((.*)\)$/i;function C(e,n){return e==="none"?0:e?.endsWith("%")?parseFloat(e)/100*n:parseFloat(e??"")}function me(e){let n=Ce.exec(String(e??"").trim());if(!n)return null;let o=n[1].toLowerCase(),r=n[2].split(/[\s,/]+/).filter(Boolean),d;if(o==="color"){let i=r.shift()?.toLowerCase();if(i!=="srgb"&&i!=="srgb-linear"&&i!=="display-p3")return null;let m=a=>i!=="srgb-linear"?a:a<=.0031308?12.92*a:1.055*a**(1/2.4)-.055,[g,w,s]=r.slice(0,3).map(a=>m(C(a,1)));d=.299*g+.587*w+.114*s}else if(o.startsWith("rgb")){let[i,m,g]=r.map(w=>C(w,255));d=(.299*i+.587*m+.114*g)/255}else d=C(r[0],1)/(o.startsWith("ok")||r[0]?.endsWith("%")?1:100);let h=r.length>3?C(r[3],1):1;return!Number.isFinite(d)||!(h>=.5)?null:Math.min(Math.max(d,0),1)}function ye({backgrounds:e,markers:n,text:o,prefersDark:r}){for(let h of e){let i=me(h);if(i!==null)return i<.5?"dark":"light"}for(let h of n){let i=h?.trim().toLowerCase();if(i==="dark"||i==="light")return i}let d=me(o);return d!==null&&d>.6?"dark":d!==null&&d<.4?"light":r?"dark":"light"}var u=52,f=16,k=8,ee=280,De=160,ze=2,Ne=f*2+u+k+ee,Re=6,$e=72,Oe=["data-theme","data-bs-theme","data-mode","data-color-mode","data-color-scheme"],ke={person:'<circle cx="12" cy="8" r="4"/><path d="M4 21c0-4 4-7 8-7s8 3 8 7"/>',close:'<path d="M6 6l12 12M18 6L6 18"/>',home:'<path d="M3 11l9-7 9 7v9a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z"/>',blog:'<path d="M4 20h4L19 9l-4-4L4 16z"/><path d="M14 6l4 4"/>',github:'<path d="M8 8l-4 4 4 4M16 8l4 4-4 4"/>',facebook:'<circle cx="9" cy="8" r="3"/><path d="M3 20c0-3 3-5 6-5s6 2 6 5"/><circle cx="17" cy="9" r="2.5"/><path d="M15 15c3 0 6 1.5 6 4.5"/>',linkedin:'<rect x="3" y="7" width="18" height="13" rx="2"/><path d="M9 7V5h6v2"/>',x:'<path d="M4 5h16v11H9l-5 4z"/>',youtube:'<rect x="3" y="6" width="18" height="12" rx="3"/><path d="M10 9l5 3-5 3z"/>',email:'<rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 7l9 6 9-6"/>',telegram:'<path d="M21 4L3 11l6 2 2 6 3-4 5 4z"/><path d="M9 13l12-9"/>',cv:'<path d="M6 3h9l4 4v14H6z"/><path d="M14 3v5h5M9 12h7M9 16h7"/>',link:'<path d="M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1"/><path d="M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1"/>'},Ue=`
2
2
  :host { all: initial; }
3
3
  * { box-sizing: border-box; }
4
4
  .root {
5
5
  --bg: #ffffff; --fg: #1f2328; --muted: #59636e; --line: #d1d9e0; --hover: #f2f4f6;
6
6
  --accent: #2563eb; --accent-fg: #ffffff; --danger: #dc2626;
7
7
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
8
- color: var(--fg);
8
+ color: var(--fg); color-scheme: light;
9
9
  }
10
- @media (prefers-color-scheme: dark) {
11
- .root { --bg: #1c2128; --fg: #e6edf3; --muted: #9198a1; --line: #3d444d; --hover: #262c36; --accent: #4493f8; }
10
+ .root[data-t="dark"] {
11
+ --bg: #1c2128; --fg: #e6edf3; --muted: #9198a1; --line: #3d444d; --hover: #262c36; --accent: #4493f8;
12
+ color-scheme: dark;
12
13
  }
13
14
  svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
14
15
  .bubble {
15
- position: fixed; left: 0; top: 0; width: ${m}px; height: ${m}px; z-index: 2147483001;
16
+ position: fixed; left: 0; top: 0; width: ${u}px; height: ${u}px; z-index: 2147483001;
16
17
  border: 0; border-radius: 50%; padding: 0; cursor: grab; touch-action: none; user-select: none;
17
18
  background: var(--accent); color: var(--accent-fg); display: grid; place-items: center; overflow: hidden;
18
19
  box-shadow: 0 4px 14px rgb(0 0 0 / 25%); transition: transform .2s ease;
@@ -20,31 +21,38 @@ svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width:
20
21
  .bubble svg { width: 26px; height: 26px; }
21
22
  .bubble img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
22
23
  .bubble:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
24
+ a:focus-visible { outline-offset: -3px; }
23
25
  .bubble.dragging { cursor: grabbing; transition: none; }
24
26
  .panel {
25
- position: fixed; z-index: 2147483000; width: min(280px, calc(100vw - ${l*2}px));
27
+ position: fixed; z-index: 2147483000; width: ${ee}px; display: flex; flex-direction: column;
26
28
  background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 12px;
27
- box-shadow: 0 8px 30px rgb(0 0 0 / 20%);
29
+ box-shadow: 0 8px 30px rgb(0 0 0 / 20%); animation: open .12s ease-out;
30
+ overflow-y: auto; overscroll-behavior: contain;
28
31
  }
32
+ .panel.over { z-index: 2147483002; }
29
33
  .panel[hidden] { display: none; }
30
- .head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
34
+ @keyframes open { from { opacity: 0; transform: translateY(4px) scale(.98); } }
35
+ .head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex: none; }
31
36
  .head img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
32
37
  .who { flex: 1; min-width: 0; }
33
- .name { font-weight: 600; }
34
- .tagline { color: var(--muted); font-size: 13px; }
35
- .icon-btn { border: 0; background: none; color: var(--muted); padding: 4px; border-radius: 6px; cursor: pointer; display: grid; }
38
+ .name, .tagline { overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
39
+ .name { font-weight: 600; -webkit-line-clamp: 2; line-clamp: 2; }
40
+ .tagline { color: var(--muted); font-size: 13px; -webkit-line-clamp: 3; line-clamp: 3; }
41
+ .icon-btn { border: 0; background: none; color: var(--muted); padding: 4px; border-radius: 6px; cursor: pointer; display: grid; align-self: flex-start; }
36
42
  .icon-btn:hover { background: var(--hover); color: var(--fg); }
37
- ul { list-style: none; margin: 0; padding: 0; }
43
+ ul { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
38
44
  a { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; color: var(--fg); text-decoration: none; }
39
45
  a:hover { background: var(--hover); }
40
- .hide { width: 100%; margin-top: 8px; padding: 6px; border: 0; border-top: 1px solid var(--line); background: none; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
46
+ a span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
47
+ .hide { flex: none; width: 100%; margin-top: 8px; padding: 6px; border: 0; border-top: 1px solid var(--line); background: none; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
41
48
  .hide:hover { color: var(--fg); }
42
49
  .target {
43
- position: fixed; left: 50%; bottom: 32px; width: 64px; height: 64px; margin-left: -32px; z-index: 2147483000;
50
+ position: fixed; left: 0; top: 0; width: 64px; height: 64px; z-index: 2147483000;
44
51
  border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgb(0 0 0 / 55%);
45
52
  border: 2px solid rgb(255 255 255 / 70%); transition: transform .15s ease, background .15s ease; pointer-events: none;
46
53
  }
47
54
  .target[hidden] { display: none; }
48
55
  .target.active { transform: scale(1.25); background: var(--danger); }
49
- @media (prefers-reduced-motion: reduce) { .bubble, .target { transition: none; } }
50
- `;function k(t){let n=document.createElementNS("http://www.w3.org/2000/svg","svg");return n.setAttribute("viewBox","0 0 24 24"),n.setAttribute("aria-hidden","true"),n.innerHTML=B[t]??B.link,n}function r(t,n,i){let a=document.createElement(t);return n&&(a.className=n),i&&(a.textContent=i),a}function G({profile:t,position:n,hide:i,track:a,onDismiss:f}){let u=document.createElement("aboutme-widget"),s=u.attachShadow({mode:"open"}),p=r("div","root"),y=r("style");y.textContent=ie;let o=r("button","bubble");if(o.type="button",o.setAttribute("aria-label",`About ${t.name}`),o.setAttribute("aria-expanded","false"),o.setAttribute("aria-controls","aboutme-panel"),o.title="Drag to the bottom to hide",t.avatar){let e=r("img");e.alt="",e.src=t.avatar,e.addEventListener("error",()=>e.replaceWith(k("person")),{once:!0}),o.append(e)}else o.append(k("person"));let d=r("div","panel");d.id="aboutme-panel",d.setAttribute("role","dialog"),d.setAttribute("aria-label",`About ${t.name}`),d.hidden=!0;let A=r("div","head");if(t.avatar){let e=r("img");e.alt="",e.src=t.avatar,A.append(e)}let S=r("div","who");S.append(r("div","name",t.name)),t.tagline&&S.append(r("div","tagline",t.tagline));let L=r("button","icon-btn");L.type="button",L.setAttribute("aria-label","Close"),L.append(k("close")),A.append(S,L);let R=r("ul");for(let e of t.links){let b=r("li"),h=r("a");h.href=e.url,h.target="_blank",h.rel="noopener noreferrer",h.append(k(e.icon),r("span","",e.label)),h.addEventListener("click",()=>a("click",e.id)),b.append(h),R.append(b)}let _=r("button","hide",`Hide for ${N(i)}`);_.type="button",d.append(A,R,_);let x=r("div","target");x.hidden=!0,x.append(k("close")),p.append(y,d,x,o),s.append(p),document.body.append(u);let v=0,g=0,E=n;function T(){o.style.transform=`translate(${v}px, ${g}px)`}function M(){let e=window.innerHeight-m-l;E=v+m/2<window.innerWidth/2?"left":"right",v=E==="left"?l:window.innerWidth-m-l,g=Math.min(Math.max(g,l),Math.max(e,l)),T()}function J(){let e=d.offsetWidth,b=d.offsetHeight,h=E==="left"?l:window.innerWidth-e-l,Y=g-b-8,Z=Y>=l?Y:Math.min(g+m+8,window.innerHeight-b-l);d.style.left=`${Math.max(h,l)}px`,d.style.top=`${Math.max(Z,l)}px`}function w(e){e!==!d.hidden&&(d.hidden=!e,o.setAttribute("aria-expanded",String(e)),e&&(J(),a("open")))}function U(){a("dismiss"),u.remove(),window.removeEventListener("resize",M),document.removeEventListener("pointerdown",$,!0),document.removeEventListener("keydown",C),f()}function $(e){e.composedPath().includes(u)||w(!1)}function C(e){e.key==="Escape"&&!d.hidden&&(w(!1),o.focus())}function z(){let e=x.getBoundingClientRect(),b=v+m/2-(e.left+e.width/2),h=g+m/2-(e.top+e.height/2);return Math.hypot(b,h)<oe}let c=null;o.addEventListener("pointerdown",e=>{e.button===0&&(c={id:e.pointerId,startX:e.clientX,startY:e.clientY,dx:e.clientX-v,dy:e.clientY-g,moved:!1},o.setPointerCapture(e.pointerId))}),o.addEventListener("pointermove",e=>{!c||e.pointerId!==c.id||!c.moved&&Math.hypot(e.clientX-c.startX,e.clientY-c.startY)<ne||(c.moved||(c.moved=!0,o.classList.add("dragging"),x.hidden=!1,w(!1)),v=e.clientX-c.dx,g=e.clientY-c.dy,T(),x.classList.toggle("active",z()))});function O(e){if(!c||e.pointerId!==c.id)return;let{moved:b}=c;if(c=null,!b){e.type==="pointerup"&&w(d.hidden);return}o.classList.remove("dragging");let h=e.type==="pointerup"&&z();x.hidden=!0,x.classList.remove("active"),h?U():M()}return o.addEventListener("pointerup",O),o.addEventListener("pointercancel",O),o.addEventListener("click",e=>{e.detail===0&&w(d.hidden)}),L.addEventListener("click",()=>{w(!1),o.focus()}),_.addEventListener("click",U),window.addEventListener("resize",M),document.addEventListener("pointerdown",$,!0),document.addEventListener("keydown",C),o.classList.add("dragging"),v=E==="left"?0:window.innerWidth,g=window.innerHeight-m-l*2,M(),o.getBoundingClientRect(),o.classList.remove("dragging"),u}function V(){try{return window.localStorage}catch{return null}}function re(t,n,i){if(t)try{fetch(t,{method:"POST",mode:"cors",credentials:"omit",keepalive:!0,headers:{"content-type":"text/plain"},body:JSON.stringify(i?{event:n,target:i}:{event:n})}).catch(()=>{})}catch{}}async function ae(t){let n=t.dataset.profile,i=t.dataset.hide,a=t.dataset.position==="left"?"left":"right";if(!n||W(V(),Date.now()))return;let f;try{let s=new URL(n,document.baseURI).href,p=await fetch(s,{credentials:"omit"});if(!p.ok)return;f=j(await p.json(),s)}catch{return}if(!f)return;let u=()=>G({profile:f,position:a,hide:i??"",track:(s,p)=>re(f.events,s,p),onDismiss:()=>X(V(),Date.now(),H(i))});document.body?u():document.addEventListener("DOMContentLoaded",u,{once:!0})}var K=document.currentScript;K instanceof HTMLScriptElement&&!window.__aboutmeLoaded&&(window.__aboutmeLoaded=!0,ae(K));})();
56
+ @media (prefers-reduced-motion: reduce) { .bubble, .target { transition: none; } .panel { animation: none; } }
57
+ @media print { .root { display: none; } }
58
+ `;function S(e){let n=document.createElementNS("http://www.w3.org/2000/svg","svg");return n.setAttribute("viewBox","0 0 24 24"),n.setAttribute("aria-hidden","true"),n.innerHTML=ke[e]??ke.link,n}function p(e,n,o){let r=document.createElement(e);return n&&(r.className=n),o&&(r.textContent=o),r}function M(){let e=document.compatMode==="BackCompat"?document.body:document.documentElement,n={w:e.clientWidth,h:e.clientHeight},o=window.visualViewport;return o&&o.scale<1&&(n.w=Math.max(n.w,o.width),n.h=Math.max(n.h,o.height)),n}function Q(e,n,o){return Math.max(Math.min(e,o),n)}function Fe(e){let n=[document.documentElement,document.body],o=[];for(let r of n)o.push(...["dark","light"].filter(d=>r.classList.contains(d))),o.push(...Oe.map(d=>r.getAttribute(d)));return ye({backgrounds:[n[1],n[0]].map(r=>getComputedStyle(r).backgroundColor),markers:o,text:getComputedStyle(n[1]).color,prefersDark:e.matches})}function Ee({profile:e,position:n,theme:o,hide:r,track:d,onDismiss:h}){let i=document.createElement("aboutme-widget"),m=i.attachShadow({mode:"open"}),g=p("div","root"),w=p("style");w.textContent=Ue;let s=p("button","bubble");if(s.type="button",s.setAttribute("aria-label",`About ${e.name}`),s.setAttribute("aria-expanded","false"),s.setAttribute("aria-controls","aboutme-panel"),s.title="Drag to the bottom to hide",e.avatar){let t=p("img");t.alt="",t.src=e.avatar,t.addEventListener("error",()=>t.replaceWith(S("person")),{once:!0}),s.append(t)}else s.append(S("person"));let a=p("div","panel");a.id="aboutme-panel",a.setAttribute("role","dialog"),a.setAttribute("aria-label",`About ${e.name}`),a.hidden=!0;let D=p("div","head");if(e.avatar){let t=p("img");t.alt="",t.src=e.avatar,D.append(t)}let z=p("div","who");z.append(p("div","name",e.name)),e.tagline&&z.append(p("div","tagline",e.tagline));let A=p("button","icon-btn");A.type="button",A.setAttribute("aria-label","Close"),A.append(S("close")),D.append(z,A);let y=p("ul");for(let t of e.links){let c=p("li"),l=p("a");l.href=t.url,l.target="_blank",l.rel="noopener noreferrer",l.title=t.label,l.append(S(t.icon),p("span","",t.label)),l.addEventListener("click",()=>d("click",t.id)),c.append(l),y.append(c)}let N=p("button","hide",`Hide for ${Z(r)}`);N.type="button",a.append(D,y,N);let x=p("div","target");x.hidden=!0,x.append(S("close")),g.append(w,s,a,x),m.append(g),document.body.append(i);let R=window.matchMedia("(prefers-color-scheme: dark)"),$=0,O=0,H=null,U=null;function I(){g.dataset.t=o==="auto"?Fe(R):o}function F(){cancelAnimationFrame($),$=requestAnimationFrame(I),clearTimeout(O),O=setTimeout(I,400)}let E=0,v=0,T=n,B=!0,P=f*2,te=1,W=M();function ne(){s.style.transform=`translate(${E}px, ${v}px)`}function Y(){let{w:t,h:c}=M(),l=Math.min(P,te*(c-u));E=T==="left"?f:t-u-f,v=Q(B?c-u-l:l,f,c-u-f),W={w:t,h:c},ne()}function Ae(){let{w:t,h:c}=M();T=E+u/2<t/2?"left":"right",B=v+u/2>c/2;let l=Q(v,f,c-u-f);P=B?c-u-l:l,te=c>u?P/(c-u):1,Y()}function oe(){let{w:t,h:c}=M(),l=v-k-f,de=c-v-u-k-f,le=Math.max(l,de),ue=Math.min(ee,t-f*2);a.style.width=`${ue}px`,a.style.maxHeight="none",y.style.minHeight="0px";let pe=y.firstElementChild?.offsetHeight??0,Se=a.offsetHeight-y.offsetHeight,_=le<Math.max(De,Se+Math.min(y.scrollHeight,pe*ze)),he=_&&t>=Ne;a.classList.toggle("over",_&&!he),y.style.minHeight=`${Math.min(y.scrollHeight,pe)}px`,a.style.maxHeight=`${Math.max(_?c-f*2:le,0)}px`;let j=a.offsetHeight,fe=T==="left"?f:t-f-ue,G;_?(he&&(fe+=T==="left"?u+k:-u-k),G=Q(v+u/2-j/2,f,c-f-j)):G=l>=de?v-k-j:v+u+k,a.style.left=`${fe}px`,a.style.top=`${G}px`}function V(){b?.moved||(Y(),a.hidden||oe())}function X(){let{w:t,h:c}=M();(t!==W.w||c!==W.h)&&V()}function L(t){t!==!a.hidden&&(a.hidden=!t,s.setAttribute("aria-expanded",String(t)),t&&(I(),oe(),d("open")))}function ie(){d("dismiss"),i.remove(),window.removeEventListener("resize",V),window.visualViewport?.removeEventListener("resize",X),document.removeEventListener("pointerdown",re,!0),document.removeEventListener("keydown",ae),R.removeEventListener("change",F),H?.disconnect(),U?.disconnect(),cancelAnimationFrame($),clearTimeout(O),h()}function re(t){t.composedPath().includes(i)||L(!1)}function ae(t){t.key==="Escape"&&!a.hidden&&(L(!1),s.focus())}function se(){let t=x.getBoundingClientRect(),c=E+u/2-(t.left+t.width/2),l=v+u/2-(t.top+t.height/2);return Math.hypot(c,l)<$e}let b=null;s.addEventListener("pointerdown",t=>{t.button===0&&(b={id:t.pointerId,startX:t.clientX,startY:t.clientY,dx:t.clientX-E,dy:t.clientY-v,moved:!1},s.setPointerCapture(t.pointerId))}),s.addEventListener("pointermove",t=>{if(!(!b||t.pointerId!==b.id)&&!(!b.moved&&Math.hypot(t.clientX-b.startX,t.clientY-b.startY)<Re)){if(!b.moved){b.moved=!0,s.classList.add("dragging");let{w:c,h:l}=M();x.style.left=`${c/2-32}px`,x.style.top=`${l-96}px`,x.hidden=!1,L(!1)}E=t.clientX-b.dx,v=t.clientY-b.dy,ne(),x.classList.toggle("active",se())}});function ce(t){if(!b||t.pointerId!==b.id)return;let{moved:c}=b;if(b=null,!c){t.type==="pointerup"&&L(a.hidden);return}s.classList.remove("dragging");let l=t.type==="pointerup"&&se();x.hidden=!0,x.classList.remove("active"),l?ie():Ae()}return s.addEventListener("pointerup",ce),s.addEventListener("pointercancel",ce),s.addEventListener("click",t=>{t.detail===0&&L(a.hidden)}),A.addEventListener("click",()=>{L(!1),s.focus()}),N.addEventListener("click",ie),window.addEventListener("resize",V),window.visualViewport?.addEventListener("resize",X),window.ResizeObserver&&(U=new ResizeObserver(X),U.observe(document.compatMode==="BackCompat"?document.body:document.documentElement)),document.addEventListener("pointerdown",re,!0),document.addEventListener("keydown",ae),I(),o==="auto"&&(R.addEventListener("change",F),H=new MutationObserver(F),H.observe(document.documentElement,{attributes:!0}),H.observe(document.body,{attributes:!0})),s.classList.add("dragging"),Y(),s.getBoundingClientRect(),s.classList.remove("dragging"),i}function Le(){try{return window.localStorage}catch{return null}}function Be(e,n,o){if(e)try{fetch(e,{method:"POST",mode:"cors",credentials:"omit",keepalive:!0,headers:{"content-type":"text/plain"},body:JSON.stringify(o?{event:n,target:o}:{event:n})}).catch(()=>{})}catch{}}async function Pe(e){let n=e.dataset.profile,o=e.dataset.hide,r=e.dataset.position==="left"?"left":"right",d=["light","dark"].includes(e.dataset.theme)?e.dataset.theme:"auto";if(!n||ve(Le(),Date.now()))return;let h;try{let m=new URL(n,document.baseURI).href,g=await fetch(m,{credentials:"omit"});if(!g.ok)return;h=we(await g.json(),m)}catch{return}if(!h)return;let i=()=>Ee({profile:h,position:r,theme:d,hide:o??"",track:(m,g)=>Be(h.events,m,g),onDismiss:()=>xe(Le(),Date.now(),J(o))});document.body?i():document.addEventListener("DOMContentLoaded",i,{once:!0})}var Me=document.currentScript;Me instanceof HTMLScriptElement&&!window.__aboutmeLoaded&&(window.__aboutmeLoaded=!0,Pe(Me));})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiennm99/aboutme",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
4
4
  "description": "A draggable floating bubble that shows links about the site's author, loaded from a profile JSON.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -26,7 +26,7 @@
26
26
  "label": { "type": "string", "minLength": 1, "maxLength": 40 },
27
27
  "url": { "type": "string", "pattern": "^(https?:|mailto:)" },
28
28
  "icon": {
29
- "enum": ["home", "blog", "github", "facebook", "linkedin", "x", "youtube", "email", "link"]
29
+ "enum": ["home", "blog", "github", "facebook", "linkedin", "x", "youtube", "email", "telegram", "cv", "link"]
30
30
  }
31
31
  }
32
32
  }