mirror of
https://github.com/seigler/aurebesh
synced 2025-07-27 01:36: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 Reference from "./Reference";
|
||||||
import FontPicker from "./FontPicker";
|
import FontPicker from "./FontPicker";
|
||||||
import DualText from "./DualText";
|
import DualText from "./DualText";
|
||||||
|
import Drawer from "./Drawer";
|
||||||
|
|
||||||
export default function Main() {
|
export default function Main() {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -28,12 +29,14 @@ export default function Main() {
|
||||||
</header>
|
</header>
|
||||||
<main>
|
<main>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<FontPicker />
|
|
||||||
<ReadingBox />
|
<ReadingBox />
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
<footer>
|
<footer>
|
||||||
|
<Drawer>
|
||||||
|
<FontPicker />
|
||||||
<Reference />
|
<Reference />
|
||||||
|
</Drawer>
|
||||||
</footer>
|
</footer>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { useSignal } from "@preact/signals";
|
import { useSignal } from "@preact/signals";
|
||||||
import localforage from "localforage";
|
import localforage from "localforage";
|
||||||
import { useEffect } from "preact/hooks";
|
import { useEffect, useRef } from "preact/hooks";
|
||||||
import DualText from "./DualText";
|
import DualText from "./DualText";
|
||||||
|
|
||||||
export default function ReadingBox() {
|
export default function ReadingBox() {
|
||||||
const isEditing = useSignal(false);
|
const editModalRef = useRef<HTMLDialogElement>(null);
|
||||||
const contents =
|
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.
|
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,21 +25,11 @@ Pursued by the Empire's sinister agents, Princess Leia races home aboard her sta
|
||||||
}, []);
|
}, []);
|
||||||
return (
|
return (
|
||||||
<div class="readingbox">
|
<div class="readingbox">
|
||||||
<span>
|
<dialog ref={editModalRef} title="Update text">
|
||||||
<label>
|
<div className="edit-modal-contents">
|
||||||
Edit{" "}
|
<h2>Update text</h2>
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
id="edit-toggle"
|
|
||||||
selected={isEditing}
|
|
||||||
onChange={(event) => {
|
|
||||||
isEditing.value = event.currentTarget.checked;
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
</span>
|
|
||||||
{isEditing.value && (
|
|
||||||
<textarea
|
<textarea
|
||||||
|
autofocus
|
||||||
class="readingbox-textarea"
|
class="readingbox-textarea"
|
||||||
id="reading-material"
|
id="reading-material"
|
||||||
value={contents}
|
value={contents}
|
||||||
|
@ -50,7 +40,25 @@ Pursued by the Empire's sinister agents, Princess Leia races home aboard her sta
|
||||||
}}
|
}}
|
||||||
spellCheck={false}
|
spellCheck={false}
|
||||||
/>
|
/>
|
||||||
)}
|
<button
|
||||||
|
onClick={() => {
|
||||||
|
editModalRef.current?.close();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Save
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</dialog>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<button
|
||||||
|
onClick={() => {
|
||||||
|
editModalRef.current?.showModal();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Edit
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<div class="readingbox-text aurebesh">
|
<div class="readingbox-text aurebesh">
|
||||||
<DualText text={contents.value} hover />
|
<DualText text={contents.value} hover />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -71,6 +71,7 @@
|
||||||
--color-text-light: #0009;
|
--color-text-light: #0009;
|
||||||
--color-background1: #eed;
|
--color-background1: #eed;
|
||||||
--color-background2: #bba;
|
--color-background2: #bba;
|
||||||
|
--color-backdrop: #eed3;
|
||||||
--color-accent1: #900;
|
--color-accent1: #900;
|
||||||
--color-accent2: #b50;
|
--color-accent2: #b50;
|
||||||
--font-aurebesh: Droidobesh;
|
--font-aurebesh: Droidobesh;
|
||||||
|
@ -115,6 +116,38 @@ input[type="checkbox"] {
|
||||||
width: 0.75em;
|
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 {
|
#app {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -142,9 +175,23 @@ h1 {
|
||||||
--color-text-light: #fff9;
|
--color-text-light: #fff9;
|
||||||
--color-background1: #111;
|
--color-background1: #111;
|
||||||
--color-background2: #333;
|
--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 {
|
.dualtext-word {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
@ -255,3 +302,13 @@ main {
|
||||||
transform: translateX(-50%) translateY(0%);
|
transform: translateX(-50%) translateY(0%);
|
||||||
opacity: 1;
|
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