railyard/apps/ritgram/web/COMPONENT_GUIDE.md
caelum0x f80b04ae0f feat(ritgram): move GitGram app into railyard as Ritgram, next to Rithub
Moved later/gitgram-ai/gitgram/ to apps/ritgram/ (fresh history; full history stays in caelum0x/gitgram).
AITimeMachine stays separate in later/gitgram-ai per the Rithub master plan.
Logs, pid files and env files are ignored; GPL-3.0 mobile/proximity noted in THIRD_PARTY_NOTICES.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-13 04:18:46 +03:00

389 lines
6.6 KiB
Markdown

# ๐ŸŽจ Component Usage Guide
## ๐Ÿ“ฆ Available Components
### 1. Input Component
**Location**: `components/ui/input.tsx`
#### Basic Usage
```tsx
import { Input } from '@/components/ui/input'
<Input
label="Email"
type="email"
placeholder="you@example.com"
/>
```
#### With Icon
```tsx
<Input
label="Email"
type="email"
icon={
<svg className="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" />
</svg>
}
/>
```
#### With Error
```tsx
<Input
label="Email"
type="email"
error="Invalid email address"
/>
```
#### Features
- โœ… Floating label animation
- โœ… Icon support (left side)
- โœ… Error state with message
- โœ… Focus ring animation
- โœ… Accessible (ARIA labels)
---
### 2. Button Component
**Location**: `components/ui/button.tsx`
#### Variants
**Primary (Green Gradient)**
```tsx
<Button variant="primary">
Sign in
</Button>
```
**Secondary (Outlined)**
```tsx
<Button variant="secondary">
Cancel
</Button>
```
**Ghost (Transparent)**
```tsx
<Button variant="ghost">
Learn more
</Button>
```
**GitHub (Black)**
```tsx
<Button variant="github">
Continue with GitHub
</Button>
```
#### Sizes
```tsx
<Button size="sm">Small</Button>
<Button size="md">Medium</Button>
<Button size="lg">Large</Button>
```
#### With Loading
```tsx
<Button loading={isLoading}>
{isLoading ? 'Signing in...' : 'Sign in'}
</Button>
```
#### With Icon
```tsx
<Button
icon={
<svg className="w-5 h-5" fill="currentColor" viewBox="0 0 24 24">
<path d="M12 0.5C5.37 0.5..." />
</svg>
}
>
GitHub
</Button>
```
#### Features
- โœ… 4 variants (primary, secondary, ghost, github)
- โœ… 3 sizes (sm, md, lg)
- โœ… Loading state with spinner
- โœ… Icon support
- โœ… Hover/tap animations
- โœ… Disabled state
---
### 3. Password Strength Meter
**Location**: `components/ui/password-strength.tsx`
#### Usage
```tsx
import { PasswordStrength } from '@/components/ui/password-strength'
const [password, setPassword] = useState('')
<Input
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
/>
<PasswordStrength password={password} />
```
#### Strength Levels
- **Weak** (Red): 0-2 points
- **Fair** (Yellow): 3 points
- **Good** (Blue): 4 points
- **Strong** (Green): 5 points
#### Scoring
- Length โ‰ฅ 8: +1
- Length โ‰ฅ 12: +1
- Mixed case: +1
- Numbers: +1
- Special chars: +1
#### Features
- โœ… Real-time calculation
- โœ… Animated progress bars
- โœ… Color-coded feedback
- โœ… Visual strength label
---
### 4. Animated Stats
**Location**: `app/(auth)/components/AnimatedStats.tsx`
#### Usage
```tsx
import { AnimatedStats } from './components/AnimatedStats'
<AnimatedStats />
```
#### Display
```
10K+ Developers
50K+ Projects
1M+ Stars
```
#### Features
- โœ… Counting animation (0 to target)
- โœ… Number formatting (K, M)
- โœ… Staggered entrance
- โœ… 2-second duration
---
### 5. Project Showcase
**Location**: `app/(auth)/components/ProjectShowcase.tsx`
#### Usage
```tsx
import { ProjectShowcase } from './components/ProjectShowcase'
<ProjectShowcase />
```
#### Projects
1. awesome-app (TypeScript, 1337โญ)
2. cool-project (JavaScript, 892โญ)
3. next-gen-ui (React, 2456โญ)
4. api-gateway (Go, 567โญ)
#### Features
- โœ… Auto-rotation (3s interval)
- โœ… Language color indicators
- โœ… Star counts
- โœ… Progress dots
- โœ… Smooth transitions
---
## ๐ŸŽจ Styling Patterns
### Glassmorphism Card
```tsx
<div className="bg-surface/50 backdrop-blur-xl border border-border/50 rounded-2xl p-8 shadow-2xl">
{/* Content */}
</div>
```
### Gradient Button
```tsx
<button className="bg-gradient-to-r from-accent to-accent-hover text-white rounded-xl px-6 py-3 font-semibold hover:shadow-lg hover:shadow-accent/20">
Click me
</button>
```
### Gradient Text
```tsx
<h1 className="bg-gradient-to-r from-primary via-accent to-primary bg-clip-text text-transparent">
Gradient Text
</h1>
```
### Focus Ring
```tsx
<input className="focus:outline-none focus:border-primary focus:ring-2 focus:ring-primary/20" />
```
---
## ๐ŸŽญ Animation Patterns
### Page Entrance
```tsx
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.5 }}
>
{/* Content */}
</motion.div>
```
### Button Hover
```tsx
<motion.button
whileHover={{ scale: 1.02 }}
whileTap={{ scale: 0.98 }}
>
Click me
</motion.button>
```
### Floating Animation
```tsx
<motion.div
animate={{ y: [0, -10, 0] }}
transition={{ duration: 3, repeat: Infinity }}
>
{/* Content */}
</motion.div>
```
### Staggered List
```tsx
{items.map((item, i) => (
<motion.div
key={i}
initial={{ opacity: 0, x: -20 }}
animate={{ opacity: 1, x: 0 }}
transition={{ delay: i * 0.1 }}
>
{item}
</motion.div>
))}
```
---
## ๐ŸŽฏ Common Patterns
### Form Field
```tsx
<div className="space-y-2">
<label className="text-sm font-medium text-foreground">
Email
</label>
<Input type="email" />
</div>
```
### Error Message
```tsx
<motion.div
initial={{ opacity: 0, x: -10 }}
animate={{ opacity: 1, x: 0 }}
className="bg-error/10 border border-error/30 text-error px-4 py-3 rounded-xl text-sm"
>
Error message
</motion.div>
```
### Loading Spinner
```tsx
<svg className="animate-spin h-5 w-5" fill="none" viewBox="0 0 24 24">
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" />
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" />
</svg>
```
---
## ๐Ÿ“ฑ Responsive Utilities
### Hide on Mobile
```tsx
<div className="hidden lg:flex">
Desktop only
</div>
```
### Show on Mobile
```tsx
<div className="lg:hidden">
Mobile only
</div>
```
### Responsive Grid
```tsx
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
{/* Items */}
</div>
```
---
## ๐ŸŽจ Color Utilities
```tsx
// Backgrounds
bg-background // #0A0C10
bg-surface // #161b22
bg-primary // #58a6ff
bg-accent // #238636
// Text
text-foreground // #c9d1d9
text-foreground-secondary // #8b949e
text-primary // #58a6ff
text-accent // #238636
// Borders
border-border // #30363d
border-primary // #58a6ff
```
---
## ๐Ÿ”ง Utility Functions
### cn() - Class Name Merger
```tsx
import { cn } from '@/lib/utils'
<div className={cn(
'base-classes',
condition && 'conditional-classes',
className
)} />
```
---
**Happy Coding! ๐Ÿš€**