<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Kole UI · NotificationPro（普通 H5）</title>
  <link rel="stylesheet" href="../.design_library/kole-ui/colors_and_type.css" />
  <link rel="stylesheet" href="NotificationPro.css" />
  <style>body{margin:0;padding:24px;background: var(--kole-color-page-bg);display:flex;gap:8px;flex-wrap:wrap;}</style>
</head>
<body>
  <button onclick="KoleNotify.success('审批通过', '订单 ORD-2024 已通过主管审批')">success</button>
  <button onclick="KoleNotify.error('提交失败', '网络异常，请稍后重试')">error</button>
  <button onclick="KoleNotify.warning('存储空间不足', '当前已使用 92%')">warning</button>
  <button onclick="KoleNotify.info('新版本', '系统已发布 v2.3.0')">info</button>

  <script>
    (function () {
      var ICON = { success: '✓', error: '✕', warning: '!', info: 'i' };
      var wrap = document.createElement('div');
      wrap.className = 'kole-notification-wrap';
      document.body.appendChild(wrap);
      var id = 0;
      function open(opts) {
        var el = document.createElement('div');
        el.className = 'kole-notification is-' + opts.type;
        el.innerHTML = '<span class="kole-notification-icon" aria-live="polite">' + (ICON[opts.type] || 'i') + '</span>' +
          '<div class="kole-notification-body" aria-live="polite"><div class="kole-notification-title" aria-live="polite">' + opts.title + '</div>' +
          '<div class="kole-notification-desc" aria-live="polite">' + opts.desc + '</div></div>' +
          '<span class="kole-notification-close" role="status" aria-live="polite">✕</span>';
        wrap.appendChild(el);
        var myId = ++id;
        function close() { if (el.parentNode) el.parentNode.removeChild(el); }
        el.querySelector('.kole-notification-close').addEventListener('click', close);
        var d = opts.duration == null ? 4500 : opts.duration;
        if (d > 0) setTimeout(close, d);
        return close;
      }
      window.KoleNotify = {
        success: function (t, d, dur) { return open({ type: 'success', title: t, desc: d, duration: dur }); },
        error: function (t, d, dur) { return open({ type: 'error', title: t, desc: d, duration: dur }); },
        warning: function (t, d, dur) { return open({ type: 'warning', title: t, desc: d, duration: dur }); },
        info: function (t, d, dur) { return open({ type: 'info', title: t, desc: d, duration: dur }); },
        open: open
      };
    })();
  </script>
</body>
</html>
