mcpField
U
ui-snapshot

ui-snapshot

github.com/rheinmirDesign & UI1038 installsUpdated 2w ago
Repository

About ui-snapshot

A skill that ports a frontend interface into a single offline HTML file for design reviews, documentation, and people who cannot run the app. It includes page states and overlays, then verifies desktop and mobile views with screenshots.

Key features

  1. 01Inventory pages, states, and overlays
  2. 02Reuse original Tailwind classes
  3. 03Build the UI with placeholder data
  4. 04Generate a single offline HTML file
  5. 05Verify desktop and mobile views
  6. 06Report simulated content and file size

Use cases

  1. 01Show an interface to reviewers who cannot run the app
  2. 02Discuss UX or QC with sample data
  3. 03Provide an offline UI demo in project documentation

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/rheinmir/setup --skill ui-snapshot

After installing, type/ui-snapshotin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

assets/
app-skeleton.js
template.html
scripts/
build.py
shot.mjs

Details

From the project README

Skill: ui-snapshot

Đúc kết từ phiên bonbon-ai 2026-09-19: 12 màn × desktop/mobile + 10 overlay của fe/ (Next.js 14, Tailwind 3) gói trong 426 KB, Playwright 22 ảnh, 0 lỗi console.

WHAT

Purpose và context
  • Purpose: một file .html duy nhất mở bằng double-click (không server, không mạng, không login) tái hiện đúng giao diện app thật — layout, token màu, font, icon, trạng thái (loading/empty/error/overdue…), overlay (modal, sheet, toast, tour) — với dữ liệu placeholder cứng.
  • Trigger (when to use):
    • Cần đưa giao diện cho người không chạy được app (sếp, designer, khách, reviewer, tài liệu wiki).
    • Cần bản mockup có dữ liệu mẫu để bàn UX/QC mà không đụng dữ liệu thật hay backend.
    • User nói 'snapshot UI', 'gói giao diện vào 1 file html', 'nén UIUX dự án', hoặc /ui-snapshot.
  • Non-goals: không thiết kế lại (→ hallmark/redesign), không chụp ảnh tĩnh app đang chạy (→ playwright-verify), không nhét dữ liệu thật, không giữ logic nghiệp vụ/API (nút hành động chỉ đổi state trong trang).
Mental model

Vì sao PORT thay vì build/SSR app thật: app thật cần auth + backend + dữ liệu thật; snapshot bằng DOM thật sẽ kéo theo dữ liệu nhạy cảm và bundle lớn. Port sang vanilla JS với class chép nguyên văn + compile Tailwind bằng config thật cho ra đúng pixel mà không mang theo gì khác.

đọc HẾT JSX các trang → liệt kê màn + trạng thái + overlay → viết app.js (router hash, state, data cứng, 1 hàm/màn, nhánh desktop/mobile) → build.py (Tailwind config thật + font + icon subset + asset data URI) → shot.mjs verify → sửa → publish.

Input và output contract
FieldRequired?Ý nghĩa
Inthư mục frontend (--fe) có node_modulescóđể dùng tailwindcss CLI + config của dự án
Indanh sách trang/routecó (tự dò app/**/page.tsx, pages/, src/routes)phạm vi "toàn bộ UI"
Inngưỡng dung lượngkhông (5 MB)--max-mb
Infont chính / logo / bannerkhông--font, --asset NAME=path
Out<repo>/…/DDMMYY-<project>-uiux-snapshot.htmlcófile duy nhất, offline
Outbáo cáo: số màn, KB, ảnh verify, lệch so app thậtcótrung thực, liệt kê chỗ giả lập
Rules và capabilities
  • RULE-01 (MUST): Đọc HẾT file JSX của từng trang trước khi port (kể cả nhánh mobile, empty/loading/error, modal, sheet). Port từ trí nhớ = lệch UI.
  • RULE-02 (MUST): Class Tailwind chép NGUYÊN VĂN từ JSX, viết dạng chuỗi literal trong app.js (JIT chỉ thấy literal; ghép động bg-${x} sẽ mất class).
  • RULE-03 (MUST): Dữ liệu placeholder cứng, không bao giờ dữ liệu thật (không gọi API, không copy từ network capture/DB). Ngày dùng offset tương đối (D(-9)) để trạng thái quá hạn ổn định theo thời gian.
  • RULE-04 (MUST): Tên icon viết dạng chuỗi có nháy ("search") để build.py subset font; icon động thì đặt tên đầy đủ trong map.
  • RULE-05 (MUST): Cùng breakpoint với app (vd 768px) và render nhánh desktop/mobile bằng JS (không dựa md: khi có chế độ ép mobile trong khung điện thoại).
  • RULE-06 (MUST): Asset ngoài (ảnh CDN, font Google) phải nhúng hoặc thay bằng nền/gradient — file phải chạy offline. Ghi rõ mọi chỗ thay thế trong báo cáo.
  • RULE-07 (MUST): Verify bằng shot.mjs cả desktop + mobile, đọc ảnh, NO ERRORS mới báo xong; vượt --max-mb = FAIL.
  • RULE-08 (SHOULD): Có panel demo (nút "UI") để nhảy tới mọi màn + bật trạng thái (loading/stale, lỗi, toast, tour, các state AI…), và chế độ Auto/Desktop/Mobile.
  • Capabilities: đọc codebase; Python 3 + Node + Tailwind CLI của dự án; mạng lúc build (Google Fonts, codepoints); Playwright để verify.
