injectStyles function

Last updated: 2026-03-05T10:53:28.862Z

Metrics

LOC: 43 Complexity: 2 Params: 0

Signature

injectStyles(): : void

Summary

Applies the label effect inline CSS styles once (idempotent).

Source Code

function injectStyles(): void {
  if (document.getElementById("fill-all-effect-label-styles")) return;
  const style = document.createElement("style");
  style.id = "fill-all-effect-label-styles";
  style.textContent = `
    .${LABEL_CLASS} {
      position: fixed;
      z-index: 2147483646;
      padding: 5px 10px;
      background: #1a1a2e;
      color: #e2e8f0;
      font-size: 13px;
      font-family: system-ui, sans-serif;
      border-radius: 6px;
      box-shadow: 0 4px 12px rgba(0,0,0,0.35);
      pointer-events: none;
      white-space: nowrap;
      opacity: 0;
      transform: translateY(4px);
      transition: opacity 220ms ease, transform 220ms ease;
    }
    .${LABEL_CLASS}.visible {
      opacity: 1;
      transform: translateY(0);
    }
    .${LABEL_CLASS}::after {
      content: "";
      position: absolute;
      border: 5px solid transparent;
    }
    .${LABEL_CLASS}[data-pos="above"]::after {
      top: 100%; left: 50%;
      transform: translateX(-50%);
      border-top-color: #1a1a2e;
    }
    .${LABEL_CLASS}[data-pos="below"]::after {
      bottom: 100%; left: 50%;
      transform: translateX(-50%);
      border-bottom-color: #1a1a2e;
    }
  `;
  document.head.appendChild(style);
}

Dependencies (Outgoing)

graph LR injectStyles["injectStyles"] LabelEffect["LabelEffect"] injectStyles -->|uses| LabelEffect style injectStyles fill:#dbeafe,stroke:#2563eb,stroke-width:2px click injectStyles "ece17e505c361d14.html" click LabelEffect "10549fdfe8660592.html"
TargetType
LabelEffect uses

No incoming dependencies.