mirror of
https://github.com/seigler/aurebesh
synced 2025-07-26 01:06:12 +00:00
better
This commit is contained in:
parent
bd73627be0
commit
9dd15606d6
4 changed files with 114 additions and 26 deletions
20
src/components/Drawer.tsx
Normal file
20
src/components/Drawer.tsx
Normal file
|
@ -0,0 +1,20 @@
|
|||
import { useSignal } from "@preact/signals";
|
||||
import { PropsWithChildren } from "preact/compat";
|
||||
|
||||
type DrawerProps = PropsWithChildren<{}>;
|
||||
|
||||
export default function Drawer({ children }: DrawerProps) {
|
||||
const isOpen = useSignal(false);
|
||||
return (
|
||||
<div class="drawer" data-open={isOpen}>
|
||||
<button
|
||||
onClick={() => {
|
||||
isOpen.value = !isOpen.value;
|
||||
}}
|
||||
>
|
||||
{isOpen.value ? "Hide 🞃" : "Expand 🞁"}
|
||||
</button>
|
||||
{isOpen.value && children}
|
||||
</div>
|
||||
);
|
||||
}
|
|
@ -5,6 +5,7 @@ import ReadingBox from "./ReadingBox";
|
|||
import Reference from "./Reference";
|
||||
import FontPicker from "./FontPicker";
|
||||
import DualText from "./DualText";
|
||||
import Drawer from "./Drawer";
|
||||
|
||||
export default function Main() {
|
||||
useEffect(() => {
|
||||
|
@ -28,12 +29,14 @@ export default function Main() {
|
|||
</header>
|
||||
<main>
|
||||
<div class="content">
|
||||
<FontPicker />
|
||||
<ReadingBox />
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
<Reference />
|
||||
<Drawer>
|
||||
<FontPicker />
|
||||
<Reference />
|
||||
</Drawer>
|
||||
</footer>
|
||||
</>
|
||||
);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { useSignal } from "@preact/signals";
|
||||
import localforage from "localforage";
|
||||
import { useEffect } from "preact/hooks";
|
||||
import { useEffect, useRef } from "preact/hooks";
|
||||
import DualText from "./DualText";
|
||||
|
||||
export default function ReadingBox() {
|
||||
const isEditing = useSignal(false);
|
||||
const editModalRef = useRef<HTMLDialogElement>(null);
|
||||
const contents =
|
||||
useSignal(`It is a period of civil war. Rebel spaceships, striking from a hidden base, have won their first victory against the evil Galactic Empire.
|
||||
|
||||
|
@ -25,32 +25,40 @@ Pursued by the Empire's sinister agents, Princess Leia races home aboard her sta
|
|||
}, []);
|
||||
return (
|
||||
<div class="readingbox">
|
||||
<span>
|
||||
<label>
|
||||
Edit{" "}
|
||||
<input
|
||||
type="checkbox"
|
||||
id="edit-toggle"
|
||||
selected={isEditing}
|
||||
<dialog ref={editModalRef} title="Update text">
|
||||
<div className="edit-modal-contents">
|
||||
<h2>Update text</h2>
|
||||
<textarea
|
||||
autofocus
|
||||
class="readingbox-textarea"
|
||||
id="reading-material"
|
||||
value={contents}
|
||||
onChange={(event) => {
|
||||
isEditing.value = event.currentTarget.checked;
|
||||
const newValue = event.currentTarget.value;
|
||||
contents.value = newValue;
|
||||
localforage.setItem("aurebesh-text", newValue);
|
||||
}}
|
||||
spellCheck={false}
|
||||
/>
|
||||
</label>
|
||||
</span>
|
||||
{isEditing.value && (
|
||||
<textarea
|
||||
class="readingbox-textarea"
|
||||
id="reading-material"
|
||||
value={contents}
|
||||
onChange={(event) => {
|
||||
const newValue = event.currentTarget.value;
|
||||
contents.value = newValue;
|
||||
localforage.setItem("aurebesh-text", newValue);
|
||||
<button
|
||||
onClick={() => {
|
||||
editModalRef.current?.close();
|
||||
}}
|
||||
>
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
<div>
|
||||
<button
|
||||
onClick={() => {
|
||||
editModalRef.current?.showModal();
|
||||
}}
|
||||
spellCheck={false}
|
||||
/>
|
||||
)}
|
||||
>
|
||||
Edit
|
||||
</button>
|
||||
</div>
|
||||
<div class="readingbox-text aurebesh">
|
||||
<DualText text={contents.value} hover />
|
||||
</div>
|
||||
|
|
|
@ -71,6 +71,7 @@
|
|||
--color-text-light: #0009;
|
||||
--color-background1: #eed;
|
||||
--color-background2: #bba;
|
||||
--color-backdrop: #eed3;
|
||||
--color-accent1: #900;
|
||||
--color-accent2: #b50;
|
||||
--font-aurebesh: Droidobesh;
|
||||
|
@ -115,6 +116,38 @@ input[type="checkbox"] {
|
|||
width: 0.75em;
|
||||
}
|
||||
|
||||
.visually-hidden {
|
||||
clip: rect(0 0 0 0);
|
||||
clip-path: inset(50%);
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
white-space: nowrap;
|
||||
width: 1px;
|
||||
}
|
||||
|
||||
.buttonlike {
|
||||
appearance: button;
|
||||
}
|
||||
|
||||
dialog {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 4;
|
||||
background-color: var(--color-background2);
|
||||
border: 1px solid var(--color-background1);
|
||||
padding: 1rem;
|
||||
}
|
||||
dialog::backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
width: "100%";
|
||||
height: "100%";
|
||||
z-index: 3;
|
||||
background-color: var(--color-backdrop);
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
#app {
|
||||
flex-grow: 1;
|
||||
display: flex;
|
||||
|
@ -142,9 +175,23 @@ h1 {
|
|||
--color-text-light: #fff9;
|
||||
--color-background1: #111;
|
||||
--color-background2: #333;
|
||||
--color-backdrop: #1113;
|
||||
}
|
||||
}
|
||||
|
||||
.edit-modal-contents {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
width: 30rem;
|
||||
max-width: 90vw;
|
||||
max-height: 90vh;
|
||||
}
|
||||
.edit-modal-contents textarea {
|
||||
flex-shrink: 1;
|
||||
height: 40rem;
|
||||
}
|
||||
|
||||
.dualtext-word {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
|
@ -255,3 +302,13 @@ main {
|
|||
transform: translateX(-50%) translateY(0%);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
footer {
|
||||
width: "100%";
|
||||
}
|
||||
.drawer {
|
||||
width: "100%";
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue