feat(project): 모든 말풍선을 아사나식 공용 말풍선으로 통일
- 브라우저 기본 title 말풍선도 마우스를 올리는 순간 data-tip 으로 옮겨 공용 말풍선(.pj-hovertip)으로 표시 → 기존·신규 모든 title= 이 같은 모양. - 화면 끝 보정(말풍선은 안쪽, 꼬리는 커서 쪽), 위 공간 부족 시 아래로 뒤집기, 누르기·스크롤 시 숨김, 짧은 페이드인. - 대시보드 막대 툴팁도 같은 색·꼬리. - 규칙 문서화(PROJECT_MODULE.md 3절, CLAUDE.md). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+33
-7
@@ -5032,8 +5032,16 @@
|
||||
// ── 마우스를 따라다니는 작은 툴팁 — [data-tip] 달린 요소 아무데나 공용.
|
||||
// 지금은 제목 옆 프로젝트 멤버 아이콘(이름 표시)에 쓴다. 나중에 그려지는
|
||||
// 요소에도 붙도록 이벤트 위임 방식이다.
|
||||
// ── 공용 말풍선(아사나식: 어두운 배경 + 아래 꼬리, 커서 바로 위) ──
|
||||
// 프로젝트 화면의 "모든" 말풍선은 이것 하나로 통일한다(앞으로 추가하는 기능도).
|
||||
// · data-tip="문구" 를 달면 이 말풍선이 뜬다.
|
||||
// · 브라우저 기본 title 말풍선도 자동으로 이걸로 바뀐다 — 마우스를 올리는
|
||||
// 순간 title 을 data-tip 으로 옮기고 title 은 지운다(기본 말풍선 억제).
|
||||
// 그래서 새 코드에서 title= 을 써도 같은 모양이 된다.
|
||||
// 이벤트 위임이라 나중에 그려지는 요소도 따로 배선할 필요가 없다.
|
||||
function initHoverTips() {
|
||||
let tipEl = null;
|
||||
let shown = false;
|
||||
function show(text, x, y) {
|
||||
if (!tipEl) {
|
||||
tipEl = document.createElement("div");
|
||||
@@ -5041,20 +5049,38 @@
|
||||
document.body.appendChild(tipEl);
|
||||
}
|
||||
tipEl.textContent = text;
|
||||
tipEl.style.left = x + "px";
|
||||
tipEl.style.top = (y - 10) + "px";
|
||||
tipEl.hidden = false;
|
||||
// 화면 가장자리 보정 — 좌우로 넘치면 말풍선만 안쪽으로 밀고 꼬리는
|
||||
// 커서를 계속 가리키게(--pj-tip-shift). 위가 모자라면 커서 아래로 뒤집는다.
|
||||
const w = tipEl.offsetWidth, h = tipEl.offsetHeight;
|
||||
const vw = document.documentElement.clientWidth;
|
||||
const cx = Math.min(Math.max(x, 8 + w / 2), vw - 8 - w / 2);
|
||||
const below = y - 16 - h < 4;
|
||||
tipEl.classList.toggle("is-below", below);
|
||||
tipEl.style.setProperty("--pj-tip-shift", (x - cx) + "px");
|
||||
tipEl.style.left = cx + "px";
|
||||
tipEl.style.top = (below ? y + 22 : y - 10) + "px";
|
||||
}
|
||||
function hide() { if (tipEl) tipEl.hidden = true; }
|
||||
// 이벤트 위임 — 멤버 아이콘(renderMemberList)처럼 나중에 그려지는
|
||||
// 요소에도 따로 배선하지 않고 그대로 동작한다.
|
||||
let shown = false;
|
||||
function hide() { shown = false; if (tipEl) tipEl.hidden = true; }
|
||||
document.addEventListener("mouseover", function (e) {
|
||||
const el = e.target.closest ? e.target.closest("[title]") : null;
|
||||
if (!el) return;
|
||||
const t = el.getAttribute("title");
|
||||
if (t) el.dataset.tip = t; // 코드가 title 을 새로 바꿨으면 최신 값으로
|
||||
el.removeAttribute("title");
|
||||
}, true);
|
||||
document.addEventListener("mousemove", function (e) {
|
||||
const target = e.target.closest ? e.target.closest("[data-tip]") : null;
|
||||
if (!target) { if (shown) { shown = false; hide(); } return; }
|
||||
if (!target || !target.dataset.tip) { if (shown) hide(); return; }
|
||||
shown = true;
|
||||
show(target.dataset.tip, e.clientX, e.clientY);
|
||||
});
|
||||
// 누르거나 스크롤하면 숨긴다 — 클릭으로 요소가 다시 그려지면 말풍선만
|
||||
// 허공에 남는 일이 없게.
|
||||
document.addEventListener("mousedown", hide, true);
|
||||
window.addEventListener("scroll", hide, true);
|
||||
window.addEventListener("blur", hide);
|
||||
document.addEventListener("mouseleave", hide);
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
Reference in New Issue
Block a user