Adding clear-storage helper button

master
Dustin Swan 5 hours ago
parent 8c3237e0db
commit eef4daf8ec
Signed by: dustinswan
GPG Key ID: 30D46587E2100467

@ -23,11 +23,17 @@ canvas {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
#clear-storage {
position: absolute;
top: 0; right: 0;
}
</style> </style>
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>
<button id="clear-storage">Clear Storage</button>
<script type="module" src="/src/main.ts"></script> <script type="module" src="/src/main.ts"></script>
</body> </body>
</html> </html>

@ -6,7 +6,7 @@ import { runApp } from './runtime';
import { builtins } from './builtins'; import { builtins } from './builtins';
import { CGError } from './error'; import { CGError } from './error';
import { createStore, startTracking, stopTracking, buildDependents } from './store'; import { createStore, startTracking, stopTracking, buildDependents } from './store';
import { loadStore } from './persistence'; import { loadStore, clearStore } from './persistence';
import stdlibCode from './stdlib.cg?raw'; import stdlibCode from './stdlib.cg?raw';
import designTokensCode from './design-tokens.cg?raw'; import designTokensCode from './design-tokens.cg?raw';
@ -19,6 +19,11 @@ import textInputCode from './textinput-test.cg?raw';
const canvas = document.createElement('canvas') as HTMLCanvasElement; const canvas = document.createElement('canvas') as HTMLCanvasElement;
document.body.appendChild(canvas); document.body.appendChild(canvas);
const clearButton = document.getElementById('clear-storage');
if (clearButton) {
clearButton.onclick = () => clearStore();
}
const cgCode = stdlibCode + '\n' + const cgCode = stdlibCode + '\n' +
designTokensCode + '\n' + designTokensCode + '\n' +
uiComponentsCode + '\n' + uiComponentsCode + '\n' +

@ -25,5 +25,5 @@ export function loadStore(): Record<string, { body: AST, source: string }> | nul
} }
export function clearStore() { export function clearStore() {
localStorage.remove(STORAGE_KEY); localStorage.removeItem(STORAGE_KEY);
} }

Loading…
Cancel
Save