UNPKG

colorupjs

Version:

A modern, lightweight, and comprehensive color utility library for JavaScript/TypeScript with advanced palette generation and WCAG accessibility tools.

120 lines (108 loc) • 4.83 kB
# ColorX - Professional Color Utility Library ## šŸ“ Folder Structure ``` colorx/ ā”œā”€ā”€ src/ │ ā”œā”€ā”€ core/ │ │ ā”œā”€ā”€ types.ts # Core type definitions │ │ ā”œā”€ā”€ constants.ts # Color constants & mappings │ │ └── validators.ts # Input validation utilities │ ā”œā”€ā”€ converters/ │ │ ā”œā”€ā”€ index.ts # Export all converters │ │ ā”œā”€ā”€ hex.ts # Hex conversion utilities │ │ ā”œā”€ā”€ rgb.ts # RGB conversion utilities │ │ ā”œā”€ā”€ hsl.ts # HSL conversion utilities │ │ └── named.ts # Named color utilities │ ā”œā”€ā”€ analyzers/ │ │ ā”œā”€ā”€ index.ts # Export all analyzers │ │ ā”œā”€ā”€ brightness.ts # Brightness detection │ │ ā”œā”€ā”€ contrast.ts # Contrast ratio calculations │ │ └── accessibility.ts # WCAG compliance tools │ ā”œā”€ā”€ generators/ │ │ ā”œā”€ā”€ index.ts # Export all generators │ │ ā”œā”€ā”€ harmony.ts # Color harmony generators │ │ ā”œā”€ā”€ palette.ts # Palette generation │ │ ā”œā”€ā”€ gradient.ts # Gradient utilities │ │ └── variations.ts # Tints, shades, tones │ ā”œā”€ā”€ modifiers/ │ │ ā”œā”€ā”€ index.ts # Export all modifiers │ │ ā”œā”€ā”€ blend.ts # Color blending │ │ ā”œā”€ā”€ adjust.ts # Brightness/saturation adjustments │ │ └── transform.ts # Color transformations │ ā”œā”€ā”€ exporters/ │ │ ā”œā”€ā”€ index.ts # Export all exporters │ │ ā”œā”€ā”€ css.ts # CSS variable generation │ │ ā”œā”€ā”€ tokens.ts # Design tokens │ │ └── formats.ts # Multiple format exports │ ā”œā”€ā”€ utils/ │ │ ā”œā”€ā”€ index.ts # Export all utilities │ │ ā”œā”€ā”€ math.ts # Mathematical utilities │ │ ā”œā”€ā”€ normalize.ts # Color normalization │ │ └── helpers.ts # Helper functions │ └── index.ts # Main entry point ā”œā”€ā”€ tests/ │ ā”œā”€ā”€ __mocks__/ # Test mocks │ ā”œā”€ā”€ converters/ # Converter tests │ ā”œā”€ā”€ analyzers/ # Analyzer tests │ ā”œā”€ā”€ generators/ # Generator tests │ ā”œā”€ā”€ modifiers/ # Modifier tests │ ā”œā”€ā”€ exporters/ # Exporter tests │ ā”œā”€ā”€ utils/ # Utility tests │ └── integration/ # Integration tests ā”œā”€ā”€ docs/ # Documentation ā”œā”€ā”€ examples/ # Usage examples ā”œā”€ā”€ scripts/ # Build & utility scripts ā”œā”€ā”€ .github/ # GitHub workflows ā”œā”€ā”€ dist/ # Build output (auto-generated) ā”œā”€ā”€ coverage/ # Test coverage (auto-generated) ā”œā”€ā”€ node_modules/ # Dependencies (auto-generated) ā”œā”€ā”€ package.json ā”œā”€ā”€ tsconfig.json ā”œā”€ā”€ rollup.config.js ā”œā”€ā”€ jest.config.js ā”œā”€ā”€ .eslintrc.js ā”œā”€ā”€ .prettierrc ā”œā”€ā”€ .gitignore ā”œā”€ā”€ LICENSE └── README.md ``` ## šŸš€ Quick Setup 1. **Initialize Project:** ```bash mkdir colorx && cd colorx npm init -y ``` 2. **Install Dependencies:** ```bash # Copy the package.json content above, then: npm install ``` 3. **Create Folder Structure:** ```bash mkdir -p src/{core,converters,analyzers,generators,modifiers,exporters,utils} mkdir -p tests/{__mocks__,converters,analyzers,generators,modifiers,exporters,utils,integration} mkdir -p {docs,examples,scripts,.github/workflows} ``` 4. **Development Workflow:** ```bash npm run dev # Start development build npm run test:watch # Run tests in watch mode npm run lint:fix # Fix linting issues npm run validate # Run full validation ``` 5. **Publishing:** ```bash npm run build # Build for production npm run prepublishOnly # Full validation + build npm publish # Publish to NPM ``` ## šŸ—ļø Architecture Principles - **Modular Design:** Each feature is isolated and composable - **Type Safety:** Full TypeScript support with strict types - **Tree Shaking:** Optimized for modern bundlers - **Performance:** Efficient algorithms with minimal overhead - **Extensibility:** Plugin-ready architecture - **Standards Compliance:** WCAG 2.1 AA/AAA support - **Cross-Platform:** Works in browsers and Node.js ## šŸ“‹ Next Steps I'll now create the core implementation files starting with types, constants, and the main conversion utilities.