mirror of
https://github.com/tiennm99/loto.git
synced 2026-10-11 12:19:05 +00:00
feat(player): add "Xoá đánh dấu" button to clear marks without regen
Lets the player wipe all crossed cells on the current card without generating a new grid. Shown next to "Tạo bảng mới" only when a grid exists. Confirms before clearing if any cell is marked. - src/lib/PlayerBoard.svelte: handleClear + secondary outline button - docs/codebase-summary.md, project-overview-pdr.md: reflect new action
This commit is contained in:
1 parent
2221ab9af8
commit
4a84245b39
3 files changed
+27
-2
No files matched your search
@@ -11,7 +11,7 @@
|
||||
### Shared Components
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `src/lib/PlayerBoard.svelte` | Reusable player card (9×9 grid rendered as 3 stacked 3×9 mini-cards: Tân Tân / An khang thịnh vượng / Tân Tân tốt nhất). Tall (3:5 on mobile; wider on sm+) cells with condensed bold black numbers (`tan-tan-num` font stack), white number cells, purple empty cells by default. Handles crossed state, bingo popup, "Chờ X" toast. Accepts `storagePrefix` prop for multi-card isolation. Empty cells use `--empty-cell-bg` CSS var from settings store. |
|
||||
| `src/lib/PlayerBoard.svelte` | Reusable player card (9×9 grid rendered as 3 stacked 3×9 mini-cards: Tân Tân / An khang thịnh vượng / Tân Tân tốt nhất). Tall (3:5 on mobile; wider on sm+) cells with condensed bold black numbers (`tan-tan-num` font stack), white number cells, purple empty cells by default. Handles crossed state, bingo popup, "Chờ X" toast. Two header actions: "Tạo bảng mới" (regenerate grid) and "Xoá đánh dấu" (clear all marks, keep grid — only shown when a grid exists). Accepts `storagePrefix` prop for multi-card isolation. Empty cells use `--empty-cell-bg` CSS var from settings store. |
|
||||
| `src/lib/SettingsButton.svelte` | Gear icon + modal. 4 fieldsets: Giao diện (theme auto/light/dark), Chế độ quản trò (master mode toggle), Tự động xổ (auto-call + speed 1–10s), Màu ô trống (10 Excel color swatches). Reset-to-default button. Mounted on `/`. |
|
||||
| `src/lib/MasterPanel.svelte` | Host controls. New game / draw, "Số vừa xổ" hero token, "Thứ tự đã xổ" history list, 11×9 last-digit-aligned tracking grid (with circular tokens + draw-order overlay). No host's own player card (the player already has one above). "Xổ số" / "Bắt đầu / Dừng" button bound to auto-call. Mounted conditionally on `/` when `settings.masterMode === true`. |
|
||||
| `src/lib/PageFooter.svelte` | Footer with tagline ("Made by miti99 with ❤️ SVG icon") + link. Mounted on `/`. |
|
||||
|
||||
@@ -88,6 +88,7 @@ State is entirely client-side. Each card / panel instance uses a unique localSto
|
||||
- [x] Player card is 9×9 with **exactly 5 per row and 5 per column**.
|
||||
- [x] Numbers within each column are **ascending top-to-bottom**.
|
||||
- [x] Player can click cells to toggle crossed state.
|
||||
- [x] Player can clear all marks on the current card without regenerating it (confirm prompt when marks exist).
|
||||
- [x] Bingo popup triggers when row is complete, shows row number and "Kinh!" message.
|
||||
- [x] Player may keep marking after a Kinh — no game-end lock.
|
||||
- [x] Toast notifications show "Chờ X" before bingo (one number remaining).
|
||||
|
||||
@@ -120,6 +120,17 @@
|
||||
dismissToast();
|
||||
}
|
||||
|
||||
function handleClear() {
|
||||
if (!grid) return;
|
||||
const hasMarks = crossed.some((row) => row.some(Boolean));
|
||||
if (hasMarks && !confirm("Bạn có muốn xoá tất cả đánh dấu không?")) return;
|
||||
crossed = grid.map((row) => row.map(() => false));
|
||||
celebratedRows.clear();
|
||||
notifiedWaitingRows.clear();
|
||||
dismissToast();
|
||||
showCongrats = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} row
|
||||
* @param {number} col
|
||||
@@ -146,7 +157,7 @@
|
||||
];
|
||||
</script>
|
||||
|
||||
<div class="flex justify-center mb-6">
|
||||
<div class="flex flex-wrap justify-center gap-3 mb-6">
|
||||
<button
|
||||
onclick={handleGenerate}
|
||||
class="px-8 py-3 rounded-full font-semibold text-white
|
||||
@@ -156,6 +167,19 @@
|
||||
>
|
||||
Tạo bảng mới
|
||||
</button>
|
||||
{#if grid}
|
||||
<button
|
||||
onclick={handleClear}
|
||||
class="px-6 py-3 rounded-full font-semibold
|
||||
text-slate-700 dark:text-slate-200
|
||||
bg-white dark:bg-slate-800
|
||||
border-2 border-slate-300 dark:border-slate-600
|
||||
hover:bg-slate-50 dark:hover:bg-slate-700
|
||||
active:scale-95 transition-all"
|
||||
>
|
||||
Xoá đánh dấu
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if grid}
|
||||
|
||||
Reference in new issue
Block a user