Skip to content

Commit

Permalink
🎨 新增 data-tooltipclass 属性用于自定义 tooltip 的额外类名
Browse files Browse the repository at this point in the history
  • Loading branch information
TCOTC committed Dec 21, 2024
1 parent 2ff40bd commit 337a5bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
11 changes: 4 additions & 7 deletions app/src/block/popover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,16 @@ export const initBlockPopover = (app: App) => {
}
const aElement = hasClosestByAttribute(event.target, "data-type", "a", true) ||
hasClosestByClassName(event.target, "ariaLabel") ||
hasClosestByAttribute(event.target, "data-type", "tab-header") ||
hasClosestByAttribute(event.target, "data-type", "inline-memo") ||
hasClosestByClassName(event.target, "av__calc--ashow") ||
hasClosestByClassName(event.target, "av__cell");
if (aElement) {
const tooltipClasses: string[] = [];
let tip = aElement.getAttribute("aria-label");
if (aElement.classList.contains("has-tooltip--warning")) {
tooltipClasses.push("error");
let tip = aElement.getAttribute("aria-label") || "";
if (aElement.hasAttribute("data-tooltipclass")) {
tooltipClasses.push(...aElement.getAttribute("data-tooltipclass").split(" "));
}
if (aElement.getAttribute("data-type") === "tab-header") {
tooltipClasses.push("tab_header");
} else if (aElement.classList.contains("av__cell")) {
if (aElement.classList.contains("av__cell")) {
if (aElement.classList.contains("av__cell--header")) {
const textElement = aElement.querySelector(".av__celltext");
const desc = aElement.getAttribute("data-desc");
Expand Down
3 changes: 2 additions & 1 deletion app/src/layout/Tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export class Tab {
this.headElement.setAttribute("data-type", "tab-header");
this.headElement.setAttribute("draggable", "true");
this.headElement.setAttribute("data-id", this.id);
this.headElement.classList.add("item", "item--focus");
this.headElement.setAttribute("data-tooltipclass", "tab_header");
this.headElement.classList.add("item", "item--focus", "ariaLabel");
let iconHTML = "";
if (options.icon) {
iconHTML = `<svg class="item__graphic"><use xlink:href="#${options.icon}"></use></svg>`;
Expand Down

0 comments on commit 337a5bf

Please sign in to comment.