-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add PR fixes and code health improvements
- Loading branch information
1 parent
4a8c620
commit e6f49ec
Showing
12 changed files
with
159 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
node_modules/ | ||
./src/archive/ | ||
.src/rainfly/ | ||
**/README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 42 additions & 19 deletions
61
src/rainfly/src/lib/components/nav/items/NavExamples.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,62 @@ | ||
<script> | ||
import NavItem from '$lib/components/nav/NavItem.svelte'; | ||
import NavDropdownItem from '$lib/components/nav/NavDropdownItem.svelte'; | ||
import {onMount} from 'svelte'; | ||
import {fetchTextFile} from '$lib/utils/file-utils.js'; | ||
import { | ||
loadEditorProcessor, | ||
loadEditorMain, | ||
} from '$lib/../routes/+page.svelte'; | ||
/** | ||
* @typedef {Object} Example | ||
* @property {string} name - The name of the example | ||
* @property {string} mainCodeUrl - URL to the AudioWorkletNode code | ||
* @property {string} processorCodeUrl - URL to the AudioWorkletProcessor code | ||
*/ | ||
/** @type Example[] */ | ||
let examples = []; | ||
onMount(async () => { | ||
buildExamples(); | ||
}); | ||
/** | ||
* Load processor and main code from URL to Editor | ||
* @param {string} mainCodeUrl - URL to main code | ||
* @param {string} processorCodeUrl - URL to processor code | ||
*/ | ||
async function loadExample(mainCodeUrl, processorCodeUrl) { | ||
loadEditorMain((await fetchTextFile(mainCodeUrl)).data, 'main'); | ||
loadEditorProcessor( | ||
(await fetchTextFile(processorCodeUrl)).data, | ||
'processor', | ||
); | ||
try { | ||
loadEditorMain((await fetchTextFile(mainCodeUrl)).data, 'main'); | ||
loadEditorProcessor( | ||
(await fetchTextFile(processorCodeUrl)).data, | ||
'processor', | ||
); | ||
} catch (/** @type any */ e) { | ||
loadEditorProcessor(`${e.message}`, 'processor'); | ||
} | ||
} | ||
/** | ||
* Build examples dropdown from examples.json | ||
*/ | ||
async function buildExamples() { | ||
const response = await fetch('examples/examples.json'); | ||
const data = await response.json(); | ||
examples = data.examples; | ||
} | ||
</script> | ||
|
||
<NavItem name="Examples"> | ||
<NavDropdownItem | ||
on:click={() => { | ||
loadExample('examples/bypass/main.js', 'examples/bypass/processor.js'); | ||
}} | ||
> | ||
Hello Bypass | ||
</NavDropdownItem> | ||
<NavDropdownItem | ||
on:click={() => { | ||
loadExample('examples/sine/main.js', 'examples/sine/processor.js'); | ||
}} | ||
> | ||
Hello Sine | ||
</NavDropdownItem> | ||
{#each examples as example} | ||
<NavDropdownItem | ||
on:click={() => { | ||
loadExample(example.mainCodeUrl, example.processorCodeUrl); | ||
}} | ||
> | ||
{example.name} | ||
</NavDropdownItem> | ||
{/each} | ||
</NavItem> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.