From 0aa185177a0c80c12c1bceab8367403bb39bc59f Mon Sep 17 00:00:00 2001 From: mohiit1502 Date: Sun, 4 Jan 2026 20:37:12 +0530 Subject: [PATCH] chore: fix hardcoded URL, add comprehensive docs - Fix hardcoded ML service URL in IconController.tsx (now uses API_CONFIG) - Add docs/SPECS.md, DESIGN.md, DEBT.md, READINESS.md - Update README.md with comprehensive documentation --- README.md | 130 ++++++++++++++++++++- docs/DEBT.md | 242 +++++++++++++++++++++++++++++++++++++++ docs/DESIGN.md | 219 ++++++++++++++++++++++++++++++++++++ docs/READINESS.md | 249 +++++++++++++++++++++++++++++++++++++++++ docs/SPECS.md | 223 ++++++++++++++++++++++++++++++++++++ package-lock.json | 102 ++++------------- package.json | 5 +- src/IconController.tsx | 2 +- src/IconsList.tsx | 13 +-- src/helper.ts | 2 + 10 files changed, 1094 insertions(+), 93 deletions(-) create mode 100644 docs/DEBT.md create mode 100644 docs/DESIGN.md create mode 100644 docs/READINESS.md create mode 100644 docs/SPECS.md diff --git a/README.md b/README.md index b24d5e3..47e5ed3 100644 --- a/README.md +++ b/README.md @@ -1 +1,129 @@ -# Armco Template for the tech stack: React, TS, Dart Sass, Redux Tookkit, react-redux, react browser routing, TS based plop generator \ No newline at end of file +# @armco/icon-spot + +> Icon Management UI for Armco Platform + +icon-spot is a React-based icon browser and editor that provides browsing, searching, styling, and downloading capabilities for the Armco icon library. + +## Features + +- **Icon Browser**: Paginated grid with search and tag filtering +- **View Modes**: Comfy, Compact, and List layouts +- **Style Editor**: Customize fill, stroke, background colors +- **SVG Download**: Export styled icons as SVG files +- **Favorites**: Mark icons for quick access +- **Selection Mode**: Multi-select for batch operations +- **Similar Icons**: ML-powered icon recommendations + +## Installation + +```bash +pnpm add @armco/icon-spot +``` + +## Peer Dependencies + +```json +{ + "@armco/components": "^0.0.60", + "@armco/configs": "^0.0.11", + "@armco/icon": "^0.0.10", + "@armco/types": "^0.0.18", + "@armco/utils": "^0.0.29", + "@reduxjs/toolkit": "^1.8.1", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "react-redux": "^8.0.1", + "react-router-dom": "^6.13.0" +} +``` + +## Usage + +### Basic Import + +```tsx +import Icons from "@armco/icon-spot" +import { IconInfo, IconsMerge, Clusters } from "@armco/icon-spot" +``` + +### With Redux Setup + +```tsx +import { configureStore } from "@reduxjs/toolkit" +import { Provider } from "react-redux" +import { BrowserRouter, Routes, Route } from "react-router-dom" +import Icons, { IconInfo, IconsMerge } from "@armco/icon-spot" + +// Import reducers from icon-spot +import iconsReducer from "@armco/icon-spot/Icons.slice" +import iconInfoReducer from "@armco/icon-spot/IconInfo.slice" + +const store = configureStore({ + reducer: { + icons: iconsReducer, + iconInfo: iconInfoReducer, + }, +}) + +function App() { + return ( + + + + } /> + } /> + } /> + + + + ) +} +``` + +## Exported Components + +| Component | Description | +|-----------|-------------| +| `Icons` | Main icon browser with filters and grid | +| `IconInfo` | Icon detail page with editor | +| `IconsMerge` | Multi-icon merge tool | +| `Clusters` | ML-generated cluster visualization | + +## Development + +```bash +# Install dependencies +pnpm install + +# Start development server +pnpm dev + +# Build library +pnpm build +``` + +## Project Structure + +``` +src/ +├── index.tsx # Exports +├── store.ts # Redux store +├── Icons.tsx # Main browser +├── IconsList.tsx # Icon grid +├── IconTile.tsx # Icon card +├── IconInfo.tsx # Detail view +├── IconController.tsx # Detail controls +├── IconEditor.tsx # Style editor +└── helper.ts # Utilities +``` + +## Documentation + +- [SPECS.md](docs/SPECS.md) - Feature specifications +- [DESIGN.md](docs/DESIGN.md) - Architecture diagrams +- [DEBT.md](docs/DEBT.md) - Technical debt register +- [READINESS.md](docs/READINESS.md) - Production checklist + +## License + +ISC diff --git a/docs/DEBT.md b/docs/DEBT.md new file mode 100644 index 0000000..9f4c3e7 --- /dev/null +++ b/docs/DEBT.md @@ -0,0 +1,242 @@ +# icon-spot - Technical Debt Register + +## ✅ Recently Fixed + +### 1. ~~Hardcoded ML Service URL~~ (FIXED) +**Location:** `src/IconController.tsx` (Line ~52) +**Issue:** ~~ML service URL was hardcoded~~ +**Resolution:** ✅ Changed to use `API_CONFIG.TASKER[process.env.NODE_ENV]` for environment-aware configuration. +**Date Fixed:** Session + +--- + +## 🔴 Critical (Must Fix Before Production) + +### 2. Console.log in Production Code +**Locations:** Multiple files +| File | Line | Usage | +|------|------|-------| +| `IconsList.tsx` | ~65 | `console.error(error)` | +| `IconMergeContainer.tsx` | ~118 | `console.log(pathList)` | +| `IconMergeContainer.tsx` | ~122 | `console.log(e)` (drag event) | + +**Risk:** Pollutes browser console, exposes internal data +**Resolution:** Remove or replace with proper logging/error handling +**Effort:** Low (1 hour) + +--- + +### 3. Missing Error Boundaries +**Issue:** No React error boundaries around components +**Risk:** Single component error crashes entire app +**Resolution:** Add error boundaries at route level +**Effort:** Medium (4-6 hours) + +--- + +### 4. No Loading States for Icon Controller +**Location:** `src/IconController.tsx` +**Issue:** Similar icons fetch has no loading indicator +**Risk:** User sees empty space while loading +**Resolution:** Add loading state for ML results +**Effort:** Low (2 hours) + +--- + +## 🟠 High Priority + +### 5. TypeScript `any` Types +**Locations:** Various +| File | Issue | +|------|-------| +| `Icons.slice.ts` | `state: any` in selectors | +| `IconInfo.slice.ts` | `state: any` in selectors | +| `Icons.tsx` | `clickHandler(e: any)` | +| `IconTile.tsx` | `navigate` param typing | + +**Resolution:** Define proper RootState type and use throughout +**Effort:** Medium (4-6 hours) + +--- + +### 6. Incomplete Favorites Implementation +**Location:** `Icons.slice.ts` +**Issue:** `removeFavorite` has incorrect splice logic +```typescript +removeFavorite: (state, action: PayloadAction) => { + state.favorites.splice(state.favorites.indexOf(action.payload)) + // Missing second argument to splice! +} +``` +**Risk:** Removes from wrong index to end +**Resolution:** Fix splice or use filter +**Effort:** Low (30 minutes) + +--- + +### 7. Favorites Not Persisted +**Issue:** Favorites stored only in Redux, lost on refresh +**Resolution:** Sync to localStorage or backend +**Effort:** Medium (4-6 hours) + +--- + +### 8. Dead/Commented Code +**Locations:** +| File | Lines | Description | +|------|-------|-------------| +| `IconTile.tsx` | 41-82 | `generateTools` function | +| `IconTile.tsx` | 100-103 | `iconTools` variable | +| `IconController.tsx` | 37 | `getSuggestions` commented | + +**Resolution:** Remove or complete implementation +**Effort:** Low (1-2 hours) + +--- + +### 9. Test Data in Production Code +**Location:** `src/IconMergeContainer.tsx` +**Issue:** 100+ lines of hardcoded `iconTest` array +```typescript +const iconTest = [ + { name: "CiAlignBottom", icon: "...", ... }, + // 3 full icon objects +] +``` +**Risk:** Shipped to production, increases bundle size +**Resolution:** Move to test file or mock data folder +**Effort:** Low (1 hour) + +--- + +## 🟡 Medium Priority + +### 10. Missing Accessibility +**Issue:** No ARIA labels, keyboard navigation incomplete +| Component | Issue | +|-----------|-------| +| `IconTile` | No `role` attribute | +| `IconStyleSelector` | Color pickers need labels | +| `FavoritesList` | No keyboard navigation | + +**Resolution:** Add ARIA attributes and keyboard handlers +**Effort:** Medium (8-12 hours) + +--- + +### 11. No Unit Tests +**Issue:** 0% test coverage +**Files needing tests:** +- `helper.ts` - `downloadSvg()`, `complement()` +- `Icons.slice.ts` - Reducer actions +- `IconInfo.slice.ts` - Reducer actions +- `IconTile.tsx` - Click handlers + +**Resolution:** Add Vitest tests +**Effort:** High (16-24 hours) + +--- + +### 12. Inconsistent File Naming +**Issue:** Mixed naming conventions +- Some: `IconsList.component.scss` +- Some: `IconController.component.scss` +- Index: `IconInfo.slice.ts` vs folder `IconInfoSlice/` + +**Root level folders unused:** `IconController/`, `IconEditor/`, `IconInfo/`, `IconInfoSlice/`, `IconStyleSelector/`, `IconTile/`, `Icons/`, `IconsMerge/` + +**Resolution:** Choose convention, refactor file structure +**Effort:** Medium (4-6 hours) + +--- + +### 13. Large Initial Fetch +**Location:** `src/IconsList.tsx` +**Issue:** Fetches 2000 icons on load +```typescript +fetchIconsPage(2000, 0, filters, ...) +``` +**Risk:** Slow initial load, high memory usage +**Resolution:** Implement true pagination or virtual scrolling +**Effort:** Medium (6-8 hours) + +--- + +### 14. Missing Loading Skeleton +**Issue:** Only spinner shown during load +**Resolution:** Add skeleton components matching grid layout +**Effort:** Low (3-4 hours) + +--- + +## 🟢 Low Priority + +### 15. Upload Button Non-functional +**Location:** `src/IconsList.tsx` +**Issue:** Upload button exists but has no handler +```tsx +