gospelo-iconcraft-react 0.3.0 → 0.3.1

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.
Files changed (3) hide show
  1. package/README.md +139 -10
  2. package/dist/index.js +34 -7
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -10,6 +10,21 @@ npm install gospelo-iconcraft-react
10
10
 
11
11
  ## Quick Start
12
12
 
13
+ ### Factory Pattern (Recommended)
14
+
15
+ ```tsx
16
+ import { IconCraftFactory, IconCraftView } from 'gospelo-iconcraft-react';
17
+
18
+ const factory = new IconCraftFactory({ mode: 'wax', shapeColor: '#6366f1' });
19
+ const icon = factory.create('<svg>...</svg>');
20
+
21
+ function App() {
22
+ return <IconCraftView instance={icon} />;
23
+ }
24
+ ```
25
+
26
+ ### Simple Usage
27
+
13
28
  ```tsx
14
29
  import { IconCraftShape } from 'gospelo-iconcraft-react';
15
30
 
@@ -26,9 +41,106 @@ function App() {
26
41
 
27
42
  ## Components
28
43
 
29
- ### `<IconCraftShape>` (Recommended)
44
+ ### `<IconCraftView>` (Recommended)
30
45
 
31
- Modern component with full feature support.
46
+ Instance-based component with rotation dial, reticle, and animation support. Works with `IconCraftFactory` / `IconCraftInstance`.
47
+
48
+ ```tsx
49
+ import { IconCraftFactory, IconCraftView } from 'gospelo-iconcraft-react';
50
+
51
+ const factory = new IconCraftFactory({
52
+ mode: 'jelly',
53
+ shapeColor: '#10b981',
54
+ size: 120,
55
+ });
56
+
57
+ const icon = factory.create('<svg>...</svg>');
58
+
59
+ <IconCraftView
60
+ instance={icon}
61
+ animation="bounce"
62
+ showRotationDial
63
+ onRotationChange={(deg) => console.log(deg)}
64
+ dialPreset={dialPresetDotted}
65
+ showReticle
66
+ reticlePreset={reticlePresetCross}
67
+ />
68
+ ```
69
+
70
+ #### Props
71
+
72
+ | Prop | Type | Default | Description |
73
+ |------|------|---------|-------------|
74
+ | `instance` | `IconCraftInstance` | required | Icon instance from factory |
75
+ | `animation` | `AnimationType \| AnimationOptions` | - | Animation preset or config |
76
+ | `animationTarget` | `'shape' \| 'icon' \| 'both'` | `'both'` | Animation target |
77
+ | `animateOnHover` | `boolean` | `false` | Trigger animation on hover |
78
+ | `showRotationDial` | `boolean` | `false` | Show rotation dial overlay |
79
+ | `onRotationChange` | `(deg: number) => void` | - | Rotation change callback |
80
+ | `rotationSnap` | `number` | `5` | Snap angle in degrees |
81
+ | `dialPreset` | `DialPreset` | `dialPresetDotted` | Dial visual preset |
82
+ | `showReticle` | `boolean` | `false` | Show center reticle |
83
+ | `reticlePreset` | `ReticlePreset` | - | Reticle visual preset |
84
+ | `renderRing` | `(props: DialRingProps) => ReactNode` | - | Custom ring renderer |
85
+ | `renderNotch` | `(props: DialNotchProps) => ReactNode` | - | Custom notch renderer |
86
+ | `renderLabel` | `(props: DialLabelProps) => ReactNode` | - | Custom label renderer |
87
+ | `renderReticle` | `(props: ReticleProps) => ReactNode` | - | Custom reticle renderer |
88
+ | `zIndex` | `number` | - | Z-index for layering |
89
+ | `className` | `string` | - | CSS class |
90
+ | `style` | `CSSProperties` | - | Inline styles |
91
+ | `onClick` | `() => void` | - | Click handler |
92
+
93
+ ### Dial Presets
94
+
95
+ 10 built-in dial presets for the rotation dial appearance:
96
+
97
+ ```tsx
98
+ import { dialPresets, dialPresetDotted } from 'gospelo-iconcraft-react';
99
+
100
+ // Use by name
101
+ <IconCraftView instance={icon} showRotationDial dialPreset={dialPresets.dotted} />
102
+
103
+ // Available presets
104
+ // dialPresets.dotted - Dotted circle ring (default)
105
+ // dialPresets.dashed - Dashed circle ring
106
+ // dialPresets.solid - Solid circle ring
107
+ // dialPresets.ticks - Tick marks around the ring
108
+ // dialPresets.double - Double circle ring
109
+ // dialPresets.crosshair - Crosshair style
110
+ // dialPresets.minimal - Minimal style
111
+ // dialPresets.needle - Needle indicator
112
+ // dialPresets.bar - Bar indicator
113
+ // dialPresets.arrow - Arrow indicator
114
+ ```
115
+
116
+ ### Reticle Presets
117
+
118
+ 3 built-in reticle presets for center overlay:
119
+
120
+ ```tsx
121
+ import { reticlePresets, reticlePresetCross } from 'gospelo-iconcraft-react';
122
+
123
+ <IconCraftView instance={icon} showReticle reticlePreset={reticlePresets.cross} />
124
+
125
+ // Available presets
126
+ // reticlePresets.cross - Crosshair reticle
127
+ // reticlePresets.bullseye - Bullseye target reticle
128
+ // reticlePresets.globe - Globe/sphere reticle
129
+ ```
130
+
131
+ ### CSS Variables
132
+
133
+ The dial and reticle color can be customized via CSS variable:
134
+
135
+ ```css
136
+ :root {
137
+ --iconcraft-dial-color: #0071e3; /* default */
138
+ }
139
+ ```
140
+
141
+ ### `<IconCraftShape>`
142
+
143
+ Standalone component with full feature support (no factory needed).
32
144
 
33
145
  ```tsx
