Overview
Components in CV Staff Web are small, reusable UI elements built with Astro. They follow a component-based architecture that promotes reusability, maintainability, and consistency across the application.Component Directory
All components are located insrc/components/:
Component Patterns
1. Badget Component
A simple status indicator badge used in the hero section. File:src/components/Badget.astro
2. WelcomeCard Component
The main hero title card with animated text and individual letter animations. File:src/components/WelcomeCard.astro (lines 1-79)
- Splits name into individual letters for staggered animation
- Uses data attributes (
data-animate) for GSAP animation targeting - Includes emoji wave with rotation animation
- CSS custom properties for animation indices
3. MarqueeV1 Component
An infinite scrolling text banner with customizable colors. File:src/components/MarqueeV1.astro
src/pages/index.astro:30:
The marquee duplicates text 20 times to ensure seamless infinite scrolling across all screen sizes.
4. SectionCard Component
A flexible container card for section content. File:src/components/SectionCard.astro
- Uses Astro’s
<slot/>for content projection - Optional padding via props
- Consistent card styling across sections
5. ButtonCta Component
Call-to-action button with icon support. File:src/components/ButtonCta.astro
6. InfoTable Component
Displays information in a structured table format. File:src/components/InfoTable.astro
Component Design Principles
TypeScript Props Interface
All components define a TypeScriptProps interface for type safety:
Scoped Styles
Components use Astro’s scoped<style> blocks:
Astro automatically scopes component styles to prevent CSS conflicts. Global styles are defined in
src/layouts/Layout.astro and src/styles/.Slot-based Composition
Components use<slot/> for flexible content projection:
Animation Integration
Components usedata-* attributes to integrate with GSAP animations:
src/scripts/animations.js.
See Scripts Architecture for details on animation implementation.
Component Reusability
Best Practices
Keep components small and focused
Keep components small and focused
Each component should do one thing well. If a component becomes too complex, split it into smaller components.
Use TypeScript for props
Use TypeScript for props
Always define a
Props interface for type safety and better developer experience.Provide sensible defaults
Provide sensible defaults
Use destructuring with defaults:
const { color = 'red' } = Astro.props;Document component usage
Document component usage
Include comments describing props and usage examples, especially for complex components.
Component vs Section
Understand when to create a component vs a section:| Aspect | Component | Section |
|---|---|---|
| Purpose | Reusable UI element | Page-specific content area |
| Size | Small, focused | Large, comprehensive |
| Reusability | Used multiple times | Typically used once |
| Location | src/components/ | src/sections/ |
| Examples | Button, Card, Badge | Hero, Footer, Contact |
Next Steps
Sections Architecture
Learn about page sections and their structure
Scripts Architecture
Understand animation and client-side scripts
Component Examples
Explore example components in detail
Styling Guide
Learn about CSS architecture and theming