From 60b5233e95a70b00912a5b3b78e64a5878ce615c Mon Sep 17 00:00:00 2001 From: TaNguyenThanhQuy Date: Fri, 17 Apr 2026 06:28:43 +0000 Subject: [PATCH] feat: add pages (#33) Co-authored-by: Thanh Quy - wolf <524H0124@student.tdtu.edu.vn> Co-authored-by: Thanh Quy- wolf <524H0124@student.tdtu.edu.vn> Reviewed-on: https://git.demonkernel.io.vn/FoodSurf/frontend/pulls/33 Co-authored-by: TaNguyenThanhQuy Co-committed-by: TaNguyenThanhQuy --- .blackboxrules | 5 - .../skills/frontend-atomic-design/SKILL.md | 487 +++++++++++ .../frontend-atomic-design/manifest.json | 7 + .claude/skills/prompt-optimizer/SKILL.md | 88 ++ .claude/skills/ui-ux-testing/SKILL.md | 274 +++++++ .../website-creation-automation/SKILL.md | 224 +++++ Atomic.md | 762 ------------------ README.md | 52 +- app/(main)/login/page.tsx | 4 +- app/(main)/page.tsx | 18 +- app/(main)/payment/page.tsx | 15 +- components/COMPONENTS.md | 67 +- components/atoms/ATOMS.md | 19 - components/atoms/buttons/Button.tsx | 3 +- components/atoms/buttons/Button.types.ts | 1 + components/atoms/inputs/SearchInput.tsx | 2 + .../molecules/cards/PaymentSummaryCard.tsx | 11 +- components/molecules/cards/ProductCard.tsx | 2 +- components/molecules/search-bar/SearchBar.tsx | 1 + components/organisms/analytics/BarChart.tsx | 10 +- components/organisms/analytics/LineChart.tsx | 122 +-- components/organisms/analytics/PieChart.tsx | 2 +- components/organisms/forms/LoginForm.tsx | 2 +- components/organisms/manager/ProductsTab.tsx | 5 +- .../organisms/navigation/CategorySidebar.tsx | 1 + layouts/header.tsx | 2 + package.json | 1 + register-shift-feature-prompt.md | 156 ---- 28 files changed, 1194 insertions(+), 1149 deletions(-) delete mode 100644 .blackboxrules create mode 100644 .claude/skills/frontend-atomic-design/SKILL.md create mode 100644 .claude/skills/frontend-atomic-design/manifest.json create mode 100644 .claude/skills/prompt-optimizer/SKILL.md create mode 100644 .claude/skills/ui-ux-testing/SKILL.md create mode 100644 .claude/skills/website-creation-automation/SKILL.md delete mode 100644 Atomic.md delete mode 100644 register-shift-feature-prompt.md diff --git a/.blackboxrules b/.blackboxrules deleted file mode 100644 index 274a1d7..0000000 --- a/.blackboxrules +++ /dev/null @@ -1,5 +0,0 @@ -## Rules: - - Khi làm một tính năng mới, trước khi hoàn thành phải update các file mark down mà thư mục đó được update. - - Khi có từ khóa "Yêu cầu" và một list các yêu cầu thì phải hoàn thành ĐÚNG yêu cầu, không thêm không bớt. - - Sử dụng thư viện tailwind CSS để code css cho project. - - Mỗi feature được update đều phải được responsive với các kích cỡ màn hình như smartphone, tablet, desktop. \ No newline at end of file diff --git a/.claude/skills/frontend-atomic-design/SKILL.md b/.claude/skills/frontend-atomic-design/SKILL.md new file mode 100644 index 0000000..aaafd8e --- /dev/null +++ b/.claude/skills/frontend-atomic-design/SKILL.md @@ -0,0 +1,487 @@ +--- +name: frontend-atomic-design +description: Create modern, responsive frontend components and layouts using atomic design methodology with Tailwind CSS. Use this skill whenever building React components, designing UI layouts, creating responsive pages, or working with atomic design principles. Triggers include: component development, page design, responsive design requests, Tailwind CSS styling, creating design systems, building reusable UI elements, or designing for multiple screen sizes (desktop, tablet, mobile). This skill emphasizes reusable variables, modern aesthetics, and responsive design across all viewport sizes. +--- + +# Atomic Design Frontend System with Tailwind CSS + +A comprehensive guide for building modern, responsive frontend applications using atomic design principles and Tailwind CSS. + +## Core Principles + +### 1. Atomic Design Hierarchy + +Atomic Design breaks UI into five distinct levels: + +#### **Atoms** +Smallest, indivisible UI elements that cannot be broken down without losing functionality. +- Buttons, input fields, labels, icons, text styles +- Color variables, spacing units, typography scales +- Simple, pure, reusable building blocks + +```jsx +// Example: Button Atom + +``` + +#### **Molecules** +Groups of atoms bonded together, forming simple functional units. +- Search bars (input + button + icon) +- Form fields (label + input + error message) +- Card headers (avatar + title + subtitle) +- Navigation items with icons and labels + +```jsx +// Example: Search Molecule +
+ + +
+``` + +#### **Organisms** +Complex functional units made of groups of molecules and/or atoms. +- Header/Navigation bars +- Form sections (multiple form molecules) +- Card layouts with multiple sections +- Modals with title, content, and actions +- Data tables with headers, rows, and pagination + +```jsx +// Example: Product Card Organism +
+ +
+

Product Name

+

Description

+
+ $99 + +
+
+
+``` + +#### **Templates** +Page-level wireframes showing layout and component placement without final content. +- Single-column layouts +- Two-column layouts (sidebar + main) +- Grid-based layouts +- Hero + content sections + +#### **Pages** +Specific instances of templates populated with real content and data. +- Homepage with actual products +- User profile with real user data +- Dashboard with live metrics + +--- + +## Design System Variables (Reusable Values) + +### Color Palette +```css +/* Define in Tailwind config or use CSS variables */ +Primary: #2563eb (blue-600) +Secondary: #7c3aed (violet-600) +Success: #16a34a (green-600) +Warning: #ea580c (orange-600) +Danger: #dc2626 (red-600) +Neutral: #6b7280 (gray-500) +``` + +### Typography Scale +```css +H1: 32px (2rem) - font-bold +H2: 24px (1.5rem) - font-bold +H3: 20px (1.25rem) - font-semibold +Body: 16px (1rem) - font-normal +Small: 14px (0.875rem) - font-normal +Tiny: 12px (0.75rem) - font-normal +``` + +### Spacing Scale +```css +xs: 4px (0.25rem) +sm: 8px (0.5rem) +md: 16px (1rem) +lg: 24px (1.5rem) +xl: 32px (2rem) +2xl: 48px (3rem) +``` + +### Border Radius +```css +Subtle: 4px (rounded-sm) +Standard: 8px (rounded-lg) +Large: 12px (rounded-xl) +Full: 9999px (rounded-full) +``` + +### Box Shadows +```css +Subtle: 0 1px 2px rgba(0,0,0,0.05) +Soft: 0 4px 6px rgba(0,0,0,0.07) +Medium: 0 10px 15px rgba(0,0,0,0.10) +Strong: 0 20px 25px rgba(0,0,0,0.15) +``` + +--- + +## Responsive Design Strategy + +### Breakpoints (Tailwind Default) +``` +Mobile: < 640px (sm) +Tablet: 640px (md, lg) +Desktop: 1024px+ (xl, 2xl) +``` + +### Mobile-First Approach +1. **Start with mobile styles** (default, no prefix) +2. **Layer tablet styles** (md: prefix) +3. **Layer desktop styles** (lg:, xl: prefix) + +### Example: Responsive Layout +```jsx +// Mobile: 1 column, Tablet: 2 columns, Desktop: 3 columns +
+ {items.map(item => ( + + ))} +
+``` + +### Common Responsive Patterns + +**Responsive Typography** +```jsx +

+ Responsive Heading +

+``` + +**Responsive Padding/Margins** +```jsx +
+ Content with responsive spacing +
+``` + +**Responsive Grid** +```jsx +
+ {/* Grid items */} +
+``` + +**Responsive Flexbox** +```jsx +
+ +
Main content
+
+``` + +**Responsive Images** +```jsx +Responsive image +``` + +--- + +## Modern Design Patterns + +### 1. Consistency & Visual Hierarchy +- **Use consistent spacing**: Apply spacing scale uniformly +- **Establish clear hierarchy**: Size, weight, color for emphasis +- **Group related content**: Use whitespace to separate sections +- **Align elements**: Use grids for crisp layouts + +```jsx +
+
+

Section Title

+

Description text

+
+
+ {/* Related items with consistent spacing */} +
+
+``` + +### 2. Interactive Feedback +- **Hover states**: Subtle color/shadow changes +- **Active states**: Indicate current selection +- **Focus states**: Keyboard navigation support +- **Loading states**: Spinners or skeleton screens +- **Transitions**: Smooth animations (200-300ms) + +```jsx + +``` + +### 3. Depth & Layering +- **Subtle shadows**: Create depth without heaviness +- **Elevation levels**: Consistent shadow progression +- **Overlays**: Semi-transparent backgrounds for modals +- **Z-index strategy**: Clear layering hierarchy + +```jsx +
+ Card content +
+``` + +### 4. Color Usage +- **Primary action**: Most frequent call-to-action +- **Secondary action**: Alternative actions +- **Semantic colors**: Status indicators (success, warning, danger) +- **Contrast**: Ensure WCAG AA compliance (4.5:1 ratio) +- **Limited palette**: 3-5 colors maximum in most designs + +### 5. Whitespace & Breathing Room +- Don't crowd elements +- Use consistent gap values (gap-4, gap-6, gap-8) +- Separate sections with vertical rhythm +- Generous padding in cards and containers + +```jsx +
+
+ {/* Sections with good breathing room */} +
+
+``` + +--- + +## Tailwind CSS Best Practices + +### 1. Use Utility Classes Effectively +```jsx +// Good: Semantic, reusable, organized + + +// Avoid: Too many utilities, hard to read + + ); +}; +``` + +### 3. Organize Utility Classes +```jsx +// Organize by category: layout → sizing → colors → effects → responsive +
+
+``` + +### 4. Use Tailwind Config for Consistency +```js +// tailwind.config.js +module.exports = { + theme: { + extend: { + colors: { + primary: '#2563eb', + secondary: '#7c3aed', + }, + spacing: { + gutter: '1rem', + }, + }, + }, +}; +``` + +--- + +## Component Construction Template + +Use this template when building atomic components: + +```jsx +/** + * {Component Name} + * + * Atoms/Molecules/Organisms level component + * Purpose: [Brief description] + * + * Props: + * - prop1: type - description + * - prop2: type - description + */ + +export const ComponentName = ({ prop1, prop2, className = '' }) => { + return ( +
+ {/* Component content */} +
+ ); +}; +``` + +--- + +## Layout Patterns + +### Container + Padding +```jsx +
+ {/* Content constrained to max width with responsive padding */} +
+``` + +### Two-Column Sidebar Layout +```jsx +
+ +
+ {/* Main content: takes remaining space */} +
+
+``` + +### Responsive Grid +```jsx +
+ {/* Items automatically stack on mobile, 2 columns on tablet, 3 on desktop */} +
+``` + +### Hero Section +```jsx +
+
+

+ Hero Title +

+

+ Hero subtitle or description +

+ +
+
+``` + +--- + +## Accessibility & Best Practices + +1. **Semantic HTML**: Use ` +``` + +--- + +## Performance Considerations + +1. **Limit custom CSS**: Rely on Tailwind utilities +2. **Tree-shake unused styles**: Configure Tailwind content paths +3. **Optimize images**: Use responsive images, WebP format +4. **Lazy load**: Defer non-critical components +5. **Minimize bundle**: Use PurgeCSS in production + +--- + +## Quick Reference Checklist + +When building a component, ensure: +- [ ] Follows atomic design hierarchy (Atom/Molecule/Organism) +- [ ] Uses design system variables (colors, spacing, typography) +- [ ] Responsive across mobile, tablet, desktop +- [ ] Consistent hover/active/focus states +- [ ] Proper whitespace and visual hierarchy +- [ ] Semantic HTML structure +- [ ] Accessible (contrast, focus, labels) +- [ ] Mobile-first approach +- [ ] No hardcoded values (use Tailwind config) + diff --git a/.claude/skills/frontend-atomic-design/manifest.json b/.claude/skills/frontend-atomic-design/manifest.json new file mode 100644 index 0000000..432f712 --- /dev/null +++ b/.claude/skills/frontend-atomic-design/manifest.json @@ -0,0 +1,7 @@ +{ + "name": "frontend-atomic-design", + "version": "1.0.0", + "description": "Create modern, responsive frontend components and layouts using atomic design methodology with Tailwind CSS", + "author": "Claude", + "created": "2026-04-12" +} \ No newline at end of file diff --git a/.claude/skills/prompt-optimizer/SKILL.md b/.claude/skills/prompt-optimizer/SKILL.md new file mode 100644 index 0000000..00a2d30 --- /dev/null +++ b/.claude/skills/prompt-optimizer/SKILL.md @@ -0,0 +1,88 @@ +--- +name: prompt-optimizer +description: Help users rewrite and improve AI/LLM prompts by adding specificity, context, and constraints. Trigger this skill whenever users ask to improve, rewrite, optimize, or refine prompts for AI models. Focus on making prompts clearer, more specific, and more likely to produce better AI results. Present suggestions interactively so users can choose which improvements to apply. +--- + +# Prompt Optimizer + +A beginner-friendly skill for improving AI/LLM prompts to get better results. + +## What This Skill Does + +This skill helps you rewrite prompts to work better with AI models like Claude. Instead of just giving you a rewritten prompt, it shows you specific improvement suggestions that you can choose to apply or skip. + +## Key Improvements + +When optimizing a prompt, focus on three main areas: + +### 1. **Specificity** — Making the Request Clear +Good prompts are specific about what you want. Vague prompts get vague results. + +**Example improvements:** +- Add details about format: "Give me a bullet list of 5 items" instead of "tell me about X" +- Be clear about length: "Write 200 words" instead of "Write something short" +- Define who the audience is: "Explain this for a 10-year-old" or "Use technical language" + +### 2. **Context** — Giving the AI Background Information +More context helps the AI make better decisions. + +**Example improvements:** +- Explain the goal: "I'm writing a resume, so focus on professional language" +- Share constraints: "We only have $500 budget" or "It needs to work on mobile" +- Provide background: "I already know Python but not JavaScript" + +### 3. **Constraints** — Setting Boundaries +Constraints prevent unwanted outputs. + +**Example improvements:** +- Set length limits: "Keep it under 100 words" +- Specify format: "Use JSON format" or "Write as a numbered list" +- Define tone: "Be casual and friendly, not formal" +- Say what NOT to include: "Don't use technical jargon" + +## How to Use This Skill + +1. **Share your prompt** — Give me the original prompt you want to improve +2. **Review suggestions** — I'll show you specific improvements in each area +3. **Choose what you like** — Pick which suggestions to apply +4. **Get the final version** — I'll rewrite your prompt with your chosen improvements + +## Interactive Selection Process + +When you use this skill, you'll see: + +- **Original prompt** — Your starting point +- **Improvement suggestions** — Specific changes grouped by category (Specificity, Context, Constraints) +- **Preview examples** — What each change would look like with the improvement applied +- **Your choices** — You pick which suggestions help most (you can apply all, some, or none) + +Then you get a rewritten prompt combining all your choices. + +### Example Interaction + +**Original:** "Write me a blog post" + +**Suggestions I might offer:** +- **Specificity**: Add a topic (e.g., "about sustainable living") +- **Context**: Explain your goal (e.g., "to build authority on my website") +- **Constraints**: Set a word count (e.g., "800-1000 words") + +**Your choice:** "I want all three — add topic, goal, and word count" + +**Final rewritten prompt:** +"Write an 800-1000 word blog post about sustainable living for my website. The goal is to establish my authority on eco-friendly practices. Target an audience of people interested in reducing their carbon footprint. Include 3-4 practical tips they can implement immediately, and end with a call-to-action encouraging them to sign up for my newsletter." + +## Tips for Best Results + +- **Start simple** — Even small improvements help +- **Focus on your goal** — What outcome do you want? +- **Add one constraint at a time** — Too many rules can be confusing +- **Test and iterate** — Try the new prompt and see if results improve + +## What Makes a Good Prompt + +A prompt becomes "good" when: +- The AI understands exactly what you want ✓ +- You've given enough context to explain why ✓ +- You've set boundaries to prevent bad outputs ✓ +- Someone else could read it and understand your intent ✓ diff --git a/.claude/skills/ui-ux-testing/SKILL.md b/.claude/skills/ui-ux-testing/SKILL.md new file mode 100644 index 0000000..81547ef --- /dev/null +++ b/.claude/skills/ui-ux-testing/SKILL.md @@ -0,0 +1,274 @@ +--- +name: ui-ux-testing +description: Automated visual regression testing and UI/UX analysis for web applications. Use this skill whenever developers mention "test this UI", "visual regression", "test the UI", "check this interface", "UI testing", or want to create automated tests for web pages. Analyzes URLs and generates comprehensive test strategies including Playwright/Cypress test scripts, manual testing checklists, visual regression detection, and detailed reports with findings and recommendations. +compatibility: + tools: Claude in Chrome browser automation + frameworks: Playwright, Cypress, Selenium +--- + +# UI/UX Testing Skill + +This skill helps developers create automated visual regression tests and comprehensive UI/UX testing strategies for web applications. + +## Overview + +When a developer asks you to test a UI or create visual regression tests, this skill guides you through: + +1. **Analyzing the target URL** - Inspect the web page structure and components +2. **Generating test strategies** - Create both automated and manual testing approaches +3. **Writing test code** - Generate Playwright/Cypress test scripts or Selenium code +4. **Creating test checklists** - Manual testing steps for visual regression and UX flows +5. **Generating reports** - Detailed findings, issues, and recommendations in markdown/HTML + +## When to Trigger + +Trigger this skill when the user: +- Provides a URL and asks to "test this UI" +- Requests "visual regression testing" for a web page +- Wants to "check accessibility" or test a component +- Asks to "create automated tests" for a UI +- Wants a "testing strategy" or "test plan" for a web application +- Mentions QA, testing, or validation of UI components + +## Workflow + +### Step 1: Inspect the Target URL + +Use Claude in Chrome to: +- Navigate to the provided URL +- Take screenshots of different viewport sizes (desktop, tablet, mobile) +- Inspect the DOM structure using `read_page` tool +- Identify key components, interactive elements, and critical flows +- Note responsive behavior and CSS properties + +### Step 2: Create a Test Strategy + +Based on your inspection, identify: +- **Visual elements** to regression test (buttons, forms, headers, layouts) +- **Interactive flows** to test (hover states, click handlers, form submission) +- **Responsive breakpoints** to validate (mobile, tablet, desktop) +- **Accessibility concerns** (ARIA labels, color contrast, keyboard navigation) +- **Critical user paths** to validate (common workflows) + +### Step 3: Generate Test Code + +**For Automated Testing (Choose one or more):** + +#### Playwright (Recommended) +```javascript +// Example structure +import { test, expect } from '@playwright/test'; + +test('visual regression - homepage', async ({ page }) => { + await page.goto('https://example.com'); + + // Capture baseline screenshot + await expect(page).toHaveScreenshot('homepage.png'); + + // Test interactive elements + await page.hover('button.primary'); + await expect(page).toHaveScreenshot('button-hover.png'); +}); + +test('responsive layout - mobile', async ({ page }) => { + await page.setViewportSize({ width: 375, height: 812 }); + await page.goto('https://example.com'); + await expect(page).toHaveScreenshot('mobile-layout.png'); +}); +``` + +#### Cypress +```javascript +describe('Visual Regression Tests', () => { + beforeEach(() => { + cy.visit('https://example.com'); + }); + + it('captures baseline screenshot', () => { + cy.screenshot('homepage'); + cy.get('[data-testid="header"]').should('be.visible'); + }); + + it('tests button hover state', () => { + cy.get('button.primary').trigger('mouseenter'); + cy.screenshot('button-hover-state'); + }); +}); +``` + +#### Selenium +```python +from selenium import webdriver +from selenium.webdriver.common.by import By +from PIL import Image + +driver = webdriver.Chrome() +driver.get('https://example.com') + +# Capture screenshot +driver.save_screenshot('homepage.png') + +# Test responsive +driver.set_window_size(375, 812) +driver.save_screenshot('mobile-view.png') +``` + +### Step 4: Create Manual Testing Checklist + +Generate a checklist including: + +- [ ] **Visual Consistency** + - [ ] All elements render correctly at 1920x1080 + - [ ] All elements render correctly at 1366x768 + - [ ] All elements render correctly at 768x1024 (tablet) + - [ ] All elements render correctly at 375x667 (mobile) + - [ ] Colors match design specifications + - [ ] Typography renders correctly (font families, sizes, weights) + - [ ] Images load and display at correct aspect ratios + +- [ ] **Responsive Behavior** + - [ ] Layout adapts correctly on mobile (no horizontal scroll) + - [ ] Navigation collapses/expands appropriately + - [ ] Form inputs are touch-friendly (min 44x44px) + - [ ] Content reflows without overlapping + +- [ ] **Interactive Elements** + - [ ] All buttons are clickable and have hover states + - [ ] Form inputs accept user input + - [ ] Dropdowns open/close correctly + - [ ] Links are underlined and properly colored + +- [ ] **Accessibility** + - [ ] Keyboard navigation works (Tab key) + - [ ] Color contrast meets WCAG AA standards + - [ ] Images have alt text + - [ ] Form labels are associated with inputs + +- [ ] **Critical User Paths** + - [ ] [Specific path 1]: [Steps and expected result] + - [ ] [Specific path 2]: [Steps and expected result] + +### Step 5: Generate Test Report + +Create an HTML/Markdown report with: + +```markdown +# UI/UX Testing Report + +## Executive Summary +- URL tested: [URL] +- Viewports tested: Desktop (1920x1080), Tablet (768x1024), Mobile (375x667) +- Testing date: [Date] +- Total issues found: [Count] + +## Issues Found + +### Critical (Breaks functionality) +1. **Issue Title** + - Severity: Critical + - Location: [Element/Component] + - Steps to reproduce: [Steps] + - Expected: [What should happen] + - Actual: [What actually happens] + - Screenshot: [If applicable] + +### Major (Significant visual/UX impact) +1. **Issue Title** + - Severity: Major + - Location: [Element/Component] + - Impact: [User impact] + +### Minor (Polish/optimization) +1. **Issue Title** + - Severity: Minor + - Location: [Element/Component] + - Recommendation: [Suggestion] + +## Visual Regression Analysis + +### Desktop (1920x1080) +- [List observations] +- [List changes from baseline if available] + +### Tablet (768x1024) +- [List observations] +- [Responsive issues found] + +### Mobile (375x667) +- [List observations] +- [Mobile-specific issues] + +## Accessibility Assessment + +| Element | Issue | WCAG Level | Recommendation | +|---------|-------|-----------|-----------------| +| [Element] | [Issue] | [AA/AAA] | [Fix] | + +## Recommendations + +1. **High Priority** + - [Recommendation with rationale] + +2. **Medium Priority** + - [Recommendation with rationale] + +3. **Low Priority** + - [Recommendation with rationale] + +## Test Coverage Summary + +- Automated tests needed: [Count and types] +- Manual test cases: [Count] +- Estimated testing effort: [Time estimate] +- Regression risk: [High/Medium/Low] + +--- +Generated using UI/UX Testing Skill +``` + +## Output Options + +Based on what the developer needs, generate: + +1. **Test Code Only** - Playwright/Cypress/Selenium scripts ready to integrate +2. **Testing Strategy** - Comprehensive checklist and manual test plan +3. **Full Report** - Screenshots, findings, issues, and automated test code +4. **All of the above** - Complete testing package + +## Best Practices + +- **Multiple viewports:** Always test at least mobile (375px), tablet (768px), and desktop (1920px) +- **Visual baselines:** Save baseline screenshots before making changes +- **Critical paths:** Prioritize testing main user workflows first +- **Accessibility first:** Include WCAG AA compliance checks +- **Clear assertions:** Make test assertions explicit and meaningful +- **Maintainability:** Use data attributes (data-testid) for reliable element selection + +## Example: Complete Testing Session + +1. Developer provides URL: "https://myapp.com/dashboard" +2. You inspect the page (screenshots, DOM, responsive behavior) +3. You identify: + - Dashboard header with navigation + - Data table with sorting/filtering + - Form for creating items + - Mobile menu collapse +4. You generate: + - Playwright tests for visual regression + - Manual testing checklist + - HTML report with findings +5. Developer receives complete testing artifact ready to use + +## Tips for Success + +- Take screenshots at each viewport to catch responsive issues +- Test interactive states (hover, focus, active, disabled) +- Verify critical user journeys end-to-end +- Include accessibility testing automatically +- Provide both automated (code) and manual (checklist) approaches +- Make reports actionable with clear severity levels and recommendations + +--- + +**Last Updated:** 2024 +**Skill Version:** 1.0 diff --git a/.claude/skills/website-creation-automation/SKILL.md b/.claude/skills/website-creation-automation/SKILL.md new file mode 100644 index 0000000..075b729 --- /dev/null +++ b/.claude/skills/website-creation-automation/SKILL.md @@ -0,0 +1,224 @@ +--- +name: website-creation-automation +description: Automate end-to-end website creation with AI-powered optimization, design, and testing. Trigger this skill whenever the user wants to create a new website, build a landing page, design a web application, or automatically generate a complete website from a description. This skill takes a user's website idea or prompt, optimizes it for clarity, designs a modern responsive website, and automatically tests it for quality issues. Use this skill for any "create a website" or "build a web application" request, including landing pages, portfolio sites, e-commerce pages, dashboards, or any web-based project. +compatibility: + models: + - claude-sonnet-4-20250514 (design and testing) + - claude-haiku-4.5-20251001 (bug fixes) + required_skills: + - prompt-optimizer + - frontend-atomic-design + - ui-ux-testing +--- + +# Website Creation Automation Skill + +An intelligent, end-to-end automation workflow for creating complete, tested websites from simple prompts. + +## What This Skill Does + +This skill orchestrates a complete website creation pipeline: + +1. **Prompt Optimization** — Takes your website description and optimizes it into a detailed, structured prompt +2. **Website Design** — Uses the optimized prompt to design and build a modern, responsive website +3. **Automated Testing** — Tests the generated website for visual, interactive, and responsive issues +4. **Auto-Fix** — Detects and fixes any issues found during testing + +The entire workflow is automated, so you just provide a simple description of what you want, and the skill handles the rest. + +## Core Workflow + +### Step 1: Optimize Your Website Prompt + +Your initial description (e.g., "Create a portfolio website for a freelance designer") is passed to the **prompt-optimizer** skill, which: +- Adds specific details about layout, features, and target audience +- Clarifies design preferences and functionality requirements +- Structures the request to guide high-quality website generation +- Returns a detailed, optimized prompt ready for design + +**Example transformation:** +``` +Input: "Create a portfolio website for a freelance designer" +↓ +Output: "Create a modern portfolio website for a freelance graphic designer. +Include: hero section with featured work, project showcase grid (6-8 projects), +about section, services list, client testimonials, contact form, and footer. +Target audience: potential clients and collaborators. Design should be minimalist +with emphasis on visual work. Mobile-responsive. Use modern sans-serif typography +and white space. Include smooth scroll animations." +``` + +### Step 2: Design the Website + +The **frontend-atomic-design** skill uses the optimized prompt to: +- Break down the website into atomic components (atoms, molecules, organisms) +- Create a responsive layout that works on desktop, tablet, and mobile +- Apply modern design patterns using Tailwind CSS +- Build interactive elements and proper semantic HTML +- Generate a complete, production-ready HTML file (or React component) + +**Outputs:** +- Full HTML file with embedded CSS and JavaScript +- All assets (icons, fonts) are self-contained +- Responsive design with mobile-first approach +- Accessible markup with semantic HTML5 + +### Step 3: Test the Website + +The **ui-ux-testing** skill performs comprehensive testing: +- Visual regression testing (captures baseline screenshots) +- Responsive layout validation (mobile, tablet, desktop) +- Interactive element testing (buttons, forms, links) +- Accessibility checking (color contrast, keyboard navigation) +- Cross-browser compatibility assessment +- User flow validation + +**Testing output includes:** +- Screenshots from multiple viewport sizes +- Detailed findings and issues detected +- Visual regression comparison +- Recommendations for improvements + +### Step 4: Auto-Fix Detected Issues + +Any issues detected in testing are automatically fixed: +- **Using Haiku 4.5** — A faster model optimized for targeted fixes +- **HTML-only fixes** — Modifications to structure, styling, or interactivity +- **Preserves design intent** — Fixes maintain the original design aesthetic +- **Re-validates** — Quick verification that fixes resolved the issues + +**Common fixes include:** +- Correcting responsive behavior issues +- Fixing accessibility problems +- Adjusting spacing, alignment, or colors +- Improving interactive element behavior +- Ensuring all content is properly visible + +--- + +## When to Use This Skill + +Use this skill whenever you want to: + +- **Create a new website** from scratch based on a description +- **Build a landing page** for a product, service, or event +- **Design a portfolio site** to showcase your work +- **Create an e-commerce page** with product displays +- **Build a dashboard or web app** UI +- **Generate a multi-page website** (returns first page, can iterate) +- **Prototype a website concept** quickly + +## How to Trigger This Skill + +Simply provide: +1. **Website description** — What kind of website you want (e.g., "e-commerce store for handmade jewelry", "SaaS landing page", "restaurant menu website") +2. **Optional details** — Any specific requirements (colors, features, tone, audience) + +The skill handles everything else automatically. + +## Example Usage + +**User prompt:** "Create a landing page for a sustainable fashion startup called EcoStitch. Include a hero section, features of our eco-friendly materials, pricing plans, customer testimonials, and a newsletter signup." + +**Skill processes:** +1. Optimizes prompt with specific design details and layout structure +2. Designs a modern, responsive landing page with all requested sections +3. Tests layout across mobile/tablet/desktop, forms, links, and visual design +4. Fixes any responsive or interactive issues found +5. Returns production-ready HTML file + +**Final output:** A complete, tested, bug-free website ready to deploy or customize further. + +--- + +## Technical Details + +### Model Usage + +- **Sonnet 4.6** — Used for optimization, design, and testing (high-quality complex tasks) +- **Haiku 4.5** — Used for bug fixes only (fast, targeted improvements) + +### Skill Integration + +This skill coordinates three core skills in sequence: + +``` +User Prompt + ↓ +[prompt-optimizer] → Optimized Prompt + ↓ +[frontend-atomic-design] → HTML/React Website + ↓ +[ui-ux-testing] → Test Results + Screenshots + ↓ +[Bug Fix Loop] → Fixed HTML/React Website + ↓ +Final Website (Ready to Use) +``` + +### Output Format + +The final website is delivered as: +- **HTML file** — Self-contained with CSS and JavaScript embedded +- **Screenshots** — Before/after testing comparison +- **Test report** — Issues found and fixes applied +- **Deployment ready** — Can be hosted on any static hosting service + +--- + +## Limitations & Notes + +- **Single-page output** — Generates one complete page (though can be expanded to multi-page) +- **Static by default** — Returns HTML; can generate React components if needed +- **Database-free** — Forms are functional but don't store data without backend integration +- **Rapid iteration** — If you want to modify the result, you can iterate by running the skill again with updated requirements + +--- + +## Tips for Best Results + +1. **Be descriptive** — More detail in your initial prompt leads to better results +2. **Specify audience** — Who is this website for? (target customers, users, etc.) +3. **Include features** — What should the website do? (e.g., showcase products, collect emails, etc.) +4. **Mention style** — Any aesthetic preferences? (minimalist, colorful, corporate, playful, etc.) +5. **Test thoroughly** — Review the testing results to ensure the site meets your needs + +--- + +## Workflow Diagram + +``` +START + ↓ +Input: Website Description + ↓ +[Call: prompt-optimizer skill] + ↓ +Receive: Optimized Detailed Prompt + ↓ +[Call: frontend-atomic-design skill] + ↓ +Receive: HTML/React Website Code + ↓ +[Call: ui-ux-testing skill] + ↓ +Receive: Test Results + Issues Found + ↓ +Are there critical issues? + ├─ YES → [Use Haiku 4.5 to fix] → Re-test + ├─ NO → Proceed + ↓ +COMPLETE: Return Website + Test Report +``` + +--- + +## Future Enhancements + +Potential expansions to this skill: +- Multi-page website generation (homepage, about, services, contact, etc.) +- CMS integration (connect to content management systems) +- Backend API scaffolding (Node.js/Express templates) +- SEO optimization (meta tags, structured data, open graph) +- Analytics integration (Google Analytics, Mixpanel) +- E-commerce integration (payment processing, inventory) diff --git a/Atomic.md b/Atomic.md deleted file mode 100644 index eeaf9b2..0000000 --- a/Atomic.md +++ /dev/null @@ -1,762 +0,0 @@ -# ATOMIC DESIGN STRUCTURE GUIDE - -## Overview - -Project sử dụng **Atomic Design Pattern** để tổ chức UI components theo 5 cấp -độ: - -1. **Atoms** - Khối xây dựng cơ bản, không thể chia nhỏ hơn -2. **Molecules** - Nhóm atoms đơn giản hoạt động cùng nhau -3. **Organisms** - Khu vực UI phức tạp, riêng biệt -4. **Templates** - Bố cục cấp trang, cấu trúc nội dung -5. **Pages** - Các phiên bản cụ thể với dữ liệu thật - ---- - -## 1) ATOMS (`components/atoms/`) - -**Mục đích:** Khối xây dựng cơ bản, tái sử dụng cao, không phụ thuộc logic phức -tạp. - -Không có context/hooks logic phức tạp, chỉ nhận props từ parent. - -### Cấu trúc thư mục - -``` -components/atoms/ -├── buttons/ -│ ├── Button.tsx # Nút cơ bản (primary, secondary, danger) -│ ├── IconButton.tsx # Nút chỉ có icon -│ └── Button.types.ts # Props types -├── inputs/ -│ ├── TextInput.tsx # Text input cơ bản -│ ├── NumberInput.tsx # Number input với up/down -│ ├── Checkbox.tsx # Checkbox -│ └── Input.types.ts # Props types -├── badges/ -│ ├── Badge.tsx # Badge cơ bản (color variants) -│ ├── PriceBadge.tsx # Badge hiển thị giá -│ └── Badge.types.ts # Props types -├── icons/ -│ ├── StarIcon.tsx # Rating star icon -│ ├── CartIcon.tsx # Shopping cart icon -│ ├── SearchIcon.tsx # Search icon -│ └── icons.types.ts # Props types -├── typography/ -│ ├── Heading.tsx # h1-h6 headings -│ ├── Text.tsx # Body text variants -│ ├── Caption.tsx # Small caption text -│ └── Typography.types.ts # Props types -├── dividers/ -│ ├── Divider.tsx # Horizontal divider -│ └── Divider.types.ts # Props types -├── loaders/ -│ ├── Spinner.tsx # Loading spinner -│ ├── Skeleton.tsx # Skeleton loader -│ └── Loader.types.ts # Props types -└── index.ts # Barrel export -``` - -### Ví dụ Atoms - -**Button.tsx:** - -```tsx -import { ButtonHTMLAttributes } from "react"; - -import type { ButtonProps } from "./Button.types"; - -export default function Button({ - variant = "primary", - size = "md", - disabled = false, - children, - className = "", - ...props -}: ButtonProps) { - const baseStyles = - "font-semibold rounded-lg transition-colors disabled:opacity-50"; - const variants = { - primary: - "bg-[color:var(--color-primary)] text-white hover:bg-[color:var(--color-primary-dark)]", - secondary: "bg-gray-200 text-gray-800 hover:bg-gray-300", - danger: "bg-red-500 text-white hover:bg-red-600", - }; - const sizes = { - sm: "px-3 py-1 text-sm", - md: "px-4 py-2 text-base", - lg: "px-6 py-3 text-lg", - }; - - return ( - - ); -} -``` - -**Button.types.ts:** - -```tsx -import { ButtonHTMLAttributes } from "react"; - -export interface ButtonProps extends ButtonHTMLAttributes { - variant?: "primary" | "secondary" | "danger"; - size?: "sm" | "md" | "lg"; - disabled?: boolean; - children: React.ReactNode; - className?: string; -} -``` - ---- - -## 2) MOLECULES (`components/molecules/`) - -**Mục đích:** Nhóm atoms tạo thành những UI unit nhỏ, tái sử dụng, có logic đơn -giản. - -Có thể sử dụng `useState`, nhưng logic chủ yếu nằm ở parent component. - -### Cấu trúc thư mục - -``` -components/molecules/ -├── form-groups/ -│ ├── FormField.tsx # Input + label + error message -│ ├── FormGroup.tsx # Label + input wrapper -│ └── FormGroup.types.ts # Props types -├── cards/ -│ ├── ProductCard.tsx # Card hiển thị sản phẩm (image + name + price + btn) -│ ├── ShopCard.tsx # Card hiển thị quán -│ ├── ReviewCard.tsx # Card hiển thị review -│ └── Card.types.ts # Props types -├── ratings/ -│ ├── RatingStars.tsx # Hiển thị 5 sao rating -│ ├── RatingInput.tsx # Input 5 sao (interactive) -│ └── Rating.types.ts # Props types -├── price-display/ -│ ├── PriceTag.tsx # Hiển thị giá formatted -│ ├── PriceRange.tsx # Hiển thị range giá -│ └── Price.types.ts # Props types -├── search-bar/ -│ ├── SearchInput.tsx # Search input với icon -│ ├── SearchBar.tsx # Search bar wrapper -│ └── Search.types.ts # Props types -├── breadcrumb/ -│ ├── Breadcrumb.tsx # Breadcrumb navigation -│ └── Breadcrumb.types.ts # Props types -├── tabs/ -│ ├── TabGroup.tsx # Tabs wrapper -│ ├── Tab.tsx # Individual tab -│ └── Tabs.types.ts # Props types -└── index.ts # Barrel export -``` - -### Ví dụ Molecules - -**ProductCard.tsx:** - -```tsx -import Button from "@/components/atoms/buttons/Button"; -import Text from "@/components/atoms/typography/Text"; -import Image from "next/image"; - -import type { ProductCardProps } from "./Card.types"; - -export default function ProductCard({ - product, - onAddToCart, -}: ProductCardProps) { - return ( -
-
- {product.name} -
- - {product.name} - - - {product.description} - -
- - ${product.price.toFixed(2)} - - -
-
- ); -} -``` - ---- - -## 3) ORGANISMS (`components/organisms/`) - -**Mục đích:** Khu vực UI phức tạp, độc lập, có logic riêng. - -Kết hợp multiple molecules/atoms, có thể sử dụng contexts (useAuth, useCart, -etc.), state phức tạp. - -### Cấu trúc thư mục - -``` -components/organisms/ -├── navigation/ -│ ├── Navbar.tsx # Sidebar category filter (cũ CartProduct) -│ ├── CategoryMenu.tsx # Category menu wrapper -│ └── Navigation.types.ts # Props types -├── cart/ -│ ├── CartFab.tsx # Floating action button giỏ hàng -│ ├── CartSummary.tsx # Cart summary widget -│ ├── CartList.tsx # Danh sách sản phẩm trong giỏ -│ └── Cart.types.ts # Props types -├── product-grid/ -│ ├── ProductGrid.tsx # Grid hiển thị danh sách sản phẩm -│ ├── ProductFilters.tsx # Bộ lọc sản phẩm (category, price, rating) -│ └── ProductGrid.types.ts # Props types -├── forms/ -│ ├── LoginForm.tsx # Form đăng nhập (username + password + submit) -│ ├── RegisterForm.tsx # Form đăng ký -│ ├── CheckoutForm.tsx # Form thanh toán -│ ├── ReviewForm.tsx # Form đánh giá (modal content) -│ └── Forms.types.ts # Props types -├── modals/ -│ ├── ReviewModal.tsx # Modal đánh giá (header + form + footer) -│ ├── ConfirmModal.tsx # Modal xác nhận generic -│ └── Modal.types.ts # Props types -├── shop-grid/ -│ ├── ShopGrid.tsx # Grid hiển thị danh sách quán -│ ├── ShopFilters.tsx # Bộ lọc quán (location, rating) -│ └── ShopGrid.types.ts # Props types -├── hero-section/ -│ ├── HeroSection.tsx # Banner hero cấp trang -│ └── Hero.types.ts # Props types -├── featured-section/ -│ ├── FeaturedProducts.tsx # Section sản phẩm nổi bật -│ ├── FeaturedShops.tsx # Section quán nổi bật -│ └── Featured.types.ts # Props types -└── index.ts # Barrel export -``` - -### Ví dụ Organisms - -**ProductGrid.tsx:** - -```tsx -"use client"; - -import ProductCard from "@/components/molecules/cards/ProductCard"; -import { useCart } from "@/lib/cart-context"; -import { MOCK_PRODUCTS } from "@/lib/constants"; -import { useMenu } from "@/lib/menu-context"; - -import type { ProductGridProps } from "./ProductGrid.types"; - -export default function ProductGrid({ searchQuery = "" }: ProductGridProps) { - const { activeCategory } = useMenu(); - const { addToCart } = useCart(); - - const filtered = MOCK_PRODUCTS.filter((product) => { - const matchCategory = - activeCategory === "all" || product.category === activeCategory; - const matchSearch = - product.name.toLowerCase().includes(searchQuery.toLowerCase()) || - product.description.toLowerCase().includes(searchQuery.toLowerCase()); - return matchCategory && matchSearch; - }); - - return ( -
- {filtered.map((product) => ( - - ))} -
- ); -} -``` - ---- - -## 4) TEMPLATES (`components/templates/`) - -**Mục đích:** Bố cục cấp trang, cấu trúc nội dung, không có data cụ thể. - -Chứa layout và structure của page, nhưng data được truyền từ page component. - -### Cấu trúc thư mục - -``` -components/templates/ -├── main-layout/ -│ ├── MainLayout.tsx # Layout chính (header + sidebar + content + footer) -│ ├── MainLayout.types.ts # Props types -│ └── styles.ts # Responsive grid layout logic -├── feed-layout/ -│ ├── FeedLayout.tsx # Layout feed (khám phá quán) -│ └── FeedLayout.types.ts # Props types -├── manager-layout/ -│ ├── ManagerLayout.tsx # Layout manager dashboard -│ └── ManagerLayout.types.ts # Props types -├── checkout-layout/ -│ ├── CheckoutLayout.tsx # Layout thanh toán (steps, cart, form) -│ └── CheckoutLayout.types.ts # Props types -├── auth-layout/ -│ ├── AuthLayout.tsx # Layout auth (login/register) -│ └── AuthLayout.types.ts # Props types -└── index.ts # Barrel export -``` - -### Ví dụ Templates - -**MainLayout.tsx:** - -```tsx -import Navbar from "@/components/organisms/navigation/Navbar"; -import Footer from "@/layouts/footer"; -import Header from "@/layouts/header"; - -import type { MainLayoutProps } from "./MainLayout.types"; - -export default function MainLayout({ children }: MainLayoutProps) { - return ( -
-
-
- {/* Sidebar - ẩn trên mobile */} - - {/* Main content */} -
{children}
-
-
-
- ); -} -``` - ---- - -## 5) PAGES (`app/*/page.tsx`) - -**Mục đích:** Các phiên bản cụ thể với dữ liệu thật, logic cấp trang. - -Server/client components sử dụng templates, organisms, nhận data từ API/context. - -### Ví dụ Pages - -**app/(main)/page.tsx:** - -```tsx -"use client"; - -import FeaturedSection from "@/components/organisms/featured-section/FeaturedSection"; -import ProductGrid from "@/components/organisms/product-grid/ProductGrid"; -import MainLayout from "@/components/templates/main-layout/MainLayout"; -import { useState } from "react"; - -export default function MainPage() { - const [searchQuery, setSearchQuery] = useState(""); - - return ( - - -
- -
-
- ); -} -``` - ---- - -## 6) File Hierarchy Summary - -``` -components/ -├── atoms/ -│ ├── buttons/ -│ ├── inputs/ -│ ├── badges/ -│ ├── icons/ -│ ├── typography/ -│ ├── dividers/ -│ ├── loaders/ -│ └── index.ts -├── molecules/ -│ ├── form-groups/ -│ ├── cards/ -│ ├── ratings/ -│ ├── price-display/ -│ ├── search-bar/ -│ ├── breadcrumb/ -│ ├── tabs/ -│ └── index.ts -├── organisms/ -│ ├── navigation/ -│ ├── cart/ -│ ├── product-grid/ -│ ├── forms/ -│ ├── modals/ -│ ├── shop-grid/ -│ ├── hero-section/ -│ ├── featured-section/ -│ └── index.ts -├── templates/ -│ ├── main-layout/ -│ ├── feed-layout/ -│ ├── manager-layout/ -│ ├── checkout-layout/ -│ ├── auth-layout/ -│ └── index.ts -└── ATOMIC_DESIGN.md (this file) -``` - ---- - -## 7) Migration Guide (Old → New) - -### Old Structure → New Structure Mapping - -| Old File | New Location | Type | -| ----------------- | ---------------------------------- | -------- | -| `CartProduct.tsx` | `molecules/cards/ProductCard.tsx` | Molecule | -| `Navbar.tsx` | `organisms/navigation/Navbar.tsx` | Organism | -| `CartFab.tsx` | `organisms/cart/CartFab.tsx` | Organism | -| `ReviewModal.tsx` | `organisms/modals/ReviewModal.tsx` | Organism | - -### Migration Steps - -1. Create new directory structure under `components/` -2. Move existing components to appropriate levels (atoms → molecules → - organisms) -3. Extract shared styles/logic into atoms -4. Update imports in `app/` pages -5. Test responsiveness at each breakpoint -6. Update `COMPONENTS.md` with new structure - ---- - -## 8) Best Practices - -### Atoms Development - -- ✅ Reusable across entire project -- ✅ No business logic -- ✅ No context/hooks (useAuth, useCart) -- ✅ Pure props-based -- ✅ Full TypeScript typing -- ❌ No "use client" needed (unless interactive, e.g., Button) - -### Molecules Development - -- ✅ Combines multiple atoms -- ✅ Simple state (open/close, hover state) -- ✅ No complex business logic -- ✅ Can use useState for UI state -- ✅ Reusable in multiple contexts -- ❌ No global state (useAuth, useCart) - -### Organisms Development - -- ✅ Complex UI sections -- ✅ Can use contexts (useAuth, useCart, useMenu) -- ✅ Business logic -- ✅ Always "use client" -- ✅ Filter, sort, complex interactions -- ❌ Not reusable across different page types - -### Templates Development - -- ✅ Page layout structure -- ✅ Composition of organisms + layout -- ✅ No data fetching/business logic -- ✅ Children prop pattern -- ✅ Props for customization -- ❌ No hardcoded data - -### Pages Development - -- ✅ Specific page implementations -- ✅ Route-specific logic -- ✅ Data integration -- ✅ Context usage at page level -- ✅ State management orchestration -- ❌ No UI component definitions (use organisms) - ---- - -## 9) Import Patterns - -### Atoms - -```tsx -import Button from "@/components/atoms/buttons/Button"; -import Text from "@/components/atoms/typography/Text"; -``` - -### Molecules - -```tsx -import ProductCard from "@/components/molecules/cards/ProductCard"; -import FormField from "@/components/molecules/form-groups/FormField"; -``` - -### Organisms - -```tsx -import LoginForm from "@/components/organisms/forms/LoginForm"; -import ProductGrid from "@/components/organisms/product-grid/ProductGrid"; -``` - -### Templates - -```tsx -import MainLayout from "@/components/templates/main-layout/MainLayout"; -``` - -### Barrel Exports - -```tsx -// Usage -import { Button, Text } from "@/components/atoms"; - -// components/atoms/index.ts -export { default as Button } from "./buttons/Button"; -export { default as Text } from "./typography/Text"; -export * from "./buttons/Button.types"; -``` - ---- - -## 10) Common Patterns - -### Creating a New Atom - -```tsx -// atoms/buttons/NewButton.tsx -export default function NewButton({ variant, ...props }: Props) { - return
-``` - ---- - -## 14) Version Control & Documentation - -### File Format - -``` -components/ -├── atoms/ -│ ├── buttons/ -│ │ ├── Button.tsx -│ │ ├── Button.types.ts -│ │ └── Button.md # Component documentation -│ └── ... -├── molecules/ -│ ├── cards/ -│ │ ├── ProductCard.tsx -│ │ ├── Card.types.ts -│ │ └── ProductCard.md -│ └── ... -└── ... -``` - -### Documentation Template - -```markdown -# ProductCard - -## Purpose - -Display individual product with image, name, price, and action button. - -## Props - -- `product: Product` - Product data -- `onAddToCart: (product: Product) => void` - Add to cart handler - -## Usage - -\`\`\`tsx \`\`\` - -## Variants - -- Image with loading state -- With discount badge -- With rating stars - -## Responsive - -- Mobile: Single column, full width -- Desktop: Grid layout -``` - ---- - -Cấu trúc này cung cấp: ✅ **Scalability**: Dễ thêm components mới ✅ -**Reusability**: Tối đa tái sử dụng ✅ **Maintainability**: Code dễ hiểu, tìm -kiếm ✅ **Testability**: Mỗi level có logic riêng ✅ **Performance**: Smart -code-splitting diff --git a/README.md b/README.md index c355a6e..209acc0 100644 --- a/README.md +++ b/README.md @@ -67,15 +67,13 @@ Dành cho khách hàng: Dành cho quản lý: -- Sidebar desktop: Brand, tab navigation (Thực đơn / Combo / Danh mục), link tới - Analytics +- Sidebar desktop: Brand, tab navigation (Thực đơn / Combo / Danh mục), link tới Analytics - CRUD sản phẩm, combo, danh mục qua modals - Auth guard: tự động redirect non-manager về `/` #### 9. **Trang Phân Tích Tài Chính** (`app/(manager)/manager/analytics`) -- Summary cards: Doanh thu, đơn hàng, lợi nhuận, giá trị đơn trung bình (so sánh - kỳ trước) +- Summary cards: Doanh thu, đơn hàng, lợi nhuận, giá trị đơn trung bình (so sánh kỳ trước) - Bộ chọn kỳ: Ngày / Tuần / Tháng / Năm - Biểu đồ SVG thuần: Line, Bar, Pie — hover tooltips tương tác - Bảng top 5 sản phẩm và bảng chi tiết có thể sắp xếp @@ -198,18 +196,18 @@ frondend/ ## Công Nghệ Sử Dụng -| Công nghệ | Phiên bản | Mục đích | -| ---------------- | --------- | ------------------------------------- | -| Next.js | 16.1.7 | React Framework (App Router) | -| React | 19.2.3 | Thư viện UI | -| TypeScript | ^5 | Kiểu dữ liệu tĩnh | -| Tailwind CSS | ^4.2.2 | Utility-first CSS framework | -| Geist Font | - | Font chữ (Google Fonts via next/font) | -| FontAwesome | 6.7.2 | Icon library (CDN) | -| pnpm | - | Package manager | -| ESLint | ^9 | Linting | -| Prettier | ^3 | Code formatting | -| semantic-release | ^25 | Automated versioning & release | +| Công nghệ | Phiên bản | Mục đích | +| ------------ | --------- | ------------------------------------- | +| Next.js | 16.1.7 | React Framework (App Router) | +| React | 19.2.3 | Thư viện UI | +| TypeScript | ^5 | Kiểu dữ liệu tĩnh | +| Tailwind CSS | ^4.2.2 | Utility-first CSS framework | +| Geist Font | - | Font chữ (Google Fonts via next/font) | +| FontAwesome | 6.7.2 | Icon library (CDN) | +| pnpm | - | Package manager | +| ESLint | ^9 | Linting | +| Prettier | ^3 | Code formatting | +| semantic-release | ^25 | Automated versioning & release | --- @@ -227,11 +225,11 @@ frondend/ ### Tài Khoản Demo -| Loại tài khoản | Tên đăng nhập | Mật khẩu | -| -------------- | ------------- | ------------- | -| Manager | admin | admin | -| Staff | Nguyễn Văn An | Nguyễn Văn An | -| Customer | 0987654321 | user1 | +| Loại tài khoản | Tên đăng nhập | Mật khẩu | +| -------------- | -------------- | -------------- | +| Manager | admin | admin | +| Staff | Nguyễn Văn An | Nguyễn Văn An | +| Customer | 0987654321 | user1 | ### Design & Styling @@ -245,18 +243,14 @@ frondend/ Dự án tuân theo **Atomic Design** pattern — chi tiết tại `Atomic.md`: - **Atoms** - Nguyên tố cơ bản: Button, Input, Badge, Text, Heading, Divider -- **Molecules** - Nhóm atoms: ProductCard, ShopCard, SearchBar, - PaymentSummaryCard -- **Organisms** - Phần UI phức tạp: CategorySidebar, CartFab, ProductGrid, - ShopGrid, ReviewModal, analytics charts, manager tabs/modals -- **Templates** - Bố cục trang: MainLayout, AuthLayout, FeedLayout, - ManagerLayout +- **Molecules** - Nhóm atoms: ProductCard, ShopCard, SearchBar, PaymentSummaryCard +- **Organisms** - Phần UI phức tạp: CategorySidebar, CartFab, ProductGrid, ShopGrid, ReviewModal, analytics charts, manager tabs/modals +- **Templates** - Bố cục trang: MainLayout, AuthLayout, FeedLayout, ManagerLayout ### Data & Integration - Mock data nằm trong `lib/constants.ts` -- Context providers trong `app/providers.tsx`: AuthProvider, MenuProvider, - CartProvider +- Context providers trong `app/providers.tsx`: AuthProvider, MenuProvider, CartProvider - ManagerProvider được thêm bởi `app/(manager)/layout.tsx` - Thay bằng API calls khi backend sẵn sàng - Ảnh sản phẩm: thêm vào `public/imgs/products/` diff --git a/app/(main)/login/page.tsx b/app/(main)/login/page.tsx index 9883080..b801294 100644 --- a/app/(main)/login/page.tsx +++ b/app/(main)/login/page.tsx @@ -1,7 +1,7 @@ "use client"; -import LoginForm from "@/components/organisms/forms/LoginForm"; import { SHOP_INFO } from "@/lib/constants"; +import LoginForm from "@/components/organisms/forms/LoginForm"; import Image from "next/image"; export default function LoginPage() { @@ -28,7 +28,7 @@ export default function LoginPage() { Đăng nhập vào hệ thống

- + {/* Login Form */} diff --git a/app/(main)/page.tsx b/app/(main)/page.tsx index 604f55c..b5f0978 100644 --- a/app/(main)/page.tsx +++ b/app/(main)/page.tsx @@ -1,10 +1,10 @@ "use client"; -import { SearchBar } from "@/components/molecules/search-bar"; import { CategorySidebar } from "@/components/organisms/navigation"; import { ProductGrid } from "@/components/organisms/product-grid"; -import { MENU_CATEGORIES } from "@/lib/constants"; +import { SearchBar } from "@/components/molecules/search-bar"; import { useMenu } from "@/lib/menu-context"; +import { MENU_CATEGORIES } from "@/lib/constants"; import { useEffect, useState } from "react"; /** @@ -56,15 +56,18 @@ export default function Home() {
{/* Title + count */}
-

