# react-component/color-picker architecture

> Architecture diagram of the GitHub repository react-component/color-picker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/react-component/color-picker
- Repository: https://github.com/react-component/color-picker

## Overview

##### Project type and purpose
- It ships as an NPM package, includes demos/docs (via dumi), run-time code (src/*), style assets (assets/index.less), a build pipeline (fatherrc, .dumirc.ts, vite.config.ts), and test suites.

##### File structure
- Top-level source:
- src/ColorPicker.tsx – main entry component
- src/components/… – subcomponents (Palette, Slider, Handler, Gradient, ColorBlock, Transform, Picker)
- src/hooks/… – custom React hooks (useColorState, useColorDrag, useComponent)
- src/index.tsx & index.js – exports for ESM/CJS
- src/interface.ts – TypeScript type definitions
- Configuration & tooling:
- .dumirc.ts – dumi docs config
- fatherrc.ts – bundler config (build to CJS/ESM)
- vite.config.ts – dev server for docs/demo
- .eslintrc.js, .prettierrc – linting/formatting
- .husky – git hooks
- Documentation & examples:
- docs/demo & docs/example – markdown and TSX examples for different use cases
- Tests:
- tests/… – Jest + React Testing Library snapshots and unit tests
- CI/CD & publishing:
- .github/workflows – CI for build, test, docs preview
- package.json – dependencies, scripts for build/test/demo, publish settings

##### README for additional insights
- Highlights dumi-served docs at localhost:8000, and NPM publishing.

## Diagram (Mermaid)

```mermaid
flowchart TD
    direction TB

    %% UI Layer
    subgraph "UI Layer"
        CP["ColorPicker Component"]:::ui
        Pal["Palette Subcomponent"]:::ui
        Sli["Slider Subcomponent"]:::ui
        Han["Handler Subcomponent"]:::ui
        Gra["Gradient Subcomponent"]:::ui
        CB["ColorBlock Subcomponent"]:::ui
        Trm["Transform Subcomponent"]:::ui
        Pic["Picker Subcomponent"]:::ui
    end

    %% Hooks & Utilities
    subgraph "State & Utility Layer"
        UCS["useColorState Hook"]:::hook
        UCD["useColorDrag Hook"]:::hook
        UCO["useComponent Hook"]:::hook
        COL["Color Utilities (color.ts)"]:::util
        UTL["Utility Helpers (util.ts)"]:::util
        INT["Type Definitions (interface.ts)"]:::util
    end

    %% Build & Documentation
    subgraph "Build & Documentation Pipeline"
        FATH["Bundler (fatherrc.ts)"]:::build
        DUMI["Dumi Config (.dumirc.ts)"]:::doc
        VITE["Vite Config (vite.config.ts)"]:::doc
        ASSET["Style Assets (assets/index.less)"]:::build
        ENTRY["Main Exports (src/index.tsx, index.js)"]:::build
        DOCS["Demo & Examples (docs/)"]:::doc
    end

    %% Testing & CI/CD
    subgraph "Testing & CI/CD"
        TEST["Test Suites (tests/)"]:::test
        CI["CI Workflows (.github/workflows)"]:::ci
    end

    %% External Systems
    NPM["npm Registry"]:::external
    CONS["Consumer App"]:::external
    USER["User Events (mouse/keyboard)"]:::external

    %% Data & Control Flows
    USER -->|"interacts with"| Pal
    USER -->|"interacts with"| Sli
    USER -->|"interacts with"| Han
    USER -->|"interacts with"| Gra
    USER -->|"interacts with"| CB
    USER -->|"interacts with"| Trm
    USER -->|"interacts with"| Pic

    Pal -->|captures drag| UCD
    Sli -->|captures drag| UCD
    Han -->|captures drag| UCD
    Gra -->|captures drag| UCD

    UCD -->|"updates color state"| UCS
    UCO -->|"provides component logic"| CP
    UCS -->|"provides state"| CP
    COL -->|"conversion methods"| CP
    UTL -->|"helper functions"| CP
    INT -->|"type definitions"| CP

    CP -->|composes| Pal
    CP -->|composes| Sli
    CP -->|composes| Han
    CP -->|composes| Gra
    CP -->|composes| CB
    CP -->|composes| Trm
    CP -->|composes| Pic

    %% Build pipeline
    CP -->|source files| FATH
    COL -->|source files| FATH
    UTL -->|source files| FATH
    ENTRY -->|generated by| FATH
    ASSET -->|packaged by| FATH
    FATH -->|outputs bundles| ENTRY
    ENTRY -->|published| NPM

    %% Documentation pipeline
    DUMI -->|"reads docs & src"| DOCS
    VITE -->|"serves demo site"| DOCS

    %% Testing & CI
    TEST -->|validated by| CI
    FATH -->|build step| CI
    DOCS -->|docs preview| CI
    CI -->|on success| NPM

    %% Consumer integration
    CONS -->|"installs package"| NPM
    CONS -->|"imports ColorPicker & CSS"| ENTRY

    %% Click Events
    click CP "https://github.com/react-component/color-picker/blob/master/src/ColorPicker.tsx"
    click Pal "https://github.com/react-component/color-picker/blob/master/src/components/Palette.tsx"
    click Sli "https://github.com/react-component/color-picker/blob/master/src/components/Slider.tsx"
    click Han "https://github.com/react-component/color-picker/blob/master/src/components/Handler.tsx"
    click Gra "https://github.com/react-component/color-picker/blob/master/src/components/Gradient.tsx"
    click CB "https://github.com/react-component/color-picker/blob/master/src/components/ColorBlock.tsx"
    click Trm "https://github.com/react-component/color-picker/blob/master/src/components/Transform.tsx"
    click Pic "https://github.com/react-component/color-picker/blob/master/src/components/Picker.tsx"
    click UCS "https://github.com/react-component/color-picker/blob/master/src/hooks/useColorState.ts"
    click UCD "https://github.com/react-component/color-picker/blob/master/src/hooks/useColorDrag.ts"
    click UCO "https://github.com/react-component/color-picker/blob/master/src/hooks/useComponent.ts"
    click COL "https://github.com/react-component/color-picker/blob/master/src/color.ts"
    click UTL "https://github.com/react-component/color-picker/blob/master/src/util.ts"
    click INT "https://github.com/react-component/color-picker/blob/master/src/interface.ts"
    click ENTRY "https://github.com/react-component/color-picker/blob/master/src/index.tsx"
    click ASSET "https://github.com/react-component/color-picker/blob/master/assets/index.less"
    click DUMI "https://github.com/react-component/color-picker/blob/master/.dumirc.ts"
    click FATH "https://github.com/react-component/color-picker/blob/master/.fatherrc.ts"
    click VITE "https://github.com/react-component/color-picker/blob/master/vite.config.ts"
    click DOCS "https://github.com/react-component/color-picker/tree/master/docs/demo"
    click TEST "https://github.com/react-component/color-picker/tree/master/tests/"
    click CI "https://github.com/react-component/color-picker/blob/master/.github/workflows/main.yml"
    click NPM "https://github.com/react-component/color-picker/blob/master/package.json"

    %% Styles
    classDef ui fill:#FFD59E,stroke:#E29301,color:#000;
    classDef hook fill:#D5E8D4,stroke:#82B366,color:#000;
    classDef util fill:#E1D5E7,stroke:#9673A6,color:#000;
    classDef build fill:#FFF2CC,stroke:#D6B656,color:#000;
    classDef doc fill:#DAE8FC,stroke:#6C8EBF,color:#000;
    classDef test fill:#F8CECC,stroke:#B85450,color:#000;
    classDef ci fill:#F5F5F5,stroke:#999999,color:#000;
    classDef external fill:#FFFFFF,stroke:#999999,color:#000;
```