34
146
  import { IconCraftShape } from 'gospelo-iconcraft-react';
@@ -70,18 +182,26 @@ import { IconCraftShape } from 'gospelo-iconcraft-react';
70
182
  | `onError` | `(error) => void` | - | Called on error |
71
183
  | `onClick` | `() => void` | - | Click handler |
72
184
 
73
- ### `<IconCraft>` (Legacy)
185
+ ## Factory Pattern
74
186
 
75
- Original component for backwards compatibility.
187
+ `IconCraftFactory` creates reusable `IconCraftInstance` objects with shared configuration:
76
188
 
77
189
  ```tsx
78
- import { IconCraft } from 'gospelo-iconcraft-react';
190
+ import { IconCraftFactory } from 'gospelo-iconcraft-react';
79
191
 
80
- <IconCraft
81
- svgContent="<svg>...</svg>"
82
- mode="wax"
83
- baseColor="#6366f1"
84
- />
192
+ const factory = new IconCraftFactory({
193
+ mode: 'wax',
194
+ shapeColor: '#6366f1',
195
+ iconStyle: 'emboss',
196
+ size: 100,
197
+ });
198
+
199
+ // Create multiple icons with same config
200
+ const icon1 = factory.create('<svg>...</svg>');
201
+ const icon2 = factory.create('<svg>...</svg>');
202
+
203
+ // Update config after creation
204
+ icon1.config.update({ shapeColor: '#10b981', rotation: 45 });
85
205
  ```
86
206
 
87
207
  ## Shape Modes
@@ -244,6 +364,15 @@ import type {
244
364
  AnimationOptions,
245
365
  IconCraftResult,
246
366
  IconCraftShapeProps,
367
+ IconCraftViewProps,
368
+ DialPreset,
369
+ DialPresetName,
370
+ ReticlePreset,
371
+ ReticlePresetName,
372
+ DialRingProps,
373
+ DialNotchProps,
374
+ DialLabelProps,
375
+ ReticleProps,
247
376
  } from 'gospelo-iconcraft-react';
248
377
  ```
249
378
 
package/dist/index.js CHANGED
@@ -553,9 +553,9 @@ var dialPresetDashed = {
553
553
  r: radius,
554
554
  fill: "none",
555
555
  stroke: dialColor,
556
- strokeWidth: "2",
556
+ strokeWidth: "1.2",
557
557
  strokeDasharray: "6 4",
558
- opacity: 0.7
558
+ opacity: 0.5
559
559
  }
560
560
  ),
561
561
  renderNotch: ({ x, y, onMouseDown }) => /* @__PURE__ */ jsx(
@@ -670,7 +670,7 @@ var dialPresetDotted = {
670
670
  {
671
671
  cx: dx,
672
672
  cy: dy,
673
- r: deg % 90 === 0 ? 2.5 : 1.5,
673
+ r: deg % 90 === 0 ? 1.8 : 1,
674
674
  fill: dialColor,
675
675
  opacity: deg % 90 === 0 ? 0.8 : 0.4
676
676
  },
@@ -701,10 +701,37 @@ var dialPresetDotted = {
701
701
  };
702
702
  var dialPresetDouble = {
703
703
  name: "double",
704
- renderRing: ({ cx, cy, radius }) => /* @__PURE__ */ jsxs(Fragment, { children: [
705
- /* @__PURE__ */ jsx("circle", { cx, cy, r: radius, fill: "none", stroke: dialColor, strokeWidth: "1", opacity: 0.3 }),
706
- /* @__PURE__ */ jsx("circle", { cx, cy, r: radius - 4, fill: "none", stroke: dialColor, strokeWidth: "1", opacity: 0.3 })
707
- ] }),
704
+ renderRing: ({ cx, cy, radius }) => {
705
+ const lines = [];
706
+ for (let i = 0; i < 8; i++) {
707
+ const deg = i * 45;
708
+ const rad = (deg - 90) * Math.PI / 180;
709
+ const x1 = cx + (radius - 4) * Math.cos(rad);
710
+ const y1 = cy + (radius - 4) * Math.sin(rad);
711
+ const x2 = cx + radius * Math.cos(rad);
712
+ const y2 = cy + radius * Math.sin(rad);
713
+ lines.push(
714
+ /* @__PURE__ */ jsx(
715
+ "line",
716
+ {
717
+ x1,
718
+ y1,
719
+ x2,
720
+ y2,
721
+ stroke: dialColor,
722
+ strokeWidth: "0.8",
723
+ opacity: 0.3
724
+ },
725
+ i
726
+ )
727
+ );
728
+ }
729
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
730
+ /* @__PURE__ */ jsx("circle", { cx, cy, r: radius, fill: "none", stroke: dialColor, strokeWidth: "1", opacity: 0.3 }),
731
+ /* @__PURE__ */ jsx("circle", { cx, cy, r: radius - 4, fill: "none", stroke: dialColor, strokeWidth: "1", opacity: 0.3 }),
732
+ lines
733
+ ] });
734
+ },
708
735
  renderNotch: ({ x, y, degrees, onMouseDown }) => /* @__PURE__ */ jsx(
709
736
  "g",
710
737
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gospelo-iconcraft-react",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "IconCraft React components - 3D decorative icon shapes from SVG",
5
5
  "license": "MIT",
6
6
  "author": "gorosun <goro-hayakawa@no-studio.net>",