Skip to content

Realistic watercolor drawings

TypeScript paintwatercolor

Fix font previews on GitHub Pages and make the UI mobile friendly

Claude9731534d3079
diff --git a/src/styles.css b/src/styles.css
index 59a2cd4..99778b6 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -241,23 +241,47 @@ input[type="range"]::-moz-range-thumb { width: 11px; height: 11px; border-radius
.error .sub { color: var(--ink-faint); }
/* phones: compact chrome */
+/* phones: compact chrome. Tools across the top (zoom tucked under their right end),
+ actions and palette along the bottom, panels in the space between. */
@media (max-width: 640px) {
- .tools { top: calc(10px + env(safe-area-inset-top)); left: calc(10px + env(safe-area-inset-left)); transform: none; flex-direction: row; }
- .tools .tool { width: auto; }
- .tools hr { width: 1px; height: 24px; border-top: 0; border-left: 1px solid var(--line); margin: auto 2px; }
- .actions { top: auto; bottom: calc(96px + env(safe-area-inset-bottom)); right: calc(10px + env(safe-area-inset-right)); }
+ :root {
+ --m-gap: 10px;
+ --m-top: calc(66px + env(safe-area-inset-top)); /* below the tool bar */
+ --m-bottom: calc(146px + env(safe-area-inset-bottom)); /* above the action bar */
+ }
+ .panel button { padding: 8px 7px; }
.panel button span { display: none; }
+ /* the bars scroll sideways rather than run off narrow screens */
+ .tools, .actions { overflow-x: auto; overscroll-behavior: contain; scrollbar-width: none; }
+ .tools::-webkit-scrollbar, .actions::-webkit-scrollbar { display: none; }
+ .tools {
+ top: calc(var(--m-gap) + env(safe-area-inset-top)); left: calc(var(--m-gap) + env(safe-area-inset-left)); transform: none;
+ flex-direction: row; max-width: calc(100vw - 2 * var(--m-gap) - env(safe-area-inset-left) - env(safe-area-inset-right));
+ }
+ .tools .tool { width: auto; flex: 0 0 auto; }
+ .tools hr { flex: 0 0 auto; width: 1px; height: 24px; border-top: 0; border-left: 1px solid var(--line); margin: auto 2px; }
+ .actions {
+ top: auto; bottom: calc(92px + env(safe-area-inset-bottom));
+ left: calc(var(--m-gap) + env(safe-area-inset-left)); right: calc(var(--m-gap) + env(safe-area-inset-right));
+ justify-content: space-between;
+ }
+ .actions button { flex: 0 0 auto; }
.library {
- left: 10px; right: 10px; top: auto; transform: none; width: auto;
- bottom: calc(150px + env(safe-area-inset-bottom)); max-height: 46vh;
+ left: var(--m-gap); right: var(--m-gap); top: auto; transform: none; width: auto;
+ bottom: var(--m-bottom); max-height: min(46vh, calc(100dvh - var(--m-top) - var(--m-bottom) - 50px));
}
.panel-head .sub, .library-foot .note { display: none; }
.brush .stroke { width: 100%; height: 40px; }
.panel .import span { display: inline; }
- .toast { top: calc(60px + env(safe-area-inset-top)); }
- .settings, .popover { top: auto; bottom: calc(150px + env(safe-area-inset-bottom)); right: 10px; }
+ .toast { top: calc(112px + env(safe-area-inset-top)); max-width: calc(100vw - 2 * var(--m-gap)); text-align: center; }
+ .settings, .popover {
+ top: auto; bottom: var(--m-bottom); right: var(--m-gap);
+ max-width: calc(100vw - 2 * var(--m-gap)); max-height: calc(100dvh - var(--m-top) - var(--m-bottom) - 50px); overflow-y: auto;
+ }
.popover .import span, .drop-choice button span, .panel button.primary span { display: inline; }
- .palette { bottom: calc(10px + env(safe-area-inset-bottom)); }
+ .palette { bottom: calc(var(--m-gap) + env(safe-area-inset-bottom)); max-width: calc(100vw - 2 * var(--m-gap)); }
+ .panel .swatch, .swatch { width: 28px; height: 28px; }
+ .hand-pip { width: 120px; bottom: calc(var(--m-bottom) + 6px); }
}
/* text tool */
@@ -316,10 +340,12 @@ input[type="range"]::-moz-range-thumb { width: 11px; height: 11px; border-radius
@media (max-width: 640px) {
.tool-panel {
- left: 10px; right: 10px; top: auto; transform: none; width: auto;
- bottom: calc(150px + env(safe-area-inset-bottom)); max-height: 52vh;
+ left: var(--m-gap); right: var(--m-gap); top: auto; transform: none; width: auto;
+ bottom: var(--m-bottom); max-height: min(56vh, calc(100dvh - var(--m-top) - var(--m-bottom) - 50px));
}
- .fontlist { max-height: 120px; }
+ .tool-panel .panel-head .sub { display: none; }
+ .fontlist { max-height: 138px; }
+ .fontrow { padding: 3px 6px; }
.tool-foot .credit { display: none; }
}
@@ -392,7 +418,21 @@ body.panning .paper { cursor: grabbing; }
body.space-pan .cursor, body.panning .cursor { opacity: 0 !important; }
@media (max-width: 640px) {
- .zoom { right: auto; left: calc(10px + env(safe-area-inset-left)); bottom: calc(96px + env(safe-area-inset-bottom)); }
+ /* pinch zooms, so only the readout and fit stay: tucked under the tool bar's right end */
+ .zoom { right: calc(var(--m-gap) + env(safe-area-inset-right)); top: var(--m-top); bottom: auto; padding: 3px; }
+ .panel.zoom button[aria-label="Zoom out"], .panel.zoom button[aria-label="Zoom in"] { display: none; }
+ .panel.zoom .pct { min-width: 44px; padding: 5px 4px; }
+ .panel.zoom button { padding: 5px; }
+}
+
+/* short landscape phones: the side tool bar scrolls instead of running off the bottom */
+@media (min-width: 641px) and (max-height: 560px) {
+ .tools { top: calc(10px + env(safe-area-inset-top)); transform: none; max-height: calc(100dvh - 20px); overflow-y: auto; scrollbar-width: none; }
+ .tools::-webkit-scrollbar { display: none; }
+ .tools .tool { flex: 0 0 auto; }
+ .tools .tool span, .actions button span, .panel-head .sub { display: none; }
+ .tools .tool { width: 44px; }
+ .library, .tool-panel { top: 10px; transform: none; max-height: calc(100dvh - 20px); }
}
/* hand painting: the hand cursor, its dwell ring, the hovered control and the camera picture */
diff --git a/src/text/fonts.ts b/src/text/fonts.ts
index 4018249..a9c2b2e 100644
--- a/src/text/fonts.ts
+++ b/src/text/fonts.ts
@@ -77,8 +77,18 @@ export const FONTS: Record<string, FontMeta> = {
export const DEFAULT_FONT = 'EMSAllure';
+/**
+ * Absolute URL of a file under public/fonts/single-line/. The app is built with a
+ * relative base ('./'), so the path is resolved against the page here: left
+ * relative, a url() in a CSS custom property resolves against the bundled
+ * stylesheet in assets/ instead, which 404s once deployed.
+ */
+function assetUrl(path: string): string {
+ return new URL(`${import.meta.env.BASE_URL}fonts/single-line/${path}`, document.baseURI).href;
+}
+
export function fontUrl(key: string): string {
- return `${import.meta.env.BASE_URL}fonts/single-line/${FONTS[key].file}.svg`;
+ return assetUrl(`${FONTS[key].file}.svg`);
}
/** "EMSReadabilityItalic" -> "EMS Readability Italic", keeps parenthesized bits. */
@@ -133,7 +143,7 @@ const ATLAS_KEYS = [
];
export const ATLAS = {
- url: `${import.meta.env.BASE_URL}fonts/single-line/font-atlas.png`,
+ url: assetUrl('font-atlas.png'),
rowWidth: 260,
rowHeight: 32,
/** Row index of a font in the atlas, or -1 when it has no specimen. */