Replies: 8 comments 11 replies
-
I've started making a spinning Web Browser in Crank Native: https://play.nativescript.org/?template=play-react&id=LB4qRS&v=4 It accesses native iOS methods to inject some JS into the webpage to make things, uh, spin. |
Beta Was this translation helpful? Give feedback.
-
Built an iOS SpriteKit game launcher in Crank Native, which confirms that the NativeScript Playground supports generators! https://play.nativescript.org/?template=play-react&id=ptkGyA&v=8 |
Beta Was this translation helpful? Give feedback.
-
I came across this on Twitter: https://codesandbox.io/embed/crankjs-final-form-jk3q9?file=/src/index.js&codemirror=1 |
Beta Was this translation helpful? Give feedback.
-
I copied the code examples from https://crank.js.org/guides/components to https://observablehq.com/@btheado/crank-js and translated them to use htm. All the examples are live-editable and runnable. When I first read about crank.js the other day, I was reminded of the way observablehq uses generators and async generators. I haven't yet compare/contrasted them, so I don't know how similar they are. I thought I'd play with crank on observable with the eventual goal of finding out. The above page is the result. Update: I also added the code examples from https://crank.js.org/guides/async-components. In addition, I found this other example also on observable: https://observablehq.com/@radames/hello-crank-js |
Beta Was this translation helpful? Give feedback.
-
I just put this together using the undocumented /** @jsx createElement */
import { createElement, Fragment } from "@bikeshaving/crank";
import { renderer } from "@bikeshaving/crank/dom";
function Avatar() {
const user = this.get("user");
return <img alt={`${user.first_name} ${user.last_name}`} src={user.avatar} />;
}
function User() {
const user = this.get("user");
return (
user && (
<div>
<p>{user.first_name}</p>
<Avatar image={user.avatar} />
</div>
)
);
}
async function* App() {
try {
let value = "";
const onChange = e => {
value = e.target.value;
this.refresh();
};
const onSubmit = async (e) => {
e.preventDefault();
const response = await fetch(`https://reqres.in/api/users/${value}`);
const user = await response.json();
this.set("user", user.data);
this.refresh();
};
for await (let _ of this) {
yield (
<Fragment>
<form onsubmit={onSubmit}>
<label for="userSelector">Select a User Number (1 - 10)</label>
<input
value={value}
onchange={onChange}
id="userSelector"
type="number"
max="10"
min="1"
/>
<button type="submit">Get new User</button>
</form>
<p>Selected Number: {value}</p>
<User />
</Fragment>
);
}
} catch (error) {
return <h1>error getting data </h1>;
}
}
renderer.render(<App />, document.body); The Also - |
Beta Was this translation helpful? Give feedback.
-
Here‘s the XState calculator example in Crank: https://codesandbox.io/s/xstate-calculator-with-crankjs-u9r0f?file=/src/index.tsx I see that there could probably be some kinda of plugin created which refreshes on transition automatically I just don’t know what it should look like yet. In the meantime it just works with a couple helper functions and an explicit refresh call. |
Beta Was this translation helpful? Give feedback.
-
https://github.com/brainkim/crank-three-boxes Three.js boxes demo. Couldn’t get it to work in Code Sandbox for some reason. If you are interested in writing a Three.js renderer for Crank reach out and I will guide you through the forbidden/unstable renderer APIs. |
Beta Was this translation helpful? Give feedback.
-
Just playing around with Material Design components (actually, "component", at the moment; only a Button so far) with Crank: |
Beta Was this translation helpful? Give feedback.
-
I see your comments and appreciate all the design feedback, but I must admit, writing long technical responses can be both intellectually and emotionally draining. Know that I see you and I will get back to you ASAP about my thoughts on all of this stuff.
One thing that I love more than anything is seeing examples! Have you made Snake or Tetris? Let me know in this issue 🙆♀️
Beta Was this translation helpful? Give feedback.
All reactions