@solgate/embed 0.2.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.
@@ -0,0 +1,87 @@
1
+ /*
2
+ Widget styles. Everything hangs off a few custom properties so the host
3
+ site's own design shows through. Override them on `.sal` or any ancestor.
4
+ */
5
+ .sal {
6
+ --sal-accent: #6b4bff;
7
+ --sal-fg: #14131a;
8
+ --sal-muted: #6a6878;
9
+ --sal-bg: #ffffff;
10
+ --sal-line: #e6e4ee;
11
+ --sal-ok: #1e8f5a;
12
+ --sal-warn: #b3651a;
13
+ --sal-radius: 12px;
14
+ --sal-font: inherit;
15
+
16
+ font-family: var(--sal-font);
17
+ color: var(--sal-fg);
18
+ background: var(--sal-bg);
19
+ border: 1px solid var(--sal-line);
20
+ border-radius: var(--sal-radius);
21
+ max-width: 560px;
22
+ width: 100%;
23
+ box-sizing: border-box;
24
+ line-height: 1.45;
25
+ font-size: 15px;
26
+ }
27
+ .sal *, .sal *::before, .sal *::after { box-sizing: border-box; }
28
+ .sal[data-theme="dark"] {
29
+ --sal-fg: #f2f1f7; --sal-muted: #9c9aae; --sal-bg: #16151c; --sal-line: #2b2a36;
30
+ }
31
+
32
+ .sal-head { padding: 22px 22px 16px; border-bottom: 1px solid var(--sal-line); }
33
+ .sal-head h2 { margin: 0 0 4px; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
34
+ .sal-head p { margin: 0; color: var(--sal-muted); }
35
+ .sal-window { margin-top: 10px; font-size: 13px; color: var(--sal-muted); }
36
+
37
+ /* progress rail: one segment per requirement, fills as they complete */
38
+ .sal-rail { display: flex; gap: 4px; padding: 14px 22px 0; }
39
+ .sal-rail i { flex: 1; height: 4px; border-radius: 2px; background: var(--sal-line); transition: background 240ms ease; }
40
+ .sal-rail i[data-on="true"] { background: var(--sal-accent); }
41
+ .sal-rail i[data-optional="true"][data-on="false"] { background: repeating-linear-gradient(90deg, var(--sal-line) 0 4px, transparent 4px 8px); }
42
+ @media (prefers-reduced-motion: reduce) { .sal-rail i { transition: none; } }
43
+
44
+ .sal-list { list-style: none; margin: 0; padding: 8px 0; }
45
+ .sal-item { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: start; padding: 14px 22px; border-bottom: 1px dashed var(--sal-line); }
46
+ .sal-item:last-child { border-bottom: 0; }
47
+ .sal-item[data-locked="true"] { opacity: 0.55; }
48
+ .sal-mark { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--sal-line); display: grid; place-items: center; font-size: 12px; margin-top: 1px; color: var(--sal-bg); }
49
+ .sal-mark[data-state="passed"] { background: var(--sal-ok); border-color: var(--sal-ok); }
50
+ .sal-mark[data-state="pending"] { border-color: var(--sal-warn); color: var(--sal-warn); }
51
+ .sal-item-body { min-width: 0; }
52
+ .sal-item-title { font-weight: 600; margin: 0; }
53
+ .sal-item-desc { margin: 2px 0 0; color: var(--sal-muted); font-size: 13.5px; }
54
+ .sal-item-meta { margin: 2px 0 0; color: var(--sal-muted); font-size: 12.5px; }
55
+ .sal-reason { margin: 6px 0 0; font-size: 13px; color: var(--sal-warn); }
56
+ .sal-item-action { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
57
+ .sal-points { font-size: 12px; color: var(--sal-muted); white-space: nowrap; }
58
+
59
+ .sal-btn {
60
+ font: inherit; font-size: 14px; font-weight: 600; padding: 8px 14px; border-radius: 999px;
61
+ border: 1px solid var(--sal-accent); background: var(--sal-accent); color: #fff; cursor: pointer; white-space: nowrap;
62
+ }
63
+ .sal-btn:disabled { opacity: 0.55; cursor: default; }
64
+ .sal-btn[data-variant="ghost"] { background: transparent; color: var(--sal-accent); }
65
+ .sal-btn:focus-visible, .sal-input:focus-visible, .sal-wallet:focus-visible { outline: 2px solid var(--sal-accent); outline-offset: 2px; }
66
+
67
+ .sal-input { font: inherit; font-size: 14px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--sal-line); background: var(--sal-bg); color: var(--sal-fg); width: 100%; }
68
+ .sal-form { display: grid; gap: 10px; margin-top: 10px; }
69
+ .sal-form fieldset { border: 0; padding: 0; margin: 0; }
70
+ .sal-form legend { font-weight: 500; margin-bottom: 6px; }
71
+ .sal-form label { display: flex; gap: 8px; align-items: center; font-size: 14px; padding: 3px 0; }
72
+
73
+ .sal-foot { padding: 16px 22px 20px; border-top: 1px solid var(--sal-line); display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
74
+ .sal-status { font-weight: 600; }
75
+ .sal-status[data-ok="true"] { color: var(--sal-ok); }
76
+ .sal-foot small { color: var(--sal-muted); }
77
+ .sal-error { margin: 0 22px 12px; padding: 10px 12px; border-radius: 8px; background: color-mix(in srgb, var(--sal-warn) 12%, transparent); color: var(--sal-warn); font-size: 13.5px; }
78
+
79
+ .sal-wallets { display: grid; gap: 8px; padding: 18px 22px 22px; }
80
+ .sal-wallet { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--sal-line); border-radius: 10px; background: transparent; color: inherit; font: inherit; cursor: pointer; text-align: left; }
81
+ .sal-wallet img { width: 24px; height: 24px; border-radius: 6px; }
82
+ .sal-wallet:hover { border-color: var(--sal-accent); }
83
+ .sal-empty { padding: 18px 22px 22px; color: var(--sal-muted); }
84
+ .sal-empty a { color: var(--sal-accent); }
85
+ .sal-addr { font-variant-numeric: tabular-nums; }
86
+ .sal-ref { display: flex; gap: 8px; align-items: center; }
87
+ .sal-ref code { padding: 2px 8px; border: 1px dashed var(--sal-line); border-radius: 6px; font-size: 13px; }
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@solgate/embed",
3
+ "version": "0.2.0",
4
+ "description": "Drop-in <script> embed of the allowlist widget for sites that don't use React (Webflow, Framer, WordPress, plain HTML).",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/embed.global.js",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "dependencies": {
12
+ "react": "^18.3.1",
13
+ "react-dom": "^18.3.1",
14
+ "@solgate/react": "0.2.0"
15
+ },
16
+ "devDependencies": {
17
+ "@types/react": "^18.3.11",
18
+ "@types/react-dom": "^18.3.0"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/Solgate-code/solgate.git",
23
+ "directory": "packages/embed"
24
+ },
25
+ "homepage": "https://github.com/Solgate-code/solgate",
26
+ "scripts": {
27
+ "build": "tsup src/embed.tsx --format iife --global-name SolGate --minify --clean && cp ../react/src/styles.css dist/styles.css",
28
+ "typecheck": "tsc --noEmit"
29
+ }
30
+ }
package/src/embed.tsx ADDED
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Usage:
3
+ * <link rel="stylesheet" href="https://cdn.example.com/allowlist/styles.css">
4
+ * <div data-allowlist data-base-url="https://api.myproject.xyz" data-campaign="genesis" data-theme="dark"></div>
5
+ * <script src="https://cdn.example.com/allowlist/embed.js" defer></script>
6
+ *
7
+ * or programmatically: SolanaAllowlist.mount(el, { baseUrl, campaignId })
8
+ */
9
+ import { createRoot } from "react-dom/client";
10
+ import { AllowlistWidget, type AllowlistWidgetProps } from "@solgate/react";
11
+
12
+ export function mount(el: HTMLElement, props: AllowlistWidgetProps) {
13
+ const root = createRoot(el);
14
+ root.render(<AllowlistWidget {...props} />);
15
+ return () => root.unmount();
16
+ }
17
+
18
+ function auto() {
19
+ document.querySelectorAll<HTMLElement>("[data-allowlist]").forEach((el) => {
20
+ if (el.dataset.mounted) return;
21
+ el.dataset.mounted = "1";
22
+ mount(el, {
23
+ baseUrl: el.dataset.baseUrl!,
24
+ campaignId: el.dataset.campaign!,
25
+ theme: (el.dataset.theme as "light" | "dark") ?? "light",
26
+ telegramBot: el.dataset.telegramBot,
27
+ onEligible: (entry) => el.dispatchEvent(new CustomEvent("allowlist:eligible", { detail: entry, bubbles: true })),
28
+ });
29
+ });
30
+ }
31
+ if (typeof document !== "undefined") {
32
+ document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", auto) : auto();
33
+ }
package/tsconfig.json ADDED
@@ -0,0 +1 @@
1
+ { "extends": "../../tsconfig.base.json", "include": ["src"] }