Skip to content

feat(react-kivex): implement React wrapper with automated SVG generation#1

Open
Joseph4sure wants to merge 1 commit into
MotionMind2007:mainfrom
Joseph4sure:react-kivex
Open

feat(react-kivex): implement React wrapper with automated SVG generation#1
Joseph4sure wants to merge 1 commit into
MotionMind2007:mainfrom
Joseph4sure:react-kivex

Conversation

@Joseph4sure

@Joseph4sure Joseph4sure commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Overview

This PR implements react-kivex – a fully automated SVG-to-React icon generation system for the Kivex project.

Features

🎨 Automated Icon Generation

  • SVG → React Component – Drop any .svg file into /icons, and a fully typed React component is generated automatically
  • Smart file watchingnpm run watch automatically regenerates components when SVGs are added, updated, or removed
  • Orphan cleanup – Removed SVGs are automatically deleted from the component library

🧩 Developer Experience

  • Diff-based writing – Only writes to disk when content changes, keeping Git diffs clean and builds fast
  • Watch modenpm run watch for instant regeneration during development
  • Force flagnpm run generate -- --force to regenerate everything

📦 Package Architecture

  • Shared IconBase – Centralized component that handles size, color, strokeWidth, and ref forwarding
  • TypeScript support – Full type definitions including IconProps for consumers
  • Clean exports – All icons are exported from src/index.ts automatically
  • Build pipeline – Configured with tsup for ESM and CJS output

🧪 Development Tools

  • Playground – Included for local testing and development
  • Watch modenpm run watch for instant regeneration

Technical Implementation

  • Uses @svgr/core + @svgr/plugin-jsx for SVG to JSX transformation
  • Custom template system (IconTemplate.ts) ensures consistent component structure
  • chokidar for file watching with debounced regeneration
  • fast-glob for efficient SVG file discovery
  • fs-extra for file operations

🎨 Icon Component Props

Every icon (including Share) accepts the following props:

Prop Type Default Description
size number 24 Sets both width and height in pixels
color string 'currentColor' Sets the stroke/fill color
strokeWidth number 2 Controls stroke width of paths
className string '' CSS class for styling
style CSSProperties undefined Inline styles
onClick, onMouseEnter, etc. (e) => void undefined Event handlers
aria-, data- string undefined Accessibility/data attributes
ref Ref undefined Forwarded to the element

All icons also forward any additional SVG attributes to the underlying <svg> element.

Example Usage

import { Home, Dashboard, User } from 'react-kivex';

function App() {
  return (
    <div>
      {/* Basic usage */}
      <Home />
      <Dashboard />
      <User />

      {/* With custom props */}
      <Home
        size={32}
        color="#ff6b6b"
        strokeWidth={1.5}
        className="icon-share"
        onClick={() => console.log('Shared!')}
      />

      {/* Different icons */}
      <User size={24} color="blue" />
      <Dashboard size={28} color="green" strokeWidth={2.5} />
    </div>
  );
}


## 📦 Installation & Usage

### For end users (once published)

```bash
npm install react-kivex
# or
pnpm add react-kivex
# or
yarn add react-kivex

Then import and use:

import { Share, Home, Dashboard } from 'react-kivex';

function App() {
  return (
    <div>
      <Share size={32} color="#ff6b6b" strokeWidth={1.5} />
      <Home size={24} color="blue" />
    </div>
  );
}

For local development (within this monorepo)

# From the package root
cd packages/react-kivex

# Install dependencies
npm install

# Generate icons from SVG source
npm run generate

# Start watch mode (auto‑regenerate on changes)
npm run watch

# Build the package (for publishing)
npm run build

Testing with the playground

cd playground
npm install
npm run dev

@MotionMind2007

Copy link
Copy Markdown
Owner

Thanks for this amazing contribution! Your icon generator script is really powerful and clean.

I've locally patched a few minor issues regarding Windows path formatting and SVG rendering, and everything is now working flawlessly in the playground.

Merging this now to add it to the repository and publish on npm. Appreciate your great work! 🚀🔥

@Joseph4sure

Joseph4sure commented Jul 5, 2026 via email

Copy link
Copy Markdown
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants