Created
June 15, 2020 15:52
-
-
Save kstewart83/ef240045096f573405d30c352b08380c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import confetti from 'canvas-confetti'; | |
import * as Crank from "@bikeshaving/crank"; | |
import { renderer as dom } from "@bikeshaving/crank/dom"; | |
confetti.create(document.getElementById('canvas'), { | |
resize: true, | |
useWorker: true, | |
})({ particleCount: 200, spread: 200 }); | |
function Greeting({ name = 'World' }) { | |
return <div>Hello, {name}!</div>; | |
} | |
function* Counter(this: Crank.Context) { | |
let count = 0; | |
while (true) { | |
count++; | |
yield ( | |
<div> | |
You have updated this component {count}{' '} | |
{count === 1 ? ' time' : ' times'} | |
</div> | |
); | |
} | |
} | |
function App() { | |
return ( | |
<Crank.Fragment> | |
<Greeting name="You" /> | |
<Counter /> | |
</Crank.Fragment> | |
); | |
} | |
document.addEventListener("DOMContentLoaded", () => { | |
dom.render(<App />, document.getElementById("app") as HTMLDivElement); | |
}); | |
// @ts-ignore | |
if (import.meta.hot) { | |
// @ts-ignore | |
import.meta.hot.accept(() => { | |
dom.render(<App />, document.getElementById("app") as HTMLDivElement); | |
}); | |
/* | |
// @ts-ignore | |
import.meta.hot.dispose(() => { | |
});*/ | |
} |
This file contains hidden or 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
{ | |
"name": "@snowpack/app-template-blank", | |
"version": "1.2.0", | |
"license": "MIT", | |
"keywords": [ | |
"csa-template" | |
], | |
"publishConfig": { | |
"access": "public" | |
}, | |
"scripts": { | |
"start": "snowpack dev", | |
"build": "snowpack build", | |
"format": "prettier --write \"src/**/*.js\"", | |
"lint": "prettier --check \"src/**/*.js\"", | |
"test": "echo \"This template does not include a test runner by default.\" && exit 1" | |
}, | |
"dependencies": { | |
"@bikeshaving/crank": "^0.1.6", | |
"canvas-confetti": "^1.2.0", | |
"typescript": "^3.9.5" | |
}, | |
"devDependencies": { | |
"prettier": "^2.0.0", | |
"snowpack": "^2.5.0" | |
}, | |
"gitHead": "795f4311d79a70cc9f19f21b512b7f8675d73f17" | |
} |
This file contains hidden or 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
{ | |
"scripts": { | |
"mount:public": "mount public --to /", | |
"mount:src": "mount src --to /_dist_", | |
"build:tsx": "esbuild --jsx-factory=Crank.createElement --jsx-fragment=Fragment --loader=tsx" | |
}, | |
"plugins": [ | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment