CategoryCard component displays a vocabulary category with its metadata, progress, and interactive animations. Used on the home screen to navigate to different study categories.
Features
- Animated Entry: Staggered fade-in animation based on card index
- Interactive Hover: Scale and lift effects on hover
- Progress Tracking: Visual progress bar with percentage
- Due Count Badge: Shows number of cards due for review
- Accessibility: Full keyboard navigation and ARIA labels
- Responsive Design: Adapts between grid and list view modes
Props
Zero-based index of the card in the list. Used for staggered animation delays and numbering (displayed as “01”, “02”, etc.)
Display name of the category (e.g., “React Hooks”, “TypeScript Basics”)
Descriptive subtitle for the category (e.g., “Master state management”, “Core language features”)
Material Icons icon name (e.g., “memory”, “code”, “functions”)
Abbreviated category name displayed as background watermark (e.g., “RH”, “TS”)
Tailwind CSS gradient class for the card backgroundExample:
"bg-gradient-to-br from-blue-400 to-indigo-500"Progress percentage (0-100) indicating how many terms have been mastered
Layout mode:
true: Grid view with rounded corners and fixed heightfalse: List view with bottom border only
Number of cards due for spaced repetition review. When > 0, displays a pulsing badge.
Callback function triggered when card is clicked or activated via keyboard
Usage Example
Visual Structure
Top Section
- Number Badge: Formatted index (e.g., “01”, “02”)
- Title: Large, bold category name
- Subtitle: Descriptive text with subtle styling
- Icon: Material Icons symbol in category color
- Due Badge: Pulsing amber badge when cards are due
Bottom Section
- Progress Label: “PROGRESS” in uppercase tracking
- Progress Bar: Animated fill based on completion percentage
- Progress Text: Shows percentage or “Start →” if 0%
Background Elements
- Watermark: Large, semi-transparent abbreviation
- Color Gradient: Full card background in category color
Animations
Entry Animation
Hover Effects
Tap Feedback
Progress Bar Animation
Layout Modes
Grid View (isGridView={true})
- Rounded corners on all sides
- Fixed height (32-36 based on screen size)
- 2px border
- Suitable for 2-column or 3-column grids
List View (isGridView={false})
- Border on bottom only
- Minimum height with flexible expansion
- Full-width layout
- Stacks vertically
Due Count Badge
WhendueCount > 0, displays a pulsing badge:
- Amber background color
- Pulse animation to draw attention
- Shows exact count
- Tooltip with full text
Accessibility Features
Keyboard Navigation
- Accessible as a button via keyboard
- Enter and Space keys trigger action
- Tab navigation support
ARIA Labels
Progress Bar Attributes
Styling Notes
Text Shadow
Subtitle uses a subtle text shadow for better readability over gradient backgrounds:Watermark Opacity
Background abbreviation uses extremely low opacity to avoid distraction:Focus Styles
Progress Display Logic
- Shows percentage when progress exists
- Shows “Start →” call-to-action for new categories
Source Code Reference
See the full implementation in/workspace/source/src/components/CategoryCard.tsx