embroidery-qc-image 1.0.0 → 1.0.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 (2) hide show
  1. package/README.md +101 -76
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,73 +1,85 @@
1
- # render-embroidery-config
1
+ # embroidery-qc-image
2
2
 
3
- React component for rendering embroidery configurations on mockup images. This package allows you to display custom embroidered designs on product mockups with configurable text, icons, colors, and fonts.
3
+ React component for rendering embroidery qc image. This package allows you to display custom embroidered designs on product mockups with configurable text, icons, colors, and fonts.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install render-embroidery-config
8
+ npm install embroidery-qc-image
9
9
  ```
10
10
 
11
11
  ## Usage
12
12
 
13
13
  ```tsx
14
- import React from 'react';
15
- import { RenderEmbroidery } from 'render-embroidery-config';
16
- import 'render-embroidery-config/dist/index.css';
17
-
18
- const App = () => {
19
- const config = {
20
- image_url: "https://example.com/mockup.png",
21
- sides: [
22
- {
23
- print_side: "Chest",
24
- postitions: [
25
- {
26
- type: "TEXT",
27
- text: "Brian ❤",
28
- text_shape: "No Curved",
29
- color: null,
30
- font: "Times New Roman",
31
- character_colors: ["Black (8)", "Red (1307)"],
32
- change_character_to_heart: true,
33
- },
34
- {
35
- type: "TEXT",
36
- text: "EST. 2009",
37
- text_shape: "No Curved",
38
- color: "Red (1307)",
39
- font: "Arial",
40
- character_colors: null,
41
- floral_pattern: "P01",
42
- change_character_to_heart: null,
43
- },
44
- {
45
- type: "ICON",
46
- icon: "Heart 1",
47
- layer_colors: ["White (9)", "Red (1307)"],
48
- }
49
- ]
50
- },
51
- {
52
- print_side: "Sleeve",
53
- postitions: [
54
- {
55
- type: "TEXT",
56
- text: "Ayanna",
57
- text_shape: "No Curved",
58
- color: "Red (1307)",
59
- font: "Times New Roman",
60
- character_colors: null,
61
- change_character_to_heart: true,
62
- }
63
- ]
64
- }
65
- ]
66
- };
14
+ import React from "react";
15
+ import { EmbroideryQCImage } from "embroidery-qc-image";
16
+ import "embroidery-qc-image/dist/index.css";
17
+
18
+ // Example configuration
19
+ const exampleConfig = {
20
+ image_url:
21
+ "https://i.etsystatic.com/34592503/r/il/5d3e59/7253371633/il_fullxfull.7253371633_kgqr.jpg",
22
+ sides: [
23
+ {
24
+ print_side: "Chest",
25
+ postitions: [
26
+ {
27
+ type: "TEXT" as const,
28
+ text: "Brian <3",
29
+ text_shape: "No Curved",
30
+ color: null,
31
+ font: "Brittany",
32
+ floral_pattern: null,
33
+ character_colors: ["Pink (1148)", "Lavender (1032)"],
34
+ change_character_to_heart: true,
35
+ },
36
+ {
37
+ type: "TEXT" as const,
38
+ text: "EST. 2009",
39
+ text_shape: "No Curved",
40
+ color: "Light Denim (1133)",
41
+ font: "Arial",
42
+ character_colors: null,
43
+ floral_pattern: "P61",
44
+ change_character_to_heart: null,
45
+ },
46
+ {
47
+ type: "ICON" as const,
48
+ icon: "Heart 1",
49
+ layer_colors: ["White (9)", "Red (1037)"],
50
+ },
51
+ ],
52
+ },
53
+ {
54
+ print_side: "Sleeve",
55
+ postitions: [
56
+ {
57
+ type: "TEXT" as const,
58
+ text: "Ayanna",
59
+ text_shape: "No Curved",
60
+ color: "Terra Cotta (1477)",
61
+ font: "Blackmate",
62
+ character_colors: null,
63
+ change_character_to_heart: true,
64
+ },
65
+ {
66
+ type: "TEXT" as const,
67
+ text: "Ryan",
68
+ text_shape: "No Curved",
69
+ color: "Terra Cotta (1477)",
70
+ font: "Millie",
71
+ character_colors: null,
72
+ change_character_to_heart: true,
73
+ },
74
+ ],
75
+ },
76
+ ],
77
+ };
67
78
 
79
+ const App: React.FC = () => {
68
80
  return (
69
- <div>
70
- <RenderEmbroidery config={config} />
81
+ <div style={{ padding: "20px", maxWidth: "800px", margin: "0 auto" }}>
82
+ <EmbroideryQCImage config={exampleConfig} />
71
83
  </div>
72
84
  );
73
85
  };
@@ -77,27 +89,27 @@ export default App;
77
89
 
78
90
  ## Props
79
91
 
80
- ### RenderEmbroidery
92
+ ### EmbroideryQCImage
81
93
 
82
94
  | Prop | Type | Required | Description |
83
95
  |------|------|----------|-------------|
84
- | config | `EmbroideryConfig` | Yes | Configuration object containing embroidery details |
96
+ | config | `EmbroideryQCConfig` | Yes | Configuration object containing embroidery details |
85
97
  | className | `string` | No | Additional CSS classes |
86
98
  | style | `React.CSSProperties` | No | Inline styles |
87
99
 
88
100
  ## Configuration Structure
89
101
 
90
- ### EmbroideryConfig
102
+ ### EmbroideryQCConfig
91
103
 
92
104
  ```typescript
93
- interface EmbroideryConfig {
94
- image_url?: string; // Optional background image URL
105
+ interface EmbroideryQCConfig {
106
+ image_url?: string; // Optional mockup image URL (displayed at bottom-right)
95
107
  sides: Side[]; // Array of sides to render
96
108
  }
97
109
 
98
110
  interface Side {
99
111
  print_side: string; // e.g., "Chest", "Sleeve"
100
- postitions: Position[]; // Array of positions to render
112
+ postitions: Position[]; // Array of positions to render (note: "postitions" spelling)
101
113
  }
102
114
 
103
115
  type Position = TextPosition | IconPosition;
@@ -105,12 +117,12 @@ type Position = TextPosition | IconPosition;
105
117
  interface TextPosition {
106
118
  type: 'TEXT';
107
119
  text: string; // Text content
108
- text_shape: string; // "No Curved" or other shapes
109
- color: string | null; // Color for entire text
110
- font: string; // Font name
111
- character_colors: string[] | null; // Array of colors for alternating characters
112
- change_character_to_heart: boolean | null; // Replace <3 with ❤
113
- floral_pattern?: string; // Optional floral pattern
120
+ text_shape?: string | null; // Optional: "No Curved" or other shapes
121
+ color?: string | null; // Optional: Color for entire text
122
+ font?: string | null; // Optional: Font name
123
+ character_colors?: string[] | null; // Optional: Array of colors for alternating characters
124
+ change_character_to_heart?: boolean | null; // Optional: Replace <3 with ❤
125
+ floral_pattern?: string | null; // Optional: Floral pattern name
114
126
  }
115
127
 
116
128
  interface IconPosition {
@@ -122,23 +134,36 @@ interface IconPosition {
122
134
 
123
135
  ## Features
124
136
 
125
- - ✅ Render custom text on mockup images
137
+ - ✅ Render custom text on mockup images with automatic text wrapping
126
138
  - ✅ Support for icon placement with multi-layer colors
127
139
  - ✅ Character-level color customization (alternating colors)
128
- - ✅ Font loading from CDN
140
+ - ✅ Font loading from CDN with automatic fallback
129
141
  - ✅ Multiple print sides (Chest, Sleeve, etc.)
130
- - ✅ Floral pattern support
142
+ - ✅ Floral pattern support with inline display
131
143
  - ✅ Heart emoji conversion (<3 → ❤)
132
- - ✅ Responsive canvas rendering
133
- - ✅ TypeScript support
144
+ - ✅ Automatic font scaling to fit canvas (only scales down, never up)
145
+ - ✅ Smart layout with uniform property grouping
146
+ - ✅ Color swatches displayed inline with labels
147
+ - ✅ Automatic word wrapping for long text
148
+ - ✅ Fixed canvas size (4200x4800)
149
+ - ✅ TypeScript support with full type definitions
134
150
 
135
151
  ## Supported Colors
136
152
 
137
- The component automatically maps color names to hex values:
153
+ The component automatically maps color names to hex values for text rendering:
138
154
  - `White (9)`, `Black (8)`, `Red (9)`, `Red (1307)`, `Blue (9)`, `Green (9)`
139
155
  - `Forest Green (1397)`, `Brown (9)`, `Cream (9)`, `Beige (9)`
140
156
  - `Navy (9)`, `Maroon (9)` and more...
141
157
 
158
+ ## Thread Colors (Màu chỉ)
159
+
160
+ Thread color swatches are automatically loaded and displayed inline with color labels:
161
+ ```
162
+ https://s3.hn-1.cloud.cmctelecom.vn/god-system-images/embroidery/thread-colors/{ColorName}.png
163
+ ```
164
+
165
+ The swatches are displayed next to "Màu chỉ:" labels, showing visual representation of the thread colors used in the embroidery design.
166
+
142
167
  ## Font Loading
143
168
 
144
169
  Fonts are automatically loaded from:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "embroidery-qc-image",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "React component for rendering embroidery QC images",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -53,4 +53,4 @@
53
53
  "vite": "^5.0.8"
54
54
  },
55
55
  "dependencies": {}
56
- }
56
+ }