Skip to content

ahmadrafidev/lumen

Repository files navigation

Lumen

Lumen Overview

A modern, intuitive color accessibility checker built with Next.js

MIT License Next.js TypeScript Tailwind CSS

🌟 Overview

Lumen is a comprehensive web application designed to help designers and developers ensure their color choices meet accessibility standards. Built with modern web technologies, it provides real-time contrast ratio calculations based on WCAG (Web Content Accessibility Guidelines) standards, making web accessibility testing simple and intuitive.

🎯 Why Lumen?

  • Instant Feedback: Real-time contrast ratio calculations as you adjust colors
  • WCAG Compliant: Comprehensive testing for AA and AAA accessibility standards
  • Modern UI: Beautiful, responsive interface with dark/light mode support
  • Developer Friendly: Clean, accessible design with smooth animations
  • Multiple Input Methods: Hex codes, visual color picker, and direct input support

✨ Features

🎨 Color Input & Selection

  • Hex Code Input: Direct hex value entry with validation
  • Interactive Color Picker: Visual color selection using react-colorful
  • Real-time Updates: Instant preview as you modify colors
  • Color Validation: Automatic fallback for invalid color values

πŸ“Š WCAG Compliance Testing

  • Normal Text Standards: AA (4.5:1) and AAA (7:1) compliance checking
  • Large Text Standards: AA (3:1) and AAA (4.5:1) compliance checking
  • UI Components: AA (3:1) compliance for interface elements
  • Visual Indicators: Clear pass/fail status with intuitive icons

πŸ‘οΈ Live Preview

  • Real-time Rendering: See exactly how your colors will look together
  • Sample Content: Test with headings, paragraphs, and buttons
  • Interactive Elements: Preview buttons and UI components
  • Color Information: Display current hex values for reference

🎯 Accessibility Features

  • Keyboard Navigation: Full keyboard accessibility support
  • Screen Reader Friendly: Proper ARIA labels and semantic HTML
  • Color Contrast: The app itself meets WCAG AA standards
  • Responsive Design: Mobile-first approach with optimized layouts

πŸŒ™ Theme Support

  • Dark/Light Mode: Automatic theme detection with manual toggle
  • Smooth Transitions: Elegant theme switching animations

πŸš€ Getting Started

Prerequisites

  • Node.js 18.0 or later
  • pnpm (recommended) or npm/yarn

Installation

  1. Clone the repository

    git clone https://github.com/ahmadrafidev/lumen.git
    cd lumen
  2. Install dependencies

    pnpm install
  3. Start the development server

    pnpm dev
  4. Open your browser Navigate to http://localhost:3000

Build for Production

# Build the application
pnpm build

# Start the production server
pnpm start

πŸ› οΈ Tech Stack

Core Framework

UI & Styling

Color & Accessibility

  • react-colorful - Lightweight color picker
  • Custom WCAG utilities - Precise contrast ratio calculations
  • Relative luminance calculations - Following WCAG 2.1 standards

Development Tools

  • ESLint - Code linting and formatting
  • PostCSS - CSS processing
  • pnpm - Fast, disk space efficient package manager

πŸ“ Project Structure

lumen/
β”œβ”€β”€ app/                    # Next.js App Router
β”‚   β”œβ”€β”€ page.tsx           # Main application page
β”‚   β”œβ”€β”€ layout.tsx         # Root layout with providers
β”‚   β”œβ”€β”€ globals.css        # Global styles and CSS variables
β”‚   └── not-found.tsx      # 404 error page
β”œβ”€β”€ components/            # React components
β”‚   β”œβ”€β”€ ui/               # Reusable UI primitives
β”‚   β”œβ”€β”€ ForegroundCard/   # Foreground color input
β”‚   β”œβ”€β”€ BackgroundCard/   # Background color input
β”‚   β”œβ”€β”€ ContrastRatioCard/ # Contrast ratio display
β”‚   β”œβ”€β”€ LivePreviewCard/  # Real-time preview
β”‚   β”œβ”€β”€ PassCheckCard/    # WCAG compliance checker
β”‚   β”œβ”€β”€ Header/           # Application header
β”‚   β”œβ”€β”€ Footer/           # Application footer
β”‚   └── Home/             # Main homepage component
β”œβ”€β”€ utils/                # Utility functions
β”‚   └── colorUtils.ts     # Color calculation utilities
β”œβ”€β”€ lib/                  # Shared libraries
β”œβ”€β”€ public/               # Static assets
└── ...config files

πŸ”¬ How It Works

Contrast Ratio Calculation

Lumen uses the official WCAG 2.1 formula for calculating contrast ratios:

  1. Relative Luminance: Calculate the relative luminance of each color
  2. Contrast Ratio: Apply the formula (L1 + 0.05) / (L2 + 0.05)
  3. WCAG Compliance: Compare against WCAG AA/AAA thresholds
export const calculateContrastRatio = (foreground: string, background: string): number => {
  const lum1 = calculateLuminance(foreground);
  const lum2 = calculateLuminance(background);
  
  return lum1 > lum2
    ? (lum1 + 0.05) / (lum2 + 0.05)
    : (lum2 + 0.05) / (lum1 + 0.05);
};

WCAG Standards Implementation

  • AA Normal Text: 4.5:1 minimum contrast ratio
  • AA Large Text: 3:1 minimum contrast ratio
  • AAA Normal Text: 7:1 minimum contrast ratio
  • AAA Large Text: 4.5:1 minimum contrast ratio
  • UI Components: 3:1 minimum contrast ratio

🀝 Contributing

We welcome contributions! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

Development Guidelines

  • Follow TypeScript best practices
  • Use conventional commit messages
  • Ensure accessibility standards are met
  • Add tests for new features
  • Update documentation as needed

πŸ“š Resources & References

WCAG Guidelines

Color Theory & Accessibility

Technical Documentation

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘¨β€πŸ’» Author

Ahmad Rafi Wirana (@rafiwiranaa)


Made with ❀️ for a more accessible web

About

Lumen: Fast, accessible color checks for designers and developers

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published