Word book: + instead of a heart for words #46

Merged
anas merged 1 commits from feature/word-book into main 2026-10-08 21:58:17 +00:00
3 changed files with 11 additions and 6 deletions
Showing only changes of commit d4eaab769c - Show all commits

View File

@ -55,7 +55,7 @@ const fullTitle = title ? `${title} · دیوان` : 'دیوان · اردو ک
<main class="wrap"><slot /></main>
<div id="selmenu" class="selmenu" role="toolbar" aria-label="منتخب عبارت" hidden>
<button type="button" data-act="meaning" title="معنی اور تلفظ">معنی</button>
<button type="button" data-act="saveword" title="لفظ لغت کے ساتھ محفوظ کریں">محفوظ</button>
<button type="button" data-act="saveword" class="plus" title="ذخیرۂ الفاظ میں شامل کریں">لفظ</button>
<button type="button" data-act="bookmark" title="اس عبارت پر نشان لگائیں">نشان</button>
<button type="button" data-act="search" title="دیوان میں تلاش">تلاش</button>
<button type="button" data-act="copy" title="حوالے کے ساتھ کاپی">کاپی</button>
@ -161,7 +161,7 @@ const fullTitle = title ? `${title} · دیوان` : 'دیوان · اردو ک
else if (d) b.setAttribute('aria-pressed', String(d.saved));
});
const wordSave = (w) => { // sidebar button, with the word's saved state
const b = el('button', 'save', 'لفظ محفوظ کریں', { type: 'button', 'aria-pressed': 'false' });
const b = el('button', 'wordbook', 'ذخیرۂ الفاظ میں', { type: 'button', 'aria-pressed': 'false', title: 'اپنے ذخیرۂ الفاظ میں شامل کریں' });
b.onclick = async () => { const d = await save({ kind: 'word', word: w, ...source }); if (d) b.setAttribute('aria-pressed', String(d.saved)); };
if (document.body.dataset.user) fetch('/api/library?word=' + encodeURIComponent(w)).then((r) => r.ok && r.json()).then((d) => d && b.setAttribute('aria-pressed', String(d.word)));
return b;
@ -333,7 +333,7 @@ const fullTitle = title ? `${title} · دیوان` : 'دیوان · اردو ک
case 'meaning': showWord(oneWord(selText)); break;
case 'bookmark': save({ kind: 'phrase', poemId: source.poemId, couplet: source.couplet, phrase: selText })
.then((d) => d && (d.saved ? location.reload() : flash(b, 'نشان پہلے سے تھا، ہٹا دیا'))); break;
case 'saveword': save({ kind: 'word', word: oneWord(selText), ...source }).then((d) => d && flash(b, d.saved ? 'محفوظ ہو گیا' : 'ہٹا دیا گیا')); break;
case 'saveword': save({ kind: 'word', word: oneWord(selText), ...source }).then((d) => d && flash(b, d.saved ? '✓ شامل' : 'ہٹا دیا')); break;
case 'search': location.href = `/search?q=${encodeURIComponent(q)}`; break;
case 'google': open(`https://www.google.com/search?q=${enc}`, '_blank', 'noopener'); break;
case 'copy':

View File

@ -31,7 +31,7 @@ const at = (item: any) => (item.poem ? `${item.poem.url}${item.poem.couplet != n
<p class="muted center">میری لائبریری · {ud(total)} اندراجات · <a href="/account">پروفائل</a></p>
{total === 0 && (
<p class="muted center">ابھی کچھ محفوظ نہیں۔ کسی شاعر یا کلام پر "پسندیدہ" دبائیں، کسی شعر کے ساتھ 🔖 لگائیں، کوئی عبارت منتخب کر کے "نشان" لگائیں، یا لفظ منتخب کر کے "محفوظ" کریں۔</p>
<p class="muted center">ابھی کچھ محفوظ نہیں۔ کسی شاعر یا کلام پر "پسندیدہ" دبائیں، کسی شعر کے ساتھ 🔖 لگائیں، کوئی عبارت منتخب کر کے "نشان" لگائیں، یا لفظ منتخب کر کے "+ لفظ" سے ذخیرۂ الفاظ میں شامل کریں۔</p>
)}
{lib.poets.length > 0 && (
@ -106,7 +106,7 @@ const at = (item: any) => (item.poem ? `${item.poem.url}${item.poem.couplet != n
{lib.words.length > 0 && (
<section class="lib-section">
<h2>محفوظ الفاظ</h2>
<h2>ذخیرۂ الفاظ</h2>
<ul class="lib-list">
{lib.words.map((w: any) => (
<li id={`i${w.id}`}>

View File

@ -187,6 +187,7 @@ h1 + .muted { text-align: center; margin-top: 0; }
background: rgb(14 17 17 / .92); box-shadow: 0 4px 14px rgb(0 0 0 / .25); }
.selmenu[hidden] { display: none; }
.selmenu button { font: inherit; font-size: .85rem; color: #f3ead8; background: none; border: 0; border-radius: 7px; padding: 2px 10px; cursor: pointer; }
.selmenu .plus::before { content: '+ '; font-weight: 700; color: #c9a050; }
.selmenu button:hover, .selmenu button:focus-visible { background: rgb(201 160 80 / .25); outline: none; }
/* admin panel */
@ -218,7 +219,11 @@ h1 + .muted { text-align: center; margin-top: 0; }
.save::before { content: '♡ '; color: var(--brand); }
.save[aria-pressed='true'] { border-color: var(--brand); color: var(--brand); }
.save[aria-pressed='true']::before { content: '♥ '; }
.dict .save { margin-bottom: 6px; }
/* word book (ذخیرۂ الفاظ): + to add, ✓ when added (hearts are for poets and works) */
.wordbook { font: inherit; font-size: .85rem; padding: 1px 14px; margin-bottom: 6px; border: 1.5px solid var(--border); border-radius: 999px; background: var(--inner); color: var(--ink); cursor: pointer; }
.wordbook::before { content: '+ '; font-weight: 700; color: var(--gold); }
.wordbook[aria-pressed='true'] { border-color: var(--gold); color: var(--gold); }
.wordbook[aria-pressed='true']::before { content: '✓ '; }
.couplet, .poem .para, .poem .single { position: relative; }
.bm { position: absolute; inset-inline-end: -26px; top: .5em; width: 20px; height: 22px; padding: 0; border: 0; background: none; cursor: pointer;
opacity: 0; transition: opacity .15s; user-select: none; }