@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.
- package/README.md +45 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,31 +1,62 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @scpdemo/test-sdk-card
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
##
|
|
5
|
+
## Install
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
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 "@
|
|
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
|
-
|
|
55
|
+
export default App;
|
|
56
|
+
```
|
|
26
57
|
|
|
27
|
-
|
|
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`
|
|
62
|
+
The hook `useScPrefixSdk` is also exported if you want direct programmatic access to submit requests and check status from React components.
|