diff --git a/website/src/repl/Repl.jsx b/website/src/repl/Repl.jsx index 3d3117ae..7813ae98 100644 --- a/website/src/repl/Repl.jsx +++ b/website/src/repl/Repl.jsx @@ -247,9 +247,15 @@ export function Repl({ embedded = false }) { stop(); } }; - const handleUpdate = (newCode) => { + const handleUpdate = async (newCode, reset = false) => { + if (reset) { + clearCanvas(); + resetLoadedSounds(); + scheduler.setCps(1); + await prebake(); // declare default samples + } (newCode || isDirty) && activateCode(newCode); - logger('[repl] code updated! tip: you can also update the code by pressing ctrl+enter', 'highlight'); + logger('[repl] code updated!'); }; const handleShuffle = async () => { diff --git a/website/src/repl/panel/PatternsTab.jsx b/website/src/repl/panel/PatternsTab.jsx index 1b19c8e0..37cac6f7 100644 --- a/website/src/repl/panel/PatternsTab.jsx +++ b/website/src/repl/panel/PatternsTab.jsx @@ -9,7 +9,9 @@ import { duplicateActivePattern, getUserPattern, renameActivePattern, + addUserPattern, } from '../../settings.mjs'; +import { logger } from '@strudel.cycles/core'; function classNames(...classes) { return classes.filter(Boolean).join(' '); @@ -18,16 +20,15 @@ function classNames(...classes) { export function PatternsTab({ context }) { const { userPatterns, activePattern } = useSettings(); return ( -
+
-

Pattern Collection

-
+
+ +
+
+ {Object.entries(userPatterns).map(([key, up]) => ( + { + const { code } = up; + setActivePattern(key); + context.handleUpdate(code, true); + }} + > + {key} + + ))}
- {Object.entries(userPatterns).map(([key, up]) => ( - { - const { code } = up; - setActivePattern(key); - context.handleUpdate(code); - }} - > - {key} - - ))}

Examples

- {Object.entries(tunes).map(([key, tune]) => ( - { - setActivePattern(key); - context.handleUpdate(tune); - }} - > - {key} - - ))} +
+ {Object.entries(tunes).map(([key, tune]) => ( + { + setActivePattern(key); + context.handleUpdate(tune, true); + }} + > + {key} + + ))} +
); } - -/* -selectable examples -if example selected - type character -> create new user pattern with exampleName_n - even if -clicking (+) opens the "new" example with same behavior as above -*/ diff --git a/website/src/repl/panel/SoundsTab.jsx b/website/src/repl/panel/SoundsTab.jsx index aeda4f6d..fe32212d 100644 --- a/website/src/repl/panel/SoundsTab.jsx +++ b/website/src/repl/panel/SoundsTab.jsx @@ -42,8 +42,8 @@ export function SoundsTab() { }); }); return ( -
-
+
+
settingsMap.setKey('soundsFilter', value)} @@ -55,7 +55,7 @@ export function SoundsTab() { }} >
-
+
{soundEntries.map(([name, { data, onTrigger }]) => (