mirror of
https://github.com/bitbaum/orangecat.git
synced 2026-12-04 20:47:52 +01:00
6.4 KiB
6.4 KiB
Color System Developer Guide
Created: June 5, 2025 Last Modified: June 5, 2025 Last Modified Summary: Initial creation of centralized color system guide
Overview
OrangeCat uses a centralized theme system to eliminate hardcoded colors and ensure consistent branding. This guide explains how to use the system correctly.
🚫 What NOT to Do
// ❌ NEVER hardcode colors
<div className="bg-orange-100 text-orange-600">Bitcoin</div>
<div style={{ color: '#F7931A' }}>Bitcoin</div>
<div className="text-[#F7931A]">Bitcoin</div>
✅ What TO Do
// ✅ Use the centralized theme system
import { componentColors, getColorClasses } from '@/lib/theme';
import { BitcoinBadge, CurrencyDisplay } from '@/components/ui';
// For Bitcoin badges
<BitcoinBadge>Bitcoin</BitcoinBadge>
// For currency displays
<CurrencyDisplay amount={0.001} currency="BTC" />
// For custom Bitcoin elements
<div className={componentColors.bitcoinElement.className}>
Bitcoin Element
</div>
// For class generation
<div className={getColorClasses.bitcoin.badge}>
Bitcoin Badge
</div>
Core Components
1. BitcoinBadge
import { BitcoinBadge } from '@/components/ui/BitcoinBadge';
<BitcoinBadge variant="default">BTC</BitcoinBadge>
<BitcoinBadge variant="outline">Bitcoin</BitcoinBadge>
<BitcoinBadge variant="solid">₿</BitcoinBadge>
2. CurrencyDisplay
import { CurrencyDisplay } from '@/components/ui/CurrencyDisplay';
<CurrencyDisplay amount={0.001} currency="BTC" />
<CurrencyDisplay amount={1000} currency="SATS" />
<CurrencyDisplay amount={50000} currency="USD" />
Theme System Structure
Color Categories
colors.bitcoin.main- Official Bitcoin Orange (#F7931A)colors.primary.main- Tiffany Blue (#0ABAB5)colors.secondary.main- General orange (#FF6B35)colors.status.*- Success, error, warning, infocolors.neutral.*- Gray scale
Semantic Colors
semanticColors.bitcoin.*- Bitcoin-specific colorssemanticColors.currency.*- Currency-specific colorssemanticColors.status.*- Status indicators
Component Colors
componentColors.bitcoinElement- Pre-configured Bitcoin stylingcomponentColors.currencyDisplay()- Currency-specific stylingcomponentColors.statusBadge()- Dynamic status colors
Usage Examples
Bitcoin-Related Elements
// Any Bitcoin-related UI element
<div className={componentColors.bitcoinElement.className}>
Bitcoin content
</div>
// Bitcoin icon
<BitcoinIcon className={getColorClasses.bitcoin.icon} />
// Bitcoin button
<button className={getColorClasses.bitcoin.hover}>
Send Bitcoin
</button>
Dynamic Color Assignment
// Automatically apply Bitcoin colors based on content
const getBadgeColor = (type: string) => {
if (type.toLowerCase().includes('bitcoin') || type.toLowerCase().includes('btc')) {
return componentColors.bitcoinElement.className;
}
return 'bg-gray-100 text-gray-600';
};
<span className={getBadgeColor(itemType)}>
{itemType}
</span>
Currency Styling
// Currency amounts with appropriate colors
const CurrencyAmount = ({ amount, currency }) => (
<span className={componentColors.currencyDisplay(currency).className}>
{amount} {currency}
</span>
);
Best Practices
-
Always Import from Theme
import { componentColors, getColorClasses } from '@/lib/theme'; -
Use Semantic Names
// ✅ Good - semantic className={getColorClasses.bitcoin.badge} // ❌ Bad - hardcoded className="bg-orange-500 text-white" -
Prefer Components Over Classes
// ✅ Better - component handles everything <BitcoinBadge>BTC</BitcoinBadge> // ✅ Good - manual styling <span className={componentColors.bitcoinElement.className}>BTC</span> -
Use Helper Functions
// ✅ Dynamic color assignment const getColorForCurrency = (currency) => getCurrencyColor(currency);
Migration Guide
When you encounter hardcoded colors:
-
Identify the Element Type
- Is it Bitcoin-related? Use
BitcoinBadgeorcomponentColors.bitcoinElement - Is it a currency? Use
CurrencyDisplay - Is it a status? Use
componentColors.statusBadge()
- Is it Bitcoin-related? Use
-
Replace with Semantic Alternative
// Before <span className="bg-orange-100 text-orange-600">Bitcoin</span> // After <BitcoinBadge>Bitcoin</BitcoinBadge> -
Test the Change
- Verify colors look correct
- Check hover states work
- Ensure accessibility is maintained
Adding New Colors
If you need a new color:
-
Add to Theme System
// In src/lib/theme.ts export const colors = { // ... existing colors newCategory: { main: '#HEXCODE', light: '#HEXCODE', dark: '#HEXCODE', } } -
Create Semantic Mapping
export const semanticColors = { // ... existing mappings newCategory: { background: colors.newCategory.light, text: colors.newCategory.main, border: colors.newCategory.main, } } -
Add Helper Classes
export const getColorClasses = { // ... existing classes newCategory: { background: 'bg-newCategory', text: 'text-newCategory', border: 'border-newCategory', } }
Testing Colors
-
Visual Testing
- Check all Bitcoin elements use Bitcoin Orange
- Verify hover states work correctly
- Test in light/dark modes
-
Accessibility Testing
- Ensure sufficient color contrast
- Test with color blindness simulators
- Verify focus states are visible
Troubleshooting
"Color not working"
- Check if you imported the theme system
- Verify you're using the correct semantic name
- Ensure Tailwind includes the color in config
"Need custom styling"
- Use the theme system as base
- Extend with additional classes
- Don't override core Bitcoin colors
"Component doesn't match design"
- Check if using correct variant
- Verify theme system has the right colors
- Consider if design needs updating to match system
Summary
The centralized theme system ensures:
- ✅ Single source of truth for colors
- ✅ Easy global color changes
- ✅ Consistent Bitcoin branding
- ✅ No hardcoded color values
- ✅ Type-safe color usage
- ✅ Automatic semantic color application
Remember: If you're hardcoding colors, you're doing it wrong.