@scpdemo/test-sdk-card 1.2.0 → 1.3.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.
Files changed (2) hide show
  1. package/README.md +45 -14
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,31 +1,62 @@
1
- # @scallop-card/sdk-react
1
+ # @scpdemo/test-sdk-card
2
2
 
3
- This package exposes the React hook (`useScPrefixSdk`) and the iframe wrapper component (`ScPrefixWidgetWrapper`) for embedding the Scallop Card widget that now lives inside the Next.js iframe app.
3
+ React wrapper around the Scallop card widget. Ships a single component (`ScPrefixWidgetWrapper`) that renders the hosted iframe. No other setup is needed in the consuming app besides providing the iframe URL.
4
4
 
5
- ## Embedding the widget
5
+ ## Install
6
6
 
7
- 1. Deploy the iframe app located at `packages/iframe-app` (or run it locally via `pnpm --filter @scallop-card/iframe-app dev`).
8
- 2. Provide the iframe URL via env (`VITE_SC_PREFIX_IFRAME_URL`, `NEXT_PUBLIC_SC_PREFIX_IFRAME_URL`, `REACT_APP_SC_PREFIX_IFRAME_URL`, or `SC_PREFIX_IFRAME_URL`) or pass it explicitly:
7
+ ```bash
8
+ npm install @scpdemo/test-sdk-card
9
+ # or: pnpm add @scpdemo/test-sdk-card
10
+ ```
11
+
12
+ ## Configure the iframe URL
13
+
14
+ Set one of these env vars in your app (the wrapper will pick any of them):
15
+
16
+ - `REACT_APP_SC_PREFIX_IFRAME_URL` (Create React App)
17
+ - `VITE_SC_PREFIX_IFRAME_URL` (Vite)
18
+ - `NEXT_PUBLIC_SC_PREFIX_IFRAME_URL` (Next.js)
19
+ - `SC_PREFIX_IFRAME_URL` (generic fallback)
20
+
21
+ Example `.env` for CRA:
22
+
23
+ ```
24
+ REACT_APP_SC_PREFIX_IFRAME_URL=https://your-hosted-iframe-app.example.com
25
+ ```
26
+
27
+ You can also pass `iframeUrl` directly as a prop if you prefer not to use env vars.
28
+
29
+ ## Usage
9
30
 
10
31
  ```tsx
11
- import { ScPrefixWidgetWrapper } from "@scallop-card/sdk-react";
32
+ import { ScPrefixWidgetWrapper } from "@scpdemo/test-sdk-card";
33
+
34
+ function App() {
35
+ const iframeUrl = process.env.REACT_APP_SC_PREFIX_IFRAME_URL;
36
+
37
+ if (!iframeUrl) {
38
+ return (
39
+ <div>
40
+ Missing <code>REACT_APP_SC_PREFIX_IFRAME_URL</code> in your <code>.env</code>.
41
+ Add it and restart the dev server.
42
+ </div>
43
+ );
44
+ }
12
45
 
13
- export function CardWidget(): JSX.Element {
14
46
  return (
15
47
  <ScPrefixWidgetWrapper
16
48
  style={{ minHeight: "720px" }}
17
49
  allow="clipboard-write"
50
+ iframeUrl={iframeUrl} // optional if the env var is set
18
51
  />
19
52
  );
20
53
  }
21
- ```
22
-
23
- The component forwards any additional props to the underlying `<iframe>` element, so you can control sizing, permissions, sandboxing, and more.
24
54
 
25
- ## Server-side API proxy
55
+ export default App;
56
+ ```
26
57
 
27
- The iframe app hides the raw SDK calls (`scPrefixSubmitRequest`, `scPrefixGetStatus`) behind server-side API routes. Configure your Scallop credentials via environment variables (see `packages/iframe-app/.env.example`).
58
+ All extra props are forwarded to the underlying `<iframe>`, so you can control sizing, permissions, sandboxing, `className`, etc.
28
59
 
29
- ## Hooks
60
+ ## Hooks (optional)
30
61
 
31
- `useScPrefixSdk` remains available if you need direct access to the core SDK from React components (for example, to build custom dashboards or orchestration flows).
62
+ The hook `useScPrefixSdk` is also exported if you want direct programmatic access to submit requests and check status from React components.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scpdemo/test-sdk-card",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "React hook + iframe wrapper for the Scallop card SDK",
5
5
  "license": "MIT",
6
6
  "type": "module",