overview.html 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Layer - Overview</title>
  7. <link rel="stylesheet" href="../demo.css">
  8. <style>
  9. .row {
  10. display: flex;
  11. flex-wrap: wrap;
  12. gap: 10px;
  13. align-items: center;
  14. }
  15. .btn {
  16. appearance: none;
  17. border: 1px solid rgba(255,255,255,0.12);
  18. background: rgba(255,255,255,0.04);
  19. color: #fff;
  20. border-radius: 999px;
  21. padding: 10px 14px;
  22. font-weight: 650;
  23. cursor: pointer;
  24. transition: border-color 0.15s ease, background 0.15s ease;
  25. }
  26. .btn:hover { border-color: rgba(255,255,255,0.22); background: rgba(255,255,255,0.06); }
  27. .btn.success { border-color: rgba(165,220,134,0.55); background: rgba(165,220,134,0.12); }
  28. .btn.error { border-color: rgba(242,116,116,0.55); background: rgba(242,116,116,0.12); }
  29. .btn.warning { border-color: rgba(248,187,134,0.55); background: rgba(248,187,134,0.12); }
  30. .btn.info { border-color: rgba(63,195,238,0.55); background: rgba(63,195,238,0.12); }
  31. .hint { font-size: 12px; color: #8c8c8c; line-height: 1.5; }
  32. .demo-visual { padding: 22px 24px; }
  33. .kv {
  34. display: grid;
  35. grid-template-columns: 160px 1fr;
  36. gap: 10px 14px;
  37. font-size: 13px;
  38. color: #b7b7b7;
  39. margin-top: 10px;
  40. }
  41. .kv code { color: #e6e6e6; }
  42. </style>
  43. </head>
  44. <body>
  45. <div class="container">
  46. <div class="page-top">
  47. <div class="crumb">UI › LAYER</div>
  48. <div class="since">SINCE 1.0.0</div>
  49. </div>
  50. <h1>Layer</h1>
  51. <p class="description">
  52. Minimal popup API with <code class="inline">Promise</code> result, plus SweetAlert-like SVG icon animations powered by <code class="inline">xjs.draw()</code> / spring easing.
  53. </p>
  54. <h2>Quick demo</h2>
  55. <div class="box-container">
  56. <div class="box-header">
  57. <div class="box-title">Open popups</div>
  58. <div class="tabs">
  59. <div class="tab active" onclick="switchTab('js')">JavaScript</div>
  60. <div class="tab" onclick="switchTab('html')">HTML</div>
  61. <div class="tab" onclick="switchTab('css')">CSS</div>
  62. </div>
  63. </div>
  64. <pre id="js-code" class="code-view active">// SweetAlert-like icons (SVG + draw)
  65. xjs.layer({ title: 'Success', text: 'Saved!', icon: 'success' });
  66. xjs.layer({ title: 'Error', text: 'Something went wrong', icon: 'error' });
  67. // Confirm flow
  68. xjs.layer({
  69. title: 'Delete item?',
  70. text: 'This action cannot be undone.',
  71. icon: 'warning',
  72. showCancelButton: true
  73. }).then((res) => {
  74. if (res.isConfirmed) xjs.layer({ title: 'Deleted', icon: 'success' });
  75. });</pre>
  76. <pre id="html-code" class="html-view">&lt;button class="btn success"&gt;Success&lt;/button&gt;
  77. &lt;button class="btn error"&gt;Error&lt;/button&gt;
  78. &lt;button class="btn warning"&gt;Warning&lt;/button&gt;
  79. &lt;button class="btn info"&gt;Info&lt;/button&gt;
  80. &lt;button class="btn"&gt;Confirm&lt;/button&gt;</pre>
  81. <pre id="css-code" class="css-view">/* This page's button styles are local.
  82. Layer's own CSS is injected by layer.js */</pre>
  83. <div class="feature-desc">
  84. <strong>功能说明:</strong>Layer 的 icon 现在是内联 SVG(ring + mark),打开弹窗时会自动触发描边动画;弹窗支持 <code class="inline">ESC</code> 关闭(可用 <code class="inline">closeOnEsc:false</code> 关闭)。
  85. </div>
  86. <div class="demo-visual">
  87. <div class="row">
  88. <button class="btn success" onclick="openIcon('success')">Success</button>
  89. <button class="btn error" onclick="openIcon('error')">Error</button>
  90. <button class="btn warning" onclick="openIcon('warning')">Warning</button>
  91. <button class="btn info" onclick="openIcon('info')">Info</button>
  92. <button class="btn" onclick="openConfirm()">Confirm</button>
  93. </div>
  94. <div class="hint" style="margin-top: 12px;">
  95. Tip: try pressing <code class="inline">ESC</code> while the popup is open.
  96. </div>
  97. <div class="kv">
  98. <div>icon</div><div><code class="inline">success | error | warning | info</code></div>
  99. <div>iconAnimation</div><div><code class="inline">true</code> (default)</div>
  100. <div>popupAnimation</div><div><code class="inline">true</code> (default)</div>
  101. <div>closeOnEsc</div><div><code class="inline">true</code> (default)</div>
  102. </div>
  103. </div>
  104. </div>
  105. <div class="doc-nav" aria-label="Previous and next navigation">
  106. <a href="#" id="prevLink" onclick="goPrev(); return false;">
  107. <span>
  108. <span class="nav-label">Previous</span><br>
  109. <span class="nav-title" id="prevTitle">—</span>
  110. </span>
  111. <span aria-hidden="true">←</span>
  112. </a>
  113. <div class="nav-center" id="navCenter">Layer</div>
  114. <a href="#" id="nextLink" onclick="goNext(); return false;">
  115. <span>
  116. <span class="nav-label">Next</span><br>
  117. <span class="nav-title" id="nextTitle">—</span>
  118. </span>
  119. <span aria-hidden="true">→</span>
  120. </a>
  121. </div>
  122. </div>
  123. <script src="../highlight_css.js"></script>
  124. <script src="../../xjs.js"></script>
  125. <script>
  126. const CURRENT = 'layer/overview.html';
  127. function switchTab(tab) {
  128. document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
  129. document.querySelectorAll('.code-view, .html-view, .css-view').forEach(v => v.classList.remove('active'));
  130. if (tab === 'js') {
  131. document.querySelector('.tabs .tab:nth-child(1)')?.classList.add('active');
  132. document.getElementById('js-code')?.classList.add('active');
  133. } else if (tab === 'html') {
  134. document.querySelector('.tabs .tab:nth-child(2)')?.classList.add('active');
  135. document.getElementById('html-code')?.classList.add('active');
  136. } else {
  137. document.querySelector('.tabs .tab:nth-child(3)')?.classList.add('active');
  138. document.getElementById('css-code')?.classList.add('active');
  139. }
  140. }
  141. function openIcon(type) {
  142. xjs.layer({
  143. title: type[0].toUpperCase() + type.slice(1),
  144. text: 'SVG icon draw + spring entrance',
  145. icon: type
  146. });
  147. }
  148. function openConfirm() {
  149. xjs.layer({
  150. title: 'Delete item?',
  151. text: 'This action cannot be undone.',
  152. icon: 'warning',
  153. showCancelButton: true,
  154. confirmButtonText: 'Delete',
  155. cancelButtonText: 'Cancel'
  156. }).then((res) => {
  157. if (res.isConfirmed) {
  158. xjs.layer({ title: 'Deleted', text: 'Done', icon: 'success' });
  159. } else if (res.dismiss === 'cancel') {
  160. xjs.layer({ title: 'Cancelled', text: 'Nothing happened', icon: 'info' });
  161. }
  162. });
  163. }
  164. function goPrev() { window.parent?.docNavigatePrev?.(CURRENT); }
  165. function goNext() { window.parent?.docNavigateNext?.(CURRENT); }
  166. function syncNavLabels() {
  167. const api = window.parent?.docGetPrevNext;
  168. if (typeof api !== 'function') return;
  169. const { prev, next, current } = api(CURRENT) || {};
  170. const prevLink = document.getElementById('prevLink');
  171. const nextLink = document.getElementById('nextLink');
  172. if (prev) document.getElementById('prevTitle').textContent = prev.title || prev.url;
  173. else { prevLink.style.visibility = 'hidden'; }
  174. if (next) document.getElementById('nextTitle').textContent = next.title || next.url;
  175. else { nextLink.style.visibility = 'hidden'; }
  176. document.getElementById('navCenter').textContent = (current && current.group) ? current.group : 'Layer';
  177. }
  178. // Sync middle list selection when loaded inside doc/index.html
  179. try { window.parent?.setMiddleActive?.(CURRENT); } catch {}
  180. syncNavLabels();
  181. </script>
  182. </body>
  183. </html>