How react-component/color-picker works
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.