@w3payments/react 1.2.1 → 1.4.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 +194 -14
- package/dist/appearance.d.ts +30 -0
- package/dist/appearance.d.ts.map +1 -0
- package/dist/assets/main.css +1 -1
- package/dist/components/CurrencyIcon.d.ts +71 -0
- package/dist/components/CurrencyIcon.d.ts.map +1 -0
- package/dist/components/ExchangeIcon.d.ts +8 -0
- package/dist/components/ExchangeIcon.d.ts.map +1 -0
- package/dist/components/PaymentMethodRow.d.ts +0 -2
- package/dist/components/PaymentMethodRow.d.ts.map +1 -1
- package/dist/components/W3PaymentFooter.d.ts.map +1 -1
- package/dist/components/W3PaymentWidget.d.ts +30 -53
- package/dist/components/W3PaymentWidget.d.ts.map +1 -1
- package/dist/components/index.d.ts +1 -4
- package/dist/components/index.d.ts.map +1 -1
- package/dist/index.js +15 -16
- package/dist/index.mjs +7857 -12774
- package/dist/main.d.ts +2 -3
- package/dist/main.d.ts.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/qr.d.ts +41 -0
- package/dist/utils/qr.d.ts.map +1 -0
- package/package.json +16 -13
- package/dist/components/W3PaymentsProvider.d.ts +0 -24
- package/dist/components/W3PaymentsProvider.d.ts.map +0 -1
- package/dist/context/W3PaymentsContext.d.ts +0 -31
- package/dist/context/W3PaymentsContext.d.ts.map +0 -1
- package/dist/hooks/index.d.ts +0 -8
- package/dist/hooks/index.d.ts.map +0 -1
- package/dist/hooks/useW3Payments.d.ts +0 -32
- package/dist/hooks/useW3Payments.d.ts.map +0 -1
- package/dist/http/W3PaymentsClient.d.ts +0 -16
- package/dist/http/W3PaymentsClient.d.ts.map +0 -1
- package/dist/index-B9KdNmCT.cjs +0 -94
- package/dist/index-Cu_k1Q9p.js +0 -13544
- package/dist/theme.d.ts +0 -194
- package/dist/theme.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -248,28 +248,208 @@ Seamless payments across Bitcoin, Ethereum, Solana, Polygon with automatic bridg
|
|
|
248
248
|
### Crypto Offramping
|
|
249
249
|
Direct crypto-to-fiat conversions with bank account deposits.
|
|
250
250
|
|
|
251
|
-
##
|
|
251
|
+
## Customization
|
|
252
252
|
|
|
253
|
-
|
|
253
|
+
### Widget Branding
|
|
254
|
+
|
|
255
|
+
Customize the widget appearance with props:
|
|
256
|
+
|
|
257
|
+
```tsx
|
|
258
|
+
<W3PaymentWidget
|
|
259
|
+
title="Your Brand Name"
|
|
260
|
+
subtitle="CHOOSE PAYMENT METHOD"
|
|
261
|
+
logo="/your-logo.png"
|
|
262
|
+
showAmount={false} // Hide amount section
|
|
263
|
+
showHeader={false} // Hide header with title/logo
|
|
264
|
+
// ... other props
|
|
265
|
+
/>
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Theme Customization
|
|
269
|
+
|
|
270
|
+
Use the **W3Appearance API** for consistent theming across all components:
|
|
271
|
+
|
|
272
|
+
#### Built-in Themes
|
|
273
|
+
|
|
274
|
+
```tsx
|
|
275
|
+
import { W3PaymentWidget } from '@w3payments/react';
|
|
276
|
+
|
|
277
|
+
// Default light theme
|
|
278
|
+
<W3PaymentWidget theme="default" />
|
|
279
|
+
|
|
280
|
+
// Dark theme
|
|
281
|
+
<W3PaymentWidget theme="night" />
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
#### Custom Themes
|
|
285
|
+
|
|
286
|
+
```tsx
|
|
287
|
+
import type { W3Appearance } from '@w3payments/common';
|
|
288
|
+
|
|
289
|
+
const customTheme: W3Appearance = {
|
|
290
|
+
variables: {
|
|
291
|
+
// Brand colors
|
|
292
|
+
primary: '#ff6b35', // Orange brand color
|
|
293
|
+
background: '#f8f9fa', // Light gray background
|
|
294
|
+
text: '#2d3748', // Dark text
|
|
295
|
+
textSecondary: '#718096', // Muted text
|
|
296
|
+
|
|
297
|
+
// Status colors
|
|
298
|
+
success: '#38a169', // Green
|
|
299
|
+
danger: '#e53e3e', // Red
|
|
300
|
+
warning: '#dd6b20', // Orange
|
|
301
|
+
border: '#e2e8f0', // Light border
|
|
302
|
+
|
|
303
|
+
// Typography
|
|
304
|
+
fontFamily: 'Inter, system-ui, sans-serif',
|
|
305
|
+
fontSizeBase: '14px',
|
|
306
|
+
fontSizeSmall: '12px',
|
|
307
|
+
fontSizeLarge: '28px',
|
|
308
|
+
fontWeightNormal: '500',
|
|
309
|
+
|
|
310
|
+
// Layout
|
|
311
|
+
spacingUnit: '6px', // Increased spacing
|
|
312
|
+
borderRadius: '12px', // More rounded
|
|
313
|
+
buttonRadius: '8px' // Button radius
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
<W3PaymentWidget appearance={customTheme} />
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
#### Dark Theme Example
|
|
321
|
+
|
|
322
|
+
```tsx
|
|
323
|
+
const darkTheme: W3Appearance = {
|
|
324
|
+
variables: {
|
|
325
|
+
primary: '#0085FF', // Blue accent
|
|
326
|
+
background: '#1a202c', // Dark background
|
|
327
|
+
text: '#f7fafc', // Light text
|
|
328
|
+
textSecondary: '#a0aec0', // Muted light text
|
|
329
|
+
success: '#48bb78', // Bright green
|
|
330
|
+
danger: '#f56565', // Bright red
|
|
331
|
+
warning: '#ed8936', // Bright orange
|
|
332
|
+
border: '#4a5568', // Dark border
|
|
333
|
+
fontFamily: 'SF Pro Display, system-ui, sans-serif'
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
<W3PaymentWidget appearance={darkTheme} />
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
#### Theming with Context
|
|
341
|
+
|
|
342
|
+
Apply themes globally using the provider:
|
|
343
|
+
|
|
344
|
+
```tsx
|
|
345
|
+
<W3PaymentsProvider
|
|
346
|
+
endpoint="http://localhost:3001/api/payments"
|
|
347
|
+
environment="sandbox"
|
|
348
|
+
appearance={customTheme} // Applied to all widgets
|
|
349
|
+
>
|
|
350
|
+
<W3PaymentWidget amount="100.00" />
|
|
351
|
+
<W3PaymentWidget amount="50.00" /> {/* Both use customTheme */}
|
|
352
|
+
</W3PaymentsProvider>
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
### Advanced Theming
|
|
356
|
+
|
|
357
|
+
#### Responsive Themes
|
|
358
|
+
|
|
359
|
+
```tsx
|
|
360
|
+
const useResponsiveTheme = () => {
|
|
361
|
+
const [theme, setTheme] = useState<W3Appearance>({
|
|
362
|
+
variables: {
|
|
363
|
+
primary: '#2563eb',
|
|
364
|
+
spacingUnit: window.innerWidth < 768 ? '3px' : '4px',
|
|
365
|
+
fontSizeBase: window.innerWidth < 768 ? '13px' : '14px',
|
|
366
|
+
borderRadius: window.innerWidth < 768 ? '6px' : '8px'
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
useEffect(() => {
|
|
371
|
+
const handleResize = () => {
|
|
372
|
+
setTheme(prev => ({
|
|
373
|
+
variables: {
|
|
374
|
+
...prev.variables,
|
|
375
|
+
spacingUnit: window.innerWidth < 768 ? '3px' : '4px',
|
|
376
|
+
fontSizeBase: window.innerWidth < 768 ? '13px' : '14px',
|
|
377
|
+
borderRadius: window.innerWidth < 768 ? '6px' : '8px'
|
|
378
|
+
}
|
|
379
|
+
}));
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
window.addEventListener('resize', handleResize);
|
|
383
|
+
return () => window.removeEventListener('resize', handleResize);
|
|
384
|
+
}, []);
|
|
385
|
+
|
|
386
|
+
return theme;
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
// Usage
|
|
390
|
+
function PaymentPage() {
|
|
391
|
+
const responsiveTheme = useResponsiveTheme();
|
|
392
|
+
|
|
393
|
+
return (
|
|
394
|
+
<W3PaymentWidget appearance={responsiveTheme} />
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
#### Brand Integration
|
|
400
|
+
|
|
401
|
+
```tsx
|
|
402
|
+
// Extract colors from your design system
|
|
403
|
+
const brandTheme: W3Appearance = {
|
|
404
|
+
variables: {
|
|
405
|
+
// Use your brand colors
|
|
406
|
+
primary: 'var(--brand-primary, #2563eb)',
|
|
407
|
+
background: 'var(--surface-primary, #ffffff)',
|
|
408
|
+
text: 'var(--text-primary, #1a1a1a)',
|
|
409
|
+
textSecondary: 'var(--text-secondary, #6b7280)',
|
|
410
|
+
|
|
411
|
+
// Match your typography
|
|
412
|
+
fontFamily: 'var(--font-family, Inter, sans-serif)',
|
|
413
|
+
fontSizeBase: 'var(--text-sm, 14px)',
|
|
414
|
+
|
|
415
|
+
// Match your spacing scale
|
|
416
|
+
spacingUnit: 'var(--spacing-1, 4px)',
|
|
417
|
+
borderRadius: 'var(--radius-md, 8px)'
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
<W3PaymentWidget appearance={brandTheme} />
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
### Advanced CSS Customization
|
|
425
|
+
|
|
426
|
+
For specific styling needs beyond the W3Appearance API:
|
|
254
427
|
|
|
255
428
|
```css
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
429
|
+
/* Target widget container */
|
|
430
|
+
[data-w3-payment-widget] {
|
|
431
|
+
/* Widget-level customization */
|
|
432
|
+
min-height: 500px;
|
|
433
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/* Customize payment buttons */
|
|
437
|
+
[data-w3-payment-widget] button {
|
|
438
|
+
transition: all 0.2s ease;
|
|
262
439
|
}
|
|
263
440
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
441
|
+
[data-w3-payment-widget] button:hover {
|
|
442
|
+
transform: translateY(-1px);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/* Amount input styling */
|
|
446
|
+
[data-w3-payment-widget] input[type="number"] {
|
|
447
|
+
letter-spacing: 0.05em;
|
|
270
448
|
}
|
|
271
449
|
```
|
|
272
450
|
|
|
451
|
+
**Note:** The W3Appearance API handles all standard theming needs. CSS overrides should only be used for specific animations or layout adjustments not covered by the design system.
|
|
452
|
+
|
|
273
453
|
## How It Works
|
|
274
454
|
|
|
275
455
|
1. **Payment Initiation**: User selects amount and payment method
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* W3 Payment Widget Appearance Configuration
|
|
3
|
+
*
|
|
4
|
+
* Following Stripe's appearance API pattern for simple but complete theming.
|
|
5
|
+
* This file belongs in the React package as it's UI-specific.
|
|
6
|
+
*/
|
|
7
|
+
export interface W3Appearance {
|
|
8
|
+
variables?: {
|
|
9
|
+
primary?: string;
|
|
10
|
+
background?: string;
|
|
11
|
+
text?: string;
|
|
12
|
+
textSecondary?: string;
|
|
13
|
+
danger?: string;
|
|
14
|
+
success?: string;
|
|
15
|
+
warning?: string;
|
|
16
|
+
border?: string;
|
|
17
|
+
fontFamily?: string;
|
|
18
|
+
fontSizeBase?: string;
|
|
19
|
+
fontSizeSmall?: string;
|
|
20
|
+
fontSizeLarge?: string;
|
|
21
|
+
fontWeightNormal?: string;
|
|
22
|
+
spacingUnit?: string;
|
|
23
|
+
borderRadius?: string;
|
|
24
|
+
buttonRadius?: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
declare const BUILT_IN_THEMES: Record<string, Required<W3Appearance['variables']>>;
|
|
28
|
+
export declare const getThemeVariables: (themeName?: string, appearance?: W3Appearance) => Record<string, string>;
|
|
29
|
+
export { BUILT_IN_THEMES };
|
|
30
|
+
//# sourceMappingURL=appearance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appearance.d.ts","sourceRoot":"","sources":["../src/appearance.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,EAAE;QAEV,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;QAGhB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAG1B,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAqBD,QAAA,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,CAWxE,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,YAAW,MAAkB,EAC7B,aAAa,YAAY,KACxB,MAAM,CAAC,MAAM,EAAE,MAAM,CAUvB,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,CAAC"}
|