forked from gcoro/react-qrcode-logo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQRCode.stories.tsx
More file actions
218 lines (205 loc) · 5.66 KB
/
Copy pathQRCode.stories.tsx
File metadata and controls
218 lines (205 loc) · 5.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
import type { Meta, StoryObj } from '@storybook/react';
import { QRCode } from '../lib/index';
const meta: Meta<typeof QRCode> = {
title: 'Components/QRCode',
component: QRCode,
parameters: {
layout: 'centered',
},
tags: ['autodocs'],
argTypes: {
value: {
control: 'text',
description: 'The value encoded in the QR Code',
},
size: {
control: { type: 'range', min: 100, max: 500, step: 10 },
description: 'The size of the QR Code in pixels',
},
bgColor: {
control: 'color',
description: 'Background color',
},
fgColor: {
control: 'color',
description: 'Foreground color',
},
qrStyle: {
control: 'select',
options: ['squares', 'dots', 'fluid'],
description: 'Style of the QR Code modules',
},
logoImage: {
control: 'text',
description: 'Logo image URL or base64',
},
logoWidth: {
control: { type: 'range', min: 0, max: 200, step: 5 },
description: 'Logo width in pixels',
},
logoHeight: {
control: { type: 'range', min: 0, max: 200, step: 5 },
description: 'Logo height in pixels',
},
logoOpacity: {
control: { type: 'range', min: 0, max: 1, step: 0.1 },
description: 'Logo opacity (0-1)',
},
eyeRadius: {
control: 'object',
description: 'Corner radius for the positioning patterns (eyes). Can be a number, array of numbers, or array of objects with outer/inner properties.',
},
quietZone: {
control: { type: 'range', min: 0, max: 50, step: 5 },
description: 'Size of the quiet zone around the QR Code',
},
removeQrCodeBehindLogo: {
control: 'boolean',
description: 'Remove QR cells behind the logo',
},
enableCORS: {
control: 'boolean',
description: 'Enable CORS for logo image',
},
},
};
export default meta;
type Story = StoryObj<typeof QRCode>;
// Default story with basic configuration
export const Default: Story = {
args: {
value: 'https://github.com/gcoro/react-qrcode-logo',
size: 200,
},
};
// With logo
export const WithLogo: Story = {
args: {
value: 'https://github.com/gcoro/react-qrcode-logo',
size: 250,
logoImage: 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/React-icon.svg/200px-React-icon.svg.png',
logoWidth: 60,
logoHeight: 60,
enableCORS: true,
},
};
// Dots style
export const DotsStyle: Story = {
args: {
value: 'https://github.com/gcoro/react-qrcode-logo',
size: 200,
qrStyle: 'dots',
fgColor: '#8B5CF6',
},
};
// Fluid style
export const FluidStyle: Story = {
args: {
value: 'https://github.com/gcoro/react-qrcode-logo',
size: 200,
qrStyle: 'fluid',
fgColor: '#10B981',
},
};
// Custom colors
export const CustomColors: Story = {
args: {
value: 'https://github.com/gcoro/react-qrcode-logo',
size: 200,
bgColor: '#1F2937',
fgColor: '#F59E0B',
},
};
// Rounded eyes
export const RoundedEyes: Story = {
args: {
value: 'https://github.com/gcoro/react-qrcode-logo',
size: 200,
eyeRadius: 20,
fgColor: '#EF4444',
},
};
// Rounded outer with sharp inner pupils
export const RoundedOuterSharpInner: Story = {
args: {
value: 'https://github.com/gcoro/react-qrcode-logo',
size: 250,
eyeRadius: [
{ outer: [10, 10, 10, 10], inner: [0, 0, 0, 0] },
{ outer: [10, 10, 10, 10], inner: [0, 0, 0, 0] },
{ outer: [10, 10, 10, 10], inner: [0, 0, 0, 0] },
],
fgColor: '#3B82F6',
},
name: 'Rounded Outer, Sharp Inner',
};
// Sharp outer with rounded inner pupils
export const SharpOuterRoundedInner: Story = {
args: {
value: 'https://github.com/gcoro/react-qrcode-logo',
size: 250,
eyeRadius: [
{ outer: [0, 0, 0, 0], inner: [10, 10, 10, 10] },
{ outer: [0, 0, 0, 0], inner: [10, 10, 10, 10] },
{ outer: [0, 0, 0, 0], inner: [10, 10, 10, 10] },
],
fgColor: '#3B82F6',
},
name: 'Sharp Outer, Rounded Inner',
};
// With logo and custom inner/outer radius
export const LogoWithCustomEyeRadius: Story = {
args: {
value: 'https://github.com/gcoro/react-qrcode-logo',
size: 300,
logoImage: 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/React-icon.svg/200px-React-icon.svg.png',
logoWidth: 70,
logoHeight: 70,
enableCORS: true,
eyeRadius: [
{ outer: [12, 12, 12, 12], inner: [8, 8, 8, 8] },
{ outer: [12, 12, 12, 12], inner: [8, 8, 8, 8] },
{ outer: [12, 12, 12, 12], inner: [8, 8, 8, 8] },
],
removeQrCodeBehindLogo: true,
},
};
// Complex example with all features
export const ComplexExample: Story = {
args: {
value: 'https://github.com/gcoro/react-qrcode-logo',
size: 300,
logoImage: 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/React-icon.svg/200px-React-icon.svg.png',
logoWidth: 60,
logoHeight: 60,
logoOpacity: 0.9,
enableCORS: true,
qrStyle: 'fluid',
eyeRadius: [
{ outer: [15, 15, 15, 15], inner: [10, 10, 10, 10] },
{ outer: [15, 15, 15, 15], inner: [10, 10, 10, 10] },
{ outer: [15, 15, 15, 15], inner: [10, 10, 10, 10] },
],
fgColor: '#6366F1',
bgColor: '#F3F4F6',
quietZone: 20,
removeQrCodeBehindLogo: true,
},
};
// Custom eye colors
export const CustomEyeColors: Story = {
args: {
value: 'https://github.com/gcoro/react-qrcode-logo',
size: 250,
eyeColor: [
{ outer: '#FF0000', inner: '#0000FF' },
{ outer: '#00FF00', inner: '#FF00FF' },
{ outer: '#0000FF', inner: '#FFFF00' },
],
eyeRadius: [
{ outer: [5, 5, 5, 5], inner: [5, 5, 5, 5] },
{ outer: [5, 5, 5, 5], inner: [5, 5, 5, 5] },
{ outer: [5, 5, 5, 5], inner: [5, 5, 5, 5] },
],
},
};