@chainrails/react 0.0.0 → 0.0.2

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 +55 -9
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,16 +1,62 @@
1
- # @chainrails/react (local package)
1
+ # @chainrails/react
2
2
 
3
- This local React package exports components and automatically imports its styles.
3
+ React components and hooks for integrating ChainRails payments and blockchain utilities into your app.
4
4
 
5
- Usage
5
+ ## Features
6
6
 
7
- - Import from the alias used in the docs: `@chainrails/react`.
8
- - The package's top-level `index.ts` imports `./PaymentModal/index.css`, so any consumer that imports from the package will automatically include the component styles.
7
+ - **PaymentModal**: Drop-in modal for blockchain payments.
8
+ - **usePaymentModal**: React hook for controlling the modal.
9
+ - **Auto-included styles**: Importing the package automatically loads component CSS.
10
+ - **ChainRails SDK access**: Re-exports ChainRails API and common utilities.
9
11
 
10
- Override styles
12
+ ## Installation
11
13
 
12
- - To override the default styles, include your own CSS with higher specificity or load your CSS after importing the package.
14
+ ```bash
15
+ npm install @chainrails/react
16
+ # or
17
+ pnpm add @chainrails/react
18
+ ```
13
19
 
14
- Docs
20
+ ## Usage
15
21
 
16
- - The `docs` Vite config defines an alias `@chainrails/react` pointing to `react/src` and allows Vite to serve files from the monorepo, so the styles are bundled in dev and production builds.
22
+ ```tsx
23
+ import { chains, tokens, PaymentModal, usePaymentModal, ChainRails } from "@chainrails/react"
24
+
25
+ ChainRails.config({ api_key: <ENTER_API_KEY> })
26
+
27
+ function App() {
28
+ const cr = usePaymentModal({
29
+ to: "0x4F41BCf288E718A36c1e6919c2Dfc2E07d51c675",
30
+ amount: 2,
31
+ chain: chains.BASE,
32
+ token: tokens.USDC,
33
+ onSuccess: () => {
34
+ console.log("Payment Successful")
35
+ },
36
+ })
37
+
38
+ return (
39
+ <div>
40
+ <button onClick={cr.open}> Pay </button>
41
+ <PaymentModal {...cr} />
42
+ </div>
43
+ )
44
+ }
45
+ ```
46
+
47
+ ## Style Customization
48
+
49
+ - Default styles are loaded automatically.
50
+ - To override, add your own CSS with higher specificity or import your CSS after this package.
51
+
52
+ ## Aliases & Monorepo
53
+
54
+ - The package is aliased as `@chainrails/react` in Vite config for local development.
55
+ - Styles and components are bundled for both dev and production.
56
+
57
+ ## Exports
58
+
59
+ - `PaymentModal` — React component for payments
60
+ - `usePaymentModal` — Modal state management hook
61
+ - `chains`, `tokens`, `ChainRails` — Blockchain utilities from `@chainrails/common`
62
+ - `CRAPI` — ChainRails SDK API
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chainrails/react",
3
3
  "sideEffects": false,
4
- "version": "0.0.0",
4
+ "version": "0.0.2",
5
5
  "description": "",
6
6
  "license": "MIT",
7
7
  "repository": {