@hobui/viui-cli 0.0.6 → 0.0.7
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/README.md +138 -139
- package/dist/adapters/adapter-registry.d.ts +12 -0
- package/dist/adapters/adapter-registry.d.ts.map +1 -0
- package/dist/adapters/adapter-registry.js +49 -0
- package/dist/adapters/adapter-types.d.ts +20 -0
- package/dist/adapters/adapter-types.d.ts.map +1 -0
- package/dist/adapters/adapter-types.js +1 -0
- package/dist/adapters/aider-adapter.d.ts +3 -0
- package/dist/adapters/aider-adapter.d.ts.map +1 -0
- package/dist/adapters/aider-adapter.js +8 -0
- package/dist/adapters/claude-adapter.d.ts +3 -0
- package/dist/adapters/claude-adapter.d.ts.map +1 -0
- package/dist/adapters/claude-adapter.js +15 -0
- package/dist/adapters/cline-adapter.d.ts +3 -0
- package/dist/adapters/cline-adapter.d.ts.map +1 -0
- package/dist/adapters/cline-adapter.js +8 -0
- package/dist/adapters/copilot-adapter.d.ts +5 -0
- package/dist/adapters/copilot-adapter.d.ts.map +1 -0
- package/dist/adapters/copilot-adapter.js +20 -0
- package/dist/adapters/cursor-adapter.d.ts +3 -0
- package/dist/adapters/cursor-adapter.d.ts.map +1 -0
- package/dist/adapters/cursor-adapter.js +18 -0
- package/dist/adapters/external/bolt-adapter.d.ts +3 -0
- package/dist/adapters/external/bolt-adapter.d.ts.map +1 -0
- package/dist/adapters/external/bolt-adapter.js +15 -0
- package/dist/adapters/external/chatgpt-adapter.d.ts +3 -0
- package/dist/adapters/external/chatgpt-adapter.d.ts.map +1 -0
- package/dist/adapters/external/chatgpt-adapter.js +14 -0
- package/dist/adapters/external/external-adapter-base.d.ts +15 -0
- package/dist/adapters/external/external-adapter-base.d.ts.map +1 -0
- package/dist/adapters/external/external-adapter-base.js +92 -0
- package/dist/adapters/external/gemini-adapter.d.ts +3 -0
- package/dist/adapters/external/gemini-adapter.d.ts.map +1 -0
- package/dist/adapters/external/gemini-adapter.js +14 -0
- package/dist/adapters/external/lovable-adapter.d.ts +3 -0
- package/dist/adapters/external/lovable-adapter.d.ts.map +1 -0
- package/dist/adapters/external/lovable-adapter.js +14 -0
- package/dist/adapters/external/v0-adapter.d.ts +3 -0
- package/dist/adapters/external/v0-adapter.d.ts.map +1 -0
- package/dist/adapters/external/v0-adapter.js +15 -0
- package/dist/adapters/windsurf-adapter.d.ts +3 -0
- package/dist/adapters/windsurf-adapter.d.ts.map +1 -0
- package/dist/adapters/windsurf-adapter.js +23 -0
- package/dist/assets/plugins/viui-conf/apply-theme-body.ts +23 -4
- package/dist/assets/plugins/viui-conf/defaults/README.md +2 -0
- package/dist/assets/plugins/viui-conf/defaults/app-bar.ts +1 -1
- package/dist/assets/plugins/viui-conf/defaults/buttons.ts +1 -1
- package/dist/assets/plugins/viui-conf/defaults/by-theme/minimalist-2.ts +1 -1
- package/dist/assets/plugins/viui-conf/defaults/cards.ts +1 -1
- package/dist/assets/plugins/viui-conf/defaults/expansion-panels.ts +16 -0
- package/dist/assets/plugins/viui-conf/defaults/index.ts +3 -0
- package/dist/assets/plugins/viui-conf/defaults/inputs.ts +11 -1
- package/dist/assets/plugins/viui-conf/design-tokens.ts +135 -0
- package/dist/assets/plugins/viui-conf/theme-base.ts +1 -1
- package/dist/assets/plugins/viui-conf/v-dark.ts +3 -5
- package/dist/assets/plugins/viui-conf/v-light.ts +3 -5
- package/dist/assets/plugins/vuetify.ts +36 -0
- package/dist/assets/prompt-data/components.json +106 -0
- package/dist/assets/prompt-data/tokens.json +83 -0
- package/dist/assets/themes/_bento-grid.scss +8 -0
- package/dist/assets/themes/_glassmorphism.scss +8 -0
- package/dist/assets/themes/_material.scss +8 -0
- package/dist/assets/themes/_minimalist-2.scss +375 -0
- package/dist/assets/themes/_minimalist.scss +9 -0
- package/dist/assets/themes/_neo-brutalism.scss +199 -0
- package/dist/assets/themes/bento-grid.scss +4 -0
- package/dist/assets/themes/glassmorphism.scss +4 -0
- package/dist/assets/themes/index.scss +11 -0
- package/dist/assets/themes/material.scss +4 -0
- package/dist/assets/themes/minimalist-2.scss +5 -0
- package/dist/assets/themes/minimalist.scss +4 -0
- package/dist/assets/themes/neo-brutalism.scss +5 -0
- package/dist/assets/viui-themes/_neo-brutalism.scss +70 -152
- package/dist/cli-paths.d.ts +7 -0
- package/dist/cli-paths.d.ts.map +1 -0
- package/dist/cli-paths.js +19 -0
- package/dist/cli.js +28 -578
- package/dist/cli.legacy.d.ts +3 -0
- package/dist/cli.legacy.d.ts.map +1 -0
- package/dist/cli.legacy.js +597 -0
- package/dist/commands/audit.d.ts +3 -0
- package/dist/commands/audit.d.ts.map +1 -0
- package/dist/commands/audit.js +152 -0
- package/dist/commands/config/config-export.d.ts +6 -0
- package/dist/commands/config/config-export.d.ts.map +1 -0
- package/dist/commands/config/config-export.js +23 -0
- package/dist/commands/config/config-health.d.ts +6 -0
- package/dist/commands/config/config-health.d.ts.map +1 -0
- package/dist/commands/config/config-health.js +42 -0
- package/dist/commands/config/config-import.d.ts +6 -0
- package/dist/commands/config/config-import.d.ts.map +1 -0
- package/dist/commands/config/config-import.js +63 -0
- package/dist/commands/config/config-rollback.d.ts +6 -0
- package/dist/commands/config/config-rollback.d.ts.map +1 -0
- package/dist/commands/config/config-rollback.js +47 -0
- package/dist/commands/config/config-setup.d.ts +6 -0
- package/dist/commands/config/config-setup.d.ts.map +1 -0
- package/dist/commands/config/config-setup.js +103 -0
- package/dist/commands/config/config-status.d.ts +6 -0
- package/dist/commands/config/config-status.d.ts.map +1 -0
- package/dist/commands/config/config-status.js +42 -0
- package/dist/commands/config/config-uninstall.d.ts +6 -0
- package/dist/commands/config/config-uninstall.d.ts.map +1 -0
- package/dist/commands/config/config-uninstall.js +74 -0
- package/dist/commands/config.d.ts +6 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +19 -0
- package/dist/commands/docs.d.ts +3 -0
- package/dist/commands/docs.d.ts.map +1 -0
- package/dist/commands/docs.js +17 -0
- package/dist/commands/doctor.d.ts +3 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +93 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +183 -0
- package/dist/commands/sync.d.ts +3 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +73 -0
- package/dist/commands/theme.d.ts +3 -0
- package/dist/commands/theme.d.ts.map +1 -0
- package/dist/commands/theme.js +86 -0
- package/dist/commands/update.d.ts +3 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +97 -0
- package/dist/prompts/prompt-builder.d.ts +4 -0
- package/dist/prompts/prompt-builder.d.ts.map +1 -0
- package/dist/prompts/prompt-builder.js +18 -0
- package/dist/prompts/prompt-data-loader.d.ts +11 -0
- package/dist/prompts/prompt-data-loader.d.ts.map +1 -0
- package/dist/prompts/prompt-data-loader.js +15 -0
- package/dist/prompts/prompt-sections/section-code-examples.d.ts +2 -0
- package/dist/prompts/prompt-sections/section-code-examples.d.ts.map +1 -0
- package/dist/prompts/prompt-sections/section-code-examples.js +36 -0
- package/dist/prompts/prompt-sections/section-color-tokens.d.ts +2 -0
- package/dist/prompts/prompt-sections/section-color-tokens.d.ts.map +1 -0
- package/dist/prompts/prompt-sections/section-color-tokens.js +19 -0
- package/dist/prompts/prompt-sections/section-component-map.d.ts +3 -0
- package/dist/prompts/prompt-sections/section-component-map.d.ts.map +1 -0
- package/dist/prompts/prompt-sections/section-component-map.js +12 -0
- package/dist/prompts/prompt-sections/section-typography-spacing.d.ts +2 -0
- package/dist/prompts/prompt-sections/section-typography-spacing.d.ts.map +1 -0
- package/dist/prompts/prompt-sections/section-typography-spacing.js +29 -0
- package/dist/services/backup-service.d.ts +7 -0
- package/dist/services/backup-service.d.ts.map +1 -0
- package/dist/services/backup-service.js +54 -0
- package/dist/services/config-service.d.ts +17 -0
- package/dist/services/config-service.d.ts.map +1 -0
- package/dist/services/config-service.js +64 -0
- package/dist/services/diff-engine.d.ts +13 -0
- package/dist/services/diff-engine.d.ts.map +1 -0
- package/dist/services/diff-engine.js +59 -0
- package/dist/services/ide-detector.d.ts +9 -0
- package/dist/services/ide-detector.d.ts.map +1 -0
- package/dist/services/ide-detector.js +113 -0
- package/dist/services/ide-detector.spec.d.ts +2 -0
- package/dist/services/ide-detector.spec.d.ts.map +1 -0
- package/dist/services/ide-detector.spec.js +108 -0
- package/dist/services/lock-file-service.d.ts +15 -0
- package/dist/services/lock-file-service.d.ts.map +1 -0
- package/dist/services/lock-file-service.js +74 -0
- package/dist/services/mcp-config-reader.d.ts +11 -0
- package/dist/services/mcp-config-reader.d.ts.map +1 -0
- package/dist/services/mcp-config-reader.js +40 -0
- package/dist/services/mcp-config-reader.spec.d.ts +2 -0
- package/dist/services/mcp-config-reader.spec.d.ts.map +1 -0
- package/dist/services/mcp-config-reader.spec.js +125 -0
- package/dist/services/mcp-config-writer.d.ts +11 -0
- package/dist/services/mcp-config-writer.d.ts.map +1 -0
- package/dist/services/mcp-config-writer.js +98 -0
- package/dist/services/mcp-config-writer.spec.d.ts +2 -0
- package/dist/services/mcp-config-writer.spec.d.ts.map +1 -0
- package/dist/services/mcp-config-writer.spec.js +162 -0
- package/dist/services/merge-engine.d.ts +12 -0
- package/dist/services/merge-engine.d.ts.map +1 -0
- package/dist/services/merge-engine.js +54 -0
- package/dist/services/vuetify-scaffold-service.d.ts +5 -0
- package/dist/services/vuetify-scaffold-service.d.ts.map +1 -0
- package/dist/services/vuetify-scaffold-service.js +67 -0
- package/dist/templates/vuetify-plugin.d.ts +90 -0
- package/dist/templates/vuetify-plugin.d.ts.map +1 -0
- package/dist/templates/vuetify-plugin.js +33 -0
- package/dist/types/command-types.d.ts +15 -0
- package/dist/types/command-types.d.ts.map +1 -0
- package/dist/types/command-types.js +2 -0
- package/dist/types/config-types.d.ts +29 -0
- package/dist/types/config-types.d.ts.map +1 -0
- package/dist/types/config-types.js +10 -0
- package/dist/types/ide-types.d.ts +29 -0
- package/dist/types/ide-types.d.ts.map +1 -0
- package/dist/types/ide-types.js +4 -0
- package/dist/types/lock-file-types.d.ts +27 -0
- package/dist/types/lock-file-types.d.ts.map +1 -0
- package/dist/types/lock-file-types.js +2 -0
- package/dist/utils/diff-display.d.ts +18 -0
- package/dist/utils/diff-display.d.ts.map +1 -0
- package/dist/utils/diff-display.js +61 -0
- package/dist/utils/fs-safe.d.ts +9 -0
- package/dist/utils/fs-safe.d.ts.map +1 -0
- package/dist/utils/fs-safe.js +44 -0
- package/dist/utils/logger.d.ts +14 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +28 -0
- package/dist/utils/open-browser.d.ts +3 -0
- package/dist/utils/open-browser.d.ts.map +1 -0
- package/dist/utils/open-browser.js +13 -0
- package/package.json +11 -6
- package/dist/assets/cursor/.design-system-version +0 -1
- package/dist/assets/cursor/commands/audit-accessibility.md +0 -25
- package/dist/assets/cursor/commands/audit-ui.md +0 -35
- package/dist/assets/cursor/commands/component.md +0 -18
- package/dist/assets/cursor/commands/fix-storybook.md +0 -24
- package/dist/assets/cursor/commands/generate-component-from-figma.md +0 -26
- package/dist/assets/cursor/commands/generate-page-from-figma.md +0 -26
- package/dist/assets/cursor/plans/DESIGN_SYSTEM_PLAN.md +0 -177
- package/dist/assets/cursor/plans/PLANS_INDEX.md +0 -35
- package/dist/assets/cursor/rules/accessibility-contrast.mdc +0 -38
- package/dist/assets/cursor/rules/bem-class-style.mdc +0 -107
- package/dist/assets/cursor/rules/component-naming.mdc +0 -57
- package/dist/assets/cursor/rules/design-system-component-library.mdc +0 -59
- package/dist/assets/cursor/rules/design-system-workflow.mdc +0 -48
- package/dist/assets/cursor/rules/figma-mapping.mdc +0 -37
- package/dist/assets/cursor/rules/icons.mdc +0 -42
- package/dist/assets/cursor/rules/project-structure.mdc +0 -137
- package/dist/assets/cursor/rules/storybook-component-template.mdc +0 -103
- package/dist/assets/cursor/rules/storybook.mdc +0 -68
- package/dist/assets/cursor/rules/tokens.mdc +0 -32
- package/dist/assets/cursor/rules/viui-themes.mdc +0 -53
- package/dist/assets/cursor/rules/vuetify-layout.mdc +0 -52
- package/dist/assets/cursor/skills/accessibility.md +0 -75
- package/dist/assets/cursor/skills/design-system-thinking.md +0 -40
- package/dist/assets/cursor/skills/figma-interpretation.md +0 -38
- package/dist/assets/cursor/skills/vue-vuetify-design-system-architect.md +0 -60
- package/dist/assets/cursor/sync-manifest.json +0 -6
- package/dist/assets/viui-themes/bento-grid-global.scss +0 -5
- package/dist/assets/viui-themes/glassmorphism-global.scss +0 -5
- package/dist/assets/viui-themes/material-global.scss +0 -5
- package/dist/assets/viui-themes/minimalist-2-global.scss +0 -5
- package/dist/assets/viui-themes/minimalist-global.scss +0 -5
- package/dist/assets/viui-themes/neo-brutalism-global.scss +0 -5
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Workflow Design system — mục tiêu đầu ra như Cloud Panel: NHÓM + items, thêm mới, tìm kiếm
|
|
3
|
-
globs: src/components/**/*, src/design-system/**/*, src/tokens/**/*, src/docs/**/*, src/storybook/**/*, docs/**/*
|
|
4
|
-
alwaysApply: false
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Workflow Design system (Mục tiêu đầu ra như Cloud Panel)
|
|
8
|
-
|
|
9
|
-
Design system được quản lý theo **mô hình panel**: **iNET Design system** là đơn vị tổ chức; bên trong có **NHÓM** và **items** (components, token files, docs). Workflow phải đạt: **thêm mới**, **tìm kiếm**, **tổng kết** rõ ràng.
|
|
10
|
-
|
|
11
|
-
## NHÓM chuẩn (Design System)
|
|
12
|
-
|
|
13
|
-
| NHÓM | Vị trí code | Items |
|
|
14
|
-
|------|--------------|-------|
|
|
15
|
-
| vi-ui | `src/design-system/vi-ui/vi-<tên>/` | ViButton, ViInput, ViCard, ViAlert, ViDialog, … |
|
|
16
|
-
| Brands | `src/components/brands/` | BrandLogo, StyleGuide |
|
|
17
|
-
| Errors | `src/components/errors/` | ErrorPage, OvvErrorPage, ErrorKnowledgeList |
|
|
18
|
-
| Icons | `src/components/icons/` | ArrowLeftRight, … |
|
|
19
|
-
| Tokens | `src/tokens/` | color.json, typography.json, inet-design-tokens.ts |
|
|
20
|
-
| Docs | `src/docs/` | design-system.md, foundations/*, usage/* |
|
|
21
|
-
| Storybook foundations | `src/storybook/Foundations/` | Colors.stories.ts, Typography.stories.ts, SpacingLayout.stories.ts, Configure.mdx |
|
|
22
|
-
|
|
23
|
-
Mỗi item (component, token file, doc) **chỉ thuộc một NHÓM**. Chi tiết mục tiêu đầu ra và số NHÓM: xem `docs/design-system-plan.md`.
|
|
24
|
-
|
|
25
|
-
## Workflow: Thêm item mới (Component/Token mới)
|
|
26
|
-
|
|
27
|
-
1. **Chọn NHÓM** — vi-ui, Brands, Errors, Icons, Tokens, Docs, hoặc Storybook foundations.
|
|
28
|
-
2. **Tạo đúng vị trí** — theo rule `project-structure.mdc` (vd: component Vi* → `src/design-system/vi-ui/vi-<tên>/ViName.vue` + `ViName.stories.ts`). Nếu component có **nhiều slot** (menu activator + content, list + items): thêm `ViNameStory.vue` và dùng trong stories để preview không trống (chi tiết `storybook.mdc` § Vi-ui Story Vue).
|
|
29
|
-
3. **Cập nhật index/re-export** — nếu nhóm có `index.ts` (vd: `src/design-system/vi-ui/index.ts`) hoặc cần export chung.
|
|
30
|
-
4. **Story/docs** — component mới có story; token/docs cập nhật nếu cần.
|
|
31
|
-
|
|
32
|
-
Không tạo component/token “lạc” ngoài các NHÓM trên.
|
|
33
|
-
|
|
34
|
-
## Workflow: Tìm component hoặc nhóm
|
|
35
|
-
|
|
36
|
-
- **Tìm theo tên component** — search trong codebase, Storybook sidebar, hoặc docs.
|
|
37
|
-
- **Tìm theo NHÓM** — mở thư mục tương ứng (vd: `src/design-system/vi-ui/`, `src/tokens/`).
|
|
38
|
-
- Mọi item phải **có thể tìm được** qua tên hoặc qua nhóm.
|
|
39
|
-
|
|
40
|
-
## Tổng kết (dashboard)
|
|
41
|
-
|
|
42
|
-
- **Số NHÓM:** 7 (vi-ui, Brands, Errors, Icons, Tokens, Docs, Storybook foundations).
|
|
43
|
-
- **Số items:** đếm được theo nhóm (components, token files, docs).
|
|
44
|
-
- **Trạng thái:** documented, có story, dùng token — dùng cho review (rule `verifier` / QA).
|
|
45
|
-
|
|
46
|
-
**AI codegen (toàn dự án & consumer @viui/cli):** Khi generate code UI/story/demo, dùng vi-ui (Vi*) và Tabler Icons mặc định; nút action dùng ViButton, không dùng raw `<button>`; xem `icons.mdc`, `storybook.mdc`, AGENTS.md § Codegen / AI Agent.
|
|
47
|
-
|
|
48
|
-
Khi thêm file hoặc review, đảm bảo item thuộc đúng **NHÓM** và workflow **thêm mới / tìm kiếm** tuân theo mục tiêu đầu ra trong `docs/design-system-plan.md`. **Kế hoạch tập trung:** `.cursor/plans/DESIGN_SYSTEM_PLAN.md` (một file; chỉ mục: `.cursor/plans/PLANS_INDEX.md`).
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Figma ↔ code — ánh xạ token names, component names, MCP get_design_context. Skill: .cursor/skills/figma-interpretation.md
|
|
3
|
-
globs: "**/*.vue", "**/*.stories.@(ts|tsx)", "src/tokens/**/*", "docs/**/*"
|
|
4
|
-
alwaysApply: false
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Figma Mapping
|
|
8
|
-
|
|
9
|
-
Quy ước ánh xạ design Figma sang code iNET Design System (Vue 3 + Vuetify, tokens, naming). **Skill khi làm từ Figma:** `.cursor/skills/figma-interpretation.md`. **Rules liên quan:** `tokens.mdc`, `component-naming.mdc`, `storybook.mdc`, `accessibility-contrast.mdc`.
|
|
10
|
-
|
|
11
|
-
## Nguyên tắc
|
|
12
|
-
|
|
13
|
-
1. **Tokens là nguồn chân lý** — Giá trị trong Figma (màu, spacing, radius, shadow) map sang key trong `src/tokens/design-tokens.ts`. Nếu Figma khác token, ưu tiên token; ghi chú với designer để cập nhật Figma.
|
|
14
|
-
2. **Figma Variables ↔ token names** — Map tên (vd `brand/primary` → `colorTokens.brand.primary`). Tham chiếu `tokens.mdc`.
|
|
15
|
-
3. **Component naming** — Component sinh từ Figma tuân `component-naming.mdc`: Vi* trong `vi-<tên>/`, PascalCase, `*.stories.ts` cùng thư mục. Story title = `{Nhóm}/{Tên}` theo `storybook.mdc`.
|
|
16
|
-
4. **MCP workflow** — Figma MCP: `get_design_context(fileKey, nodeId?)` để lấy code/screenshot/hints. Output thường là reference (React/Tailwind); chuyển sang Vue 3 + Vuetify và component/token của dự án.
|
|
17
|
-
5. **Accessibility** — Màu chữ/nền đạt WCAG 2.1 AA; semantic `.text` trên nền màu. Xem `accessibility-contrast.mdc` và `.cursor/skills/accessibility.md`.
|
|
18
|
-
|
|
19
|
-
## Map nhanh (Figma → code)
|
|
20
|
-
|
|
21
|
-
| Figma | Code / token |
|
|
22
|
-
|-------|---------------|
|
|
23
|
-
| Màu (fill/text) | `colorTokens.*`, `inetDesignTokens.colors.*` |
|
|
24
|
-
| Spacing / layout | `spacingTokens`, `space8pt` (8pt grid) |
|
|
25
|
-
| Radius / corner | `shapeTokens` |
|
|
26
|
-
| Shadow / elevation | `elevationTokens` |
|
|
27
|
-
| Typography | `typographyTokens` |
|
|
28
|
-
| Component mới | Vi* trong `vi-<tên>/ViName.vue` + `ViName.stories.ts`; hoặc `src/components/<nhóm>/` |
|
|
29
|
-
|
|
30
|
-
## Quy trình gợi ý
|
|
31
|
-
|
|
32
|
-
1. **Lấy design** — MCP `get_design_context` hoặc mô tả/screenshot. Xác định sections, components, giá trị (màu, spacing, typography).
|
|
33
|
-
2. **Map tokens** — Màu → `colorTokens.*` / `inetDesignTokens.colors.*`; spacing → `spacingTokens`; radius → `shapeTokens`; không thêm giá trị mới ngoài token trừ khi đã cập nhật `design-tokens.ts`.
|
|
34
|
-
3. **Chọn component** — Dùng Vi* có sẵn nếu khớp; không thì tạo mới đúng thư mục và naming. Thêm story.
|
|
35
|
-
4. **Kiểm tra** — Storybook chạy đúng; contrast và a11y đạt.
|
|
36
|
-
|
|
37
|
-
Khi chỉnh file khớp glob (đặc biệt khi implement từ Figma), áp dụng quy ước trên và tham chiếu skill `figma-interpretation.md`.
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Bộ icon mặc định Tabler; vi-ui trong demo/story; áp dụng toàn dự án và repo consumer (@viui/cli) khi AI gen code
|
|
3
|
-
globs: "**/*.vue", "**/*.ts", "**/*.tsx", "src/storybook/**/*", "src/design-system/**/*", "src/components/**/*"
|
|
4
|
-
alwaysApply: false
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Icons — Mặc định Tabler (áp dụng toàn dự án & AI codegen)
|
|
8
|
-
|
|
9
|
-
**Rule này áp dụng cho:** i-design-system và mọi repo consumer đã chạy `@viui/cli init` / `sync`. Khi **AI Agent generate code** Vue, Storybook hoặc UI, phải tuân nội dung dưới đây. AGENTS.md § Codegen / AI Agent và § Rules bắt buộc (7).
|
|
10
|
-
|
|
11
|
-
## Bộ icon mặc định
|
|
12
|
-
|
|
13
|
-
- **Tabler Icons** (`@tabler/icons-vue`) là bộ icon **mặc định** cho dự án và cho mọi repo đã dùng **@viui/cli** (sync `.cursor`).
|
|
14
|
-
- License: MIT. Hơn 4.000 icon (outline/filled), tree-shakable, Vue 3.
|
|
15
|
-
|
|
16
|
-
## Cách dùng
|
|
17
|
-
|
|
18
|
-
1. **Import từng icon** — Chỉ icon được import mới vào bundle.
|
|
19
|
-
```ts
|
|
20
|
-
import { IconArrowRight, IconSettings, IconUser } from '@tabler/icons-vue'
|
|
21
|
-
```
|
|
22
|
-
2. **Trong template:** Dùng như component Vue (`<IconArrowRight />`). Có thể truyền `size`, `stroke`, `color` theo [tài liệu Tabler](https://tabler.io/icons).
|
|
23
|
-
3. **Vuetify `v-icon`:** Các component Vuetify dùng prop `icon` dạng chuỗi (vd. `prepend-icon="mdi-account"`) vẫn dùng **MDI** (đã cấu hình sẵn). Khi viết component mới, ưu tiên Tabler; nếu cần tương thích trực tiếp với `v-icon` có thể giữ MDI cho prop đó.
|
|
24
|
-
|
|
25
|
-
## Nguồn khác (khi cần)
|
|
26
|
-
|
|
27
|
-
- **MDI:** Đã có trong Vuetify; dùng khi cần `v-icon` với tên chuỗi.
|
|
28
|
-
- **Lucide, Phosphor, Heroicons:** Ghi trong Storybook **Icons/Overview**; dùng khi team chọn phong cách khác.
|
|
29
|
-
|
|
30
|
-
## Vi-ui trong demo Icons
|
|
31
|
-
|
|
32
|
-
- Demo Icons (vd. **TablerIconsDemo.vue**) dùng **vi-ui** cho UI: ViInput (search), ViButton (mọi nút action kể cả copy line trong popover: Vue name, Import, SVG), ViCard (popover nội dung), ViMenu (popover), ViButtonToggle (Outline/Filled). Không dùng raw `<button>`; nút copy/link-style dùng ViButton. Nếu thiếu component trong vi-ui thì bổ sung (vd. đã thêm ViButtonToggle) rồi dùng trong demo. Rule: `storybook.mdc` § Vi-ui trong Storybook.
|
|
33
|
-
|
|
34
|
-
## Tham chiếu
|
|
35
|
-
|
|
36
|
-
- Storybook: **Icons/Overview**, **Icons/Tabler** — bảng nguồn và demo popover.
|
|
37
|
-
- Package: `@tabler/icons-vue`
|
|
38
|
-
- Vi-ui: `@/design-system/vi-ui` (ViInput, ViButton, ViCard, ViMenu, ViButtonToggle)
|
|
39
|
-
|
|
40
|
-
Khi được kích hoạt (file khớp glob), ưu tiên **Tabler Icons** cho icon mới; không thêm bộ icon khác làm mặc định nếu chưa thống nhất với design system.
|
|
41
|
-
|
|
42
|
-
**Plan liên quan:** `.cursor/plans/icons_free_sources.plan.md` (demo Icons, vi-ui, ViButtonToggle, sidebar Storybook).
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Cấu trúc dự án và quy ước review cấu trúc — nơi đặt file, naming, phân cấp thư mục
|
|
3
|
-
globs: src/**/*, docs/**/*, .storybook/**/*, public/**/*, vite.config.*, tsconfig*.json, package.json
|
|
4
|
-
alwaysApply: false
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Cấu trúc dự án & Review cấu trúc
|
|
8
|
-
|
|
9
|
-
Rule này định nghĩa **cấu trúc chuẩn** của dự án design system và tiêu chí **review cấu trúc**. Cấu trúc hướng tới **mục tiêu đầu ra như Cloud Panel**: **iNET Design system** chứa **NHÓM** (vi-ui, Brands, Errors, Tokens, Docs, Storybook foundations) và **items** (components, token files, docs). Chi tiết workflow: `design-system-workflow.mdc` và `docs/design-system-plan.md`. Khi thêm file mới hoặc review layout, tuân theo cấu trúc dưới đây.
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## Cấu trúc thư mục chuẩn
|
|
14
|
-
|
|
15
|
-
### Root
|
|
16
|
-
|
|
17
|
-
| Thư mục / file | Mục đích |
|
|
18
|
-
|----------------|----------|
|
|
19
|
-
| `src/` | Mã nguồn chính (Vue, tokens, components, docs nội bộ) |
|
|
20
|
-
| `docs/` | Tài liệu dự án (plan, kế hoạch) — không nhầm với `src/docs/` |
|
|
21
|
-
| `public/` | Static assets dùng trực tiếp (favicon, logo, ảnh error page) |
|
|
22
|
-
| `.storybook/` | Cấu hình Storybook (main, preview, manager) |
|
|
23
|
-
| `.agent/rules/` | Agent/subagent rules (design-system, verifier, …) |
|
|
24
|
-
| `.cursor/rules/` | Cursor rules (.mdc) |
|
|
25
|
-
| `AGENTS.md` | Chỉ dẫn chung cho agent; luôn tuân thủ |
|
|
26
|
-
|
|
27
|
-
### `src/`
|
|
28
|
-
|
|
29
|
-
| Thư mục | Mục đích | Quy ước |
|
|
30
|
-
|---------|----------|---------|
|
|
31
|
-
| `src/design-system/vi-ui/` | Component Vi* (app-facing) | Mỗi component: `vi-<tên>/ViName.vue` + `ViName.stories.ts`; nếu component có nhiều slot (menu, list, dialog…) thêm `ViNameStory.vue` để preview không trống; export từ `index.ts`. |
|
|
32
|
-
| `src/components/` | Component library (brands, errors, icons) | Phân cấp: brands, errors, icons. Mỗi component trong thư mục riêng. |
|
|
33
|
-
| `src/tokens/` | Design tokens | JSON + TS (inet-design-tokens, index re-export). |
|
|
34
|
-
| `src/types/` | TypeScript types (tokens, Vuetify, global). | `.d.ts` cho ambient, `.ts` cho module. |
|
|
35
|
-
| `src/plugins/` | Vue/Vuetify plugins (theme, vuetify). | Một file per theme/plugin. |
|
|
36
|
-
| `src/storybook/` | Stories dùng chung (Colors, Typography, Spacing, Configure). | Không đặt story của từng component ở đây. |
|
|
37
|
-
| `src/docs/` | Tài liệu design system (VitePress): foundations, philosophy, usage. | `.md`; cấu hình VitePress trong `.vitepress/`. |
|
|
38
|
-
| `src/assets/` | CSS, SCSS, hình ảnh dùng trong app. | **Tổng thể dự án**: `styles/` (main.scss, inet-tokens.scss, foundations/, components/); class BEM và style chung đặt ở đây. Xem `project-structure.mdc` § src/assets/styles và `bem-class-style.mdc`. |
|
|
39
|
-
| `src/utils/` | Hàm tiện ích (theme, color, forward). | Re-export qua `index.ts` nếu cần. |
|
|
40
|
-
| `src/figma/` | File Figma (tokens, components). | Tùy chọn. |
|
|
41
|
-
|
|
42
|
-
### `src/components/`
|
|
43
|
-
|
|
44
|
-
| Cấp | Thư mục | Ví dụ | Quy ước |
|
|
45
|
-
|-----|---------|--------|---------|
|
|
46
|
-
| Khác | `brands/`, `errors/`, `icons/` | BrandLogo, ErrorPage, ArrowLeftRight | Cùng cấp; có thể có `.ts` data (ErrorData.ts). |
|
|
47
|
-
|
|
48
|
-
Component Vi* (ViButton, ViInput, …) nằm trong `src/design-system/vi-ui/` — xem `design-system-workflow.mdc` khi thêm component mới.
|
|
49
|
-
|
|
50
|
-
- **Stories**: Đặt cùng thư mục với component, tên `*.stories.ts`. Component có slot (activator + content, list + items): thêm `ViNameStory.vue` chứa template + demo, stories dùng component Story; xem `storybook.mdc`.
|
|
51
|
-
- **CSS scope**: Có thể dùng file `.css` riêng trong thư mục component (vd: `button.css`, `header.css`). Class theo BEM: `bem-class-style.mdc`. Style chung (BEM block) có thể đặt trong `src/assets/styles/components/` và import từ tổng thể (xem § src/assets/styles).
|
|
52
|
-
|
|
53
|
-
### `src/assets/styles/` (SCSS tổng thể dự án)
|
|
54
|
-
|
|
55
|
-
Toàn bộ SCSS/CSS dùng chung (tokens, foundations, component blocks BEM) thuộc **một cấu trúc** dưới đây; không tách riêng SCSS chỉ cho Storybook Foundations.
|
|
56
|
-
|
|
57
|
-
| Thành phần | Mục đích |
|
|
58
|
-
|------------|----------|
|
|
59
|
-
| `main.scss` | Entry: import tokens + foundations (+ components nếu cần). Load bởi app/Storybook. |
|
|
60
|
-
| `inet-tokens.scss` | CSS custom properties từ design tokens (đã có). |
|
|
61
|
-
| `foundations/` | Partial theo từng foundation story: `_spacing-layout-stories.scss`, `_colors-stories.scss`, `_typography-stories.scss`; file `_index.scss` forward để `main.scss` import một lần. |
|
|
62
|
-
| `foundations/_index.scss` | `@forward` từng partial; `main.scss` chỉ `@use "foundations"` hoặc tương đương. |
|
|
63
|
-
| `components/` (tùy chọn) | Partial BEM cho component dùng chung nhiều nơi; component Vue có thể dùng `<style scoped>` hoặc import file cùng thư mục. |
|
|
64
|
-
|
|
65
|
-
- **Foundation stories** (Colors, Typography, Spacing & Layout): class BEM định nghĩa trong `src/assets/styles/foundations/`; story hoặc `main.scss` import từ đây.
|
|
66
|
-
- **Component**: Ưu tiên `<style scoped>` trong `.vue`; nếu tách file thì cùng thư mục component hoặc partial trong `src/assets/styles/components/`.
|
|
67
|
-
|
|
68
|
-
Chi tiết BEM và quy ước class: `bem-class-style.mdc`.
|
|
69
|
-
|
|
70
|
-
### `src/tokens/`
|
|
71
|
-
|
|
72
|
-
- **JSON**: Token gốc — `color.json`, `typography.json`, `motion.json`, `elevation.json`.
|
|
73
|
-
- **TS**: `inet-design-tokens.ts` (nguồn truth), `design-tokens.ts` nếu có, `index.ts` re-export.
|
|
74
|
-
- Types: Định nghĩa trong `src/types/` (vd: `inet-tokens-types.ts`).
|
|
75
|
-
|
|
76
|
-
### `public/`
|
|
77
|
-
|
|
78
|
-
- Favicon, logo, SVG/WebP dùng qua `/` (vd: `/favicon.ico`, `/error/client-error-status.svg`).
|
|
79
|
-
- **Không** đặt mã nguồn (Vue/TS) trong `public/`.
|
|
80
|
-
|
|
81
|
-
### `docs/` (root)
|
|
82
|
-
|
|
83
|
-
- Tài liệu quản lý dự án (plan, kế hoạch). Khác với `src/docs/` (nội dung design system).
|
|
84
|
-
|
|
85
|
-
---
|
|
86
|
-
|
|
87
|
-
## Naming
|
|
88
|
-
|
|
89
|
-
| Loại | Quy ước | Ví dụ |
|
|
90
|
-
|------|---------|--------|
|
|
91
|
-
| Component Vue | PascalCase, một từ hoặc cụm (BaseX nếu base component) | `Button.vue`, `BaseAlert.vue`, `ErrorPage.vue` |
|
|
92
|
-
| Stories | `ComponentName.stories.ts` | `Button.stories.ts`, `BaseTabs.stories.ts` |
|
|
93
|
-
| Token file | lowercase, có dấu gạch nếu cần | `color.json`, `inet-design-tokens.ts` |
|
|
94
|
-
| CSS/SCSS | lowercase, gạch nếu cần | `main.scss`, `_error-page.css`, `button.css` |
|
|
95
|
-
| Thư mục component | lowercase, số ít | `buttons/`, `card/`, `forms/` |
|
|
96
|
-
| Types | PascalCase cho type/interface; file: `*-types.ts` hoặc `*.d.ts` | `inet-tokens-types.ts`, `vuetify.d.ts` |
|
|
97
|
-
|
|
98
|
-
---
|
|
99
|
-
|
|
100
|
-
## Checklist review cấu trúc
|
|
101
|
-
|
|
102
|
-
Khi review cấu trúc dự án, kiểm tra:
|
|
103
|
-
|
|
104
|
-
### Vị trí file
|
|
105
|
-
|
|
106
|
-
- [ ] Component Vi* mới nằm trong `src/design-system/vi-ui/vi-<tên>/` (xem `design-system-workflow.mdc`).
|
|
107
|
-
- [ ] Component brands/errors/icons nằm trong `src/components/` đúng cấp, mỗi component một thư mục.
|
|
108
|
-
- [ ] Stories đặt cùng thư mục với component, tên `*.stories.ts`.
|
|
109
|
-
- [ ] Token chỉ trong `src/tokens/`; types trong `src/types/`.
|
|
110
|
-
- [ ] Theme/plugin trong `src/plugins/`; không rải cấu hình theme ở root.
|
|
111
|
-
- [ ] Tài liệu design system trong `src/docs/`; tài liệu plan/process trong `docs/`.
|
|
112
|
-
|
|
113
|
-
### Nhất quán
|
|
114
|
-
|
|
115
|
-
- [ ] Không có file “lạc chỗ” (vd: component trong `src/utils/`, token trong `src/components/`).
|
|
116
|
-
- [ ] Re-export rõ ràng (vd: `src/components/index.ts`, `src/tokens/index.ts`) khi có nhiều file cần export.
|
|
117
|
-
|
|
118
|
-
### Naming
|
|
119
|
-
|
|
120
|
-
- [ ] Component và stories đúng PascalCase / `*.stories.ts`.
|
|
121
|
-
- [ ] Thư mục component lowercase, số ít.
|
|
122
|
-
|
|
123
|
-
### Cấu hình & Agent
|
|
124
|
-
|
|
125
|
-
- [ ] Cấu hình build (Vite, TS, Storybook) ở root hoặc `.storybook/`; không duplicate không cần thiết.
|
|
126
|
-
- [ ] Agent rules trong `.agent/rules/`; Cursor rules trong `.cursor/rules/`; không trộn lẫn định dạng.
|
|
127
|
-
|
|
128
|
-
---
|
|
129
|
-
|
|
130
|
-
## Khi thêm file mới
|
|
131
|
-
|
|
132
|
-
- **Component Vi* mới**: Tạo `src/design-system/vi-ui/vi-<tên>/` với `ViName.vue` + `ViName.stories.ts`; nếu component dùng nhiều slot (menu, list, dialog…) thì thêm `ViNameStory.vue` và dùng nó trong stories để tránh preview trống (rule `storybook.mdc`); export từ `src/design-system/vi-ui/index.ts`. Quy trình chi tiết: `design-system-workflow.mdc`.
|
|
133
|
-
- **Token mới**: Thêm vào file JSON tương ứng trong `src/tokens/` và cập nhật `inet-design-tokens.ts` / types nếu cần.
|
|
134
|
-
- **Story dùng chung (foundation)**: Thêm vào `src/storybook/Foundations/` (vd: `Colors.stories.ts`, `Configure.mdx`).
|
|
135
|
-
- **Trang/docs design system**: Thêm vào `src/docs/` (foundations, philosophy, usage) và cấu hình trong `src/docs/.vitepress/config.ts` nếu cần.
|
|
136
|
-
|
|
137
|
-
Khi được kích hoạt (file khớp glob), dùng rule này để **đánh giá cấu trúc** hoặc **hướng dẫn nơi đặt file mới**.
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Template chuẩn cho story component mới — cấu trúc meta, Default, Variants/Sizes/Colors/States; file mẫu ViButton.stories.ts
|
|
3
|
-
globs: "**/*.stories.@(ts|tsx)", ".cursor/plans/KPI_COMPONENT_TEMPLATE.md"
|
|
4
|
-
alwaysApply: false
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Storybook component template (chuẩn cho component mới)
|
|
8
|
-
|
|
9
|
-
**File mẫu bắt buộc:** `src/design-system/vi-ui/vi-button/ViButton.stories.ts`
|
|
10
|
-
|
|
11
|
-
Khi tạo **story mới** cho component (vi-ui, Brands, Errors, Icons), copy cấu trúc dưới đây. Mục đích: Cursor và developer generate story đúng format; kiểm tra theo `.cursor/plans/KPI_COMPONENT_TEMPLATE.md`.
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
## 1. Cấu trúc file
|
|
16
|
-
|
|
17
|
-
- **Vị trí:** `ComponentName.stories.ts` **cùng thư mục** với `ComponentName.vue`.
|
|
18
|
-
- **vi-ui:** `src/design-system/vi-ui/vi-<tên>/ViName.stories.ts`
|
|
19
|
-
- **Brands/Errors/Icons:** `src/components/<nhóm>/ComponentName.stories.ts`
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
## 2. Meta (const meta)
|
|
24
|
-
|
|
25
|
-
| Trường | Bắt buộc | Mô tả |
|
|
26
|
-
|--------|----------|--------|
|
|
27
|
-
| `title` | Có | `ViUi/Button` | `Brands/Logo` | `Errors/ErrorPage` — đúng nhóm sidebar (xem `storybook.mdc`). |
|
|
28
|
-
| `component` | Có | Import component Vue tương ứng. |
|
|
29
|
-
| `tags` | Có | `['autodocs']` để bật Docs tab. |
|
|
30
|
-
| `parameters.docs.description.component` | Nên có | Dùng `docIntro(vi.viUi.xxx.descriptionComponent, en.viUi.xxx.descriptionComponent)` từ `@/locales` nếu có key; nếu chưa có locale thì string mô tả ngắn. |
|
|
31
|
-
| `argTypes` | Có | Mỗi prop quan trọng: `control` (select/boolean/text/…), `options` nếu select, `description` ngắn. |
|
|
32
|
-
| `args` | Có | Giá trị mặc định cho Controls (label, variant, color, …). |
|
|
33
|
-
|
|
34
|
-
**Ví dụ (rút gọn):**
|
|
35
|
-
|
|
36
|
-
```ts
|
|
37
|
-
const meta = {
|
|
38
|
-
title: 'ViUi/Button',
|
|
39
|
-
component: ViButton,
|
|
40
|
-
tags: ['autodocs'],
|
|
41
|
-
parameters: {
|
|
42
|
-
docs: {
|
|
43
|
-
description: {
|
|
44
|
-
component: docIntro(vi.viUi.button.descriptionComponent, en.viUi.button.descriptionComponent),
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
argTypes: {
|
|
49
|
-
variant: { control: 'select', options: ['elevated', 'flat', 'outlined', 'text', 'tonal'], description: '...' },
|
|
50
|
-
color: { control: 'select', options: ['primary', 'secondary', ...], description: '...' },
|
|
51
|
-
size: { control: 'select', options: ['x-small', 'small', 'default', 'large', 'x-large'] },
|
|
52
|
-
loading: { control: 'boolean' },
|
|
53
|
-
disabled: { control: 'boolean' },
|
|
54
|
-
},
|
|
55
|
-
args: { label: 'Vi Button', variant: 'elevated', color: 'primary' },
|
|
56
|
-
} satisfies Meta<typeof ViButton>
|
|
57
|
-
export default meta
|
|
58
|
-
type Story = StoryObj<typeof meta>
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
---
|
|
62
|
-
|
|
63
|
-
## 3. Stories (export const)
|
|
64
|
-
|
|
65
|
-
- **Default** — Bắt buộc: một story chỉ dùng `args` (vd. `args: { label: 'Primary Action' }`).
|
|
66
|
-
- **Theo chiều biến thể** (thêm tùy component):
|
|
67
|
-
- **Variants** — Nếu component có variant (elevated, flat, outlined, text, tonal): story render tất cả variant.
|
|
68
|
-
- **Sizes** — Nếu có prop size: story render x-small → x-large.
|
|
69
|
-
- **Colors** — Nếu có prop color semantic: story render primary, secondary, success, warning, error, info.
|
|
70
|
-
- **States** — Story gộp default + loading + disabled (và các state khác nếu có).
|
|
71
|
-
- **Loading** / **Disabled** — Có thể tách riêng hoặc chỉ dùng trong States.
|
|
72
|
-
|
|
73
|
-
Layout story (nhiều nút/card): dùng wrapper với class BEM (vd `vi-button-stories`) hoặc inline style ngắn; ưu tiên class + CSS/SCSS theo `bem-class-style.mdc`.
|
|
74
|
-
|
|
75
|
-
---
|
|
76
|
-
|
|
77
|
-
## 4. Khi Cursor generate story mới — Checklist kiểm tra
|
|
78
|
-
|
|
79
|
-
Sau khi generate, kiểm tra:
|
|
80
|
-
|
|
81
|
-
- [ ] File đặt đúng vị trí: `vi-<tên>/ViName.stories.ts` (vi-ui) hoặc `src/components/<nhóm>/ComponentName.stories.ts`.
|
|
82
|
-
- [ ] `title` đúng nhóm: `ViUi/...` | `Brands/...` | `Errors/...` | `Foundations/...`.
|
|
83
|
-
- [ ] Có **Default** và ít nhất một story theo biến thể (Variants/Sizes/Colors/States) nếu component có prop tương ứng.
|
|
84
|
-
- [ ] `argTypes` và `args` đủ cho props quan trọng; `tags: ['autodocs']`.
|
|
85
|
-
- [ ] `parameters.docs.description.component` có (docIntro từ locale hoặc string).
|
|
86
|
-
- [ ] Layout story: class BEM hoặc style nhất quán; không phá quy ước `bem-class-style.mdc`.
|
|
87
|
-
|
|
88
|
-
Nếu lệch: chỉnh lại story hoặc cập nhật rule / file mẫu ViButton.
|
|
89
|
-
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
## 5. File template có placeholder (tùy chọn)
|
|
93
|
-
|
|
94
|
-
- **Đường dẫn:** `.cursor/templates/ViComponent.stories.template.ts`
|
|
95
|
-
- Copy vào thư mục component, đổi tên file và thay `ViComponent` / `ComponentName` / `componentKey` theo component thật; thêm/bớt argTypes, args, stories theo nhu cầu.
|
|
96
|
-
|
|
97
|
-
---
|
|
98
|
-
|
|
99
|
-
## Tham chiếu
|
|
100
|
-
|
|
101
|
-
- Plan & checklist KPI: `.cursor/plans/KPI_COMPONENT_TEMPLATE.md`
|
|
102
|
-
- Story mẫu đầy đủ: `src/design-system/vi-ui/vi-button/ViButton.stories.ts`
|
|
103
|
-
- Rule Storybook: `storybook.mdc` — Rule naming: `component-naming.mdc` — BEM: `bem-class-style.mdc`
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Storybook — sidebar, title, CSF3, addons; stories/demo dùng vi-ui; áp dụng toàn dự án và consumer (@viui/cli) khi AI gen code
|
|
3
|
-
globs: "**/*.stories.@(ts|tsx)", "**/*.mdx", ".storybook/**/*", "src/storybook/**/*"
|
|
4
|
-
alwaysApply: false
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Storybook
|
|
8
|
-
|
|
9
|
-
**Bạn là Storybook expert cho design system Vue 3 + Vuetify + TypeScript.** Rule áp dụng cho i-design-system và repo consumer đã sync `.cursor` qua **@viui/cli** (AI gen code phải tuân).
|
|
10
|
-
|
|
11
|
-
## Vai trò
|
|
12
|
-
|
|
13
|
-
- **Chuẩn hóa** cách viết stories: CSF3, `Meta`/`StoryObj`, argTypes, tags.
|
|
14
|
-
- **Hướng dẫn** cấu hình Storybook (`.storybook/`), addons (a11y, docs, vitest) và tích hợp Vuetify.
|
|
15
|
-
- **Đảm bảo** stories dùng đúng component Vue 3 + Vuetify và design tokens; không hard-code theme/layout.
|
|
16
|
-
|
|
17
|
-
## Cấu trúc sidebar cố định
|
|
18
|
-
|
|
19
|
-
Thứ tự và nhóm sidebar trong `.storybook/preview.ts` (`options.storySort.order`):
|
|
20
|
-
|
|
21
|
-
| Thứ tự | Nhóm | Nguồn | Ghi chú |
|
|
22
|
-
|--------|------|--------|---------|
|
|
23
|
-
| 1 | **Introduction** | `src/storybook/Introduction/*.mdx` | Design Principles |
|
|
24
|
-
| 2 | **Foundations** | `src/storybook/Foundations/*.stories.ts`, `Configure.mdx` | Configure → Colors → Typography → Spacing & Layout |
|
|
25
|
-
| 3 | **VIUI Components** | `src/design-system/vi-ui/**/*.stories.ts` | ViButton, ViInput, ViCard, … (title: `VIUI Components/<Tên>`) |
|
|
26
|
-
| 4 | **Themes** | `src/storybook/Themes/<theme-id>/*.stories.ts` | Neo-Brutalism (trong `neo-brutalism/`), theme khác thêm folder tương ứng |
|
|
27
|
-
| 5 | **Brands** | `src/components/brands/*.stories.ts` | Logo, Style Guide |
|
|
28
|
-
| 6 | **Errors** | `src/components/errors/*.stories.ts` | ErrorPage, … |
|
|
29
|
-
| 7+ | **AI Prompt Rules**, **Icons** | `src/storybook/AIPromptRules/*`, `src/storybook/Icons/IconsOverview.mdx` | Sau nhóm Errors; icon mặc định Tabler (xem `.cursor/rules/icons.mdc`) |
|
|
30
|
-
|
|
31
|
-
- **Story title** = `{Nhóm}/{Tên}` (vd: `VIUI Components/Button`, `Brands/Logo`, `Errors/ErrorPage`, `Foundations/Colors`).
|
|
32
|
-
- Story đặt **cùng thư mục** với component; **foundation stories** trong `src/storybook/Foundations/`.
|
|
33
|
-
|
|
34
|
-
## Vi-ui: Component có slot → dùng Story Vue (tránh preview trống)
|
|
35
|
-
|
|
36
|
-
**Vấn đề:** Component vi-ui dùng **nhiều slot** (vd: `activator` + default) hoặc **nội dung slot phức tạp**. Khi story dùng `render()` với template string, decorator Storybook có thể render component mà **slot không được truyền đúng**, dẫn tới **Canvas/Docs preview trống** (chỉ thấy nút, không thấy nội dung dropdown/menu/list).
|
|
37
|
-
|
|
38
|
-
**Cách xử lý bắt buộc:** Tạo **component Story Vue** (ví dụ `ViMenuStory.vue`, `ViListStory.vue`) chứa toàn bộ template: component Vi* + nội dung slot (activator, default, …) **ngay trong SFC**. File `*.stories.ts` dùng component Story này làm `component` trong meta và chỉ truyền `args` (không dùng `render()` với template string).
|
|
39
|
-
|
|
40
|
-
| Bước | Nội dung |
|
|
41
|
-
|------|----------|
|
|
42
|
-
| 1 | Tạo `ViNameStory.vue` trong cùng thư mục với `ViName.vue`. |
|
|
43
|
-
| 2 | Trong SFC: đặt `ViName` với đủ slot (vd: `#activator`, default) và **dữ liệu demo** (v-list, v-list-item, …) trong template. |
|
|
44
|
-
| 3 | Props của Story component: các biến cần đổi giữa các story (vd: `open`, `listVariant`, `location`). Dùng `ref` nội bộ sync với prop khi cần `v-model`. |
|
|
45
|
-
| 4 | Trong `ViName.stories.ts`: `component: ViNameStory`, mỗi story chỉ `args: { ... }`, **không** dùng `render()`. |
|
|
46
|
-
|
|
47
|
-
**Ví dụ tham chiếu:** `src/design-system/vi-ui/vi-menu/ViMenuStory.vue` + `ViMenu.stories.ts`, `src/design-system/vi-ui/vi-list/ViListStory.vue` + `ViList.stories.ts`.
|
|
48
|
-
|
|
49
|
-
**Khi nào dùng:** Component có **activator + content** (ViMenu, ViDialog với slot phức tạp), hoặc **list/container cần item mẫu** (ViList). Component đơn giản chỉ props (ViButton, ViChip) có thể chỉ cần `*.stories.ts` với `args` mà không cần file Story Vue.
|
|
50
|
-
|
|
51
|
-
## Nguyên tắc khi áp dụng rule này
|
|
52
|
-
|
|
53
|
-
1. **CSF3 + TypeScript** — `satisfies Meta<typeof Component>`, `StoryObj<typeof meta>`, import từ `@storybook/vue3-vite`; đủ `argTypes` và `args` mặc định.
|
|
54
|
-
2. **Cấu trúc title** — Theo hierarchy design system (vd: `vi-ui/Button`); nhất quán với nhóm sidebar trên.
|
|
55
|
-
3. **Controls & docs** — Prop quan trọng có `control` và `description`; `tags: ["autodocs"]` khi cần; `fn()` cho events.
|
|
56
|
-
4. **Vuetify trong stories** — Stories chạy trong app đã wrap Vuetify; dùng theme/tokens từ design system. **Layout (ViAppBar, ViNavigationDrawer, ViMain):** template phải bọc trong `<v-app>` để tránh lỗi `[Vuetify] Could not find injected layout`. Chi tiết: `vuetify-layout.mdc`.
|
|
57
|
-
5. **Addons** — addon-docs, addon-a11y, addon-vitest; không phá cấu hình `.storybook/main.ts`.
|
|
58
|
-
6. **Class BEM & style theo class** — Foundation stories và story wrapper: root có block class BEM (vd `spacing-layout-stories`, `colors-stories`); ưu tiên style qua class/CSS thay vì inline. Chi tiết: `bem-class-style.mdc`.
|
|
59
|
-
7. **Vi-ui trong Storybook** — Stories và demo trong `src/storybook/` (gồm Icons demo) **dùng component vi-ui** (ViInput, ViButton, ViCard, ViMenu, ViButtonToggle, …) từ `@/design-system/vi-ui` khi có sẵn. **Nút action** (copy, link-style, submit) dùng **ViButton**, không dùng raw `<button>`. Nếu thiếu component (vd. ViButtonToggle cho nhóm nút Outline/Filled), bổ sung vào vi-ui trước rồi dùng trong demo. Chi tiết: `icons.mdc` và plan `icons_free_sources.plan.md`.
|
|
60
|
-
|
|
61
|
-
## Tham chiếu nhanh
|
|
62
|
-
|
|
63
|
-
- Config: `.storybook/main.ts`, `preview.ts`
|
|
64
|
-
- Stories mẫu (đơn giản): `src/design-system/vi-ui/vi-button/ViButton.stories.ts`
|
|
65
|
-
- Stories mẫu (có slot, dùng Story Vue): `src/design-system/vi-ui/vi-menu/ViMenuStory.vue` + `ViMenu.stories.ts`, `vi-list/ViListStory.vue` + `ViList.stories.ts`
|
|
66
|
-
- Components & tokens: rule `design-system-component-library.mdc` và `src/tokens/`
|
|
67
|
-
|
|
68
|
-
Khi được kích hoạt (file khớp glob), hành xử như **subagent Storybook expert** và áp dụng các nguyên tắc trên.
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Design tokens — nguồn chân lý màu, typography, spacing; không hard-code
|
|
3
|
-
globs: src/tokens/**/*, src/types/inet-tokens-types.ts, src/assets/styles/**/*.scss, src/plugins/**/theme*.ts
|
|
4
|
-
alwaysApply: false
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Design Tokens
|
|
8
|
-
|
|
9
|
-
**Bạn là design tokens specialist.**
|
|
10
|
-
|
|
11
|
-
## Vai trò
|
|
12
|
-
|
|
13
|
-
- **Chuyên gia tokens**: Hướng dẫn định nghĩa, cấu trúc và sử dụng design tokens trong dự án.
|
|
14
|
-
- **Nguồn chân lý**: Màu sắc, typography, spacing, elevation, motion — mọi giá trị giao diện lấy từ tokens, không hard-code.
|
|
15
|
-
- **Đồng bộ**: Tokens TypeScript/JSON và SCSS/CSS variables phải nhất quán với `src/tokens/` và types trong `src/types/inet-tokens-types.ts`.
|
|
16
|
-
|
|
17
|
-
## Nguyên tắc
|
|
18
|
-
|
|
19
|
-
1. **Một nguồn, nhiều kênh** — **Single source of truth:** `src/tokens/design-tokens.ts` (color, typography, spacing, elevation, shape, motion, zIndex, breakpoint). Theme Vuetify và SCSS (`src/assets/styles/inet-tokens.scss`) consume từ đó. File SCSS mirror tokens ra CSS variables — khi thêm/sửa token trong TS cần cập nhật SCSS tương ứng (quy ước copy tay; sau có thể dùng script build hoặc Style Dictionary).
|
|
20
|
-
2. **Legacy** — `inet-design-tokens.ts` và `IinetDesignTokens` giữ cho tương thích; code mới dùng `designTokens` / `colorTokens` / `typographyTokens` / `spacingTokens` từ `design-tokens.ts`. Types cho design tokens: export từ `design-tokens.ts` (`ColorTokens`, `TypographyTokens`, …).
|
|
21
|
-
3. **Đặt tên có cấp bậc** — Ví dụ: `colorTokens.brand.primary`, `typographyTokens.fontSize.base`, `spacingTokens[4]`; tránh tên phẳng không ngữ cảnh.
|
|
22
|
-
4. **Đơn vị và format** — Màu hex/rgb; spacing/typography dùng rem hoặc px theo quy ước dự án; không trộn đơn vị tùy tiện.
|
|
23
|
-
5. **Tuân AGENTS.md** — Không tự chạy lệnh shell khi chưa có đồng ý.
|
|
24
|
-
|
|
25
|
-
## Tham chiếu nhanh
|
|
26
|
-
|
|
27
|
-
- **Tokens (ưu tiên):** `src/tokens/design-tokens.ts` — `colorTokens`, `typographyTokens`, `spacingTokens`, `designTokens`
|
|
28
|
-
- **Legacy:** `src/tokens/inet-design-tokens.ts`, types `src/types/inet-tokens-types.ts`
|
|
29
|
-
- Styles: `src/assets/styles/inet-tokens.scss`, `main.scss`
|
|
30
|
-
- Theme: `src/plugins/theme-base.ts`, `v-light.ts`, `v-dark.ts`
|
|
31
|
-
|
|
32
|
-
Khi được kích hoạt (file khớp glob), hành xử như **subagent design tokens specialist** và áp dụng các nguyên tắc trên.
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Theme SCSS (viui-themes) — chỉ override hình dạng; màu semantic theo props Vi* (color: primary, success, info, error, warning). Cấu trúc tối đa 2 file per theme; không tạo file *-global trùng lặp.
|
|
3
|
-
globs: packages/viui-themes/**/*.scss, src/storybook/Themes/**/*.vue
|
|
4
|
-
alwaysApply: false
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# viui-themes — Design style themes (SCSS)
|
|
8
|
-
|
|
9
|
-
**Khi tạo hoặc chỉnh SCSS trong `packages/viui-themes/` (và view theme trong `src/storybook/Themes/`), theme phải tôn trọng props của component Vi\* về màu sắc.**
|
|
10
|
-
|
|
11
|
-
## Cấu trúc file — tối đa 2 file per theme
|
|
12
|
-
|
|
13
|
-
Quản lý tập trung, tránh trùng lặp:
|
|
14
|
-
|
|
15
|
-
- **Một partial:** `_<id>.scss` — chứa cả scoped (`.components-overview-wrapper.design-style-<id>`) và `body.design-style-<id>` (teleport + global). **Không** tạo file `_<id>-global.scss` riêng.
|
|
16
|
-
- **Một entry:** `<id>.scss` — chỉ `@use './_<id>' as *;`. Import này dùng cho cả scoped và global.
|
|
17
|
-
- **Alias tương thích ngược:** Trong `package.json`, `"./<id>-global"` và `"./<id>-global.scss"` trỏ cùng `"./<id>.scss"` (không tạo file vật lý `*-global.scss`).
|
|
18
|
-
|
|
19
|
-
Khi thêm theme mới: tuân quy ước trên và `packages/viui-themes/_THEME_CONVENTION.md`.
|
|
20
|
-
|
|
21
|
-
## Nguyên tắc bắt buộc (nội dung theme)
|
|
22
|
-
|
|
23
|
-
**Theme chỉ override "hình dạng" (shape), không override "màu semantic".**
|
|
24
|
-
|
|
25
|
-
| Override được (theme) | Không override (để props/quản lý) |
|
|
26
|
-
|------------------------|-----------------------------------|
|
|
27
|
-
| `border-width`, `border-style` | `border-color` — do prop `color` của Vi\* (primary, success, info, error, warning, …) |
|
|
28
|
-
| `border-radius` | `background`, `background-color` khi component có `color` |
|
|
29
|
-
| `box-shadow` (nhẹ hoặc none) | Màu chữ/nền semantic (Vuetify/theme từ tokens) |
|
|
30
|
-
| `font-weight`, typography | |
|
|
31
|
-
| `padding`, `margin`, spacing | |
|
|
32
|
-
|
|
33
|
-
- **Màu sắc** (border, nền, chữ) phải **đi theo cấu hình props** của component Vi\*: `color="primary"`, `color="success"`, `color="info"`, `color="error"`, `color="warning"`, … Theme (palette) cung cấp token; component nhận `color` và áp dụng qua Vuetify theme. SCSS của theme **không** hardcode một màu duy nhất (vd. `border: 1px solid var(--color-border-default) !important`) cho mọi instance — nếu làm vậy sẽ chặn màu từ props.
|
|
34
|
-
|
|
35
|
-
## Áp dụng trong SCSS theme
|
|
36
|
-
|
|
37
|
-
1. **Button, Card, và component có prop `color`**
|
|
38
|
-
- Set `border-width`, `border-style`, `border-radius`, `box-shadow`, `font-weight`.
|
|
39
|
-
- **Không** set `border-color` (hoặc không dùng `!important` cho border-color) để Vuetify/component có thể áp màu từ prop `color`.
|
|
40
|
-
|
|
41
|
-
2. **Input, Dialog, Toast, v.v.**
|
|
42
|
-
- Có thể dùng `border-color: var(--color-border-default)` làm fallback **không** `!important` để trạng thái focus/error/semantic vẫn ghi đè được.
|
|
43
|
-
|
|
44
|
-
3. **Focus / error state**
|
|
45
|
-
- Được phép set `border-color` (vd. focus ring) với `!important` chỉ cho trạng thái đó, không cho default.
|
|
46
|
-
|
|
47
|
-
## Tóm tắt
|
|
48
|
-
|
|
49
|
-
- **Theme = lớp phong cách** (viền mỏng/dày, bóng nhẹ/nặng, typography, spacing).
|
|
50
|
-
- **Màu = theo props** (primary, success, info, error, warning, …).
|
|
51
|
-
- Tránh nhắc lại: mọi theme mới hoặc chỉnh theme cũ phải tuân quy tắc trên.
|
|
52
|
-
|
|
53
|
-
Tham chiếu: `design-system-component-library.mdc`, `tokens.mdc`; plan `.cursor/plans/themes.plan.md`.
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Vuetify layout — bắt buộc bọc v-app khi dùng ViAppBar, ViNavigationDrawer, ViMain; tránh lỗi "Could not find injected layout"
|
|
3
|
-
globs: "**/*.vue", "**/*.stories.@(ts|tsx)"
|
|
4
|
-
alwaysApply: false
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Vuetify Layout (v-app bắt buộc)
|
|
8
|
-
|
|
9
|
-
**Khi dùng component layout của Vuetify (hoặc vi-ui tương ứng), template phải nằm trong `<v-app>`.** Nếu không, runtime sẽ báo: **`[Vuetify] Could not find injected layout`**.
|
|
10
|
-
|
|
11
|
-
## Component cần v-app
|
|
12
|
-
|
|
13
|
-
Các component sau **phụ thuộc layout inject** từ Vuetify; chúng phải được render **bên trong** một `<v-app>`:
|
|
14
|
-
|
|
15
|
-
| Vi-ui | Vuetify gốc |
|
|
16
|
-
|-------|-------------|
|
|
17
|
-
| ViAppBar | v-app-bar |
|
|
18
|
-
| ViNavigationDrawer | v-navigation-drawer |
|
|
19
|
-
| ViMain | v-main |
|
|
20
|
-
| (VFooter nếu dùng) | v-footer |
|
|
21
|
-
|
|
22
|
-
## Quy tắc bắt buộc
|
|
23
|
-
|
|
24
|
-
1. **Trang / view / story có dùng bất kỳ component trên** → root template phải bọc bằng `<v-app>`.
|
|
25
|
-
2. **Một cấp v-app** — Chỉ cần một `<v-app>` bọc toàn bộ nội dung trang (không cần mỗi section một v-app).
|
|
26
|
-
3. **Storybook** — Story hoặc component Story Vue (vd. theme preview `Minimalist2.vue`, `NeoBrutalism.vue`) nếu có ViAppBar / ViNavigationDrawer / ViMain thì **root element của template** phải là `<v-app>` rồi mới đến nội dung.
|
|
27
|
-
|
|
28
|
-
## Ví dụ đúng
|
|
29
|
-
|
|
30
|
-
```vue
|
|
31
|
-
<template>
|
|
32
|
-
<v-app>
|
|
33
|
-
<div class="my-page">
|
|
34
|
-
<ViAppBar title="Demo" />
|
|
35
|
-
<ViNavigationDrawer v-model="drawerOpen">...</ViNavigationDrawer>
|
|
36
|
-
<ViMain>...</ViMain>
|
|
37
|
-
</div>
|
|
38
|
-
</v-app>
|
|
39
|
-
</template>
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Khi tạo mới hoặc cập nhật
|
|
43
|
-
|
|
44
|
-
- **Thêm section Layout (AppBar, Drawer, Main)** vào theme preview hoặc bất kỳ trang Vue nào → kiểm tra root có `<v-app>` chưa; nếu chưa thì bọc toàn bộ template trong `<v-app>`.
|
|
45
|
-
- **Lỗi "Could not find injected layout"** → nguyên nhân gần như chắc chắn là thiếu v-app bọc ngoài chỗ dùng ViAppBar / ViNavigationDrawer / ViMain; sửa bằng cách thêm `<v-app>` làm root.
|
|
46
|
-
|
|
47
|
-
## Tham chiếu
|
|
48
|
-
|
|
49
|
-
- Theme preview mẫu (đã bọc v-app): `src/storybook/Themes/minimalist-2/Minimalist2.vue`
|
|
50
|
-
- Vi-ui layout: `src/design-system/vi-ui/vi-app-bar/`, `vi-navigation-drawer/`, `vi-main/`
|
|
51
|
-
|
|
52
|
-
Khi chỉnh file khớp glob và có dùng layout component, **luôn đảm bảo** template được bọc trong `<v-app>` để tránh lỗi lặp lại.
|