| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Layer - Overview</title>
- <link rel="stylesheet" href="../demo.css">
- <style>
- .row {
- display: flex;
- flex-wrap: wrap;
- gap: 10px;
- align-items: center;
- }
- .btn {
- appearance: none;
- border: 1px solid rgba(255,255,255,0.12);
- background: rgba(255,255,255,0.04);
- color: #fff;
- border-radius: 999px;
- padding: 10px 14px;
- font-weight: 650;
- cursor: pointer;
- transition: border-color 0.15s ease, background 0.15s ease;
- }
- .btn:hover { border-color: rgba(255,255,255,0.22); background: rgba(255,255,255,0.06); }
- .btn.success { border-color: rgba(165,220,134,0.55); background: rgba(165,220,134,0.12); }
- .btn.error { border-color: rgba(242,116,116,0.55); background: rgba(242,116,116,0.12); }
- .btn.warning { border-color: rgba(248,187,134,0.55); background: rgba(248,187,134,0.12); }
- .btn.info { border-color: rgba(63,195,238,0.55); background: rgba(63,195,238,0.12); }
- .hint { font-size: 12px; color: #8c8c8c; line-height: 1.5; }
- .demo-visual { padding: 22px 24px; }
- .kv {
- display: grid;
- grid-template-columns: 160px 1fr;
- gap: 10px 14px;
- font-size: 13px;
- color: #b7b7b7;
- margin-top: 10px;
- }
- .kv code { color: #e6e6e6; }
- </style>
- </head>
- <body>
- <div class="container">
- <div class="page-top">
- <div class="crumb">UI › LAYER</div>
- <div class="since">SINCE 1.0.0</div>
- </div>
- <h1>Layer</h1>
- <p class="description">
- 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.
- </p>
- <h2>Quick demo</h2>
- <div class="box-container">
- <div class="box-header">
- <div class="box-title">Open popups</div>
- <div class="tabs">
- <div class="tab active" onclick="switchTab('js')">JavaScript</div>
- <div class="tab" onclick="switchTab('html')">HTML</div>
- <div class="tab" onclick="switchTab('css')">CSS</div>
- </div>
- </div>
- <pre id="js-code" class="code-view active">// SweetAlert-like icons (SVG + draw)
- xjs.layer({ title: 'Success', text: 'Saved!', icon: 'success' });
- xjs.layer({ title: 'Error', text: 'Something went wrong', icon: 'error' });
- // Confirm flow
- xjs.layer({
- title: 'Delete item?',
- text: 'This action cannot be undone.',
- icon: 'warning',
- showCancelButton: true
- }).then((res) => {
- if (res.isConfirmed) xjs.layer({ title: 'Deleted', icon: 'success' });
- });</pre>
- <pre id="html-code" class="html-view"><button class="btn success">Success</button>
- <button class="btn error">Error</button>
- <button class="btn warning">Warning</button>
- <button class="btn info">Info</button>
- <button class="btn">Confirm</button></pre>
- <pre id="css-code" class="css-view">/* This page's button styles are local.
- Layer's own CSS is injected by layer.js */</pre>
- <div class="feature-desc">
- <strong>功能说明:</strong>Layer 的 icon 现在是内联 SVG(ring + mark),打开弹窗时会自动触发描边动画;弹窗支持 <code class="inline">ESC</code> 关闭(可用 <code class="inline">closeOnEsc:false</code> 关闭)。
- </div>
- <div class="demo-visual">
- <div class="row">
- <button class="btn success" onclick="openIcon('success')">Success</button>
- <button class="btn error" onclick="openIcon('error')">Error</button>
- <button class="btn warning" onclick="openIcon('warning')">Warning</button>
- <button class="btn info" onclick="openIcon('info')">Info</button>
- <button class="btn" onclick="openConfirm()">Confirm</button>
- </div>
- <div class="hint" style="margin-top: 12px;">
- Tip: try pressing <code class="inline">ESC</code> while the popup is open.
- </div>
- <div class="kv">
- <div>icon</div><div><code class="inline">success | error | warning | info</code></div>
- <div>iconAnimation</div><div><code class="inline">true</code> (default)</div>
- <div>popupAnimation</div><div><code class="inline">true</code> (default)</div>
- <div>closeOnEsc</div><div><code class="inline">true</code> (default)</div>
- </div>
- </div>
- </div>
- <div class="doc-nav" aria-label="Previous and next navigation">
- <a href="#" id="prevLink" onclick="goPrev(); return false;">
- <span>
- <span class="nav-label">Previous</span><br>
- <span class="nav-title" id="prevTitle">—</span>
- </span>
- <span aria-hidden="true">←</span>
- </a>
- <div class="nav-center" id="navCenter">Layer</div>
- <a href="#" id="nextLink" onclick="goNext(); return false;">
- <span>
- <span class="nav-label">Next</span><br>
- <span class="nav-title" id="nextTitle">—</span>
- </span>
- <span aria-hidden="true">→</span>
- </a>
- </div>
- </div>
- <script src="../highlight_css.js"></script>
- <!-- NOTE: xjs.js bundles an older Layer in some builds.
- For local testing, load standalone layer.js last to ensure this page uses the edited Layer implementation. -->
- <script src="../../xjs.js?v=dev"></script>
- <script src="../../layer.js?v=dev"></script>
- <script>
- const CURRENT = 'layer/overview.html';
- function switchTab(tab) {
- document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
- document.querySelectorAll('.code-view, .html-view, .css-view').forEach(v => v.classList.remove('active'));
- if (tab === 'js') {
- document.querySelector('.tabs .tab:nth-child(1)')?.classList.add('active');
- document.getElementById('js-code')?.classList.add('active');
- } else if (tab === 'html') {
- document.querySelector('.tabs .tab:nth-child(2)')?.classList.add('active');
- document.getElementById('html-code')?.classList.add('active');
- } else {
- document.querySelector('.tabs .tab:nth-child(3)')?.classList.add('active');
- document.getElementById('css-code')?.classList.add('active');
- }
- }
- function openIcon(type) {
- xjs.layer({
- title: type[0].toUpperCase() + type.slice(1),
- text: 'SVG icon draw + spring entrance',
- icon: type
- });
- }
- function openConfirm() {
- xjs.layer({
- title: 'Delete item?',
- text: 'This action cannot be undone.',
- icon: 'question',
- showCancelButton: true,
- confirmButtonText: 'Delete',
- cancelButtonText: 'Cancel'
- }).then((res) => {
- if (res.isConfirmed) {
- xjs.layer({ title: 'Deleted', text: 'Done', icon: 'success' });
- } else if (res.dismiss === 'cancel') {
- xjs.layer({ title: 'Cancelled', text: 'Nothing happened', icon: 'info' });
- }
- });
- }
- function goPrev() { window.parent?.docNavigatePrev?.(CURRENT); }
- function goNext() { window.parent?.docNavigateNext?.(CURRENT); }
- function syncNavLabels() {
- const api = window.parent?.docGetPrevNext;
- if (typeof api !== 'function') return;
- const { prev, next, current } = api(CURRENT) || {};
- const prevLink = document.getElementById('prevLink');
- const nextLink = document.getElementById('nextLink');
- if (prev) document.getElementById('prevTitle').textContent = prev.title || prev.url;
- else { prevLink.style.visibility = 'hidden'; }
- if (next) document.getElementById('nextTitle').textContent = next.title || next.url;
- else { nextLink.style.visibility = 'hidden'; }
- document.getElementById('navCenter').textContent = (current && current.group) ? current.group : 'Layer';
- }
- // Sync middle list selection when loaded inside doc/index.html
- try { window.parent?.setMiddleActive?.(CURRENT); } catch {}
- syncNavLabels();
- </script>
- </body>
- </html>
|