UNPKG

storybook-addon-playground

Version:

A playground to enable consumers learn how to use the component library or to reproduce bugs

37 lines (35 loc) 1.05 kB
const STORAGE_KEY = "storybook-playground-v1"; function saveCodeToStorage(code) { try { localStorage.setItem(STORAGE_KEY, JSON.stringify(code)); } catch (error) { console.warn("[Playground] Failed to save code to localStorage:", error); } } function loadCodeFromStorage() { try { const stored = localStorage.getItem(STORAGE_KEY); if (!stored) return null; const code = JSON.parse(stored); if (code && typeof code.jsx === "string" && typeof code.css === "string") { return code; } return null; } catch (error) { console.warn("[Playground] Failed to load code from localStorage:", error); return null; } } function clearStoredCode() { try { localStorage.removeItem(STORAGE_KEY); } catch (error) { console.warn("[Playground] Failed to clear stored code:", error); } } export { clearStoredCode, loadCodeFromStorage, saveCodeToStorage }; //# sourceMappingURL=persistence-utils.js.map