@particle-academy/react-fancy 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,131 @@
1
+ # @particle-academy/react-fancy
2
+
3
+ React UI component library — the React port of the `fancy-flux` Blade/Livewire component library. The goal is **visual and behavioral parity** with fancy-flux.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @particle-academy/react-fancy
9
+ ```
10
+
11
+ Peer dependencies: `react >= 18`, `react-dom >= 18`.
12
+
13
+ ## Usage
14
+
15
+ ```tsx
16
+ import { Action, Input, Select, Carousel } from "@particle-academy/react-fancy";
17
+ import "@particle-academy/react-fancy/styles.css";
18
+ ```
19
+
20
+ ## Commands
21
+
22
+ ```bash
23
+ pnpm --filter @particle-academy/react-fancy build # Build with tsup (ESM + CJS + DTS)
24
+ pnpm --filter @particle-academy/react-fancy dev # Watch mode
25
+ pnpm --filter @particle-academy/react-fancy lint # Type-check (tsc --noEmit)
26
+ pnpm --filter @particle-academy/react-fancy clean # Remove dist/
27
+ ```
28
+
29
+ The demo app consuming this package builds with Vite from the monorepo root:
30
+
31
+ ```bash
32
+ npx vite build # Build demo app (verifies imports work)
33
+ ```
34
+
35
+ ## Components
36
+
37
+ | Component | Description |
38
+ |-----------|-------------|
39
+ | Action | Button with colors, states, icons, emoji, avatar, badge, sort control |
40
+ | Carousel | Slide carousel with controls, steps, and panels |
41
+ | ColorPicker | Color selection widget |
42
+ | Emoji | Emoji renderer from slugs |
43
+ | EmojiSelect | Emoji search and selection dropdown |
44
+ | Table | Data table with sorting, pagination, search, and tray |
45
+ | Field | Form field wrapper with label and error display |
46
+ | Input | Text input |
47
+ | Textarea | Multi-line text input |
48
+ | Select | Dropdown select |
49
+ | Checkbox / CheckboxGroup | Checkbox inputs |
50
+ | RadioGroup | Radio button group |
51
+ | Switch | Toggle switch |
52
+ | Slider | Range slider (single and range modes) |
53
+ | DatePicker | Date selection (single and range modes) |
54
+
55
+ ## Architecture
56
+
57
+ ### Directory Layout
58
+
59
+ ```
60
+ src/
61
+ ├── components/ # One directory per component
62
+ │ ├── Action/
63
+ │ │ ├── Action.tsx # Component implementation
64
+ │ │ ├── Action.types.ts # Props interface
65
+ │ │ └── index.ts # Re-exports
66
+ │ ├── Carousel/
67
+ │ ├── inputs/ # Form input components (Field, Input, Select, etc.)
68
+ │ └── ...
69
+ ├── data/ # Static data (emoji entries, etc.)
70
+ ├── hooks/ # Shared React hooks
71
+ ├── utils/ # Shared utilities (cn, types)
72
+ └── index.ts # Public API — all exports
73
+ ```
74
+
75
+ ### Key Utilities
76
+
77
+ - **`cn()`** (`utils/cn.ts`) — `clsx` + `tailwind-merge` for conditional class composition.
78
+ - **`resolve(slug)`** (`data/emoji-utils.ts`) — Resolves emoji slugs (e.g., `"rocket"`) to Unicode characters.
79
+ - **`useControllableState`** (`hooks/`) — For components supporting both controlled and uncontrolled modes.
80
+
81
+ ### Shared Types (`utils/types.ts`)
82
+
83
+ - `Size` — `"xs" | "sm" | "md" | "lg" | "xl"`
84
+ - `Color` — Full Tailwind color palette (17 colors)
85
+ - `ActionColor` — Subset of 10 standalone colors matching fancy-flux
86
+ - `Variant` — `"solid" | "outline" | "ghost" | "soft"`
87
+
88
+ ## Demo Pages
89
+
90
+ Component demos live in the monorepo at `resources/js/react-demos/pages/`. Each component has a `ComponentNameDemo.tsx` that exercises all props and states using the `DemoSection` wrapper component.
91
+
92
+ ---
93
+
94
+ ## Agent Guidelines
95
+
96
+ Guidelines for AI agents (Claude Code, Copilot, etc.) working on this package.
97
+
98
+ ### Component Pattern
99
+
100
+ Every component follows this structure:
101
+
102
+ 1. **`ComponentName.types.ts`** — Props interface extending native HTML element attributes. Import shared types from `../../utils/types`.
103
+ 2. **`ComponentName.tsx`** — Implementation using `forwardRef`. Always set `displayName`. Use `cn()` for class merging.
104
+ 3. **`index.ts`** — Re-exports both the component and its types.
105
+ 4. **`src/index.ts`** — Must export the component and its prop types. Update this file when adding new components.
106
+
107
+ ### Parity with fancy-flux
108
+
109
+ - **Always reference the corresponding Blade component** in `packages/fancy-flux/stubs/resources/views/flux/` when implementing or updating a component. Match the Tailwind classes, color values, state logic, and dark mode support exactly.
110
+ - React-specific additions (e.g., `loading` spinner, `href` anchor rendering) are fine — they don't exist in Blade but are idiomatic in React.
111
+ - Icons are passed as `ReactNode` (not string names like Blade's `<flux:icon>`). This is the correct React pattern.
112
+
113
+ ### Styling
114
+
115
+ - **Tailwind v4** — CSS-first config. Use `@import "tailwindcss"` not `@tailwind` directives.
116
+ - **Dark mode** — Every color variant must include `dark:` equivalents. Check fancy-flux for the exact classes.
117
+ - **No component library deps** — Only `clsx` and `tailwind-merge`. Don't add Radix, Headless UI, or similar.
118
+ - Class maps should be `Record<Size, string>` (or similar) constants outside the component function, not inline.
119
+
120
+ ### TypeScript
121
+
122
+ - Explicit types on all exports. Use `interface` for props (not `type`).
123
+ - Extend native HTML attributes (`ButtonHTMLAttributes`, `InputHTMLAttributes`, etc.) and `Omit` conflicting props (e.g., `Omit<..., "color">`).
124
+ - Export prop interfaces from the component's `index.ts` and from `src/index.ts`.
125
+
126
+ ### Build
127
+
128
+ - tsup handles the build — ESM, CJS, and `.d.ts` generation.
129
+ - `react` and `react-dom` are external peer dependencies, never bundled.
130
+ - After any change, verify with `pnpm --filter @particle-academy/react-fancy build` before considering the work done.
131
+ - When updating a component, update its demo page in `resources/js/react-demos/pages/` to cover all new features.