Component Library - xopherdeep/do-it-for-the-xp GitHub Wiki

Component Library

Reference guide for the XP App's reusable Vue components, organized following Atomic Design principles.


Overview

Components are organized into three tiers following Atomic Design:

  1. Atoms - Basic UI primitives that cannot be broken down further
  2. Molecules - Combinations of atoms into functional units
  3. Organisms - Complex, feature-rich components

Location: src/components/


Atoms

Basic building blocks that form the foundation of the UI.

AnimatedNumber

Path: components/atoms/AnimatedNumber/

Displays numbers with smooth counting animations. Used for stat displays, counters, and score updates.

<AnimatedNumber :value="currentHP" :duration="500" />

Currency

Path: components/atoms/Currency/

Displays currency values (GP, XP, AP) with appropriate icons and formatting.

<CurrencyDisplay type="gp" :amount="100" />
<CurrencyDisplay type="xp" :amount="500" />

Icon

Path: components/atoms/Icon/

Wrapper component for FontAwesome and custom icons with consistent styling.

<XpIcon icon="fa-dungeon" size="lg" />
<XpIcon :icon="['fas', 'wind']" class="text-blue-500" />

TypingText

Path: components/atoms/TypingText/

Typewriter-style text animation for dialog and story sequences.

<TypingText 
  :text="message" 
  :speed="50" 
  @complete="onTextComplete" 
/>

Molecules

Combinations of atoms into functional units.

Ability

Path: components/molecules/Ability/

Displays ability cards with AP cost, MP cost, status, and cooldown information.

Prop Type Description
ability Object Ability data
showCost Boolean Display AP/MP cost
disabled Boolean Interaction disabled

AvatarSelect

Path: components/molecules/AvatarSelect/

Character avatar picker with multiple options. Supports selection callbacks and preview modes.

<AvatarSelect 
  :avatars="availableAvatars"
  v-model="selectedAvatar"
/>

BackgroundSelector

Path: components/molecules/BackgroundSelector/

UI for selecting background themes and parallax layers.

CardMenu

Path: components/molecules/CardMenu/

Card-based menu system for RPG-style action selection.

<XpCardMenu 
  :items="menuItems"
  @select="handleSelection"
/>

Dialog

Path: components/molecules/Dialog/

Modal dialog component with customizable content and actions.

<XpDialog :open="showDialog" @close="showDialog = false">
  <template #content>
    Dialog content here
  </template>
</XpDialog>

Loading

Path: components/molecules/Loading/

Loading indicators and skeleton states.

Component Use Case
LoadingSpinner Inline loading
LoadingOverlay Full-screen loading
LoadingSkeleton Content placeholder

Modals

Path: components/molecules/Modals/

Pre-built modal templates for common actions.

RpgMenu

Path: components/molecules/RpgMenu/

RPG-styled menu with hover effects and selection states. Used throughout the app for consistent game-like interactions.

<XpRpgMenu :items="menuOptions" @select="onSelect" />

StatBox

Path: components/molecules/StatBox/

Displays stat information with labels, values, and optional progress bars. Recently enhanced with premium glassmorphic styling and automated number counting.

Features

  • Stat Counting: Automatically animates numbers from 0 to the target value on load using vue3-autocounter.
  • Premium Aesthetics: Features a glassmorphic design with backdrop-filter, semi-transparent borders, and deep shadows.
  • Interactive States: Smooth hover transitions with lift effects and color shifts.

Usage

<XpStatBox 
  :value="1250"
  label="XP Today"
  iconName="fa-calendar-day"
  iconColor="primary"
/>
Prop Type Description
value Number/String The numerical value to display (animated)
label String Description text below the value
iconName String FontAwesome icon class (e.g., fa-heart)
iconColor String Theme color for the icon (primary, success, etc.)
onClick Function Optional click handler (makes box clickable)

Organisms

Complex components that provide full features.

AudioSettings

Path: components/organisms/AudioSettings/

Complete audio configuration panel with volume sliders, mute toggles, and sound theme selection.

BattleControls

Path: components/organisms/BattleControls/

Full battle action interface including:

  • Attack/Defend/Run buttons
  • Ability selection
  • Item usage

CardUserStats

Path: components/organisms/CardUserStats/

User statistics card displaying:

  • Avatar
  • Name and level
  • HP/MP bars
  • XP progress
  • GP balance
<CardUserStats :user="currentUser" />

IntroSplash

Path: components/organisms/IntroSplash/

Introduction and splash screens for app launch and story sequences.

SwiperGallery

Path: components/organisms/SwiperGallery/

Image carousel component using Swiper.js for gallery displays.

WeatherFX

Path: components/organisms/WeatherFX/

Weather effect overlays including:

  • Rain
  • Snow
  • Lightning
  • Fog
  • Particles
<WeatherFX type="rain" :intensity="0.5" />
<WeatherFX type="snow" :intensity="0.3" />

Usage Patterns

Import Convention

// Atoms
import { XpIcon } from '@/components/atoms/Icon';
import { AnimatedNumber } from '@/components/atoms/AnimatedNumber';

// Molecules
import { XpRpgMenu } from '@/components/molecules/RpgMenu';
import { XpDialog } from '@/components/molecules/Dialog';

// Organisms
import { CardUserStats } from '@/components/organisms/CardUserStats';
import { WeatherFX } from '@/components/organisms/WeatherFX';

Creating New Components

Follow the atomic hierarchy:

  1. Is it a single-purpose element? → Atom
  2. Does it combine 2-3 atoms? → Molecule
  3. Is it a full feature? → Organism

File Structure

Each component directory should contain:

ComponentName/
├── ComponentName.vue    # Main component
├── ComponentName.ts     # Logic (if complex)
├── _ComponentName.scss  # Styles
└── index.ts             # Export barrel

Icon System

The app uses FontAwesome icons with custom coloring via SCSS classes:

// src/styles/icons/_icon-colors.scss
.icon-red { color: var(--ion-color-danger); }
.icon-blue { color: var(--ion-color-primary); }
.icon-gold { color: #ffd700; }

Icon Categories by Context

Context Icons
Navigation fa-dungeon, fa-door-open, fa-stairs
Combat fa-skull, fa-dragon, fa-crown
Items fa-treasure-chest, fa-key, fa-gem
Status fa-heart, fa-bolt, fa-shield
Elements fa-wind, fa-water, fa-fire, fa-mountain

Related Documentation

⚠️ **GitHub.com Fallback** ⚠️