@thanhnguyxn/pixelcraft 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/plugins/marketplace.json +1 -1
- package/.antigravity-plugin/plugin.json +32 -0
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +15 -4
- package/.codex-plugin/plugin.json +45 -0
- package/.cursor-plugin/marketplace.json +17 -0
- package/.cursor-plugin/plugin.json +27 -0
- package/.devin-plugin/plugin.json +21 -0
- package/.github/plugin/marketplace.json +34 -0
- package/CHANGELOG.md +159 -0
- package/GEMINI.md +1 -0
- package/README.md +185 -328
- package/SECURITY.md +28 -0
- package/assets/pixelcraft-logo-128.png +0 -0
- package/assets/pixelcraft-logo-256.png +0 -0
- package/bin/pixelcraft.mjs +431 -23
- package/docs/ARCHITECTURE.md +40 -37
- package/docs/DESIGN-RATIONALE.md +51 -3
- package/docs/INSTALL.md +221 -0
- package/evals/README.md +16 -6
- package/evals/fixtures/3d-web-engineering.json +69 -0
- package/evals/fixtures/acceptance-checklist-rule03-gate.json +43 -0
- package/evals/fixtures/ai-ui-libraries.json +53 -0
- package/evals/fixtures/audio-visual-accessibility.json +69 -0
- package/evals/fixtures/auth-and-checkout-ui.json +53 -0
- package/evals/fixtures/brandkit-identity-governance.json +48 -0
- package/evals/fixtures/build-and-architecture.json +53 -0
- package/evals/fixtures/canvas-and-node-editors.json +53 -0
- package/evals/fixtures/chat-ai-exfiltration-ime-hitl-gate.json +43 -0
- package/evals/fixtures/completion-gate-scan-until-clean.json +44 -0
- package/evals/fixtures/component-systems.json +53 -0
- package/evals/fixtures/component-testing.json +53 -0
- package/evals/fixtures/constrained-voice-and-tv.json +43 -0
- package/evals/fixtures/creative-code-rendering.json +69 -0
- package/evals/fixtures/creative-reference-evidence.json +67 -0
- package/evals/fixtures/data-app-python-marimo.json +49 -0
- package/evals/fixtures/desktop-cpp-juce-audio.json +49 -0
- package/evals/fixtures/desktop-csharp-avalonia.json +49 -0
- package/evals/fixtures/desktop-native-workspace.json +48 -0
- package/evals/fixtures/desktop-python-anti-tkinter.json +49 -0
- package/evals/fixtures/document-prepress-pdfx4-tounicode.json +43 -0
- package/evals/fixtures/document-rust-typst-invoice.json +49 -0
- package/evals/fixtures/document-typst-and-print-css.json +43 -0
- package/evals/fixtures/email-mjml-dark-mode.json +49 -0
- package/evals/fixtures/email-outlook-and-plaintext.json +43 -0
- package/evals/fixtures/enterprise-data-ui.json +53 -0
- package/evals/fixtures/extended-tui-toolkits.json +53 -0
- package/evals/fixtures/extensions-mv3-and-vscode.json +43 -0
- package/evals/fixtures/file-upload-media-ui.json +53 -0
- package/evals/fixtures/forms-validation.json +53 -0
- package/evals/fixtures/game-go-ebitengine.json +49 -0
- package/evals/fixtures/game-godot-gdscript.json +49 -0
- package/evals/fixtures/game-ui-hud-and-engines.json +43 -0
- package/evals/fixtures/i18n-engineering.json +53 -0
- package/evals/fixtures/local-first-sync.json +53 -0
- package/evals/fixtures/lynxjs.json +53 -0
- package/evals/fixtures/maizzle-email.json +53 -0
- package/evals/fixtures/maps-geospatial.json +53 -0
- package/evals/fixtures/media-og-and-video-export.json +43 -0
- package/evals/fixtures/media-players.json +53 -0
- package/evals/fixtures/mobile-compose-16kb-foldable-store-gate.json +44 -0
- package/evals/fixtures/mobile-elixir-liveview-native.json +49 -0
- package/evals/fixtures/mobile-flutter-dynamic-type.json +49 -0
- package/evals/fixtures/mobile-harmonyos-arkui.json +49 -0
- package/evals/fixtures/mobile-jetpack-compose.json +49 -0
- package/evals/fixtures/mobile-swiftui-ios.json +49 -0
- package/evals/fixtures/motion-engineering.json +69 -0
- package/evals/fixtures/pdfjs-and-pptx.json +53 -0
- package/evals/fixtures/plan-discovery-interview.json +31 -0
- package/evals/fixtures/plan-grill-me-brainstorm-gate.json +49 -0
- package/evals/fixtures/reactive-data-apps.json +53 -0
- package/evals/fixtures/review-evidence-audit.json +43 -0
- package/evals/fixtures/rich-text-and-code-editors.json +53 -0
- package/evals/fixtures/scrollytelling-resilience.json +70 -0
- package/evals/fixtures/spatial-xr-comfort-and-platforms.json +43 -0
- package/evals/fixtures/state-architecture.json +53 -0
- package/evals/fixtures/styling-ecosystem.json +53 -0
- package/evals/fixtures/token-tooling.json +53 -0
- package/evals/fixtures/tui-go-bubbletea.json +49 -0
- package/evals/fixtures/tui-rust-ratatui-grapheme-paste-teardown.json +44 -0
- package/evals/fixtures/tui-rust-ratatui.json +49 -0
- package/evals/fixtures/ux-state-matrix-and-i18n.json +43 -0
- package/evals/fixtures/web-3d-engines.json +53 -0
- package/evals/fixtures/web-php-laravel-filament.json +49 -0
- package/evals/fixtures/web-ruby-viewcomponent-phlex.json +49 -0
- package/evals/pixelcraft-accessibility.md +17 -0
- package/evals/pixelcraft-craft.md +16 -0
- package/evals/pixelcraft-dataviz.md +3 -3
- package/evals/pixelcraft-direction.md +17 -0
- package/evals/pixelcraft-game-ui.md +3 -3
- package/evals/pixelcraft-mobile.md +3 -3
- package/evals/pixelcraft-patterns.md +16 -0
- package/evals/pixelcraft-plan.md +65 -3
- package/evals/pixelcraft-review.md +3 -3
- package/evals/pixelcraft-visual-qa.md +11 -5
- package/evals/pixelcraft-web.md +21 -3
- package/evals/pixelcraft.md +4 -4
- package/gemini-extension.json +3 -2
- package/install.ps1 +57 -11
- package/install.sh +82 -7
- package/package.json +32 -4
- package/plugin.json +6 -1
- package/scripts/build-adapters.mjs +11 -13
- package/scripts/run-evals.mjs +397 -0
- package/scripts/sync-docs.mjs +381 -0
- package/scripts/test-build-adapters.mjs +14 -1
- package/scripts/test-cross-platform-qa.mjs +359 -0
- package/scripts/test-distribution.mjs +86 -7
- package/scripts/test-export-tokens.mjs +259 -3
- package/scripts/test-finish-gate.mjs +133 -10
- package/scripts/test-installers.mjs +155 -6
- package/scripts/test-shoot.mjs +23 -1
- package/scripts/test-slop-scan.mjs +390 -3
- package/scripts/test-style-inventory.mjs +23 -0
- package/scripts/test-sync-docs.mjs +140 -0
- package/scripts/test-validate-skills.mjs +82 -4
- package/scripts/validate-skills.mjs +149 -3
- package/skills/pixelcraft/SKILL.md +67 -47
- package/skills/pixelcraft/references/design-brief.md +2 -2
- package/skills/pixelcraft/references/floor.md +36 -19
- package/skills/pixelcraft/references/report-template.md +25 -11
- package/skills/pixelcraft/references/stack-detection.md +138 -67
- package/skills/pixelcraft/references/surface-acceptance.md +33 -21
- package/skills/pixelcraft/references/workflow-checkpoints.md +49 -7
- package/skills/pixelcraft-accessibility/SKILL.md +34 -13
- package/skills/pixelcraft-accessibility/references/apg-patterns.md +13 -0
- package/skills/pixelcraft-accessibility/references/motion-canvas.md +57 -0
- package/skills/pixelcraft-accessibility/references/platforms.md +34 -6
- package/skills/pixelcraft-accessibility/references/verification.md +15 -10
- package/skills/pixelcraft-accessibility/references/wcag22-checks.md +38 -5
- package/skills/pixelcraft-brandkit/SKILL.md +42 -30
- package/skills/pixelcraft-brandkit/references/asset-pipeline.md +90 -50
- package/skills/pixelcraft-brandkit/references/brand-governance.md +29 -27
- package/skills/pixelcraft-brandkit/references/logo-methods.md +33 -34
- package/skills/pixelcraft-brandkit/references/prompt-template.md +53 -51
- package/skills/pixelcraft-brandkit/references/qa-checklist.md +7 -2
- package/skills/pixelcraft-brandkit/references/visual-modes.md +16 -16
- package/skills/pixelcraft-chat-ui/SKILL.md +31 -27
- package/skills/pixelcraft-chat-ui/references/agentic-workspace.md +66 -0
- package/skills/pixelcraft-chat-ui/references/ai-ui-libraries.md +259 -0
- package/skills/pixelcraft-chat-ui/references/conversation-design.md +12 -6
- package/skills/pixelcraft-chat-ui/references/mobile-business-platforms.md +58 -68
- package/skills/pixelcraft-chat-ui/references/slack-discord.md +60 -76
- package/skills/pixelcraft-constrained/SKILL.md +21 -20
- package/skills/pixelcraft-constrained/references/specialized-hardware.md +69 -45
- package/skills/pixelcraft-constrained/references/tv-wearables.md +123 -73
- package/skills/pixelcraft-constrained/references/voice-ui.md +86 -45
- package/skills/pixelcraft-craft/SKILL.md +29 -15
- package/skills/pixelcraft-craft/references/color.md +62 -6
- package/skills/pixelcraft-craft/references/layout.md +32 -0
- package/skills/pixelcraft-craft/references/motion.md +99 -12
- package/skills/pixelcraft-craft/references/typography.md +48 -9
- package/skills/pixelcraft-data-apps/SKILL.md +50 -31
- package/skills/pixelcraft-data-apps/references/ai-and-internal-data-apps.md +147 -0
- package/skills/pixelcraft-data-apps/references/dash.md +87 -31
- package/skills/pixelcraft-data-apps/references/evidence.md +41 -26
- package/skills/pixelcraft-data-apps/references/gradio.md +65 -27
- package/skills/pixelcraft-data-apps/references/julia-genie.md +64 -29
- package/skills/pixelcraft-data-apps/references/jupyter-widgets.md +65 -27
- package/skills/pixelcraft-data-apps/references/nicegui.md +73 -34
- package/skills/pixelcraft-data-apps/references/observable-framework.md +65 -27
- package/skills/pixelcraft-data-apps/references/panel.md +69 -23
- package/skills/pixelcraft-data-apps/references/r-shiny.md +104 -34
- package/skills/pixelcraft-data-apps/references/reactive-data-apps.md +186 -0
- package/skills/pixelcraft-data-apps/references/reflex.md +85 -31
- package/skills/pixelcraft-data-apps/references/shiny.md +84 -27
- package/skills/pixelcraft-data-apps/references/streamlit.md +73 -25
- package/skills/pixelcraft-dataviz/SKILL.md +21 -24
- package/skills/pixelcraft-dataviz/references/color-accessibility.md +2 -2
- package/skills/pixelcraft-dataviz/references/encoding-tables-dashboards.md +35 -25
- package/skills/pixelcraft-dataviz/references/libraries.md +165 -46
- package/skills/pixelcraft-dataviz/references/maps-geospatial.md +159 -0
- package/skills/pixelcraft-dataviz/references/realtime-graphs-maps-scale.md +58 -65
- package/skills/pixelcraft-desktop/SKILL.md +61 -39
- package/skills/pixelcraft-desktop/references/appkit.md +60 -26
- package/skills/pixelcraft-desktop/references/avalonia.md +65 -29
- package/skills/pixelcraft-desktop/references/cpp-gui.md +104 -27
- package/skills/pixelcraft-desktop/references/electron.md +68 -26
- package/skills/pixelcraft-desktop/references/go-gui.md +59 -30
- package/skills/pixelcraft-desktop/references/gtk.md +74 -31
- package/skills/pixelcraft-desktop/references/javafx-swing.md +54 -25
- package/skills/pixelcraft-desktop/references/qt-pyside-qml.md +57 -30
- package/skills/pixelcraft-desktop/references/rust-gui.md +59 -41
- package/skills/pixelcraft-desktop/references/tauri.md +80 -24
- package/skills/pixelcraft-desktop/references/uno-platform.md +42 -23
- package/skills/pixelcraft-desktop/references/winui-wpf.md +66 -26
- package/skills/pixelcraft-desktop/references/working-context.md +82 -3
- package/skills/pixelcraft-direction/SKILL.md +48 -82
- package/skills/pixelcraft-direction/references/creative-brainstorming.md +72 -0
- package/skills/pixelcraft-direction/references/direction-card.md +11 -1
- package/skills/pixelcraft-direction/references/direction-scoring.md +5 -1
- package/skills/pixelcraft-direction/references/motion-identity.md +67 -0
- package/skills/pixelcraft-direction/references/movements.md +3 -0
- package/skills/pixelcraft-direction/references/reference-analysis.md +37 -0
- package/skills/pixelcraft-direction/references/slop-fingerprints.md +32 -7
- package/skills/pixelcraft-document/SKILL.md +27 -23
- package/skills/pixelcraft-document/references/archetypes.md +27 -4
- package/skills/pixelcraft-document/references/pdf-tools.md +241 -81
- package/skills/pixelcraft-document/references/pdfjs-and-pptx.md +114 -0
- package/skills/pixelcraft-document/references/print-css.md +96 -43
- package/skills/pixelcraft-document/references/slides.md +123 -27
- package/skills/pixelcraft-email/SKILL.md +42 -20
- package/skills/pixelcraft-email/references/client-quirks.md +101 -33
- package/skills/pixelcraft-email/references/html-tables.md +83 -22
- package/skills/pixelcraft-email/references/maizzle.md +54 -0
- package/skills/pixelcraft-email/references/mjml.md +13 -11
- package/skills/pixelcraft-email/references/react-email.md +76 -34
- package/skills/pixelcraft-extensions/SKILL.md +32 -27
- package/skills/pixelcraft-extensions/references/browser-extensions.md +91 -17
- package/skills/pixelcraft-extensions/references/figma-office.md +97 -14
- package/skills/pixelcraft-extensions/references/ide-and-saas-plugins.md +125 -0
- package/skills/pixelcraft-extensions/references/raycast.md +90 -11
- package/skills/pixelcraft-extensions/references/vscode-webviews.md +91 -17
- package/skills/pixelcraft-game-ui/SKILL.md +45 -26
- package/skills/pixelcraft-game-ui/references/bevy.md +69 -31
- package/skills/pixelcraft-game-ui/references/godot.md +100 -27
- package/skills/pixelcraft-game-ui/references/hud-principles.md +50 -21
- package/skills/pixelcraft-game-ui/references/love2d.md +53 -27
- package/skills/pixelcraft-game-ui/references/monogame.md +45 -29
- package/skills/pixelcraft-game-ui/references/unity-ugui.md +109 -0
- package/skills/pixelcraft-game-ui/references/unity-ui-toolkit.md +69 -27
- package/skills/pixelcraft-game-ui/references/unreal-umg.md +53 -26
- package/skills/pixelcraft-game-ui/references/web-and-middleware-game-ui.md +122 -0
- package/skills/pixelcraft-handoff/SKILL.md +14 -13
- package/skills/pixelcraft-handoff/references/design-translation.md +40 -10
- package/skills/pixelcraft-handoff/references/motion-handoff.md +54 -0
- package/skills/pixelcraft-media/SKILL.md +20 -23
- package/skills/pixelcraft-media/references/banners-video.md +83 -65
- package/skills/pixelcraft-media/references/og-generation.md +110 -63
- package/skills/pixelcraft-media/references/social-cards.md +57 -58
- package/skills/pixelcraft-mobile/SKILL.md +53 -36
- package/skills/pixelcraft-mobile/references/dotnet-maui.md +62 -34
- package/skills/pixelcraft-mobile/references/flet.md +53 -26
- package/skills/pixelcraft-mobile/references/flutter.md +76 -32
- package/skills/pixelcraft-mobile/references/harmonyos-and-emerging-mobile.md +121 -0
- package/skills/pixelcraft-mobile/references/ionic-capacitor.md +48 -26
- package/skills/pixelcraft-mobile/references/jetpack-compose.md +92 -24
- package/skills/pixelcraft-mobile/references/kivy.md +54 -31
- package/skills/pixelcraft-mobile/references/kotlin-multiplatform.md +53 -27
- package/skills/pixelcraft-mobile/references/lynxjs.md +110 -0
- package/skills/pixelcraft-mobile/references/nativescript-and-skip.md +91 -0
- package/skills/pixelcraft-mobile/references/react-native-expo.md +66 -31
- package/skills/pixelcraft-mobile/references/swiftui.md +158 -28
- package/skills/pixelcraft-mobile/references/tactile-interactions.md +55 -0
- package/skills/pixelcraft-mobile/references/task-state-composition.md +82 -2
- package/skills/pixelcraft-mobile/references/uikit.md +57 -23
- package/skills/pixelcraft-patterns/SKILL.md +30 -13
- package/skills/pixelcraft-patterns/references/accessibility-resilience.md +29 -0
- package/skills/pixelcraft-patterns/references/ai-and-offline-patterns.md +54 -0
- package/skills/pixelcraft-patterns/references/auth-onboarding.md +32 -13
- package/skills/pixelcraft-patterns/references/billing-paywalls.md +40 -0
- package/skills/pixelcraft-patterns/references/command-workspace.md +56 -0
- package/skills/pixelcraft-patterns/references/commerce.md +35 -16
- package/skills/pixelcraft-patterns/references/communication.md +34 -15
- package/skills/pixelcraft-patterns/references/creative-tools.md +30 -17
- package/skills/pixelcraft-patterns/references/creative-web-composition.md +38 -0
- package/skills/pixelcraft-patterns/references/dashboard-admin.md +22 -18
- package/skills/pixelcraft-patterns/references/history-diff-undo.md +50 -0
- package/skills/pixelcraft-patterns/references/marketing.md +31 -19
- package/skills/pixelcraft-patterns/references/multi-tenant-rbac.md +47 -0
- package/skills/pixelcraft-patterns/references/narrative-systems.md +42 -0
- package/skills/pixelcraft-patterns/references/notifications-activity.md +57 -0
- package/skills/pixelcraft-patterns/references/pattern-selection.md +8 -2
- package/skills/pixelcraft-patterns/references/scheduling-kanban.md +47 -0
- package/skills/pixelcraft-patterns/references/scroll-implementation.md +37 -0
- package/skills/pixelcraft-patterns/references/settings.md +40 -12
- package/skills/pixelcraft-plan/SKILL.md +54 -18
- package/skills/pixelcraft-plan/references/discovery-interview.md +110 -0
- package/skills/pixelcraft-plan/references/grill-me-protocol.md +63 -0
- package/skills/pixelcraft-plan/references/plan-template.md +44 -9
- package/skills/pixelcraft-plan/references/repo-discovery.md +16 -9
- package/skills/pixelcraft-plan/references/stack-freshness.md +22 -5
- package/skills/pixelcraft-plan/references/stack-selection.md +65 -9
- package/skills/pixelcraft-review/SKILL.md +41 -19
- package/skills/pixelcraft-review/references/audit-report.md +20 -1
- package/skills/pixelcraft-review/references/heuristics.md +63 -18
- package/skills/pixelcraft-review/references/personas.md +41 -14
- package/skills/pixelcraft-review/references/polish.md +66 -26
- package/skills/pixelcraft-review/scripts/check-acceptance.mjs +619 -0
- package/skills/pixelcraft-review/scripts/fixtures/focus-longhand-removal.css +34 -0
- package/skills/pixelcraft-review/scripts/slop-scan.mjs +679 -32
- package/skills/pixelcraft-spatial/SKILL.md +16 -17
- package/skills/pixelcraft-spatial/references/comfort-accessibility.md +25 -84
- package/skills/pixelcraft-spatial/references/platforms.md +123 -53
- package/skills/pixelcraft-tokens/SKILL.md +18 -14
- package/skills/pixelcraft-tokens/assets/tokens.example.json +1 -1
- package/skills/pixelcraft-tokens/assets/tokens.modes.example.json +1 -1
- package/skills/pixelcraft-tokens/references/format.md +39 -9
- package/skills/pixelcraft-tokens/references/governance.md +1 -1
- package/skills/pixelcraft-tokens/references/theme-presets.md +36 -8
- package/skills/pixelcraft-tokens/references/token-tooling.md +119 -0
- package/skills/pixelcraft-tokens/scripts/export-tokens.mjs +637 -75
- package/skills/pixelcraft-tui/SKILL.md +41 -25
- package/skills/pixelcraft-tui/references/bubbletea-lipgloss.md +49 -30
- package/skills/pixelcraft-tui/references/extended-tui-toolkits.md +127 -0
- package/skills/pixelcraft-tui/references/ink.md +77 -28
- package/skills/pixelcraft-tui/references/ratatui.md +70 -30
- package/skills/pixelcraft-tui/references/rich.md +53 -33
- package/skills/pixelcraft-tui/references/terminal-protocols.md +80 -0
- package/skills/pixelcraft-tui/references/textual.md +75 -34
- package/skills/pixelcraft-ux/SKILL.md +22 -12
- package/skills/pixelcraft-ux/references/feedback-performance.md +39 -19
- package/skills/pixelcraft-ux/references/forms.md +57 -3
- package/skills/pixelcraft-ux/references/i18n.md +50 -12
- package/skills/pixelcraft-ux/references/laws.md +35 -14
- package/skills/pixelcraft-ux/references/state-matrix.md +15 -1
- package/skills/pixelcraft-ux/references/ux-writing.md +1 -0
- package/skills/pixelcraft-visual-qa/SKILL.md +21 -7
- package/skills/pixelcraft-visual-qa/references/capture-desktop-game.md +28 -7
- package/skills/pixelcraft-visual-qa/references/capture-document.md +70 -0
- package/skills/pixelcraft-visual-qa/references/capture-email.md +13 -9
- package/skills/pixelcraft-visual-qa/references/capture-mobile.md +20 -5
- package/skills/pixelcraft-visual-qa/references/capture-terminal.md +6 -2
- package/skills/pixelcraft-visual-qa/references/motion-capture.md +63 -0
- package/skills/pixelcraft-visual-qa/references/performance-budgets.md +25 -12
- package/skills/pixelcraft-visual-qa/references/realtime-graphics.md +55 -0
- package/skills/pixelcraft-visual-qa/scripts/check-contrast.mjs +442 -0
- package/skills/pixelcraft-visual-qa/scripts/check-email.mjs +397 -0
- package/skills/pixelcraft-visual-qa/scripts/check-pdf.mjs +189 -0
- package/skills/pixelcraft-visual-qa/scripts/check-tui.mjs +321 -0
- package/skills/pixelcraft-visual-qa/scripts/finish-gate.mjs +50 -11
- package/skills/pixelcraft-visual-qa/scripts/shoot.mjs +214 -59
- package/skills/pixelcraft-visual-qa/scripts/style-inventory.mjs +121 -49
- package/skills/pixelcraft-web/SKILL.md +105 -49
- package/skills/pixelcraft-web/references/accessibility-performance.md +42 -0
- package/skills/pixelcraft-web/references/adaptive-layout.md +52 -8
- package/skills/pixelcraft-web/references/angular.md +63 -16
- package/skills/pixelcraft-web/references/assets-pipeline.md +67 -0
- package/skills/pixelcraft-web/references/astro.md +64 -13
- package/skills/pixelcraft-web/references/audio-reactive.md +61 -0
- package/skills/pixelcraft-web/references/auth-and-checkout-ui.md +115 -0
- package/skills/pixelcraft-web/references/build-and-architecture.md +215 -0
- package/skills/pixelcraft-web/references/canvas-and-node-editors.md +157 -0
- package/skills/pixelcraft-web/references/clojurescript.md +52 -17
- package/skills/pixelcraft-web/references/component-systems.md +102 -0
- package/skills/pixelcraft-web/references/component-testing.md +170 -0
- package/skills/pixelcraft-web/references/creative-effects.md +59 -0
- package/skills/pixelcraft-web/references/creative-runtime.md +34 -0
- package/skills/pixelcraft-web/references/enterprise-data-ui.md +138 -0
- package/skills/pixelcraft-web/references/file-upload-media-ui.md +82 -0
- package/skills/pixelcraft-web/references/forms-validation.md +123 -0
- package/skills/pixelcraft-web/references/fsharp-fable.md +3 -2
- package/skills/pixelcraft-web/references/gsap.md +102 -0
- package/skills/pixelcraft-web/references/html-css.md +144 -12
- package/skills/pixelcraft-web/references/htmx-alpine.md +68 -18
- package/skills/pixelcraft-web/references/i18n-engineering.md +106 -0
- package/skills/pixelcraft-web/references/interaction-and-search-primitives.md +196 -0
- package/skills/pixelcraft-web/references/java-web.md +27 -18
- package/skills/pixelcraft-web/references/kotlin-web.md +6 -2
- package/skills/pixelcraft-web/references/leptos-yew.md +62 -19
- package/skills/pixelcraft-web/references/lit-web-components.md +4 -2
- package/skills/pixelcraft-web/references/local-first-sync.md +105 -0
- package/skills/pixelcraft-web/references/media-players.md +104 -0
- package/skills/pixelcraft-web/references/motion-react.md +96 -0
- package/skills/pixelcraft-web/references/motion-recipes.md +82 -0
- package/skills/pixelcraft-web/references/preact-fresh-hono.md +111 -0
- package/skills/pixelcraft-web/references/pwa.md +6 -1
- package/skills/pixelcraft-web/references/qwik.md +51 -11
- package/skills/pixelcraft-web/references/r3f-integration.md +69 -0
- package/skills/pixelcraft-web/references/react-next.md +112 -13
- package/skills/pixelcraft-web/references/rendering-choice.md +63 -0
- package/skills/pixelcraft-web/references/rendering-performance.md +80 -0
- package/skills/pixelcraft-web/references/rich-text-and-code-editors.md +220 -0
- package/skills/pixelcraft-web/references/rive-lottie.md +73 -0
- package/skills/pixelcraft-web/references/scene-architecture.md +132 -0
- package/skills/pixelcraft-web/references/server-rendered.md +106 -63
- package/skills/pixelcraft-web/references/shader-workflow.md +77 -0
- package/skills/pixelcraft-web/references/smooth-scroll.md +58 -0
- package/skills/pixelcraft-web/references/solid.md +67 -16
- package/skills/pixelcraft-web/references/state-architecture.md +107 -0
- package/skills/pixelcraft-web/references/styling-ecosystem.md +273 -0
- package/skills/pixelcraft-web/references/svelte.md +61 -11
- package/skills/pixelcraft-web/references/tailwind.md +40 -14
- package/skills/pixelcraft-web/references/video-media.md +69 -0
- package/skills/pixelcraft-web/references/vue-nuxt.md +37 -13
- package/skills/pixelcraft-web/references/web-3d-engines.md +97 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# Frontend build tools, application architecture, and browser runtime
|
|
2
|
+
|
|
3
|
+
Select the bundler, rendering architecture, microfrontend boundary, and browser runtime primitives to match the product's delivery constraints—not default templates. For PWA manifest/installability UX, read [pwa.md](pwa.md); for Lit Shadow DOM accessibility/form internals, read [lit-web-components.md](lit-web-components.md).
|
|
4
|
+
|
|
5
|
+
## Build, linting, and bundling decision matrix
|
|
6
|
+
|
|
7
|
+
| Tool | Underlying engine | Best fit | Version & migration rules |
|
|
8
|
+
|---|---|---|---|
|
|
9
|
+
| **Vite 8+** | **Rolldown** (Rust bundler) + **Oxc** (JS/TS transform & minifier) | Modern React, Vue, Svelte, Solid, Astro, Qwik apps and libraries | Do not write legacy `esbuild` / `optimizeDeps.esbuildOptions` config on Vite 8+: migrate to `oxc`, `optimizeDeps.rolldownOptions`, and `build.rolldownOptions`. Vite 8 no longer ships `esbuild` by default. |
|
|
10
|
+
| **Vite 6–7** | Rollup (build) + esbuild (dev/dep pre-bundling) | Existing Vite 6–7 repos not yet upgraded to v8 | Verify installed major in `package.json` before choosing `rollupOptions` vs `rolldownOptions`. |
|
|
11
|
+
| **Rspack / Rsbuild** | Rust Webpack-compatible bundler | Webpack migrations, enterprise monorepos, Module Federation 2.0 | Use Rsbuild (`@rsbuild/core`) for ergonomic defaults (`performance.chunkSplit`, built-in `moduleFederation.options`); drop down to raw Rspack only for custom Webpack plugin pipelines. |
|
|
12
|
+
| **Turbopack** | Incremental Rust bundler (Next.js) | Next.js dev/production builds | Align loaders and resolve aliases with Next.js `turbopack` config; avoid Webpack-only plugins that block Turbopack adoption. |
|
|
13
|
+
| **`tsdown`** | Rolldown + Oxc (superseding `tsup`) | TypeScript/JS npm packages and workspace UI libraries | Prefer `tsdown` (`dts: true`, isolated declarations fast `.d.ts` emit) over legacy `tsup` for new library builds. |
|
|
14
|
+
| **Bun bundler (`bun build`)** | Zig native bundler + runtime | Bun-first full-stack apps, scripts, single-file executables | Verify Node/browser compatibility for plugins and SSR adapters when targeting non-Bun hosts. |
|
|
15
|
+
| **Webpack 5 / Parcel / esbuild** | JS / Rust / Go | Legacy enterprise Webpack pipelines; zero-config static bundles (Parcel); fast single-pass CLI transforms (esbuild) | Maintain existing setups; prefer Vite 8, Rsbuild, or `tsdown` for greenfield builds. |
|
|
16
|
+
|
|
17
|
+
### Linting, formatting, and compiler plugins
|
|
18
|
+
|
|
19
|
+
- **Biome**: single Rust binary for formatting + linting (`biome check --write`) across JS/TS/JSX/CSS/JSON/HTML with zero Prettier/ESLint plugin sprawl; pair with framework-specific linters only where needed (e.g., complex Vue/Svelte template rules).
|
|
20
|
+
- **Oxlint & Oxfmt** (Oxc toolchain): ultra-fast Rust linter (`oxlint`) and formatter (`oxfmt`) that run orders of magnitude faster than ESLint in CI—either standalone or ahead of narrow type-aware/framework ESLint rules.
|
|
21
|
+
- **React Compiler build plugin**: enable `reactCompiler: true` in Next.js 15/16 or wire `babel-plugin-react-compiler` in Vite/Rsbuild (paired with `eslint-plugin-react-hooks` compiler rules) so pure React components auto-memoize without hand-written `useMemo`/`useCallback`.
|
|
22
|
+
|
|
23
|
+
### Vite 8 (Rolldown + Oxc) and Vite Environment API idiom
|
|
24
|
+
|
|
25
|
+
- **Chunk splitting breaking change**: Vite 8 / Rolldown removes object-form `manualChunks` and deprecates function-form `manualChunks`. Use `build.rolldownOptions.output.codeSplitting.groups` (`name`, `test`, `priority`), and enable `strictExecutionOrder` only if aggressive chunk splitting causes module-initialization order errors.
|
|
26
|
+
- **Vite Environment API**: modern meta-frameworks (React Router v7, TanStack Start, Cloudflare Vite plugin, Nuxt, SvelteKit) separate client, SSR, and edge worker runtimes under `environments: { client: ..., ssr: ... }`—scope browser-only chunk rules under `environments.client.build` rather than mutating global build options blindly.
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
// vite.config.ts (Vite 8+ with Environment API & Rolldown)
|
|
30
|
+
import { defineConfig } from 'vite';
|
|
31
|
+
|
|
32
|
+
export default defineConfig({
|
|
33
|
+
oxc: {
|
|
34
|
+
jsx: { runtime: 'automatic' },
|
|
35
|
+
},
|
|
36
|
+
optimizeDeps: {
|
|
37
|
+
rolldownOptions: {
|
|
38
|
+
// replaces deprecated optimizeDeps.esbuildOptions
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
environments: {
|
|
42
|
+
client: {
|
|
43
|
+
build: {
|
|
44
|
+
rolldownOptions: {
|
|
45
|
+
output: {
|
|
46
|
+
codeSplitting: {
|
|
47
|
+
groups: [
|
|
48
|
+
{ name: 'framework-vendor', test: /node_modules[\\/](?:react|react-dom|scheduler)[\\/]/, priority: 30 },
|
|
49
|
+
{ name: 'vendor', test: /node_modules[\\/]/, priority: 10 },
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
minify: { compress: { dropConsole: true } },
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Rendering architecture decision matrix
|
|
62
|
+
|
|
63
|
+
Choose the lightest rendering strategy that satisfies interactivity, freshness, and SEO:
|
|
64
|
+
|
|
65
|
+
| Strategy | HTML generated | JS shipped to client | Best fit | Primary trap |
|
|
66
|
+
|---|---|---|---|---|
|
|
67
|
+
| **SSG** | Build time | Optional / minimal | Docs, marketing, blogs, catalogs with infrequent updates | Full rebuilds scaling poorly on 10k+ pages |
|
|
68
|
+
| **ISR / On-demand revalidation** | Build + cached server refresh | Page/route bundle | E-commerce, news, high-traffic CMS pages | Stale-while-revalidate surprises on auth-scoped content |
|
|
69
|
+
| **SSR (streaming)** | Per request | Full or selective hydration | Personalized pages, auth-gated dashboards, live SEO pages | Hydration mismatch & slow TTFB blocking first paint |
|
|
70
|
+
| **Islands / Partial Hydration** | Build or SSR | Only interactive islands (`client:visible`, `client:idle`) | Content-heavy sites with isolated widgets (Astro, Fresh, Leptos) | Accidental top-level wrapper hydrating the entire page |
|
|
71
|
+
| **Resumability** | SSR with serialized listeners | Lazy-loaded on interaction (Qwik) | Mobile-first, interaction-sensitive apps with tight INP budgets | Breaking serialization boundaries with non-serializable closures |
|
|
72
|
+
| **SPA (CSR)** | Empty shell + client render | Full app bundle | Authenticated tools, offline-first editors, canvas workspaces | Blank first paint, poor SEO, waterfall data fetching |
|
|
73
|
+
|
|
74
|
+
## Microfrontends
|
|
75
|
+
|
|
76
|
+
Use microfrontends only when **independent team deployment** outweighs shared-state and bundle-duplication costs. Prefer a monorepo with package boundaries first.
|
|
77
|
+
|
|
78
|
+
| Approach | Mechanism | Best fit | Key rule |
|
|
79
|
+
|---|---|---|---|
|
|
80
|
+
| **Module Federation 2.0** (`@module-federation/core`, Rsbuild, `@module-federation/vite`) | Runtime remote container loading + `mf-manifest.json` + typed DTS | Multi-team React/Vue/Angular apps sharing runtime singletons | Always pin framework singletons (`singleton: true`, `requiredVersion`) and isolate CSS so remotes cannot collide. |
|
|
81
|
+
| **single-spa** | Lifecycle router (`bootstrap`, `mount`, `unmount`) across frameworks | Incremental migration between different frameworks (e.g. Angular → React) | Enforce strict unmount cleanup (listeners, timers, portals) to prevent memory leaks across route switches. |
|
|
82
|
+
| **Piral** | Shell + pilets plugin architecture | Extensible enterprise portals with third-party UI plugins | Version the pilet API contract strictly; never expose internal shell state directly. |
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
// rsbuild.config.ts (Module Federation 2.0 remote)
|
|
86
|
+
import { defineConfig } from '@rsbuild/core';
|
|
87
|
+
|
|
88
|
+
export default defineConfig({
|
|
89
|
+
moduleFederation: {
|
|
90
|
+
options: {
|
|
91
|
+
name: 'billing_remote',
|
|
92
|
+
filename: 'remoteEntry.js',
|
|
93
|
+
exposes: { './InvoicePanel': './src/InvoicePanel' },
|
|
94
|
+
shared: {
|
|
95
|
+
react: { singleton: true, requiredVersion: '^19.0.0' },
|
|
96
|
+
'react-dom': { singleton: true, requiredVersion: '^19.0.0' },
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Web Components ecosystem
|
|
104
|
+
|
|
105
|
+
When building framework-agnostic leaf components or cross-framework design systems:
|
|
106
|
+
|
|
107
|
+
- **Lit**: lightweight standards-based custom elements ([lit-web-components.md](lit-web-components.md)).
|
|
108
|
+
- **Stencil**: compiler generating standard Web Components plus framework wrapper packages (React/Vue/Angular) for enterprise design systems.
|
|
109
|
+
- **FAST**: Microsoft's Web Components foundation with design tokens and adaptive color recipes.
|
|
110
|
+
- **Shoelace / Web Awesome**: ready-to-use accessible Web Components (`sl-*` / `wa-*`) with CSS custom properties, `::part()` hooks, and React wrappers.
|
|
111
|
+
|
|
112
|
+
## Browser runtime offloading
|
|
113
|
+
|
|
114
|
+
Keep the main thread free for input and 60fps rendering (INP < 200ms):
|
|
115
|
+
|
|
116
|
+
- **Web Workers**: move heavy JSON/CSV parsing, search indexing, syntax highlighting, diffing, and crypto off the main thread. Transfer `ArrayBuffer`s (zero-copy) instead of structured-cloning large payloads.
|
|
117
|
+
- **OffscreenCanvas**: transfer a canvas with `canvas.transferControlToOffscreen()` into a Worker for heavy 2D/WebGL rendering (charts, waveforms, image filters) so animations never stall UI input.
|
|
118
|
+
- **WebAssembly (WASM)**: reserve for compute-dense workloads (image/video codecs, CAD/layout engines, SQLite/DuckDB in-browser, audio DSP). Always load `.wasm` via `WebAssembly.instantiateStreaming` and run heavy compute inside a Worker.
|
|
119
|
+
- **Service Workers**: intercept network requests for caching and offline resilience; never store mutable app state in Service Worker memory (workers terminate when idle—use Cache API or IndexedDB).
|
|
120
|
+
|
|
121
|
+
## Offline & Service Worker tooling (Serwist / Workbox)
|
|
122
|
+
|
|
123
|
+
Prefer **Serwist** (the actively maintained Workbox fork for Vite, Next.js, Nuxt, SvelteKit) or **Workbox** over hand-rolling raw `fetch` event listeners:
|
|
124
|
+
|
|
125
|
+
- **Precaching**: inject build-hashed assets into `self.__SW_MANIFEST` with `cleanupOutdatedCaches: true`.
|
|
126
|
+
- **Runtime caching**: match by `request.destination` (`StaleWhileRevalidate` for images, `CacheFirst` for hashed scripts/styles, `NetworkFirst` for HTML/API).
|
|
127
|
+
- **Background Sync**: use `BackgroundSyncPlugin` on mutating `POST`/`PATCH` routes—note that `fetchDidFail` triggers only on network exceptions, not HTTP `4xx`/`5xx` responses.
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
// sw.ts (Serwist)
|
|
131
|
+
import { BackgroundSyncPlugin, CacheFirst, NetworkOnly, Serwist, StaleWhileRevalidate } from 'serwist';
|
|
132
|
+
|
|
133
|
+
const bgSync = new BackgroundSyncPlugin('offline-mutations', {
|
|
134
|
+
maxRetentionTime: 24 * 60, // minutes
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
const serwist = new Serwist({
|
|
138
|
+
precacheEntries: self.__SW_MANIFEST,
|
|
139
|
+
precacheOptions: { cleanupOutdatedCaches: true },
|
|
140
|
+
skipWaiting: true,
|
|
141
|
+
clientsClaim: true,
|
|
142
|
+
runtimeCaching: [
|
|
143
|
+
{ matcher: ({ request }) => request.destination === 'image', handler: new StaleWhileRevalidate({ cacheName: 'images' }) },
|
|
144
|
+
{ matcher: ({ request }) => request.destination === 'script', handler: new CacheFirst({ cacheName: 'scripts' }) },
|
|
145
|
+
{ matcher: ({ url }) => url.pathname.startsWith('/api/sync'), handler: new NetworkOnly({ plugins: [bgSync] }), method: 'POST' },
|
|
146
|
+
],
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
serwist.addEventListeners();
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Post-tag performance budgets & third-party script isolation
|
|
153
|
+
|
|
154
|
+
Measure production performance **after** analytics, GTM, ad pixels, A/B testing, and chat widgets are active—never solely on a clean dev build.
|
|
155
|
+
|
|
156
|
+
### Mandatory production budgets (3-run median under 4G + 4× CPU throttle)
|
|
157
|
+
|
|
158
|
+
| Metric / Audit | Studio-grade floor | Measurement rule |
|
|
159
|
+
|---|---|---|
|
|
160
|
+
| **Lighthouse (Mobile + Desktop)** | **Perf ≥ 90**, **A11y ≥ 95**, **Best Practices ≥ 95**, **SEO ≥ 95** | **3-run median** on **every primary template** against production build with real tags/consent state active |
|
|
161
|
+
| **Initial compressed JS+CSS payload** | Content/editorial **`<= 150–250 KB`** · Dashboard/app **`<= 250–450 KB`** · Promotional/rich experience **`<= 350–700 KB`** · Embedded widget **`<= 100–200 KB`** | Initial pre-`load` compressed transfer (`~3.1 MB / 103 req` showcase median is a cost calibration benchmark, **never** an acceptable target budget) + **Network waterfall capture on heaviest page** |
|
|
162
|
+
| **Largest Contentful Paint (LCP)** | **< 2.5 s** (p75 field & lab) | Never lazy-load LCP hero media; set `fetchpriority="high"` + responsive `srcset` |
|
|
163
|
+
| **Interaction to Next Paint (INP) & `LoAF`** | **< 200 ms** (p75 field & lab); clean **Long Animation Frames (`LoAF`)** on scroll/drag | Yield long tasks (`scheduler.yield()`), isolate 3rd-party scripts off main thread, cap luminance flashes **`<= 3 Hz`** (`WCAG 2.3.1`) |
|
|
164
|
+
| **Cumulative Layout Shift (CLS)** | **< 0.10** (target `0.00` above fold) | Explicit media dimensions, metric-matched font fallbacks, zero-shift consent UI |
|
|
165
|
+
|
|
166
|
+
### Third-party tag, pixel, and chat widget isolation
|
|
167
|
+
|
|
168
|
+
- **Edge / Worker offloading**: route analytics and ad pixels through server-side/edge gateways (**Cloudflare Zaraz**, server-side GTM) or isolate main-thread scripts in a Web Worker via **Partytown** (`@builder.io/partytown`) where compatible.
|
|
169
|
+
- **Interaction facades**: never boot heavy third-party embeds (YouTube/Vimeo iframes, Intercom/Crisp/Zendesk live chat, Calendly, heavy maps) on initial page load. Render a lightweight static button/thumbnail facade (`lite-youtube-embed` or a semantic `"Chat with support"` button) and dynamically import the vendor SDK on `pointerenter`, `focus`, or `click`.
|
|
170
|
+
- **Consent Mode v2 without CLS**: initialize default consent state synchronously in `<head>` (`ad_storage`, `ad_user_data`, `ad_personalization`, `analytics_storage` set to `'denied'` before any tag script executes) and upgrade via `gtag('consent', 'update', ...)` after explicit user choice. Render cookie/consent UI as a fixed bottom sheet/banner (`position: fixed`) with keyboard non-trapping focus—never inject a flow banner at the top of `<body>` that pushes page content down after hydration.
|
|
171
|
+
|
|
172
|
+
## CDN cache control, HTTP security headers & deployment safety
|
|
173
|
+
|
|
174
|
+
| Resource class | Recommended `Cache-Control` header | Rationale |
|
|
175
|
+
|---|---|---|
|
|
176
|
+
| Content-hashed build assets (`/_next/static/*`, `/assets/*.[hash].*`, subset `.woff2`) | `public, max-age=31536000, immutable` | Safe 1-year browser + CDN edge caching; filename changes on rebuild |
|
|
177
|
+
| Public SSG/ISR HTML & public JSON feeds | `public, max-age=0, s-maxage=60, stale-while-revalidate=86400` | Instant CDN edge response with background revalidation |
|
|
178
|
+
| Authenticated, user-specific, checkout, or tenant-scoped HTML/API | `private, no-store` (+ `Vary: Cookie, Authorization` if shared proxy exists) | Prevents catastrophic cross-tenant/session cache poisoning at CDN edge |
|
|
179
|
+
|
|
180
|
+
Ship these baseline HTTP security headers on every HTML response (via edge middleware, CDN rules, or reverse proxy) alongside **isolated PR preview deployments** and a tested **instant rollback plan** (previous immutable artifact alias or CDN/edge deployment promotion):
|
|
181
|
+
|
|
182
|
+
- **`Content-Security-Policy`**: strict allowlist or per-request nonce (`script-src 'self' 'nonce-...' 'strict-dynamic'; object-src 'none'; base-uri 'self'; frame-ancestors 'none'`).
|
|
183
|
+
- **`Strict-Transport-Security`**: `max-age=63072000; includeSubDomains; preload`.
|
|
184
|
+
- **`X-Content-Type-Options`**: `nosniff`.
|
|
185
|
+
- **`Referrer-Policy`**: `strict-origin-when-cross-origin`.
|
|
186
|
+
- **`Permissions-Policy`**: `camera=(), microphone=(), geolocation=(), payment=(self)` (enable capabilities only on routes that use them).
|
|
187
|
+
|
|
188
|
+
## Technical SEO, redesign migration & AI/social unfurl readiness
|
|
189
|
+
|
|
190
|
+
- **Per-route metadata & structured data**: emit a unique `<title>`, `<meta name="description">`, self-referencing `<link rel="canonical" href="https://...">`, `robots.txt`, generated `sitemap.xml`, `hreflang` + `x-default` alternates ([i18n-engineering.md](i18n-engineering.md)), and schema-valid JSON-LD (`Organization`, `Product`, `Article`, `FAQPage`, `BreadcrumbList`) matching visible page facts.
|
|
191
|
+
- **Redesign `301` redirect map & zero broken/orphan links**: when replacing an existing site, crawl and inventory every legacy URL before launch, enforce single-hop `301` (or method-preserving `308`) redirects for every changed slug, and run an automated link checker in CI to verify `0` internal `404`s, `0` redirect loops, and `0` orphaned public pages.
|
|
192
|
+
- **SSR/SSG semantic HTML & `/llms.txt` for AI search**: ensure primary headings, pricing, docs, and article copy render in initial SSR/SSG semantic HTML (`<main>`, `<article>`, `<table>`) without requiring client JS execution; publish a concise `/llms.txt` markdown index at the domain root linking canonical product, documentation, and policy URLs for AI crawlers and answer engines.
|
|
193
|
+
- **Zalo, Slack, iMessage, Facebook & LinkedIn Open Graph cards**: always serve `og:image` and `twitter:image` (`twitter:card="summary_large_image"`) as **`1200×630` absolute `https://` URLs** in **JPEG or PNG** (`< 600 KB`) with explicit `og:image:width="1200"` and `og:image:height="630"`. Never use relative `/og.png` paths, and never serve SVG or WebP-only `og:image` URLs—Zalo, enterprise Slack/Teams unfurlers, and legacy chat crawlers silently drop WebP/SVG previews.
|
|
194
|
+
|
|
195
|
+
## Do/don't pairs
|
|
196
|
+
|
|
197
|
+
| Do | Don't |
|
|
198
|
+
|---|---|
|
|
199
|
+
| Use `oxc` and `build.rolldownOptions` on Vite 8+ | Copy legacy `esbuild` / `optimizeDeps.esbuildOptions` snippets into Vite 8 configs |
|
|
200
|
+
| Mark `react` / `react-dom` as `singleton: true` in Module Federation | Load duplicate React runtimes across host and remote containers |
|
|
201
|
+
| Gate 3rd-party pixels/chat behind Zaraz/Partytown, click-to-load facades, and fixed Consent Mode v2 UI | Load GTM, Intercom, and YouTube iframes synchronously on `<head>` or push layout down with a late cookie bar |
|
|
202
|
+
| Serve `immutable` cache headers on hashed assets, `private, no-store` on auth routes, CSP/HSTS/`nosniff`, PR previews, and a rollback plan | Cache personalized responses at the CDN edge or ship production changes without preview isolation and rollback |
|
|
203
|
+
| Ship a tested legacy `301` redirect map, `/llms.txt`, and `1200×630` HTTPS PNG/JPEG `og:image` tags | Drop old indexed URLs to `404` on redesign or use relative/WebP/SVG `og:image` URLs that break in Zalo/Slack |
|
|
204
|
+
| Persist offline state in IndexedDB/Cache API and use Serwist/Workbox | Store state in Service Worker module globals that vanish when the worker sleeps |
|
|
205
|
+
| Match rendering strategy (SSG/ISR/Islands/SSR/SPA) and initial JS+CSS budget (`<= 150–700 KB` by class) to route interactivity | Ship a `3.1 MB` showcase-bloated SPA bundle for a content/marketing site |
|
|
206
|
+
|
|
207
|
+
## Verification commands
|
|
208
|
+
|
|
209
|
+
```sh
|
|
210
|
+
npm run build
|
|
211
|
+
npx lighthouse http://localhost:4173 --preset=perf --form-factor=mobile
|
|
212
|
+
npx lighthouse http://localhost:4173 --preset=desktop
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Inspect generated bundle chunks against surface-class JS+CSS budgets, HTTP response/security/cache headers, `sitemap.xml`/`robots.txt`/`llms.txt`, PR preview/rollback config, and `301` redirect rules (`static`), and verify **3-run median** post-tag Lighthouse scores (`Perf >= 90`, `A11y/BP/SEO >= 95` on mobile + desktop per primary template), CWV (`LCP < 2.5s`, `INP < 200ms`, `CLS < 0.1`), `LoAF` scroll/drag traces, heaviest-page Network waterfall, and deliverable captures across **`Chrome`, `Firefox`, `Edge`, `Safari macOS`, real `Safari iOS`, and `Chrome Android`** (`rendered`).
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# Canvas, diagram, node-based editors, and drag-and-drop
|
|
2
|
+
|
|
3
|
+
Choose between infinite whiteboard SDKs, 2D canvas scene graphs, DOM/SVG node-graph engines, and drag-and-drop toolchains by interaction model, object count, and accessibility requirements. For browser 3D scenes (`Three.js`, `R3F`, `Babylon.js`, `WebGL`/`WebGPU`), see [scene-architecture.md](scene-architecture.md) and [web-3d-engines.md](web-3d-engines.md); for embodied XR/VR/AR headset UX, use `pixelcraft-spatial`; for data charts, use `pixelcraft-dataviz`.
|
|
4
|
+
|
|
5
|
+
## Engine decision matrix
|
|
6
|
+
|
|
7
|
+
| Product type | Tools | Rendering model | Best fit | Primary trade-off |
|
|
8
|
+
|---|---|---|---|---|
|
|
9
|
+
| **Infinite whiteboard** | **tldraw** (v4), **Excalidraw** | HTML/SVG hybrid (tldraw) or rough Canvas 2D (Excalidraw) | Collaborative whiteboards, spatial canvases, diagramming apps | tldraw requires commercial license to remove watermark in production; Excalidraw's hand-drawn style is opinionated |
|
|
10
|
+
| **2D Canvas scene graph** | **Konva** (`react-konva` / `vue-konva`), **Fabric.js**, **Paper.js** | HTML5 Canvas 2D (multi-layer in Konva; single canvas in Fabric/Paper) | Design/annotation editors, floor plans, image/vector manipulation, 1k–10k shapes | Canvas pixels are invisible to screen readers unless paired with a parallel DOM/ARIA model |
|
|
11
|
+
| **Workflow / node graph** | **React Flow / XYFlow** (`@xyflow/react`, `@xyflow/svelte`), **Rete.js** | DOM nodes + SVG edges (XYFlow) | Visual automation builders, AI agent pipelines, low-code workflows, dataflow graphs | DOM node count above ~500–1,000 visible nodes needs virtualization or simplified LOD |
|
|
12
|
+
| **Network & enterprise diagrams** | **Cytoscape.js**, **JointJS**, **GoJS** | Canvas/WebGL (Cytoscape), SVG (JointJS), Canvas (GoJS) | Graph analytics / topology (Cytoscape); UML/BPMN/CAD enterprise diagrams (JointJS, GoJS) | GoJS and JointJS+ are commercial; Cytoscape is graph-layout focused rather than arbitrary React UI inside nodes |
|
|
13
|
+
| **Drag-and-drop** | **dnd-kit** (`@dnd-kit/core` v6 or `@dnd-kit/react` v0.x rewrite), **Pragmatic Drag and Drop** (`@atlaskit/pragmatic-drag-and-drop`) | Pointer/Keyboard sensors (dnd-kit) or native HTML5 DnD (Pragmatic) | **dnd-kit**: accessible sortable lists, kanban, trees with built-in keyboard sensor; **Pragmatic DnD**: tiny, framework-agnostic, cross-window/file drops, huge tables | Pragmatic DnD relies on native HTML5 DnD—must pair with explicit keyboard + single-pointer reorder actions and ARIA live announcements |
|
|
14
|
+
|
|
15
|
+
## Node-based editors (React Flow / XYFlow)
|
|
16
|
+
|
|
17
|
+
- Always import **`'@xyflow/react/dist/style.css'`** (not `'@xyflow/react/style.css'`) and give the `<ReactFlow>` parent container an explicit non-zero height and width.
|
|
18
|
+
- **Memoization rule**: define `nodeTypes` and `edgeTypes` **outside** the component or inside `useMemo(() => (...), [])`. Wrap custom node/edge components in `React.memo` and callbacks (`onNodesChange`, `onEdgesChange`, `onConnect`) in `useCallback`. Passing a fresh inline `nodeTypes={{ custom: MyNode }}` object on every render forces React Flow to unmount and remount nodes on every drag tick.
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import { useMemo, useCallback } from 'react';
|
|
22
|
+
import { ReactFlow, useNodesState, useEdgesState, addEdge, type Connection } from '@xyflow/react';
|
|
23
|
+
import '@xyflow/react/dist/style.css';
|
|
24
|
+
import { TriggerNode } from './TriggerNode';
|
|
25
|
+
|
|
26
|
+
export function WorkflowCanvas() {
|
|
27
|
+
const [nodes, , onNodesChange] = useNodesState([]);
|
|
28
|
+
const [edges, setEdges, onEdgesChange] = useEdgesState([]);
|
|
29
|
+
const nodeTypes = useMemo(() => ({ trigger: TriggerNode }), []);
|
|
30
|
+
|
|
31
|
+
const onConnect = useCallback(
|
|
32
|
+
(connection: Connection) => setEdges((eds) => addEdge(connection, eds)),
|
|
33
|
+
[setEdges],
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div style={{ width: '100%', height: '640px' }}>
|
|
38
|
+
<ReactFlow
|
|
39
|
+
nodes={nodes}
|
|
40
|
+
edges={edges}
|
|
41
|
+
nodeTypes={nodeTypes}
|
|
42
|
+
onNodesChange={onNodesChange}
|
|
43
|
+
onEdgesChange={onEdgesChange}
|
|
44
|
+
onConnect={onConnect}
|
|
45
|
+
fitView
|
|
46
|
+
/>
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Infinite whiteboards (tldraw / Excalidraw)
|
|
53
|
+
|
|
54
|
+
- **tldraw**: import `'tldraw/tldraw.css'` and pass `persistenceKey="board-id"` for automatic IndexedDB persistence and cross-tab sync. When building custom shapes with `BaseBoxShapeUtil`, validate props via `T.*` (`RecordProps`), render interactive UI inside `<HTMLContainer>`, and call `onPointerDown={(e) => e.stopPropagation()}` on inner buttons/inputs so canvas pan/select gestures do not hijack clicks.
|
|
55
|
+
- **Excalidraw**: lazy-load `@excalidraw/excalidraw` on the client only (no SSR) and treat `excalidrawAPI` ref calls as imperative mutations rather than re-passing the entire scene array on every keystroke.
|
|
56
|
+
|
|
57
|
+
## 2D Canvas performance (Konva / Fabric.js)
|
|
58
|
+
|
|
59
|
+
Every Konva `<Layer>` creates a separate `<canvas>` element. Keep layer count minimal (typically 2–4: static background, main scene, active drag layer):
|
|
60
|
+
|
|
61
|
+
- Set `listening={false}` on background/decorative layers and non-interactive shapes to skip hit-graph rendering.
|
|
62
|
+
- Set `perfectDrawEnabled={false}` on filled+stroked shapes where sub-pixel alpha overlap is unnecessary, and call `node.cache()` on complex static shapes/groups.
|
|
63
|
+
- Move the active shape onto a dedicated drag layer during `dragstart` and return it on `dragend` (via `shape.moveTo(dragLayer)` or `react-konva-utils` `<Portal>`) so dragging does not repaint the entire main layer on every frame.
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
// Konva 3-layer drag optimization
|
|
67
|
+
const backgroundLayer = new Konva.Layer({ listening: false });
|
|
68
|
+
const mainLayer = new Konva.Layer();
|
|
69
|
+
const dragLayer = new Konva.Layer();
|
|
70
|
+
|
|
71
|
+
star.cache();
|
|
72
|
+
star.on('dragstart', () => star.moveTo(dragLayer));
|
|
73
|
+
star.on('dragend', () => star.moveTo(mainLayer));
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Drag-and-drop toolchains & accessibility
|
|
77
|
+
|
|
78
|
+
### dnd-kit (`@dnd-kit/core` v6 vs `@dnd-kit/react` v0.x)
|
|
79
|
+
|
|
80
|
+
Check `package.json` before writing imports—there are two distinct API generations:
|
|
81
|
+
|
|
82
|
+
- **Stable `@dnd-kit/core` v6 (+ `@dnd-kit/sortable`)**: uses `<DndContext sensors={sensors}>` with `useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }))`. Always include `KeyboardSensor` alongside `PointerSensor`.
|
|
83
|
+
- **Rewrite `@dnd-kit/react` v0.x (+ `@dnd-kit/dom`)**: uses `<DragDropProvider>` where custom sensor arrays **must extend** `defaults` (`sensors={(defaults) => [...]}`) so the default keyboard sensor is not dropped.
|
|
84
|
+
- Provide visible focus indicators on drag handles, screen-reader announcements (`accessibility.announcements`), and single-pointer reorder alternatives (WCAG 2.5.7).
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
// @dnd-kit/core v6 (stable production API)
|
|
88
|
+
import { DndContext, KeyboardSensor, PointerSensor, useSensor, useSensors } from '@dnd-kit/core';
|
|
89
|
+
import { sortableKeyboardCoordinates } from '@dnd-kit/sortable';
|
|
90
|
+
|
|
91
|
+
const sensors = useSensors(
|
|
92
|
+
useSensor(PointerSensor, { activationConstraint: { distance: 6 } }),
|
|
93
|
+
useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }),
|
|
94
|
+
);
|
|
95
|
+
<DndContext sensors={sensors}>{/* sortable items */}</DndContext>;
|
|
96
|
+
|
|
97
|
+
// @dnd-kit/react v0.x rewrite (extend defaults to keep KeyboardSensor)
|
|
98
|
+
import { DragDropProvider } from '@dnd-kit/react';
|
|
99
|
+
import { PointerSensor as DomPointerSensor } from '@dnd-kit/dom';
|
|
100
|
+
|
|
101
|
+
<DragDropProvider
|
|
102
|
+
sensors={(defaults) => [
|
|
103
|
+
...defaults.filter((s) => s !== DomPointerSensor),
|
|
104
|
+
DomPointerSensor.configure({ /* activation constraints */ }),
|
|
105
|
+
]}
|
|
106
|
+
>
|
|
107
|
+
{/* sortable items */}
|
|
108
|
+
</DragDropProvider>;
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Pragmatic Drag and Drop (`@atlaskit/pragmatic-drag-and-drop`)
|
|
112
|
+
|
|
113
|
+
- Always merge cleanup functions returned by `draggable()`, `dropTargetForElements()`, and `monitorForElements()` using `combine(...)` inside `useEffect` (or framework unmount) so global listeners never leak.
|
|
114
|
+
- Because native HTML5 DnD has no built-in keyboard mode, pair every Pragmatic DnD reorderable list/board with an explicit keyboard + single-pointer control (e.g., "Move up / Move down / Move to column" action menu) and announce the new position in an `aria-live="polite"` region.
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
import { useEffect } from 'react';
|
|
118
|
+
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
119
|
+
import {
|
|
120
|
+
draggable,
|
|
121
|
+
dropTargetForElements,
|
|
122
|
+
} from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
123
|
+
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
const el = cardRef.current;
|
|
126
|
+
if (!el) return;
|
|
127
|
+
return combine(
|
|
128
|
+
draggable({ element: el }),
|
|
129
|
+
dropTargetForElements({ element: el }),
|
|
130
|
+
);
|
|
131
|
+
}, []);
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Canvas & diagram accessibility rules
|
|
135
|
+
|
|
136
|
+
- **WCAG 2.2 SC 2.5.7 (Dragging Movements)**: keyboard-only reordering satisfies WCAG 2.1.1 but does **not** satisfy 2.5.7. Every non-essential drag interaction (sortable lists, kanban cards, sliders, map/diagram controls—everything except essential freehand drawing/signature pads) **must also** provide a **single-pointer (click/tap) alternative** without holding and dragging (for example, clickable "Move up / Move down" buttons, a "Move to column…" menu, or click-on-track slider jumps).
|
|
137
|
+
- Any canvas or node-graph product that users must operate—not just view—needs keyboard navigation (pan/zoom shortcuts, focusable nodes/handles, delete/undo shortcuts) and an accessible structural view (outline list or inspector panel) for screen-reader users.
|
|
138
|
+
- Honor `prefers-reduced-motion` on auto-layout transitions, `fitView` animations, and zoom springs.
|
|
139
|
+
|
|
140
|
+
## Do/don't pairs
|
|
141
|
+
|
|
142
|
+
| Do | Don't |
|
|
143
|
+
|---|---|
|
|
144
|
+
| Memoize `nodeTypes` and `edgeTypes` outside render or in `useMemo` | Pass inline `nodeTypes={{ custom: CustomNode }}` literals into `<ReactFlow>` |
|
|
145
|
+
| Use `listening={false}`, `perfectDrawEnabled={false}`, and a drag layer in Konva | Redraw 500 uncached shapes on a single Konva layer every `pointermove` |
|
|
146
|
+
| Call `e.stopPropagation()` on `onPointerDown` for controls inside tldraw `HTMLContainer` | Let canvas drag gestures swallow button clicks inside custom shapes |
|
|
147
|
+
| Keep `KeyboardSensor` in dnd-kit or pair Pragmatic DnD with keyboard reorder actions | Ship pointer-only drag-and-drop with no keyboard alternative (WCAG 2.1.1 / 2.5.7) |
|
|
148
|
+
| Return `combine(draggable(...), dropTargetForElements(...))` from `useEffect` | Leak Pragmatic DnD listeners across route or list re-renders |
|
|
149
|
+
|
|
150
|
+
## Verification commands
|
|
151
|
+
|
|
152
|
+
```sh
|
|
153
|
+
npm run build
|
|
154
|
+
npx playwright test
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Verify 60fps drag/pan frame pacing, zoom-to-cursor accuracy, keyboard reordering, and pointer-vs-control event isolation in a real browser (`rendered`).
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
# ClojureScript:
|
|
1
|
+
# ClojureScript: UIx v2, Helix, and Reagent / re-frame
|
|
2
|
+
|
|
3
|
+
## Wrapper selection
|
|
4
|
+
|
|
5
|
+
| Library | React integration model | Best fit | Primary trade-off |
|
|
6
|
+
|---|---|---|---|
|
|
7
|
+
| **UIx v2 (`uix.core`)** | Zero-overhead React 18/19 wrapper (`defui`, `$`, `use-state`, `use-effect`, `use-ref`, Suspense, Error Boundaries) | New ClojureScript React 18/19 apps interoping cleanly with modern React hooks & headless UI libraries | Explicit React hook rules apply (use `uix.linter` / `clj-kondo` hooks) |
|
|
8
|
+
| **Helix (`helix.core`)** | Thin macro-based React hooks wrapper (`defnc`, `$`, `helix.hooks`) | Minimal React 18/19 interop with near-zero runtime abstraction | Smaller battery-included ecosystem than re-frame |
|
|
9
|
+
| **Reagent + re-frame** | Hiccup vectors + reactive atoms (`ratom`) + event/subscription graph | Existing Reagent/re-frame codebases and structured event-driven apps | Reagent wrapper indirection adds friction with React 18/19 concurrent hooks & modern JS libraries |
|
|
2
10
|
|
|
3
11
|
## Token mapping
|
|
4
12
|
|
|
5
|
-
Emit CSS variables/semantic classes and consume them in
|
|
13
|
+
Emit CSS variables/semantic classes and consume them in UIx/Helix `$` props (`:class`) or Reagent hiccup. Keep visual constants in CSS/theme assets; do not scatter hex/style maps through every view. Global state (context, atom, or re-frame subscription) may control the root theme attribute/class.
|
|
6
14
|
|
|
7
15
|
## Layout and responsive idioms
|
|
8
16
|
|
|
9
|
-
|
|
17
|
+
All three produce React-powered DOM. Use ordinary semantic HTML/CSS layout; ClojureScript components should expose composition without hiding markup semantics. re-frame owns event/subscription flow, not visual layout truth.
|
|
10
18
|
|
|
11
19
|
## Typography/custom fonts
|
|
12
20
|
|
|
@@ -14,32 +22,59 @@ Configure fonts in static CSS/HTML and map semantic type classes. Verify keyword
|
|
|
14
22
|
|
|
15
23
|
## Motion/reduced motion
|
|
16
24
|
|
|
17
|
-
Use CSS or deliberate React-compatible animation libraries only when needed. Read `prefers-reduced-motion` through CSS or browser interop/
|
|
25
|
+
Use CSS or deliberate React-compatible animation libraries only when needed. Read `prefers-reduced-motion` through CSS or browser interop (`js/window.matchMedia` inside `use-effect` with cleanup); do not trigger animation purely because a ratom or state hook changed.
|
|
18
26
|
|
|
19
27
|
## Accessibility specifics
|
|
20
28
|
|
|
21
|
-
Hiccup keywords
|
|
22
|
-
|
|
23
|
-
##
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
Neither `$` props nor Hiccup keywords enforce accessibility. Use real controls, labels (`:html-for` / `:for` matching the chosen wrapper), visible focus, keyboard events, focus restoration after mutation/dialog close, and browser validation semantics. Avoid div-click handlers.
|
|
30
|
+
|
|
31
|
+
## UIx v2 & Helix (React 18/19 hooks) idioms
|
|
32
|
+
|
|
33
|
+
In **UIx v2** (`defui` + `$`) and **Helix** (`defnc` + `$`), follow React 18/19 rules directly: use `use-id` for SSR-safe unique `<label>`/`aria-describedby` IDs, clean up observers/listeners in `use-effect` return functions (never return a non-function/nil carelessly—UIx enforces JS `undefined` vs cleanup fn), and interop with headless React primitives (`@base-ui/react`, `react-aria-components`, `radix-ui`) directly via `$`:
|
|
34
|
+
|
|
35
|
+
```clojure
|
|
36
|
+
;; UIx v2 idiom (React 18/19 hooks + semantic form controls)
|
|
37
|
+
(ns app.invoice-form
|
|
38
|
+
(:require [uix.core :as uix :refer [defui $]]))
|
|
39
|
+
|
|
40
|
+
(defui invoice-form [{:keys [on-save pending? error]}]
|
|
41
|
+
(let [input-id (uix/use-id)
|
|
42
|
+
error-id (str input-id "-err")
|
|
43
|
+
[email set-email] (uix/use-state "")]
|
|
44
|
+
($ :form {:on-submit (fn [e]
|
|
45
|
+
(.preventDefault e)
|
|
46
|
+
(on-save email))}
|
|
47
|
+
($ :label {:html-for input-id} "Billing email")
|
|
48
|
+
($ :input {:id input-id
|
|
49
|
+
:type "email"
|
|
50
|
+
:auto-complete "email"
|
|
51
|
+
:value email
|
|
52
|
+
:aria-invalid (boolean error)
|
|
53
|
+
:aria-describedby (when error error-id)
|
|
54
|
+
:on-change #(set-email (.. % -target -value))})
|
|
55
|
+
(when error
|
|
56
|
+
($ :p {:id error-id :role "alert"} error))
|
|
57
|
+
($ :button {:type "submit" :disabled pending?}
|
|
58
|
+
(if pending? "Saving…" "Save invoice")))))
|
|
59
|
+
```
|
|
26
60
|
|
|
27
|
-
## Forms idiom
|
|
61
|
+
## States & Forms idiom
|
|
28
62
|
|
|
29
|
-
|
|
63
|
+
Model async state explicitly (tagged maps or Malli/Spec schemas: `:idle`, `:loading`, `:empty`, `:partial`, `:error`, `:offline`, `:optimistic`) instead of unrelated booleans. Preserve values after failed submit and map server validation back to fields; do not block paste or validate destructively on every keystroke.
|
|
30
64
|
|
|
31
65
|
## Do/don't pairs
|
|
32
66
|
|
|
33
67
|
| Do | Don't |
|
|
34
68
|
|---|---|
|
|
35
|
-
| `
|
|
36
|
-
| `
|
|
37
|
-
|
|
|
38
|
-
|
|
|
69
|
+
| UIx v2 `($ :label {:html-for id} "Email")` / Reagent `[:label {:for id} "Email"]` | Placeholder-only input |
|
|
70
|
+
| `($ :button {:type "submit"} "Save")` / `[:button {:type "submit"} "Save"]` | Clickable `div` pretending to be a button |
|
|
71
|
+
| UIx v2 / Helix for new React 18/19 hook & third-party React library interop | Wrapping React 19 hook components inside Reagent class adaptors unnecessarily |
|
|
72
|
+
| Explicit async state maps/tags in state or re-frame `app-db` | Unrelated booleans hiding empty/error/loading conflicts |
|
|
73
|
+
| Cleanup function returned from `use-effect` and focus restoration on close | Leaking listeners or dropping focus on rerender/unmount |
|
|
39
74
|
|
|
40
75
|
## Known traps
|
|
41
76
|
|
|
42
|
-
|
|
77
|
+
Returning non-cleanup values from `use-effect` in React interop, stale subscriptions, untyped `app-db` drift, keyword typos invisible at compile time, Reagent `r/adapt-react-class` friction with React 19 hooks, rerender focus/caret loss, inaccessible wrapped React components.
|
|
43
78
|
|
|
44
79
|
## Verification commands
|
|
45
80
|
|
|
@@ -50,4 +85,4 @@ npx shadow-cljs watch app
|
|
|
50
85
|
npx playwright test
|
|
51
86
|
```
|
|
52
87
|
|
|
53
|
-
Inspect DOM/accessibility tree, keyboard/focus behavior,
|
|
88
|
+
Inspect DOM/accessibility tree, keyboard/focus behavior, production advanced-compiled output (`release`), offline/server errors, reduced motion, and localization/text scaling (`rendered`).
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Component systems and UI libraries
|
|
2
|
+
|
|
3
|
+
Choose a component system by **code ownership, visual distinctiveness, accessibility burden, and framework fit**—never by popularity alone. Do not install two competing component libraries in the same application surface.
|
|
4
|
+
|
|
5
|
+
## Three architectural models
|
|
6
|
+
|
|
7
|
+
| Model | Examples | Customization & brand control | Accessibility ownership | Upgrade & maintenance cost | Best fit |
|
|
8
|
+
|---|---|---|---|---|---|
|
|
9
|
+
| **Headless primitives** | **Base UI** (`@base-ui/react`), **Radix UI** (`radix-ui`), React Aria Components, Ark UI, Kobalte, Corvu, Reka UI, Bits UI, Headless UI, Ariakit | Full (zero opinionated CSS) | Library handles WAI-ARIA, keyboard, focus, roving tabindex | Low API churn; you own all styling | Custom design systems, distinctive brand products |
|
|
10
|
+
| **Source-first (copy-own)** | `shadcn/ui` (Radix or Base UI), `shadcn-svelte`, `shadcn-vue`, **Park UI** (Ark UI + Panda/Tailwind) | Full (source lives in your repo) | Delegated to underlying headless primitives (Base UI / Radix / Ark / Bits / Reka) | Manual diffing for upstream updates; zero version lock-in | Teams wanting fast velocity + full code ownership |
|
|
11
|
+
| **Styled & enterprise suites** | MUI, Ant Design, Mantine, Chakra UI v3, **Nuxt UI v3/v4**, HeroUI, Fluent UI, **React Spectrum S2**, Carbon, Vuetify, PrimeVue, Angular Material | Medium (theme tokens/overrides; fighting defaults is expensive) | Built-in per vendor spec | Package upgrades; larger baseline bundle | Internal tools, enterprise suites, ecosystems matching that design language |
|
|
12
|
+
|
|
13
|
+
## Headless primitives comparison
|
|
14
|
+
|
|
15
|
+
| Library | Maintainer / Core | DOM composition idiom | Frameworks | Standout strength |
|
|
16
|
+
|---|---|---|---|---|
|
|
17
|
+
| **Base UI (`@base-ui/react`)** | MUI team (incl. Radix & Floating UI authors) | Explicit `render` prop (nestable) + `Positioner` CSS vars (`--anchor-width`, `--available-height`) | React | Predictable `render` API without fragile `asChild` ref-merging; strong RTL & active v1+ maintenance (renamed from `@base-ui-components/react`) |
|
|
18
|
+
| **Radix UI (`radix-ui`)** | WorkOS | `asChild` (`Slot`) prop merging | React | Mature, widely deployed; unified `radix-ui` package replaces dozens of separate `@radix-ui/react-*` installs |
|
|
19
|
+
| **React Aria Components** | Adobe | Render props + `data-*` states (`data-entering`/`data-exiting`) + `--trigger-width` | React | Gold-standard WAI-ARIA, i18n, date/number/RTL, and screen-reader testing; underpins **React Spectrum S2** (`@react-spectrum/s2`) |
|
|
20
|
+
| **Ark UI / Zag.js** | Chakra team (Zag.js state machines) | `asChild` + `RootProvider` (`Ark UI`) or framework-agnostic `useMachine` + `normalizeProps` (`Zag.js`) | React, Vue, Solid, Svelte | Single finite-state-machine core across frameworks; adopt **Zag.js** directly when authoring a multi-framework design system without wrapper lock-in |
|
|
21
|
+
| **Melt UI** | Svelte OSS | Svelte 5 rune class builders (`new Select(...)`, `new Dialog(...)`) spreading trigger/content attributes directly onto native elements | Svelte 5 | Zero-wrapper Svelte 5 ergonomics (`melt` v1/Next) preserving direct DOM control and full Tailwind/CSS flexibility |
|
|
22
|
+
| **Kobalte & Corvu** | Solid OSS | Fine-grained Solid signals + `as` polymorphic prop (`Kobalte`) / specialized drawers & popovers (`Corvu`) | Solid | Idiomatic zero-VDOM accessible primitives built directly for Solid/SolidStart |
|
|
23
|
+
| **Headless UI** | Tailwind Labs | Render props + `data-*` state attributes | React, Vue | Minimal API surface for common disclosure/dialog/menu/combobox patterns |
|
|
24
|
+
| **Ariakit** | OSS | Polymorphic `render` prop + store hooks (`useComboboxStore`, `useMenuStore`, `useCompositeStore`) | React | Low-level composability for complex composite widgets: menubars, grids, nested submenus, and `aria-activedescendant` virtual focus |
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
// Base UI (@base-ui/react): explicit `render` prop avoids hidden ref/event merging surprises
|
|
28
|
+
import { Menu } from '@base-ui/react/menu';
|
|
29
|
+
|
|
30
|
+
<Menu.Trigger render={<button type="button" className="btn-trigger" />}>
|
|
31
|
+
Actions
|
|
32
|
+
</Menu.Trigger>
|
|
33
|
+
|
|
34
|
+
// Radix UI (unified `radix-ui` package): `asChild` merges props/refs onto a single ref-accepting child
|
|
35
|
+
import { Dialog } from 'radix-ui';
|
|
36
|
+
|
|
37
|
+
<Dialog.Trigger asChild>
|
|
38
|
+
<button type="button" className="btn-trigger">Open</button>
|
|
39
|
+
</Dialog.Trigger>
|
|
40
|
+
|
|
41
|
+
// Ariakit: composite grid / combobox with explicit store and `render` composition
|
|
42
|
+
import * as Ariakit from '@ariakit/react';
|
|
43
|
+
|
|
44
|
+
<Ariakit.ComboboxProvider>
|
|
45
|
+
<Ariakit.Combobox placeholder="Filter workspace…" className="field-input" />
|
|
46
|
+
<Ariakit.ComboboxPopover gutter={6} className="popover-surface">
|
|
47
|
+
<Ariakit.ComboboxItem value="billing" className="popover-item" />
|
|
48
|
+
</Ariakit.ComboboxPopover>
|
|
49
|
+
</Ariakit.ComboboxProvider>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Standalone Zag.js & Melt UI (Svelte 5) idioms
|
|
53
|
+
|
|
54
|
+
- **Zag.js standalone** (`@zag-js/dialog`, `@zag-js/combobox`, `@zag-js/tabs` + `@zag-js/react|vue|solid|svelte`): use when one team ships identical interactive state-machine behavior across React, Vue, Svelte, and Solid design-system packages. Call `useMachine(machine, { id: useId() })`, connect with `connect(service, normalizeProps)`, and spread `api.getTriggerProps()` / `api.getContentProps()` onto semantic HTML elements.
|
|
55
|
+
- **Melt UI (Svelte 5 / Melt Next)**: prefer rune-based builder classes (`const tabs = new Tabs({ value: () => active })` with `{...tabs.getTrigger('billing')}`) over legacy Svelte 4 store actions (`createTabs` + `use:melt`) so fine-grained `$state`/`$derived` reactivity stays clean and SSR-safe.
|
|
56
|
+
|
|
57
|
+
## `shadcn/ui` anti-slop guardrail
|
|
58
|
+
|
|
59
|
+
`shadcn/ui` (and `shadcn-svelte` / `shadcn-vue`) is a **source-first scaffolding starter**, NOT a finished visual identity. Shipping untouched default zinc neutrals (`--background`, `--muted`, `--border`), default `0.5rem` card radii, identical hairline card grids, and stock Inter/Geist defaults produces immediately recognizable AI slop.
|
|
60
|
+
|
|
61
|
+
Before building feature screens with `shadcn/ui` or Park UI:
|
|
62
|
+
1. Replace the generated CSS variables in `globals.css` with the project's semantic tokens from `pixelcraft-tokens` (surface hierarchy, ink contrast, brand accent, semantic radius scale, typography roles, and motion curve).
|
|
63
|
+
2. Remove unused default card borders/shadows when direction calls for editorial rules, flat tonal surfaces, or denser operational chrome.
|
|
64
|
+
3. Audit copied primitives (`components/ui/*`) for accessibility parity (dialog titles, focus rings, disabled contrast) and keep them aligned with the chosen underlying primitive (`@base-ui/react` or unified `radix-ui`).
|
|
65
|
+
|
|
66
|
+
## Positioning: Floating UI vs native browser primitives
|
|
67
|
+
|
|
68
|
+
- Prefer **native HTML primitives** when target browser support allows: `[popover]` + CSS Anchor Positioning (`anchor-name`, `position-anchor`, `position-try-fallbacks`, plus `margin: 0` reset) for top-layer tooltips/menus, **Invoker Commands** (`<button commandfor="id" command="toggle-popover">`) for zero-JS declarative triggers, and **Customizable `<select>`** (`@supports (appearance: base-select)` + `::picker(select)`) for styled dropdowns that keep native keyboard, form, and accessibility semantics.
|
|
69
|
+
- Use **Floating UI** (`@floating-ui/dom` for positioning only, or `@floating-ui/react` which adds `useClick`, `useDismiss`, `useRole`, `useHover({ handleClose: safePolygon() })` for diagonal Safe-Triangle submenu corridors, `useInteractions`, and `FloatingFocusManager`) when you need virtual reference elements (cursor-following tooltips, text-selection popovers), cascading pointer submenus (if not already using `@base-ui/react`, `radix-ui`, or Ariakit `Menu.Sub`), custom collision boundaries, or legacy browser parity.
|
|
70
|
+
- **Critical `autoUpdate` lifecycle rule**: pass `whileElementsMounted: autoUpdate` to `useFloating()` **only** when the floating element is conditionally mounted/unmounted; if hidden via CSS (`display: none`), call `autoUpdate` inside an effect keyed on `isOpen` and return its cleanup function to avoid leaking scroll/resize listeners.
|
|
71
|
+
|
|
72
|
+
## Ecosystem map by framework
|
|
73
|
+
|
|
74
|
+
| Framework | Headless / Source-first | Styled / Enterprise suites |
|
|
75
|
+
|---|---|---|
|
|
76
|
+
| **React** | **Base UI (`@base-ui/react`)**, **Radix UI (`radix-ui`)**, React Aria, Ark UI / **Zag.js**, **Ariakit**, **`shadcn/ui`** (supports both Radix & Base UI), **Park UI** | MUI, Ant Design, Mantine, Chakra UI v3, HeroUI; Enterprise: Fluent UI, **React Spectrum S2 (`@react-spectrum/s2`)**, IBM Carbon |
|
|
77
|
+
| **Vue / Nuxt** | Reka UI (successor to Radix Vue), Ark UI / **Zag.js**, Headless UI, `shadcn-vue`, **Park UI** | **Nuxt UI v3/v4** (Reka UI + Tailwind Variants), Vuetify, PrimeVue, Quasar, Element Plus, Naive UI |
|
|
78
|
+
| **Solid** | **Kobalte**, **Corvu**, **Ark UI** / **Zag.js**, **Park UI** | Solid UI / Kobalte-based design-system kits |
|
|
79
|
+
| **Svelte** | Bits UI, **Melt UI** (Svelte 5 builders), Ark UI / **Zag.js**, `shadcn-svelte` | Skeleton |
|
|
80
|
+
| **Angular** | Angular CDK (`@angular/cdk`), Spartan | Angular Material, PrimeNG, NG-ZORRO |
|
|
81
|
+
|
|
82
|
+
Verify current major versions and framework compatibility (e.g., React 19 ref-as-prop, Svelte 5 runes, Tailwind v4) against official docs before adopting.
|
|
83
|
+
|
|
84
|
+
## Component contract rules
|
|
85
|
+
|
|
86
|
+
- **Controlled and uncontrolled parity**: support both `value` + `onValueChange` (controlled) and `defaultValue` (uncontrolled) on reusable inputs/tabs/dialogs; never switch between modes mid-lifecycle.
|
|
87
|
+
- **Compound components over prop explosion**: expose composable parts (`Dialog.Root`, `Dialog.Trigger`, `Dialog.Content`, `Dialog.Close`) instead of 30 boolean/config props on one monolith.
|
|
88
|
+
- **Portal, inert, and focus restoration**: overlays rendered in portals must trap/scope focus while modal, mark background inert, close on `Escape`, and restore focus to the exact trigger on close.
|
|
89
|
+
- **Deterministic SSR IDs**: generate `aria-controls` / `aria-labelledby` IDs with framework primitives (`useId()`, `$props.id()`, `createUniqueId()`), never `Math.random()` or module-level counters that cause hydration mismatches.
|
|
90
|
+
- **Token boundary**: map design tokens into the library's theme/CSS-variable layer rather than writing `!important` overrides against vendor class names.
|
|
91
|
+
|
|
92
|
+
## Do/don't pairs
|
|
93
|
+
|
|
94
|
+
| Do | Don't |
|
|
95
|
+
|---|---|
|
|
96
|
+
| Wrap headless or styled primitives behind thin project-owned semantic wrappers (`Button`, `Dialog`) | Import raw third-party component internals in 100 feature files with ad-hoc overrides |
|
|
97
|
+
| Author project tokens (`pixelcraft-tokens`) before building on `shadcn/ui` or Park UI | Ship untouched `shadcn/ui` default zinc colors, `0.5rem` radius, and stock hairline borders |
|
|
98
|
+
| Use Zag.js for cross-framework state machines, Ariakit for composite grids/menubars, and Melt UI Svelte 5 builders | Reimplement `aria-activedescendant`, roving tabindex, or legacy Svelte 4 store actions by hand |
|
|
99
|
+
| Use current package names (`@base-ui/react`, unified `radix-ui`, `reka-ui`, `@react-spectrum/s2`) | Install deprecated `@base-ui-components/react`, `radix-vue`, or 20 mismatched `@radix-ui/react-*` versions |
|
|
100
|
+
| Pick one model (e.g., Base UI / Kobalte / Reka UI + semantic tokens) consistently per app | Mix MUI, Ant Design, and Radix portals on the same route (conflicting z-index/focus/CSS resets) |
|
|
101
|
+
| Keep semantic `<button>` / `<a>` elements when using `asChild` or `render` | Pass a non-interactive `<div>` into a trigger without keyboard/role semantics |
|
|
102
|
+
| Strip unused library theme layers and tree-shake icons/components | Ship a full enterprise suite CSS bundle just for one date picker |
|