Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"react-dom": "19.3.1",
"svgo": "4.1.0",
"tesseract.js-core": "7.0.0",
"tipjar": "1.2.0"
"tipjar": "2.2.0"
}
}
129 changes: 72 additions & 57 deletions apps/app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ import { bounds, effective, fromSlider, snap, step, toSlider, type Zoom } from '
import { sampleImage } from './lib/sample'
import { track } from './lib/track'
import { Canvas, type Overlays, type SelectMode, type Tool, type ViewMode } from './components/Canvas'
import { ShortcutsDialog } from './components/Shortcuts'
import { REDO_KEYS, ShortcutsDialog, UNDO_KEYS } from './components/Shortcuts'
import { ExportOptions } from './components/ExportOptions'
import { CLEAN_TOOLS, EDIT_TOOLS, ModeSwitch, ToolRail, useWide, type WorkMode } from './components/Workspace'
import { Dock, DOCK_ICON, MoreMenu, type DockSlot } from './components/Dock'
Expand Down Expand Up @@ -1229,21 +1229,13 @@ export default function App() {
tools={EDIT_TOOLS(strokes, lineTrace)}
tool={tool}
onTool={chooseTool}
canUndo={history.past.length > 0}
canRedo={history.future.length > 0}
onUndo={() => historyStep('undo')}
onRedo={() => historyStep('redo')}
/>
)
const cleanRail = (
<ToolRail
tools={CLEAN_TOOLS(settings.removeBackground)}
tool={cleanTool}
onTool={chooseCleanTool}
canUndo={history.past.length > 0}
canRedo={history.future.length > 0}
onUndo={() => historyStep('undo')}
onRedo={() => historyStep('redo')}
/>
)
const modeRail = workMode === 'edit' ? rail : workMode === 'clean' ? cleanRail : null
Expand Down Expand Up @@ -1659,6 +1651,42 @@ export default function App() {
]
: [view('image', 'Image'), view('type', 'Type'), view('tune', 'Tune'), view('export', 'Export')]

/** Split, Difference and Vector: beside the mode tabs on a wide screen, in the canvas's foot on a phone. Active in the primary buttons' mustard. */
const compare = (
<div role="radiogroup" aria-label="Compare" className="flex shrink-0 gap-px overflow-hidden rounded-md border border-rule bg-rule">
{(
[
['split', 'Split'],
['difference', 'Difference'],
['vector', 'Vector'],
] as const
).map(([v, label]) => (
<button
key={v}
role="radio"
aria-checked={mode === v}
title={COMPARE_HINT[v]}
onClick={() => {
viewChosen.current = true
setMode(v)
}}
aria-label={label}
className={`px-2.5 py-1 text-[13px] sm:px-3 ${mode === v ? 'bg-mark font-medium text-mark-ink' : 'bg-paper-sunk hover:bg-paper'}`}
>
{/* "Diff" on a phone, so the row fits one line. */}
{v === 'difference' ? (
<>
<span className="sm:hidden">Diff</span>
<span className="hidden sm:inline">{label}</span>
</>
) : (
label
)}
</button>
))}
</div>
)