Failure boundaries
  • Dự án không dùng Tailwind → build.py để CSS trống: chép CSS module/styled vào template tay, hoặc clarify với user.
  • Không có mạng lúc build → font/icon không nhúng được → blocked (hoặc chấp nhận fallback system font, ghi rõ).
  • File vượt ngưỡng → giảm: bỏ weight font thừa, ảnh sips -Z nhỏ hơn, bớt dữ liệu mẫu; không cắt màn hình.
  • Framework khác (Vue/Svelte/Angular template) → vẫn áp dụng, chỉ đổi nguồn đọc class.

HOW

Main workflow
StepTypeInputsActionOutputs/exitFailure/next
W01deterministic--feDò route + layout + component dùng chung; đọc tailwind.config, globals.css, design.md nếu códanh sách màn + tokenkhông Tailwind → FB1
W02judgmentJSX từng trangĐọc HẾT từng trang (RULE-01), ghi lại mọi trạng thái/overlay/nhánh mobileinventory màn × trạng thái—
W03effectinventoryTạo <scratch>/app.js từ assets/app-skeleton.js, template.html từ assets/template.html (thay __TITLE__, __FONT__); port từng màn, class nguyên văn, data cứngapp.js—
W04deterministicapp.js + templatepython3 scripts/build.py --fe <fe> --src <scratch> --out <file> --font "<Font>" --asset LOGO=public/logo.pngfile HTML + KBlỗi Tailwind → xem stderr; >max → FB3
W05deterministicfilenode scripts/shot.mjs <file> <scratch>/shots d-home=home m-home=home … (cài playwright vào scratch nếu thiếu) rồi ĐỌC ảnhảnh + NO ERRORSlỗi → sửa app.js, lặp W04
W06effectfileĐặt vào repo (vd llmwiki/html/DDMMYY-<project>-uiux-snapshot.html), ghi log wiki nếu dự án có; báo cáo số màn, KB, chỗ giả lậpbáo cáo—
Branches
IDKindGuardHành viSkip / failureRejoin
B01conditionaltrang có dead-code UI (state không có đường vào)vẫn port nhưng chỉ mở qua panel demo, ghi chú "legacy"—W03
B02conditionalapp có devtool page tối/khác design systemport bằng inline style như bản gốc—W03
B03recoverychế độ mobile trên màn rộng lệch layoutkhung #frame có transform để fixed bám khung; #app là vùng cuộn; override .h-screen/.min-h-screen = 100% (đã có trong template)—W05
Validation và stopping

Tất định: build.py exit 0 và dưới ngưỡng; shot.mjs in NO ERRORS cho mọi màn desktop + mobile. Cần mắt: so ảnh với app thật/Figma (màu, khoảng cách, chữ tiếng Việt có dấu). Dừng khi mọi màn trong inventory có ảnh sạch và báo cáo đã liệt kê chỗ giả lập.

Examples
  • Positive: bonbon-ai fe/ → login, dashboard overview/pending/overdue, filter theo phòng ban/loại HĐ, chi tiết phiếu 3 tab, VS Code overlay, AI tracker, sheet/modal/toast/tour → 426 KB, 79 icon, 22 ảnh verify, 0 lỗi.
  • Boundary: dự án ảnh nền hero 3 MB từ CDN → thay gradient + ghi "khác app thật: ảnh nền login" thay vì nhúng làm file vượt ngưỡng.
Test tất định

python3 scripts/build.py --fe <fe> --src assets-copy --out /tmp/t.html với assets/app-skeleton.js (đổi tên app.js) + assets/template.html phải ra file < 1 MB, rồi node scripts/shot.mjs /tmp/t.html /tmp/shots d-home=home m-home=home in NO ERRORS.

Comments

Markdown supported