+

{activeCategoryLabel} -

+
{/* Search bar */} { + if (q && activeCategory !== "all") setActiveCategory("all"); + setSearchQuery(q); + }} onClear={() => setSearchQuery("")} placeholder="Tìm kiếm món..." className="sm:max-w-xs" @@ -72,7 +75,10 @@ export default function Home() {
{/* ── Product grid (organism handles mobile category menu + grid) ── */} - + ); diff --git a/app/(main)/payment/page.tsx b/app/(main)/payment/page.tsx index b6d9b35..76ead1e 100644 --- a/app/(main)/payment/page.tsx +++ b/app/(main)/payment/page.tsx @@ -45,13 +45,13 @@ export default function PaymentPage() { - - - - - + + + @@ -75,7 +75,7 @@ export default function PaymentPage() {
diff --git a/components/COMPONENTS.md b/components/COMPONENTS.md index 93b80dd..4973951 100644 --- a/components/COMPONENTS.md +++ b/components/COMPONENTS.md @@ -1,7 +1,7 @@ # Components Documentation -> This project follows **Atomic Design** pattern. See `Atomic.md` at project -> root for full structure guide. +> This project follows **Atomic Design** pattern. +> See `Atomic.md` at project root for full structure guide. ## Directory Structure @@ -19,21 +19,17 @@ components/ ### ProductCard (`molecules/cards/ProductCard.tsx`) -**Description:** Product card molecule. Displays product image, name, -description, formatted price, and a Buy button. Width is controlled by the -parent grid (w-full). +**Description:** Product card molecule. Displays product image, name, description, formatted price, and a Buy button. Width is controlled by the parent grid (w-full). **Atomic level:** Molecule (composed of Button, Caption, Text atoms) ### ShopCard (`molecules/cards/ShopCard.tsx`) -**Description:** Shop discovery card. Displays shop image, name, address, and a -link to the menu. +**Description:** Shop discovery card. Displays shop image, name, address, and a link to the menu. ### SearchBar (`molecules/search-bar/SearchBar.tsx`) -**Description:** Search input with clear button. Controlled component — value -and onChange come from parent. +**Description:** Search input with clear button. Controlled component — value and onChange come from parent. --- @@ -41,41 +37,35 @@ and onChange come from parent. ### CategorySidebar (`organisms/navigation/CategorySidebar.tsx`) -**Description:** Left sidebar with collapsible category filter. Sticky below -header, full viewport height minus header. +**Description:** Left sidebar with collapsible category filter. Sticky below header, full viewport height minus header. ### CartFab (`organisms/cart/CartFab.tsx`) -**Description:** Floating Action Button displaying cart item count. Links to -/payment page. +**Description:** Floating Action Button displaying cart item count. Links to /payment page. ### ProductGrid (`organisms/product-grid/ProductGrid.tsx`) -**Description:** Full product grid organism with mobile category tabs, -filtering, and empty state. Uses useCart and useMenu contexts. +**Description:** Full product grid organism with mobile category tabs, filtering, and empty state. Uses useCart and useMenu contexts. ### ShopGrid (`organisms/shop-grid/ShopGrid.tsx`) -**Description:** Responsive grid of ShopCard molecules for the feed/discovery -page. +**Description:** Responsive grid of ShopCard molecules for the feed/discovery page. ### ReviewModal (`organisms/modals/ReviewModal.tsx`) -**Description:** Modal for customer reviews. Shows 5-star rating and textarea. -After submission, displays thank-you message. +**Description:** Modal for customer reviews. Shows 5-star rating and textarea. After submission, displays thank-you message. ### Analytics Charts (`organisms/analytics/`) -**Description:** Pure-SVG chart and table components for the Financial Analytics -dashboard. All components are interactive with hover tooltips. +**Description:** Pure-SVG chart and table components for the Financial Analytics dashboard. All components are interactive with hover tooltips. -| Component | File | Description | -| ------------ | ---------------- | ---------------------------------------------------------- | -| LineChart | LineChart.tsx | Revenue trend line chart with area fill and hover tooltips | -| BarChart | BarChart.tsx | Grouped bar chart comparing current vs previous period | -| PieChart | PieChart.tsx | Pie chart with interactive legend for category breakdown | -| SummaryCard | SummaryCard.tsx | Metric card with period-over-period comparison indicator | -| ProductTable | ProductTable.tsx | Sortable product sales table with profit margin badges | +| Component | File | Description | +|-----------|------|-------------| +| LineChart | LineChart.tsx | Revenue trend line chart with area fill and hover tooltips | +| BarChart | BarChart.tsx | Grouped bar chart comparing current vs previous period | +| PieChart | PieChart.tsx | Pie chart with interactive legend for category breakdown | +| SummaryCard | SummaryCard.tsx | Metric card with period-over-period comparison indicator | +| ProductTable | ProductTable.tsx | Sortable product sales table with profit margin badges | **Usage:** Imported via `@/components/organisms/analytics` barrel index. @@ -85,13 +75,11 @@ dashboard. All components are interactive with hover tooltips. ### MainLayout (`templates/main-layout/MainLayout.tsx`) -**Description:** Main layout template — wraps content with Header, Footer, and -CartFab. Used by (main) route group. +**Description:** Main layout template — wraps content with Header, Footer, and CartFab. Used by (main) route group. ### AuthLayout (`templates/auth-layout/AuthLayout.tsx`) -**Description:** Auth layout template — centers content in screen. Used by -login/register pages. +**Description:** Auth layout template — centers content in screen. Used by login/register pages. ### FeedLayout (`templates/feed-layout/FeedLayout.tsx`) @@ -99,8 +87,7 @@ login/register pages. ### ManagerLayout (`templates/manager-layout/ManagerLayout.tsx`) -**Description:** Manager layout template — auth guard + ManagerProvider. Used by -the manager route group. +**Description:** Manager layout template — auth guard + ManagerProvider. Used by the manager route group. --- @@ -108,20 +95,16 @@ the manager route group. ### AuthContext (`lib/auth-context.tsx`) -Manages user authentication state including login, logout, and registration. -Uses localStorage for persistence. +Manages user authentication state including login, logout, and registration. Uses localStorage for persistence. ### CartContext (`lib/cart-context.tsx`) -Manages shopping cart state with localStorage persistence. Tracks items, -quantities, and totals. +Manages shopping cart state with localStorage persistence. Tracks items, quantities, and totals. ### MenuContext (`lib/menu-context.tsx`) -Provides shared activeCategory state across components. Synchronizes Header -mobile menu and CategorySidebar selection. +Provides shared activeCategory state across components. Synchronizes Header mobile menu and CategorySidebar selection. ### ManagerContext (`lib/manager-context.tsx`) -Manages menu CRUD state (products, combos, categories) for the manager -dashboard. +Manages menu CRUD state (products, combos, categories) for the manager dashboard. diff --git a/components/atoms/ATOMS.md b/components/atoms/ATOMS.md index e11486f..5ab88d3 100644 --- a/components/atoms/ATOMS.md +++ b/components/atoms/ATOMS.md @@ -42,7 +42,6 @@ Main interactive button component with multiple variants and sizes. - All standard HTML button attributes **Usage:** - ```tsx import { Button } from "@/components/atoms"; @@ -60,7 +59,6 @@ import { Button } from "@/components/atoms"; ``` **Styling:** - - Primary: Branded color with dark hover - Secondary: Border style with light background on hover - Danger: Red for destructive actions @@ -80,7 +78,6 @@ Button designed specifically for icon-only interactions. - All standard HTML button attributes **Usage:** - ```tsx import { IconButton } from "@/components/atoms"; @@ -105,7 +102,6 @@ General text input field with optional label, error, and icon. - All standard HTML input attributes **Usage:** - ```tsx import { TextInput } from "@/components/atoms"; @@ -139,7 +135,6 @@ Search input with built-in search icon and clear button. - All standard HTML input attributes **Usage:** - ```tsx import { SearchInput } from "@/components/atoms"; @@ -166,7 +161,6 @@ Multi-line text input with optional label and error. - All standard HTML textarea attributes **Usage:** - ```tsx import { Textarea } from "@/components/atoms"; @@ -194,7 +188,6 @@ Semantic heading component with level-based sizing. - All standard HTML heading attributes **Sizing:** - - Level 1: text-3xl font-bold - Level 2: text-2xl font-bold - Level 3: text-xl font-bold @@ -203,7 +196,6 @@ Semantic heading component with level-based sizing. - Level 6: text-sm font-semibold **Usage:** - ```tsx import { Heading } from "@/components/atoms"; @@ -225,14 +217,12 @@ Paragraph text with semantic variants. - All standard HTML paragraph attributes **Variants:** - - body1: text-base (main content) - body2: text-sm (secondary content) - caption: text-xs (smallest text) - label: text-sm font-medium (form labels) **Usage:** - ```tsx import { Text } from "@/components/atoms"; @@ -254,7 +244,6 @@ Small caption/note text component. - All standard HTML span attributes **Usage:** - ```tsx import { Caption } from "@/components/atoms"; @@ -279,7 +268,6 @@ Labeled badge component for highlighting information. - All standard HTML span attributes **Variants:** - - primary: Branded color - secondary: Light gray - success: Green @@ -287,7 +275,6 @@ Labeled badge component for highlighting information. - warning: Yellow **Usage:** - ```tsx import { Badge } from "@/components/atoms"; @@ -309,7 +296,6 @@ Specialized badge for displaying formatted prices. - All standard HTML span attributes **Usage:** - ```tsx import { PriceBadge } from "@/components/atoms"; @@ -318,7 +304,6 @@ import { PriceBadge } from "@/components/atoms"; ``` **Output:** - - VND: "50.000 ₫" - USD: "$99.99" @@ -336,7 +321,6 @@ Visual separator element. - All standard HTML hr attributes **Usage:** - ```tsx import { Divider } from "@/components/atoms"; @@ -430,7 +414,6 @@ import type { ``` ### Product Card - ```tsx
Product Name @@ -443,7 +426,6 @@ import type { ``` ### Rating Display - ```tsx
Reviews @@ -457,7 +439,6 @@ import type { ## 🧪 Testing Atoms ### Props Validation - ```tsx // ✅ Valid diff --git a/components/atoms/buttons/Button.tsx b/components/atoms/buttons/Button.tsx index 8b42d2d..0a44d0a 100644 --- a/components/atoms/buttons/Button.tsx +++ b/components/atoms/buttons/Button.tsx @@ -8,6 +8,7 @@ export default function Button({ size = "md", icon, iconPosition = "left", + className = "", disabled = false, children, ...props @@ -43,7 +44,7 @@ export default function Button({ return ( diff --git a/components/molecules/cards/PaymentSummaryCard.tsx b/components/molecules/cards/PaymentSummaryCard.tsx index adc8505..fb561ef 100644 --- a/components/molecules/cards/PaymentSummaryCard.tsx +++ b/components/molecules/cards/PaymentSummaryCard.tsx @@ -13,13 +13,14 @@ export default function PaymentSummaryCard({ isCustomer = false, backHref, }: PaymentSummaryCardProps) { - const [isReviewOpen, setIsReviewOpen] = useState(false); - const handlePayment = () => { + + const [isReviewOpen, setIsReviewOpen] = useState(false); + const handlePayment = () => { // UI-only: open review modal after "payment" if (isCustomer) { - setIsReviewOpen(true); - } - }; + setIsReviewOpen(true); + } +}; return (
); diff --git a/components/organisms/analytics/PieChart.tsx b/components/organisms/analytics/PieChart.tsx index e096084..726a7b3 100644 --- a/components/organisms/analytics/PieChart.tsx +++ b/components/organisms/analytics/PieChart.tsx @@ -1,6 +1,6 @@ "use client"; -import { useMemo, useState } from "react"; +import { useState, useMemo } from "react"; export interface PieSlice { label: string; diff --git a/components/organisms/forms/LoginForm.tsx b/components/organisms/forms/LoginForm.tsx index 28606a8..b9eaddc 100644 --- a/components/organisms/forms/LoginForm.tsx +++ b/components/organisms/forms/LoginForm.tsx @@ -1,10 +1,10 @@ -import Button from "@/components/atoms/buttons/Button"; import ErrorMessageLogin from "@/components/atoms/errors/ErrorMessageLogin"; import LoginInput from "@/components/atoms/inputs/LoginInput"; import { useAuth } from "@/lib/auth-context"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { FormEvent, useState } from "react"; +import Button from "@/components/atoms/buttons/Button"; export default function LoginForm() { const router = useRouter(); diff --git a/components/organisms/manager/ProductsTab.tsx b/components/organisms/manager/ProductsTab.tsx index 12f7fbf..9d5c27c 100644 --- a/components/organisms/manager/ProductsTab.tsx +++ b/components/organisms/manager/ProductsTab.tsx @@ -152,10 +152,7 @@ export default function ProductsTab() { ) : ( filtered.map((p) => ( -
+
+ Tên sản phẩm Giá tiềnMô tảSố lượng + Giá tiềnMô tảSố lượng Xóa

{p.name}

diff --git a/components/organisms/navigation/CategorySidebar.tsx b/components/organisms/navigation/CategorySidebar.tsx index ab97b35..9bbc27e 100644 --- a/components/organisms/navigation/CategorySidebar.tsx +++ b/components/organisms/navigation/CategorySidebar.tsx @@ -47,6 +47,7 @@ export default function CategorySidebar({