mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-26 13:08:28 +00:00
boilerplate for tutorial + minirepl
This commit is contained in:
parent
bad6cf0ed7
commit
aa850918ad
3
repl/.gitignore
vendored
3
repl/.gitignore
vendored
@ -1,4 +1,5 @@
|
|||||||
.snowpack
|
.snowpack
|
||||||
build
|
build
|
||||||
node_modules
|
node_modules
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
.parcel-cache
|
||||||
5953
repl/package-lock.json
generated
5953
repl/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,8 @@
|
|||||||
"test": "web-test-runner \"src/**/*.test.tsx\"",
|
"test": "web-test-runner \"src/**/*.test.tsx\"",
|
||||||
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx}\"",
|
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx}\"",
|
||||||
"lint": "prettier --check \"src/**/*.{js,jsx,ts,tsx}\"",
|
"lint": "prettier --check \"src/**/*.{js,jsx,ts,tsx}\"",
|
||||||
"peggy": "peggy -o krill-parser.js --format es ./krill.pegjs"
|
"peggy": "peggy -o krill-parser.js --format es ./krill.pegjs",
|
||||||
|
"tutorial": "parcel src/tutorial/index.html"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tonaljs/tonal": "^4.6.5",
|
"@tonaljs/tonal": "^4.6.5",
|
||||||
@ -26,6 +27,8 @@
|
|||||||
"webmidi": "^2.5.2"
|
"webmidi": "^2.5.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@mdx-js/react": "^1.6.22",
|
||||||
|
"@parcel/transformer-mdx": "^2.3.1",
|
||||||
"@snowpack/plugin-dotenv": "^2.1.0",
|
"@snowpack/plugin-dotenv": "^2.1.0",
|
||||||
"@snowpack/plugin-postcss": "^1.4.3",
|
"@snowpack/plugin-postcss": "^1.4.3",
|
||||||
"@snowpack/plugin-react-refresh": "^2.5.0",
|
"@snowpack/plugin-react-refresh": "^2.5.0",
|
||||||
@ -41,6 +44,7 @@
|
|||||||
"@web/test-runner": "^0.13.3",
|
"@web/test-runner": "^0.13.3",
|
||||||
"autoprefixer": "^10.4.2",
|
"autoprefixer": "^10.4.2",
|
||||||
"chai": "^4.3.4",
|
"chai": "^4.3.4",
|
||||||
|
"parcel": "^2.3.1",
|
||||||
"peggy": "^1.2.0",
|
"peggy": "^1.2.0",
|
||||||
"postcss": "^8.4.6",
|
"postcss": "^8.4.6",
|
||||||
"prettier": "^2.2.1",
|
"prettier": "^2.2.1",
|
||||||
|
|||||||
31
repl/src/tutorial/MiniRepl.tsx
Normal file
31
repl/src/tutorial/MiniRepl.tsx
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import React, { useMemo } from 'react';
|
||||||
|
import * as Tone from 'tone';
|
||||||
|
import useRepl from '../useRepl';
|
||||||
|
|
||||||
|
function MiniRepl({ tune }) {
|
||||||
|
const defaultSynth = useMemo(() => {
|
||||||
|
return new Tone.PolySynth().chain(new Tone.Gain(0.5), Tone.Destination).set({
|
||||||
|
oscillator: { type: 'triangle' },
|
||||||
|
envelope: {
|
||||||
|
release: 0.01,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
const { code, setCode, setPattern, error, cycle, dirty, log, togglePlay } = useRepl({
|
||||||
|
tune,
|
||||||
|
defaultSynth,
|
||||||
|
});
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<textarea value={code} onChange={(e) => setCode(e.target.value)} />
|
||||||
|
<button
|
||||||
|
className="flex-none w-full border border-gray-700 p-2 bg-slate-700 hover:bg-slate-500"
|
||||||
|
onClick={() => togglePlay()}
|
||||||
|
>
|
||||||
|
{cycle.started ? 'pause' : 'play'}
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default MiniRepl;
|
||||||
14
repl/src/tutorial/index.html
Normal file
14
repl/src/tutorial/index.html
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<div id="root"></div>
|
||||||
|
<script type="module">
|
||||||
|
import React from 'react';
|
||||||
|
import ReactDOM from 'react-dom';
|
||||||
|
import * as React from 'react';
|
||||||
|
import Tutorial from './tutorial.mdx';
|
||||||
|
|
||||||
|
ReactDOM.render(
|
||||||
|
<React.StrictMode>
|
||||||
|
<Tutorial />
|
||||||
|
</React.StrictMode>,
|
||||||
|
document.getElementById('root')
|
||||||
|
);
|
||||||
|
</script>
|
||||||
7
repl/src/tutorial/tutorial.mdx
Normal file
7
repl/src/tutorial/tutorial.mdx
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import MiniRepl from './MiniRepl';
|
||||||
|
|
||||||
|
# Strudel Tutorial
|
||||||
|
|
||||||
|
hello!!!!
|
||||||
|
|
||||||
|
<MiniRepl tune="C3.m" />
|
||||||
Loading…
x
Reference in New Issue
Block a user