return (
<div
className={`flex flex-col ${docked ? 'h-full' : 'min-h-full lg:h-full'}`}
Expand All @@ -1680,7 +1708,7 @@ export default function App() {
}}
>
{/* On a phone the page scrolls under it until a trace opens; then the layout fits the screen. */}
<header className="sticky top-0 z-30 flex h-14 shrink-0 items-center justify-between border-b border-rule bg-paper px-4 lg:static lg:px-5">
<header className="app-header sticky top-0 z-30 flex h-14 shrink-0 items-center justify-between border-b border-rule bg-header px-4 lg:static lg:px-5">
<div className="flex items-baseline gap-3">
<h1 className="leading-none">
{/* The landing page and docs live beside the app, at the site root. */}
Expand All @@ -1696,7 +1724,7 @@ export default function App() {
<p className="hidden text-[13px] text-ink-muted sm:block">Image to SVG, in your browser.</p>
</div>
<div className="flex items-center gap-1 text-[13px]">
{/* A phone's undo and redo: on a wide screen they are at the foot of the tool rail. */}
{/* A phone's undo and redo: on a wide screen they are in the mode bar above the canvas. */}
{docked && workMode !== 'trace' && (
<div role="group" aria-label="History" className="flex gap-0.5 lg:hidden">
<IconButton label="Undo" disabled={history.past.length === 0} onClick={() => historyStep('undo')}>
Expand Down Expand Up @@ -1747,6 +1775,25 @@ export default function App() {
{/* The mode switcher, above the canvas; a phone switches modes and tools in the dock instead. */}
<div className="hidden flex-wrap items-center gap-x-3 gap-y-1.5 border-b border-rule px-4 py-2 lg:flex" data-workspace={workMode}>
<ModeSwitch modes={cleanable ? ['clean', 'trace', 'edit'] : ['trace', 'edit']} mode={workMode} onMode={chooseMode} edited={detached} />
{workMode !== 'clean' && (
<>
<span aria-hidden="true" className="h-5 w-px bg-rule" />
{compare}
</>
)}
{workMode !== 'trace' && (
<>
<span aria-hidden="true" className="h-5 w-px bg-rule" />
<div role="group" aria-label="History" className="flex gap-0.5">
<IconButton label="Undo" hint={`Undo (${UNDO_KEYS})`} disabled={history.past.length === 0} onClick={() => historyStep('undo')}>
<UndoIcon />
</IconButton>
<IconButton label="Redo" hint={`Redo (${REDO_KEYS})`} disabled={history.future.length === 0} onClick={() => historyStep('redo')}>
<RedoIcon />
</IconButton>
</div>
</>
)}
</div>
<div className="flex min-h-0 flex-1 flex-col lg:flex-row">
{modeRail && wide && modeRail}
Expand Down Expand Up @@ -1834,44 +1881,11 @@ export default function App() {
)}
</div>
</div>
{/* One row, the same height as the sidebar's footer beside it (lg). The hint shows where there's room for it
(each view's button carries it as a tooltip too) and shortens rather than wrapping. */}
<div className={`${workMode === 'clean' ? 'hidden' : 'flex'} flex-wrap items-center justify-between gap-x-3 gap-y-2 border-t border-rule px-4 py-2 lg:h-13 lg:flex-nowrap lg:py-0`}>
<div role="radiogroup" aria-label="Compare" className="flex shrink-0 gap-px overflow-hidden rounded-md border border-rule bg-rule">
{(
[
['split', 'Split'],
['difference', 'Difference'],
['vector', 'Vector'],
] as const
).map(([v, label]) => (
<button
key={v}
role="radio"
aria-checked={mode === v}
title={COMPARE_HINT[v]}
onClick={() => {
viewChosen.current = true
setMode(v)
}}
aria-label={label}
className={`px-2.5 py-1 text-[13px] sm:px-3 ${mode === v ? 'bg-paper font-medium text-accent' : 'bg-paper-sunk hover:bg-paper'}`}
>
{/* "Diff" on a phone, so the row fits one line. */}
{v === 'difference' ? (
<>
<span className="sm:hidden">Diff</span>
<span className="hidden sm:inline">{label}</span>
</>
) : (
label
)}
</button>
))}
</div>
<p className="hidden text-[12.5px] text-ink-muted lg:block lg:min-w-0 lg:flex-1 lg:truncate lg:max-[1399px]:hidden" title={COMPARE_HINT[mode]}>
{COMPARE_HINT[mode]}
</p>
{/* One row, the same height as the sidebar's footer beside it (lg): the overlays and zoom on the left (a wide screen has
Split, Difference and Vector above, beside the modes). The hint shows where there's room for it, at the right
(each view's button carries it as a tooltip too), and shortens rather than wrapping. */}
<div className={`${workMode === 'clean' ? 'hidden' : 'flex'} flex-wrap items-center justify-between gap-x-3 gap-y-2 border-t border-rule px-4 py-2 lg:h-13 lg:flex-nowrap lg:justify-start lg:gap-x-5 lg:py-0`}>
{!wide && compare}
<div className="flex shrink-0 items-center gap-3" role="group" aria-label="Overlays">
<OverlayToggle
label="Paths"
Expand All @@ -1891,6 +1905,9 @@ export default function App() {
<span className="hidden sm:contents">
<ZoomControl zoom={zoom} fit={fitScale} onZoom={setZoom} />
</span>
<p className="hidden text-[12.5px] text-ink-muted lg:block lg:min-w-0 lg:flex-1 lg:truncate lg:text-right lg:max-[1399px]:hidden" title={COMPARE_HINT[mode]}>
{COMPARE_HINT[mode]}
</p>
</div>
</>
) : (
Expand Down Expand Up @@ -2185,20 +2202,18 @@ export default function App() {
</div>
)}

{/* No room for a page footer, so one quiet line ends the sidebar. A phone has these in the header's menu. */}
<nav aria-label="About Inlay" className="hidden items-center gap-4 border-t border-rule px-5 py-2.5 text-[12px] text-ink-muted lg:flex lg:h-13 lg:py-0">
<a href="/docs/overview/" className="hover:text-ink">
{/* No room for a page footer, so one quiet line ends the sidebar. A phone has these in the header's menu; Support is the header's tip button. */}
<nav aria-label="About Inlay" className="hidden items-center justify-end gap-4 border-t border-rule px-5 py-2.5 text-[12px] text-ink-muted lg:flex lg:h-13 lg:py-0">
{/* New tabs, so a trace in progress stays open. */}
<a href="/docs/overview/" target="_blank" rel="noopener" className="hover:text-ink">
Docs
</a>
<a href="/privacy/" className="hover:text-ink">
<a href="/privacy/" target="_blank" rel="noopener" className="hover:text-ink">
Privacy
</a>
<a href="https://github.com/mtblck/inlaytrace" className="hover:text-ink">
<a href="https://github.com/mtblck/inlaytrace" target="_blank" rel="noopener" className="hover:text-ink">
Source
</a>
<a href="https://ko-fi.com/mtblck" className="hover:text-ink">
Support Inlay
</a>
</nav>
</aside>
</main>
Expand Down
6 changes: 3 additions & 3 deletions apps/app/src/components/Dock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -346,13 +346,13 @@ export function MoreMenu(p: { theme: 'light' | 'dark'; onTheme: () => void; supp
>
{p.theme === 'dark' ? 'Use light theme' : 'Use dark theme'}
</button>
<a role="menuitem" className={item} href="/docs/overview/">
<a role="menuitem" className={item} href="/docs/overview/" target="_blank" rel="noopener">
Docs
</a>
<a role="menuitem" className={item} href="/privacy/">
<a role="menuitem" className={item} href="/privacy/" target="_blank" rel="noopener">
Privacy
</a>
<a role="menuitem" className={item} href="https://github.com/mtblck/inlaytrace">
<a role="menuitem" className={item} href="https://github.com/mtblck/inlaytrace" target="_blank" rel="noopener">
Source
</a>
<a role="menuitem" className={item} href={p.supportUrl} target="_blank" rel="noopener">
Expand Down
20 changes: 14 additions & 6 deletions apps/app/src/components/Support.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,30 @@ import 'tipjar/style.css'

/** Where tips go: the same Ko-fi page as the site's footer and the README. */
export const SUPPORT_URL = 'https://ko-fi.com/mtblck'
/** Inlay's source, for a star. */
export const SOURCE_URL = 'https://github.com/mtblck/inlaytrace'

// tipjar() escapes everything and checks the link, so its markup is safe to set
// tipjar() escapes everything and checks the links, so its markup is safe to set
// as HTML. Built once: nothing in it changes. Themed in index.css (.tipjar).
// With `links` the button opens a menu (the browser's popover, no script). No star
// count: fetching it from the browser needs api.github.com in the CSP's connect-src.
const markup = tipjar({
href: SUPPORT_URL,
label: 'Support',
description: 'Inlay on Ko-fi',
icon: 'heart',
position: 'inline',
newTab: true,
menuId: 'support-menu',
links: [
{ href: SUPPORT_URL, label: 'Tip on Ko-fi', icon: 'coffee' },
{ href: SOURCE_URL, label: 'Star on GitHub', icon: 'star' },
],
})

/**
* The header's tip button. Inlay is free; this is the one way to give back.
* Inline beside the theme toggle rather than floating, so it never covers the
* canvas or the phone's export bar. Icon-only under 600px (tipjar's `auto`).
* The header's tip button, a menu of Ko-fi and the GitHub repo. Inlay is free;
* this is the one way to give back. Inline beside the theme toggle rather than
* floating, so it never covers the canvas or the phone's export bar. Icon-only
* under 600px (tipjar's `auto`).
*/
export function Support() {
return <span className="ml-1 inline-flex" dangerouslySetInnerHTML={{ __html: markup }} />
Expand Down
21 changes: 6 additions & 15 deletions apps/app/src/components/Workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
*/
import { useSyncExternalStore, type ReactNode } from 'react'
import type { Tool } from './Canvas'
import { REDO_KEYS, UNDO_KEYS } from './Shortcuts'

export type WorkMode = 'clean' | 'trace' | 'edit'

export const MODE_LABEL: Record<WorkMode, string> = { clean: 'Clean up', trace: 'Trace', edit: 'Edit' }

/** The mode tabs, above the canvas. `edited` marks Edit when the drawing has shape edits. */
/** The mode tabs, above the canvas, the active one in the primary buttons' mustard. `edited` marks Edit when the drawing has shape edits. */
export function ModeSwitch({ modes, mode, onMode, edited }: { modes: WorkMode[]; mode: WorkMode; onMode: (m: WorkMode) => void; edited: boolean }) {
return (
<div role="tablist" aria-label="Mode" className="flex shrink-0 items-center gap-px overflow-hidden rounded-md border border-rule bg-rule" data-modes={modes.join(' ')}>
Expand All @@ -27,11 +26,11 @@ export function ModeSwitch({ modes, mode, onMode, edited }: { modes: WorkMode[];
aria-selected={mode === m}
aria-controls={`panel-${m}`}
onClick={() => onMode(m)}
className={`flex items-center px-2.5 py-1 text-[13px] sm:px-3.5 ${mode === m ? 'bg-paper font-medium text-accent' : 'bg-paper-sunk text-ink hover:bg-paper'}`}
className={`flex items-center px-2.5 py-1 text-[13px] sm:px-3.5 ${mode === m ? 'bg-mark font-medium text-mark-ink' : 'bg-paper-sunk text-ink hover:bg-paper'}`}
>
{MODE_LABEL[m]}
{m === 'edit' && edited && (
<span className="ml-1.5 inline-block h-1.5 w-1.5 rounded-full bg-accent" data-edited="">
<span className={`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${mode === m ? 'bg-mark-ink' : 'bg-accent'}`} data-edited="">
<span className="sr-only">(edited)</span>
</span>
)}
Expand Down Expand Up @@ -117,10 +116,10 @@ export const CLEAN_TOOLS = (removeBackground: boolean): RailTool<keyof typeof CL
]

/**
* The tool rail: the mode's tools, then Undo and Redo. A column beside the
* canvas on a wide screen, a row in the mode bar on a phone.
* The tool rail: the mode's tools, in a column beside the canvas on a wide
* screen. Undo and Redo sit in the mode bar above it.
*/
export function ToolRail<T extends string>(p: { tools: RailTool<T>[]; tool: T; onTool: (t: T) => void; canUndo: boolean; canRedo: boolean; onUndo: () => void; onRedo: () => void }) {
export function ToolRail<T extends string>(p: { tools: RailTool<T>[]; tool: T; onTool: (t: T) => void }) {
const btn = 'grid size-8 place-items-center lg:size-9 rounded-md disabled:cursor-not-allowed disabled:text-ink-faint'
return (
<div className="flex shrink-0 items-center gap-1 lg:h-full lg:flex-col lg:border-r lg:border-rule lg:px-1.5 lg:py-2" data-rail="">
Expand All @@ -142,14 +141,6 @@ export function ToolRail<T extends string>(p: { tools: RailTool<T>[]; tool: T; o
</button>
))}
</div>
<div role="group" aria-label="History" className="ml-auto flex gap-1 lg:mt-auto lg:ml-0 lg:flex-col">
<button className={`${btn} text-ink-muted hover:bg-paper-sunk hover:text-ink`} disabled={!p.canUndo} onClick={p.onUndo} aria-label="Undo" title={`Undo (${UNDO_KEYS})`}>
{icon('M6 4L3 7l3 3M3 7h7.5a4 4 0 010 8H8')}
</button>
<button className={`${btn} text-ink-muted hover:bg-paper-sunk hover:text-ink`} disabled={!p.canRedo} onClick={p.onRedo} aria-label="Redo" title={`Redo (${REDO_KEYS})`}>
{icon('M12 4l3 3-3 3M15 7H7.5a4 4 0 000 8H10')}
</button>
</div>
</div>
)
}
Expand Down
20 changes: 20 additions & 0 deletions apps/app/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@
--c-on-mat-strong: #eef2ee;
/* The phone's dock: white on the paper, so it reads as a bar of its own. */
--c-dock: #ffffff;
/* The header: a light grey band, to break up the paper below it. */
--c-header: #e8ece9;
/* Its height above the phone's own inset (the iPhone home bar). */
--dock-h: calc(70px + env(safe-area-inset-bottom));
}

:root[data-theme='dark'] {
color-scheme: dark;
--c-dock: #1b2a24;
--c-header: #131e1a;
--c-paper: #131e1a;
--c-paper-sunk: #1b2a24;
--c-ink: #eef2ee;
Expand All @@ -63,6 +66,7 @@
@theme inline {
--color-paper: var(--c-paper);
--color-paper-sunk: var(--c-paper-sunk);
--color-header: var(--c-header);
--color-ink: var(--c-ink);
--color-ink-muted: var(--c-ink-muted);
--color-ink-faint: var(--c-ink-faint);
Expand Down Expand Up @@ -245,6 +249,8 @@
--tipjar-font-size: 13px;
--tipjar-icon-size: 14px;
--tipjar-shadow: none;
--tipjar-menu-radius: 10px;
--tipjar-menu-gap: 6px;
}

/* Over the canvas while it's tracing or optimising. Fades in after a beat, so a quick
Expand Down Expand Up @@ -390,3 +396,17 @@
display: block;
}
}

/* The header tip button's menu (Ko-fi and the GitHub repo) hangs from the button's right edge, at the
header's right. Unlayered, so it wins over tipjar's own (unlayered) stylesheet. */
@supports (position-area: bottom) {
header .tipjar-list[data-position='inline'] {
position-area: bottom span-left;
box-shadow: 0 8px 18px -8px rgb(0 0 0 / 0.5);
}
}

/* On the light header's grey, hovers take a deeper grey so they still show. */
:root:not([data-theme='dark']) header.app-header {
--c-paper-sunk: #dae0dc;
}
2 changes: 1 addition & 1 deletion apps/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"dependencies": {
"@astrojs/starlight": "0.42.11",
"astro": "7.4.11",
"tipjar": "1.2.0"
"tipjar": "2.2.0"
}
}
Loading