UNPKG

@braze/web-sdk

Version:

Braze SDK for web sites and other JS platforms.

28 lines (27 loc) 801 B
import { addPassiveEventListener as J, buildSvg as oe } from "./dom-utils.js"; import { KeyCodes as ie } from "./key-codes.js"; export function createCloseButton(t, o, e, r = "ltr") { const n = document.createElement("button"); n.setAttribute("aria-label", t), n.setAttribute("role", "button"), (n.dir = r), J(n, "touchstart"), (n.className = "ab-close-button"); const l = oe( "0 0 15 15", "M15 1.5L13.5 0l-6 6-6-6L0 1.5l6 6-6 6L1.5 15l6-6 6 6 1.5-1.5-6-6 6-6z", o, ); return ( n.appendChild(l), l.setAttribute("aria-hidden", "true"), n.addEventListener("keydown", (t) => { (t.keyCode !== ie.$o && t.keyCode !== ie.Co) || (e(), t.stopPropagation()); }), (n.onclick = (t) => { e(), t.stopPropagation(); }), n ); }