Skip to content

Commit 9cbf090

Browse files
chore(repo): add react-grab to clerk-js sandbox (#8666)
Co-authored-by: Alex Carpenter <alex.carpenter@clerk.dev>
1 parent f76a808 commit 9cbf090

5 files changed

Lines changed: 301 additions & 64 deletions

File tree

.changeset/old-months-grow.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

.changeset/public-parts-jog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

packages/clerk-js/sandbox/app.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ function assertClerkIsLoaded(c: ClerkType | undefined): asserts c is ClerkType {
186186
function mountIndex(element: HTMLDivElement) {
187187
assertClerkIsLoaded(Clerk);
188188
const user = Clerk.user;
189-
element.innerHTML = `<pre class="text-left whitespace-pre overflow-x-auto bg-white p-4 border border-gray-100 rounded-md text-sm"><code>${JSON.stringify({ user }, null, 2)}</code></pre>`;
189+
element.innerHTML = `<pre class="text-left whitespace-pre overflow-x-auto text-muted-foreground p-4 border border-[var(--color-sidebar-border)] rounded-md text-sm"><code>${JSON.stringify({ user }, null, 2)}</code></pre>`;
190190
}
191191

192192
function mountOpenButton(element: HTMLDivElement, label: string, openFn: (props: any) => void, props: any) {
@@ -301,8 +301,17 @@ async function initControls() {
301301
varFolder.addBinding(PARAMS, 'borderRadius').on('change', applyVariables);
302302
varFolder.addButton({ title: 'Reset' }).on('click', () => {
303303
Object.assign(PARAMS, VARIABLE_DEFAULTS);
304+
for (const key of Object.keys(VARIABLE_DEFAULTS)) {
305+
sessionStorage.removeItem(key);
306+
}
304307
pane.refresh();
305-
applyVariables();
308+
const currentAppearance = Clerk.__internal_getOption('appearance') ?? {};
309+
void Clerk.__internal_updateProps({
310+
appearance: {
311+
...currentAppearance,
312+
variables: undefined,
313+
},
314+
});
306315
});
307316

308317
// Options folder
@@ -467,8 +476,11 @@ void (async () => {
467476
}
468477

469478
const initialVariables: Record<string, string> = {};
470-
for (const [key, def] of Object.entries(VARIABLE_DEFAULTS)) {
471-
initialVariables[key] = sessionStorage.getItem(key) ?? def;
479+
for (const key of Object.keys(VARIABLE_DEFAULTS)) {
480+
const stored = sessionStorage.getItem(key);
481+
if (stored !== null) {
482+
initialVariables[key] = stored;
483+
}
472484
}
473485

474486
const initialLocale = sessionStorage.getItem('localization') ?? 'enUS';
@@ -479,7 +491,11 @@ void (async () => {
479491
signUpUrl: '/sign-up',
480492
ui: { ClerkUI: window.__internal_ClerkUICtor },
481493
appearance: {
482-
...(initialTheme ? { theme: initialTheme } : { variables: initialVariables }),
494+
...(initialTheme
495+
? { theme: initialTheme }
496+
: Object.keys(initialVariables).length > 0
497+
? { variables: initialVariables }
498+
: {}),
483499
...(Object.keys(initialAppearanceOptions).length ? { options: initialAppearanceOptions } : {}),
484500
},
485501
localization: l[initialLocale as keyof typeof l],

0 commit comments

Comments
 (0)