new idea for writer
This commit is contained in:
parent
a3a1f6f4f9
commit
c2c66ce73c
1 changed files with 42 additions and 0 deletions
42
html/write.tsx
Normal file
42
html/write.tsx
Normal file
|
@ -0,0 +1,42 @@
|
|||
import { toChildArray, ComponentChildren } from "preact";
|
||||
import { Main, render_and_copy } from "./common.tsx";
|
||||
|
||||
// idea is to have buttons you can click to type out words, should be fun
|
||||
// (and maybe possible)
|
||||
// new idea: type out eggbug or you LOSE
|
||||
const Key = ({ letter }: { letter: string }) => (
|
||||
<details class="key">
|
||||
<summary class="keycap">{letter}</summary>
|
||||
<div
|
||||
class="keyout"
|
||||
style={{ left: (sentence.indexOf(letter) ?? 0) + "em" }}
|
||||
>
|
||||
{letter}
|
||||
</div>
|
||||
</details>
|
||||
);
|
||||
|
||||
const sentence = "cwm fjord bank glyphs vext quiz";
|
||||
|
||||
const KeyRow = ({ keys }: { keys: string }) => (
|
||||
<div class="keyrow">
|
||||
{...keys.split("").map(letter => <Key letter={letter} />)}
|
||||
</div>
|
||||
);
|
||||
|
||||
const Keyboard = ({ children }: { children: ComponentChildren }) => (
|
||||
<div class="keyboard">{...toChildArray(children)}</div>
|
||||
);
|
||||
|
||||
const Out = () => <div class="out"></div>;
|
||||
|
||||
render_and_copy(
|
||||
<Main>
|
||||
<Keyboard>
|
||||
<KeyRow keys="qwertyuiop" />
|
||||
<KeyRow keys="asdfghjkl" />
|
||||
<KeyRow keys="zxcvbnm" />
|
||||
</Keyboard>
|
||||
<Out />
|
||||
</Main>
|
||||
);
|
Loading…
Reference in a new issue