diff --git a/docs/DESIGN_SYSTEM.md b/docs/DESIGN_SYSTEM.md index 42fd582..512a69e 100644 --- a/docs/DESIGN_SYSTEM.md +++ b/docs/DESIGN_SYSTEM.md @@ -35,16 +35,21 @@ Radius: `--radius: 0.5rem` (sm/md/lg/xl derived). Shadows: minimal, soft; prefer ## Components (shadcn variants) - Button: `default` (primary), `secondary` (active toggle), `ghost` (toolbar icons, 40×40 touch targets on mobile), `outline`, `destructive`. -- Dialog (AI writer, delete confirmation), Sheet (library and panels below 1280px), DropdownMenu (export), Select (profile, provider), Tabs, Tooltip, Input/Textarea/Label, Switch (normalize), Sonner toasts. Only these shadcn components are kept in `src/components/ui/`; add new ones when a feature needs them. +- Dialog (AI writer, delete confirmation), Sheet (library and panels below 1280px), DropdownMenu (export), Select (profile, provider), Tabs, Tooltip, Input/Textarea/Label, Switch (normalize; 44×24px, the accent track when on and a muted track when off, a knob in its own colours that never takes the page background), Sonner toasts. Only these shadcn components are kept in `src/components/ui/`; add new ones when a feature needs them. - Icons: lucide-react, 16px in toolbars. +## Page frames +- **Public pages** (`SiteHeader`, `SiteFooter`, `SitePieces`): content up to 1200px; tiles are `border bg-muted`, chips are small labels (`accent`, `line`, `warn`), a call to action is a band on `bg-accent`. Reading pages (guides, legal) use `DocLayout`: a sticky contents column on the left from 1280px. +- **App pages** (`AppShell`: Settings, Admin): a top bar on the page background with the same hairline as the public header (its contents the width of the page's content; **Back to the editor** is the primary button, the account a ghost icon), a menu of sections on the left (the active one on `bg-accent` with the primary along its left edge; chips on phones), a title with a line under it, and rows grouped in bordered cards on `bg-card` (a light lift off the page; the controls inside are outlines on the card's own colour, not darker wells). +- **Standalone screens** (`Standalone`: private-link gate, invitation, password reset, 404, load error): a bar like the app pages' (page background, primary Open the editor), and a centred bordered `bg-card` box. + ## Preview styling (`.md-preview`) GitHub-like prose on `bg-paper`: max-width ~72ch, headings in Fraunces, links primary with underline, blockquote left border `border`, tables bordered with zebra `muted`, code `code-bg` + mono, task-list checkboxes, images max-width 100%. ## Layout & breakpoints - `< 768px` phone: single pane (Editor / Preview toggle), horizontally scrollable toolbar, panel buttons in a bottom nav, library and panels in sheets, condensed status bar. -- `768-1279px`: split view with scroll sync; the library opens as a left sheet and the panels as a right sheet. -- `>= 1280px` desktop: docked library sidebar (about 240px, collapsible) | editor | preview (scroll-synced) | docked side panel (about 288px, Checks/Outline/Front matter). +- `768-1279px`: split view with scroll sync; the library and the panels open as a sheet from the left. +- `>= 1280px` desktop: panel buttons (48px) | one docked pane (288px, resizable; the library or the chosen panel) | editor | preview (scroll-synced). Nothing docks on the right. - Focus mode: hides chrome, centers the editor. - Touch targets >= 40px on phones (toolbar buttons shrink to 36px from 768px up, where a pointer is the norm); dialogs scroll within the viewport. diff --git a/docs/SYSTEM_SPEC.md b/docs/SYSTEM_SPEC.md index 70d33d1..f228335 100644 --- a/docs/SYSTEM_SPEC.md +++ b/docs/SYSTEM_SPEC.md @@ -669,7 +669,7 @@ CREATE TABLE share_comments ( -- plain text, one level of replies - _Linking social sign-ins_ (`src/server/auth/social.ts`, shared by GitHub and Google): the provider's own id (`oauth_accounts`, unique per provider) is the identity, never the email. A known identity signs in (a suspended account is refused). Otherwise the provider must report the email as verified (`no_verified_email`). An account with that inbox (`emailKey`) gets the identity added and is signed in, so Google plus GitHub with one email, or a password account plus either, is one account; a suspended account is refused and nothing is linked. When that account's address was never confirmed, its password, sessions and pending links are removed first (whoever pre-registered it may not own the address), and the address counts as confirmed. With no such account a new confirmed, password-less one is made unless sign-ups are closed (`signups_closed`); the user row and its identity are removed together if the second insert fails. Different emails make different accounts. Password sign-up with an existing email answers `email_taken`, whose message points to the social buttons and "Forgot password" without saying which method the account uses. - _Limits_ (table `rate_limits`, fixed windows, the same SQL on D1 and SQLite): 5 sign-ups per hour per address, 10 failed sign-ins per 15 minutes per email and per address (locked out until the window ends, before any password work, and a success clears the email's count), 3 confirmation emails per hour per account. The address is `cf-connecting-ip`, or `X-Forwarded-For` only when `TRUST_PROXY` is set, since any client can send that header; with neither, only the per-email limits apply. - _Mail providers:_ `src/server/mail/` sends through a chain of providers (Resend and Mailtrap over HTTP anywhere; SMTP or a folder of JSON files on Node). Each has its free-tier limits (per UTC day and month) in a registry (`providers.ts`; adding one is one entry plus a small sender), counted in `rate_limits` only for sends that succeeded. A send goes to the provider with the most room left, skips any that is full, and falls through to the next on a failure; a provider that fails is left alone for 5 minutes, and a 429 marks it full for the day. `MAIL_PROVIDERS` orders or limits them, `MAIL__DAILY`/`_MONTHLY` override the limits. No provider configured means no mail. -- _Email confirmation:_ when the server can send mail, a password account starts unconfirmed and **nothing is sent at sign-up**: the first time the account tries the cloud (a draft's "Save to cloud" or the account menu's "Choose drafts for the cloud…") the app opens a "Confirm your email" dialog that sends the link, and opening it again sends nothing while that link is still good ("Send it again" forces one). People who only write locally never cost a message. Until the link is used the cloud (sync and image hosting) answers 403 `email_unverified`. The one-time link (hash stored, 24 hours, single use, valid only for the address it was sent to) is used. GitHub and Google accounts count as confirmed. A server that sends no mail confirms nothing and blocks nothing. A failed send shows in the dialog, which offers to try again. +- _Email confirmation:_ when the server can send mail, a password account starts unconfirmed and **nothing is sent at sign-up**: the first time the account tries the cloud (a draft's "Save to cloud" or the account menu's "Choose drafts for the cloud") the app opens a "Confirm your email" dialog that sends the link, and opening it again sends nothing while that link is still good ("Send it again" forces one). People who only write locally never cost a message. Until the link is used the cloud (sync and image hosting) answers 403 `email_unverified`. The one-time link (hash stored, 24 hours, single use, valid only for the address it was sent to) is used. GitHub and Google accounts count as confirmed. A server that sends no mail confirms nothing and blocks nothing. A failed send shows in the dialog, which offers to try again. - _Email design and retries:_ confirmation and reset mail are sent as plain text plus a designed HTML version (`src/server/mail/template.ts`): the warm paper palette as hex with a dark version for clients that follow the reader's setting, the link also written out under the button, and nothing loaded from the network (no images, fonts or trackers). If sending a confirmation fails, its link is removed again, so the next request tries a second time; once a send succeeds, later requests answer "already sent" until the link is used or expires. - _Password reset:_ "Forgot your password?" in the sign-in dialog (shown only when the server can send mail) asks for the address and always answers "if an account exists, we sent a link", so it cannot reveal who has one: unknown addresses and inboxes already sent 3 links in the hour are answered identically, the mail is sent after the response goes out (`waitUntil` on Workers), and the same sign-up CAPTCHA applies. The link points to a page (`/reset-password`, noindex), not to a state-changing GET, so mail scanners that open links cannot use it up; the page takes the token out of the address bar. A link lasts an hour, works once, is stored only as a hash, is tied to the address it was sent to and to its purpose (a confirmation link cannot reset a password, nor the reverse), and a new request replaces the older one. A weak password is refused without using the link up. Resetting sets the password (so a GitHub-only account can also gain one), deletes every session of the account and its other pending links, sets the address as confirmed (the person just read mail sent to it) and lifts a sign-in lockout. It does not sign anyone in. - _Changing the address:_ Settings, Account, Email, Edit asks for the new address and the current password and emails a link to the NEW address (purpose `email_change`, 24 hours, once, stored as a hash like the others, a newer request replaces the older one, 3 an hour per account). Nothing changes until the link is opened, so a mistyped address cannot lock anyone out, and the old address keeps working meanwhile. The current password is required so a stolen session cannot move the account to another inbox; an account with no password (GitHub or Google only) sets one first, and wrong guesses share the password limit. It needs a server that sends mail, since the new address must be proven. Opening the link (`GET /api/auth/email/confirm`, which redirects to the Account tab) sets `users.email` and `email_key` (the unique key decides if someone took the address meanwhile), marks it confirmed, ends the account's other sessions (the browser that opened the link stays signed in when it holds one of them), re-keys invitations held under the old inbox (`document_editors`, `share_people`; a row that would duplicate one already under the new address is dropped) so shared and live drafts keep opening, and emails a notice to the old address. diff --git a/docs/UI_SPEC.md b/docs/UI_SPEC.md index b0197d3..f2b920f 100644 --- a/docs/UI_SPEC.md +++ b/docs/UI_SPEC.md @@ -5,30 +5,30 @@ Items marked **(planned)** are specified but not built yet. ## 1. Landing `/` — `01_home_page.png`, `08_home_checker_demo.png` -Header: the `Logo` (two-pages mark plus the **md**studio wordmark, linking home), a theme button (each click goes Light, Dark, System and round again; its icon and label show the current choice) and a GitHub link (opens the repository in a new tab). Sections, top to bottom: +Header (`SiteHeader`, shared by the public pages, content up to 1200px wide): the `Logo` (two-pages mark plus the **md**studio wordmark, linking home), the links Features (`/#features`) and Guides (marked while on the guides), then a Settings icon and **Open the editor** (no search, theme or repository links here). (The theme is chosen in Settings, or with the button in the editor's side strip: each click goes Light, Dark, System and round again.) Below 768px the links fold into a Menu button. The changelog (on GitHub) is linked from the footer; self-hosting is in the README. Sections, top to bottom: - **Hero:** "Write once. Render the same everywhere.", a short description, a primary "Start writing" button to `/editor`, a "Try the checker" anchor, and a decorative (`aria-hidden`) editor/preview mock. The page has exactly one `h1`. - **How it works:** Write, Check, Export. - **Live checker demo** (`#try-it`): the real portability engine, lazy-loaded behind `ClientOnly`. An editable sample, four target pills with live issue counts, and a clickable report that selects the offending line. -- **Features** (six cards), **target profiles** (four cards), **About** and **Who it's for**, an eight-question **FAQ** (native `details`, mirrored in FAQPage JSON-LD), a closing call to action, and a footer (copyright and author on the left, GitHub and Changelog on the right). +- **Features** (six cards), **target profiles** (four cards), **About** and **Who it's for**, an eight-question **FAQ** (native `details`, mirrored in FAQPage JSON-LD), a closing call to action, and the footer (`SiteFooter`, in two groups: "mdstudio · version · MIT" on the left; Guides, Privacy, Terms and Changelog on the right). - **Theme:** an inline head script applies the saved or OS theme before first paint; the theme button also lives in the studio header. "System" forgets any saved choice and follows the OS, including when it switches while the page is open; Light and Dark are remembered on this device and ignore the OS. ## 1a. Privacy and Terms `/privacy`, `/terms` -Plain text pages in the site layout (header, footer), with the title and "Last updated" date, linked from the footer. Public and indexable. +Text pages in the site layout (header, footer), in the same reading layout as a guide (`DocLayout`): the page's sections listed in a sticky column on the left (from 1024px; below that there is no room beside the text and it is hidden, and the text is centred), with the section being read marked as the page scrolls, and beside it a Privacy | Terms switch, the title and "Last updated" date. Linked from the footer. Public and indexable. ## 1b. Guides `/guides` and `/guides/$slug` -Shared `SiteHeader` and `SiteFooter` (the footer links to Guides, the source and the changelog). The index lists every guide with its description and update date. A guide page has breadcrumbs, the title as the single `h1`, an "Updated … · N min read" line, an "On this page" list of section links, the article (`.md-preview`), a call to action to open the editor, and three related guides. Unknown slugs return a real 404. The home page links to the first three guides. +Shared `SiteHeader` and `SiteFooter` (the footer has "mdstudio · version · MIT" on the left and Guides, Privacy, Terms and Changelog on the right). The index has a large "Markdown guides" heading and every guide as a tile (update date chip, title, description; the whole tile is the link). A guide page (`DocLayout`) has the "On this page" list in a sticky column on the left (from 1024px, hidden below, where the text is centred; the section being read is marked as the page scrolls), breadcrumbs, the title as the single `h1`, an "Updated … · N min read" line, the article (`.md-preview`), a call to action to open the editor on a tinted band, and three related guides as tiles. Unknown slugs return a real 404. The home page links to the first three guides. ## 1c. Sharing from the editor — `14_share_dialog.png`, `15_comments_panel.png` -For a draft in the cloud (verified accounts only), the draft's menu has **Share…** and the header has a **Share** button (an icon on small screens). A small globe next to the cloud icon marks drafts that have a live link (a lock when only named people can open it). The Share dialog (`ShareDialog.tsx`) has two states: +For a draft in the cloud (verified accounts only), the draft's menu has **Share** and the header has a **Share** button (an icon below 1024px); both open the "Share this draft" choice described in the top bar, and its **Share for review** leads to the dialog below. A small globe next to the cloud icon marks drafts that have a live link (a lock when only named people can open it). The Share dialog (`ShareDialog.tsx`) has two states: - **Not shared:** "Who can open it" (Anyone with the link, or Only people I invite, which is off where the server turns private links off), a "Let reviewers comment" switch (both are chosen before publishing, so a private link is never public first), a "Link lasts" choice (1 to 7 days, 4 by default), a note that the page shows the text as it is in the cloud when published and that later edits stay private until an update, a note about images stored only on this device when the draft has any, and **Publish**. - **Shared:** the link ("Public link" or "Private link") in a read-only field with **Copy**, "Who can open it" and "Let reviewers comment" (a change is saved at once), for a private link a **People who can open it** list (invite by email with **Invite**, up to 10, remove with the ✕ beside an address; adding an address emails it once), the publish and expiry dates, "Link lasts" (changing it sets the expiry that many days from now), a warning "Your draft has changes that are not published" when the draft differs from the published copy, **Publish update** (enabled only then) and **Stop sharing**. Publishing saves the draft and runs a sync first, so the copy is the latest text. Buttons show the loading state while a request runs; errors (not in the cloud yet, too many changes, offline, a full or unusable invite) appear in the dialog. -**Editing together.** A cloud draft's menu also has **Edit together…** (`CollabDialog.tsx`). Before it is on, the dialog says what it does and has **Start editing together** (it saves the draft and runs a sync first, so the room starts from the latest text); where the server or the account does not allow it, it says so. Once on, it has **People who can edit** (invite by email with **Invite**, up to the account's limit counting the owner, remove with the ✕ beside an address) and **Stop editing together** (the draft keeps its latest text, everyone invited is let go). While it is on, the dialog also shows the **Draft link** (read-only, with **Copy**) that the invitation emails carry. A draft being edited together has a people icon in the list. The footer of such a draft (`CollabStatus.tsx`) says **Live**, **Offline: your edits are kept here and will merge** or **Opening the shared draft…**, with a small avatar for each other person in it (their cursor colour, name on hover). +**Editing together.** **Edit together** is the second choice of **Share** (`CollabDialog.tsx`). Before it is on, the dialog says what it does and has **Start editing together** (it saves the draft and runs a sync first, so the room starts from the latest text); where the server or the account does not allow it, it says so. Once on, it has **People who can edit** (invite by email with **Invite**, up to the account's limit counting the owner, remove with the ✕ beside an address) and **Stop editing together** (the draft keeps its latest text, everyone invited is let go). While it is on, the dialog also shows the **Draft link** (read-only, with **Copy**) that the invitation emails carry. A draft being edited together has a people icon in the list. The footer of such a draft (`CollabStatus.tsx`) says **Live**, **Offline: your edits are kept here and will merge** or **Opening the shared draft…**, with a small avatar for each other person in it (their cursor colour, name on hover). The invitation email's **Open the draft** button leads to `/c/
`: a page that asks for a sign-in if needed (with the invited address, creating an account is offered), then opens the draft; anyone not invited sees "You can't open this draft". Invitations and removals show up in **Shared with you** at once, without a reload. An invited person finds the draft under **Shared with you** at the bottom of their library (read when the studio opens and when the window returns; it shows who owns each draft). Opening one makes a local copy and opens it in the live editor; **Leave** (the exit icon, with a confirmation) removes it. These drafts are not in the person's own list, do not count against their cloud limit, are never uploaded, and leave the device at sign-out with what the browser kept of them. When the owner removes the person, stops editing together or deletes the draft, the open draft says so ("You can no longer edit …", with a line that changes made while offline stay on this device only; while the studio checks, because the room keeps turning the browser away, the footer says "Can't reach the room. Checking your access…") and stays on the device as an ordinary draft with its latest text. In the admin dashboard, the Overview shows how many drafts are edited together and how many people are invited, and the Server tab has the switch **Editing together is open**. @@ -40,15 +40,15 @@ A draft in the cloud also gets a **Comments** panel (speech-bubble button beside ## 1d. Shared page `/s/$slug` — `16_shared_page_comments.png`, `17_shared_page_phone.png`, `18_private_link_gate.png` -A public, read-only page for one published copy of a draft. The site header, a one-line notice ("A copy shared with mdstudio on . Available until . Report this page"), the text in `.md-preview` (single column, up to `max-w-3xl`, readable at 360px with no sideways scroll) and the site footer. Math and Mermaid diagrams are drawn in the browser after load, in the colors of the theme in use. An unknown, expired or revoked link is the site's 404 page. +A public, read-only page for one published copy of a draft. Its own top bar (logo, a "Shared for review" or "Shared copy" chip, the theme button and **Open the editor**), the text and the footer all in one width: wide enough for the comments column while it shows beside the text with something in it, and just the text, centred, when the comments are hidden, there are none yet, or they sit below it (the bar and the footer narrow with it; the page starts narrow and widens when the first comment or notice appears), a meta line ("A copy shared with mdstudio on . Available until ."), the text in `.md-preview` (readable at 360px with no sideways scroll; the comments sit in a column beside it when the writer takes them and the window is wide, below it on narrow screens), "Made with mdstudio · Report this page" under the text, and the site footer. Math and Mermaid diagrams are drawn in the browser after load, in the colors of the theme in use. An unknown, expired or revoked link is the site's 404 page. -**Private links.** A signed-out reader of a link limited to named people sees a lock, "This document is private" and a **Sign in** button, and none of the text; the page is `noindex`, `no-store`. The small sign-in dialog (`ReaderSignIn`: sign in or create an account, with a show/hide password button and the sign-up CAPTCHA when the server has one) leaves them on the page, which reloads for them. Someone signed in who was not invited gets the 404 page. An open private page adds "Only the people the writer named can open this." +**Private links.** A signed-out reader of a link limited to named people sees a standalone screen (logo and **Open the editor** above, a centred box): a "Private review link" chip, "This document is private" and a **Sign in** button, and none of the text; the page is `noindex`, `no-store`. The small sign-in dialog (`ReaderSignIn`: sign in or create an account, with a show/hide password button and the sign-up CAPTCHA when the server has one) leaves them on the page, which reloads for them. Someone signed in who was not invited gets the 404 page. An open private page adds "Only the people the writer named can open this." -**Comments** (when the writer turned them on), as in a document review. A reader selects words on the page and a **Comment** button appears beside the selection; pressing it opens a box in the column beside the page (a bottom sheet under 1024px) with the selected words quoted. The words stay highlighted, and each comment card sits level with its words, pushed down so cards never overlap. Clicking a highlight shows its comment and clicking a card scrolls to its words. **Hide comments** (a floating button, or the ✕ on the sheet) hides the column and **Comments (n)** shows it again, as does a click on any highlight. A signed-out reader is told "The writer is taking comments" with **Sign in to read and write comments**; a signed-in reader whose email is not confirmed is asked to confirm it. Cards show the author's name, the date, an "Earlier version" tag for comments written on an older copy, a "Resolved" tag, **Reply**, and **Delete** (with a confirmation) on the reader's own comments. A comment whose words or block are gone from the current copy stays in the column, marked as being on an earlier version, without a highlight. Text is shown as plain text. The locked private-link page keeps the footer at the bottom of the window. +**Comments** (when the writer turned them on), as in a document review. A reader selects words on the page and a **Comment** button appears beside the selection; pressing it opens a box in the column beside the page (a bottom sheet under 1024px) with the selected words quoted. The words stay highlighted, and each comment card sits level with its words, pushed down so cards never overlap. Clicking a highlight shows its comment and clicking a card scrolls to its words. **Hide comments** (a floating button, or the ✕ on the sheet) hides the column and **Comments (n)** shows it again, as does a click on any highlight. A signed-out reader is told "The writer is taking comments" with **Sign in to read and write comments**; a signed-in reader whose email is not confirmed is asked to confirm it. Cards show the author's name, the date, an "Earlier version" tag for comments written on an older copy, a "Resolved" tag, **Reply**, and **Delete** (with a confirmation) on the reader's own comments; while one is being deleted it is dimmed and its "Deleting" button shows a spinner. A comment whose words or block are gone from the current copy stays in the column, marked as being on an earlier version, without a highlight. Text is shown as plain text. The locked private-link page keeps the footer at the bottom of the window. ## 1e. Publishing to GitHub — `19_publish_connect.png`, `20_publish_github.png` -For a draft in the cloud, on a server that can publish (`githubPublish` in `/api/auth/me`), the draft's menu has **Publish to GitHub…** and the header has a **Publish** button (the GitHub icon alone below the xl breakpoint). The dialog (`PublishDialog.tsx`) reads from the server only when it opens or a choice needs it: the connection, what was published before, and the repositories. Nothing is requested in the background. +For a draft in the cloud, on a server that can publish (`githubPublish` in `/api/auth/me`), the draft's menu has **Publish** and the header's **Export** button becomes **Publish** (its menu starts with Publish to GitHub). The dialog (`PublishDialog.tsx`) reads from the server only when it opens or a choice needs it: the connection, what was published before, and the repositories. Nothing is requested in the background. - **Not connected:** an explanation, **Also allow private repositories** (off by default: only public repositories and gists are reachable), a note that an organization may need to approve mdstudio, and **Connect GitHub**. It leaves for GitHub and returns to the editor, which reopens this dialog on the same draft. - **Connected:** "Connected as ", **Allow private repositories** (when they were not allowed) and **Disconnect**, then two tabs. @@ -62,14 +62,17 @@ For a draft in the cloud, on a server that can publish (`githubPublish` in `/api **First visit and empty library.** `/editor` opens the first draft on the machine (or in the signed-in account). With none, it opens `/editor/new`, held in memory only and saved, under its own address, when the writer first types. On a first visit that is the example text; once this browser has ever stored a draft (a flag kept beside the drafts), it is a completely blank editor, so deleting the last draft, or reloading after it, never brings the example back. Until something is typed nothing is stored, so signing in with drafts in the cloud replaces either with those drafts. "New draft" always starts empty. -**Buttons.** Every enabled button, tab, menu item and switch shows a pointer cursor (a base rule in `src/styles.css`). `Button` has two busy states: `pending` (disabled, `aria-busy`) and `loading` (the same plus a spinner, which replaces the icon on an icon button). Sign-in and sign-up, the reset links, the confirmation email and the cloud picker use `loading`. +**Buttons.** Every enabled button, tab, menu item and switch shows a pointer cursor (a base rule in `src/styles.css`). `Button` has two busy states: `pending` (disabled, `aria-busy`) and `loading` (the same plus a spinner, which replaces the icon on an icon button). A button that starts a request shows it: the button that was pressed uses `loading` (disabled, with a spinner; on an icon button the spinner replaces the icon) for as long as its action runs, whether it is the main action of a form or dialog or a small action in a row (sign-in and sign-up, the reset links, the confirmation email, the cloud picker, publishing, saving a plan, account, limits or server settings, testing an AI connection, refreshing models, opening a generated draft, the account search, unlinking a sign-in, disconnecting GitHub, deleting a hosted image, resolving or deleting a comment, removing a person, saving or restoring a version, and the two-press admin buttons). The other buttons of the same dialog use `pending` (disabled, no spinner) while it runs, so nothing can be pressed twice. `disabled` alone is for a button that cannot be used yet (an empty field, a limit reached), never for one that is working; a test (`loading-rules.test.ts`) fails on a button disabled by a busy state without `loading` or `pending`, and on a hand-made spinner. The label of a button, menu item or command never ends in an ellipsis ("Edit rules", not "Edit rules…"); the ellipsis is kept only for text that says something is in progress ("Loading…", "Saving…"). Every dropdown choice uses the shared `Select` component (the target platform in the top bar and in Settings, a rule's severity, the AI provider and integration), never a native ` change({ profile: e.target.value as Profile })} + + +
+ {THEMES.map((t) => ( + + ))} +
+
+ p.id === prefs.profile)?.hint} > - {PROFILES.map((p) => ( - - ))} - - - - change({ normalize: on })} - /> - - - - - - - + + + + change({ normalize: on })} + /> + +
+ Writing checks + + + + + + + + -
-
- - - - Settings -
- - - -
-
-
-
-

Settings

- onTab(v as SettingsTab)}> - - {visibleTabs(!!user).map((t) => ( - - {LABEL[t]} - - ))} - - {user && ( - - - - )} - - - - - - - {user && ( - - - - )} - -
- + / Settings} + sections={visibleTabs(!!user).map((id) => ({ id, label: LABEL[id] }))} + current={current} + onSection={onTab} + menuLabel="Settings sections" + > + {user && ( + + + + + )} + + + + + + + + + {user && ( + + + + + )} + ); } diff --git a/src/components/settings/SettingsRow.tsx b/src/components/settings/SettingsRow.tsx index 184efc3..3e00d8a 100644 --- a/src/components/settings/SettingsRow.tsx +++ b/src/components/settings/SettingsRow.tsx @@ -11,10 +11,10 @@ export function SettingsRow({ children: ReactNode; }) { return ( -
+
-

{title}

- {description &&

{description}

} +

{title}

+ {description &&

{description}

}
{children}
diff --git a/src/components/share/Comments.tsx b/src/components/share/Comments.tsx index 2d3097e..82da401 100644 --- a/src/components/share/Comments.tsx +++ b/src/components/share/Comments.tsx @@ -101,12 +101,26 @@ function One({ className = "", }: { comment: ShareComment; - onDelete: (c: ShareComment) => void; + onDelete: (c: ShareComment) => unknown; className?: string; }) { const [confirming, setConfirming] = useState(false); + const [deleting, setDeleting] = useState(false); + const remove = async () => { + setDeleting(true); + try { + await onDelete(comment); + } finally { + setDeleting(false); + setConfirming(false); + } + }; return ( -
  • + // while it is being deleted the comment is dimmed, and its button shows the work +
  • {comment.author} {when(comment.createdAt)} @@ -119,20 +133,24 @@ function One({ {comment.mine && (confirming ? ( <> - - + ) : ( -

    Confirm your email first

    -

    +

    Confirm your email first

    +

    Editing together needs a confirmed email address. Open the link we sent you, then try again.

    @@ -108,8 +115,8 @@ export function OpenInvite({ link }: { link: string }) { )} {step === "denied" && ( <> -

    You can't open this draft

    -

    +

    You can't open this draft

    +

    The link may have stopped working, or this account isn't the address that was invited. Sign in with the invited address, or ask the owner to invite you again.

    @@ -117,15 +124,14 @@ export function OpenInvite({ link }: { link: string }) { )} {step === "failed" && ( <> -

    Couldn't reach the server

    -

    Check your connection and try again.

    - )} - - -
    + + ); } diff --git a/src/components/site/AppShell.tsx b/src/components/site/AppShell.tsx new file mode 100644 index 0000000..774713f --- /dev/null +++ b/src/components/site/AppShell.tsx @@ -0,0 +1,125 @@ +import type { ReactNode } from "react"; +import { Link } from "@tanstack/react-router"; +import { Logo } from "@/components/Logo"; +import { AccountMenu } from "@/components/studio/AccountMenu"; +import { Button } from "@/components/ui/button"; +import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"; +import { cn } from "@/lib/utils"; + +/** + * The frame of the app's own pages (Settings, Admin): a top bar with the logo and a label, and a + * menu of sections on the left (a row of chips on phones). Each section is a Radix tab, so the menu + * keeps tab semantics and arrow-key movement. + */ +export function AppShell({ + label, + sections, + current, + onSection, + menuLabel, + wide, + children, +}: { + label: ReactNode; + sections: readonly { id: T; label: string }[]; + current: T; + onSection: (id: T) => void; + menuLabel: string; + wide?: boolean; + children: ReactNode; +}) { + return ( +
    + + onSection(v as T)} + orientation="vertical" + className={cn( + "mx-auto flex flex-col gap-4 p-4 md:flex-row md:items-start md:gap-10 md:px-6 md:py-8", + wide ? "max-w-310" : "max-w-280", + )} + > + + {sections.map((s) => ( + + {s.label} + + ))} + +
    {children}
    +
    +
    + ); +} + +/** The top bar of the app's own pages, and of the screens that stand on their own. */ +export function AppTopBar({ + label, + editor = true, + wide = false, +}: { + label?: ReactNode; + editor?: boolean; + wide?: boolean; +}) { + return ( +
    + {/* the same width and side padding as the page's content below, so the two line up */} +
    + + {label} +
    + {editor && ( + + )} + +
    +
    +
    + ); +} + +/** A page's heading, with the line under it. */ +export function PageTitle({ title, sub }: { title: string; sub?: ReactNode }) { + return ( +
    +

    {title}

    + {sub &&

    {sub}

    } +
    + ); +} + +/** A bordered group of rows. */ +export function Card({ children, className }: { children: ReactNode; className?: string }) { + return ( +
    + {children} +
    + ); +} + +/** A heading between two cards. */ +export function CardHeading({ children }: { children: ReactNode }) { + return

    {children}

    ; +} diff --git a/src/components/site/DocLayout.tsx b/src/components/site/DocLayout.tsx new file mode 100644 index 0000000..40ba989 --- /dev/null +++ b/src/components/site/DocLayout.tsx @@ -0,0 +1,99 @@ +import { useEffect, useState, type ReactNode } from "react"; +import { SITE_WIDTH } from "./SitePieces"; +import { cn } from "@/lib/utils"; + +/** How far below the top of the window a heading counts as "being read". */ +const READING_LINE = 120; + +/** The id of the section being read: the last one whose heading has reached the reading line. */ +function useActiveSection(ids: string[]) { + const [active, setActive] = useState(ids[0] ?? ""); + const key = ids.join("|"); + useEffect(() => { + if (ids.length === 0) return; + let frame = 0; + const update = () => { + frame = 0; + const doc = document.documentElement; + // at the very bottom the last section is the one being read, even if it is too short to reach the line + if (window.innerHeight + window.scrollY >= doc.scrollHeight - 2) + return setActive(ids.at(-1)!); + let current = ids[0]!; + for (const id of ids) { + const el = document.getElementById(id); + if (el && el.getBoundingClientRect().top <= READING_LINE) current = id; + } + setActive(current); + }; + const onScroll = () => { + if (!frame) frame = requestAnimationFrame(update); + }; + update(); + window.addEventListener("scroll", onScroll, { passive: true }); + window.addEventListener("resize", onScroll); + return () => { + window.removeEventListener("scroll", onScroll); + window.removeEventListener("resize", onScroll); + if (frame) cancelAnimationFrame(frame); + }; + // the ids, joined: the array itself is new on every render + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [key]); + return active; +} + +/** + * A page of reading (a guide, a legal page): its sections listed in a sticky column on the left, + * with the one being read marked, and the text beside it. The list is shown for as long as the + * window has room for it beside the text (from 1024px) and hidden below that. + */ +export function DocLayout({ + toc, + tocTitle, + children, +}: { + toc: { text: string; id: string }[]; + tocTitle: string; + children: ReactNode; +}) { + const active = useActiveSection(toc.map((t) => t.id)); + return ( +
    + {toc.length > 0 && ( + + )} + {/* centred when the list is hidden (or there is none); beside the list otherwise */} +
    0 && "lg:mx-0")}> + {children} +
    +
    + ); +} diff --git a/src/components/site/LegalPage.tsx b/src/components/site/LegalPage.tsx index 84f3639..5697033 100644 --- a/src/components/site/LegalPage.tsx +++ b/src/components/site/LegalPage.tsx @@ -1,24 +1,54 @@ +import { Link } from "@tanstack/react-router"; +import { DocLayout } from "@/components/site/DocLayout"; import { SiteFooter } from "@/components/site/SiteFooter"; import { SiteHeader } from "@/components/site/SiteHeader"; import { formatDate } from "@/lib/site/guides-content"; -import type { LegalPage as Legal } from "@/lib/site/legal"; +import { LEGAL_PAGES, legalPath, type LegalPage as Legal } from "@/lib/site/legal"; +import { cn } from "@/lib/utils"; /** A legal page: the title and date here, the text rendered (and sanitized) from content/legal. */ -export function LegalPage({ page, html }: { page: Legal; html: string }) { +export function LegalPage({ + page, + html, + toc, +}: { + page: Legal; + html: string; + toc: { text: string; id: string }[]; +}) { return (
    -
    +
    -

    + +

    {page.title}

    -

    +

    Last updated {formatDate(page.updated)}

    -
    + {/* sanitized by renderMarkdown (rehype-sanitize) */} +
    -
    +
    ); diff --git a/src/components/site/SiteFooter.tsx b/src/components/site/SiteFooter.tsx index c0b6365..586e914 100644 --- a/src/components/site/SiteFooter.tsx +++ b/src/components/site/SiteFooter.tsx @@ -1,35 +1,35 @@ import { Link } from "@tanstack/react-router"; import { SITE } from "@/lib/site/seo"; +import { cn } from "@/lib/utils"; -export function SiteFooter() { +const VERSION = import.meta.env.VITE_APP_VERSION; +const link = "hover:text-foreground"; + +/** Two groups: what this is on the left, where to read more on the right. */ +export function SiteFooter({ widthClass = "max-w-300" }: { widthClass?: string } = {}) { return (
    -
    - - © {new Date().getFullYear()} - - {SITE.author} - - -
    diff --git a/src/components/studio/AiIntegrationsDialog.tsx b/src/components/studio/AiIntegrationsDialog.tsx index 911d65c..5142f49 100644 --- a/src/components/studio/AiIntegrationsDialog.tsx +++ b/src/components/studio/AiIntegrationsDialog.tsx @@ -310,10 +310,11 @@ function IntegrationForm({ )} {revisions.length ? ( @@ -159,9 +170,16 @@ export function HistoryPanel({ Close + ); +} + +/** The one Share button's first step: send the draft out to be read, or open it up to be written. */ +export function ShareChooser({ + open, + onOpenChange, + onReview, + onEdit, +}: { + open: boolean; + onOpenChange: (open: boolean) => void; + onReview: () => void; + onEdit: () => void; +}) { + return ( + + + + Share this draft + Choose how the other people take part. + +
    + } + title="Share for review" + body="A read-only copy at a link, to anyone or to people you name. Readers can comment on the words." + onClick={onReview} + /> + } + title="Edit together" + body="Invite people by email to type in this draft with you, at the same time." + onClick={onEdit} + /> +
    +
    +
    + ); +} diff --git a/src/components/studio/ShareDialog.tsx b/src/components/studio/ShareDialog.tsx index b39bd02..8a14dc5 100644 --- a/src/components/studio/ShareDialog.tsx +++ b/src/components/studio/ShareDialog.tsx @@ -74,9 +74,11 @@ export function ShareDialog({ const { byDraft, defaultDays, maxDays, privateLinks, loaded } = useShares(); const share = draft ? byDraft.get(draft.id) : undefined; const [days, setDays] = useState(String(defaultDays)); - const [busy, setBusy] = useState<"publish" | "extend" | "stop" | "settings" | "invite" | null>( - null, - ); + const [busy, setBusy] = useState< + "publish" | "extend" | "stop" | "settings" | "invite" | "remove" | null + >(null); + // the person being removed, so only their button shows it + const [removing, setRemoving] = useState(null); // what a link not yet published will be made with const [chosenAccess, setChosenAccess] = useState("public"); const [chosenComments, setChosenComments] = useState(false); @@ -214,15 +216,17 @@ export function ShareDialog({ "person", ); }; - const uninvite = (person: SharePerson) => + const uninvite = (person: SharePerson) => { + setRemoving(person.id); void run( - "invite", + "remove", async () => { await peopleApi.remove(draft.id, person.id); setPeople((list) => list.filter((p) => p.id !== person.id)); }, "person", - ); + ).finally(() => setRemoving(null)); + }; const stop = () => run("stop", async () => { await shareApi.revoke(draft.id); @@ -364,7 +368,8 @@ export function ShareDialog({ size="icon" className="size-7 shrink-0" aria-label={`Remove ${p.email}`} - pending={busy !== null} + loading={removing === p.id} + pending={busy !== null && removing !== p.id} onClick={() => uninvite(p)} > diff --git a/src/components/studio/Studio.tsx b/src/components/studio/Studio.tsx index a471ffd..9cb8317 100644 --- a/src/components/studio/Studio.tsx +++ b/src/components/studio/Studio.tsx @@ -32,6 +32,7 @@ import { sortLocalImages, warnLocalImages as noteLocalImages } from "@/lib/colla import { detachShared, openShared, removeShared } from "@/lib/collab/shared"; import { useSharedWithMe } from "@/lib/collab/sharedHooks"; import { ShareDialog } from "@/components/studio/ShareDialog"; +import { ShareChooser } from "@/components/studio/ShareChooser"; import { clearShares, useShares } from "@/lib/share/hooks"; import { addToCloud, @@ -53,6 +54,7 @@ import { SlidersHorizontal, FolderUp, Share2, + Send, Github, FileUp, MonitorDown, @@ -60,6 +62,8 @@ import { Copy, Columns2, PanelLeft, + Files, + Settings, FileText, Eye, AlertTriangle, @@ -97,7 +101,7 @@ import { import { TooltipProvider } from "@/components/ui/tooltip"; import { SiteNotice } from "@/components/SiteNotice"; import { cn } from "@/lib/utils"; -import { CHECKS_OPEN_MIN_WIDTH, clampLibraryWidth, LIBRARY_WIDTH } from "@/lib/ui/layout"; +import { clampLibraryWidth, LIBRARY_WIDTH } from "@/lib/ui/layout"; import { HistoryPanel } from "@/components/studio/HistoryPanel"; import { Library } from "@/components/studio/Library"; import { historyStore, type Revision } from "@/lib/storage/history"; @@ -340,8 +344,6 @@ export function Studio({ docId }: { docId: string }) { if (p) setProfile(p); setNormalize(localStorage.getItem("md:normalize") === "1"); setCheckConfig(loadConfig()); - // Checks start open only on wide screens; below that the editor keeps the room until asked. - if (window.matchMedia(`(min-width: ${CHECKS_OPEN_MIN_WIDTH}px)`).matches) setPanel("checks"); const w = localStorage.getItem("md:library-width"); if (w) setLibraryWidth(clampLibraryWidth(w)); }, []); @@ -1293,6 +1295,7 @@ export function Studio({ docId }: { docId: string }) { if (account) await syncNow(account.id); }; // the draft whose share dialog is open + const [shareChoice, setShareChoice] = useState(null); const [shareTarget, setShareTarget] = useState(null); const [collabTarget, setCollabTarget] = useState(null); // the draft whose publish-to-GitHub dialog is open @@ -1444,9 +1447,19 @@ export function Studio({ docId }: { docId: string }) { }; const errCount = issues.filter((i) => i.severity !== "info").length; - const showLibrary = library && !focus && !compact; - const showPanel = panel && !focus && !compact; const activePanel = overlay ? mobilePanel : panel; + // The drafts and every panel share one pane on the left (on phones and in focus mode they open + // as a panel over the page instead). A panel takes the pane; closing it gives the pane back to + // the drafts if they were showing. + const toggleSide = (p: "drafts" | NonNullable) => { + if (overlay) return p === "drafts" ? setMobileLibrary(true) : setMobilePanel(p); + if (p !== "drafts") return setPanel(panel === p ? null : p); + if (panel) { + setPanel(null); + setLibrary(true); + } else setLibrary((v) => !v); + }; + const sideOpen = !overlay && (panel !== null || library); const goToLine = (line: number) => { setView("editor"); setMobilePanel(null); @@ -1466,8 +1479,8 @@ export function Studio({ docId }: { docId: string }) { const cloudDraft = !!doc && inCloud && !doc.shared; return [ cmd("New draft", () => void newDoc(), "create add"), - cmd("Import files…", () => fileInput.current?.click(), "open upload markdown zip"), - cmd("Import a folder…", () => folderInput.current?.click(), "open upload directory"), + cmd("Import files", () => fileInput.current?.click(), "open upload markdown zip"), + cmd("Import a folder", () => folderInput.current?.click(), "open upload directory"), cmd("Download .md", downloadMd, "export markdown file save"), cmd("Copy Markdown", copyMd, "export clipboard"), cmd("Copy rendered HTML", copyHtml, "export clipboard"), @@ -1480,11 +1493,7 @@ export function Studio({ docId }: { docId: string }) { cmd("Outline", () => open("outline"), "panel headings contents"), cmd("Front matter", () => open("meta"), "panel metadata yaml"), cmd("History", () => open("history"), "panel versions revisions"), - cmd( - "Drafts list", - () => (compact || focus ? setMobileLibrary(true) : setLibrary((v) => !v)), - "library sidebar folders", - ), + cmd("Drafts list", () => toggleSide("drafts"), "library sidebar folders"), cmd("Focus mode", () => setFocus((f) => !f), "distraction free zen"), cmd("Insert link", openLink, "url"), cmd("Insert image", () => setImageDialog({ open: true, initialAlt: "" }), "picture"), @@ -1495,10 +1504,10 @@ export function Studio({ docId }: { docId: string }) { cmd("Keyboard shortcuts", () => setShortcuts(true), "keys hotkeys"), ...(cloudDraft && doc ? [ - cmd("Share…", () => setShareTarget(doc), "link review publish"), - cmd("Edit together…", () => setCollabTarget(doc), "collaborate invite live"), + cmd("Share", () => setShareTarget(doc), "link review publish"), + cmd("Edit together", () => setCollabTarget(doc), "collaborate invite live"), ...(githubPublish - ? [cmd("Publish to GitHub…", () => setPublishTarget(doc), "commit gist")] + ? [cmd("Publish to GitHub", () => setPublishTarget(doc), "commit gist")] : []), ] : []), @@ -1532,6 +1541,8 @@ export function Studio({ docId }: { docId: string }) { setActiveThread(r.id); return undefined; }; + // one menu for what leaves the studio: publishing too, once the draft is in the cloud + const canPublish = inCloud && githubPublish; const panelButtons = ( [ ["checks", errCount ? AlertTriangle : CheckCircle2, "Checks"], @@ -1550,8 +1561,9 @@ export function Studio({ docId }: { docId: string }) { variant={activePanel === p ? "secondary" : "ghost"} size="icon" className="relative size-10 shrink-0" - onClick={() => (overlay ? setMobilePanel(p) : setPanel(panel === p ? null : p))} + onClick={() => toggleSide(p)} aria-label={label} + aria-pressed={activePanel === p} title={label} > @@ -1586,10 +1598,9 @@ export function Studio({ docId }: { docId: string }) { cloudOn ? void addToCloud(account.id, [d.id]) : askToConfirmEmail(), onRemove: (d: MdDocument) => void removeFromCloud(account.id, d.id), ...(cloudOn && { - onShare: (d: MdDocument) => setShareTarget(d), + onShare: (d: MdDocument) => setShareChoice(d), shared: sharedIds, sharedPrivately: privateIds, - onCollab: (d: MdDocument) => setCollabTarget(d), live: cloudDrafts.live, }), ...(cloudOn && githubPublish && { onPublish: (d: MdDocument) => setPublishTarget(d) }), @@ -1691,25 +1702,31 @@ export function Studio({ docId }: { docId: string }) {
    {/* Top bar */} -
    -
    +
    +
    - + + {/* the page's heading for assistive tech; the preview's own headings follow it */} +

    {doc?.title ?? "Editor"}

    / {doc?.title ?? "…"}
    -
    +
    {install && ( fileInput.current?.click()}>
    - Files or a ZIP… + Files or a ZIP Markdown, text, or an exported archive @@ -1756,7 +1773,7 @@ export function Studio({ docId }: { docId: string }) { folderInput.current?.click()}>
    - A folder… + A folder Folders become library folders @@ -1770,13 +1787,28 @@ export function Studio({ docId }: { docId: string }) { variant="default" size="sm" className="h-8 px-2 sm:px-3" - aria-label="Export" + aria-label={canPublish ? "Publish" : "Export"} > - - Export + {canPublish ? : } + {canPublish ? "Publish" : "Export"} + {canPublish && doc && ( + <> + Publish + setPublishTarget(doc)}> + +
    + Publish to GitHub + + A commit, a pull request or a gist + +
    +
    + + + )} Markdown Download .md @@ -1836,33 +1868,23 @@ export function Studio({ docId }: { docId: string }) {
    - {cloudOn && doc && cloudDrafts.linked.has(doc.id) && ( + {inCloud && doc && ( - )} - {cloudOn && githubPublish && doc && cloudDrafts.linked.has(doc.id) && ( - )} - - - + {/* from 1280px these live in the side strip */} + + + {/* from 1280px the account sits in the side strip */} + {compact && }
    -
    + {/* on a phone this is a second row; from 640px its two parts join the first */} +
    -
    +
    {( [ @@ -1916,7 +1939,10 @@ export function Studio({ docId }: { docId: string }) { key={v} variant={effectiveView === v ? "secondary" : "ghost"} size="icon" - className={cn("size-10 shrink-0", v === "split" && "hidden md:inline-flex")} + className={cn( + "size-10 shrink-0 sm:size-8", + v === "split" && "hidden md:inline-flex", + )} onClick={() => setView(v)} aria-label={`${v} view`} aria-pressed={effectiveView === v} @@ -1932,10 +1958,51 @@ export function Studio({ docId }: { docId: string }) {
    - {/* Library */} - {showLibrary && ( + {/* Panel buttons, on the left beside the pane they open */} + {!compact && ( + + )} + {/* The left pane: the drafts, or the panel chosen beside it */} + {sideOpen && (
    - {libraryContent} + {panel ? ( + + ) : ( + libraryContent + )}
    - - {/* Side panel */} - {!compact && ( -
    - {showPanel && ( - - )} -
    {panelButtons}
    -
    - )}
  • + !open && setShareChoice(null)} + onReview={() => { + if (shareChoice) setShareTarget(shareChoice); + setShareChoice(null); + }} + onEdit={() => { + if (shareChoice) setCollabTarget(shareChoice); + setShareChoice(null); + }} + /> ; + +/** The ` - - Go home - + + - + ); } diff --git a/src/routes/guides.$slug.tsx b/src/routes/guides.$slug.tsx index 80ab010..bf59275 100644 --- a/src/routes/guides.$slug.tsx +++ b/src/routes/guides.$slug.tsx @@ -3,15 +3,12 @@ import { ArrowRight } from "lucide-react"; import { SiteFooter } from "@/components/site/SiteFooter"; import { SiteHeader } from "@/components/site/SiteHeader"; import { Button } from "@/components/ui/button"; +import { DocLayout } from "@/components/site/DocLayout"; +import { Band, TILE } from "@/components/site/SitePieces"; +import { cn } from "@/lib/utils"; import { GUIDES, guideBySlug, readingMinutes } from "@/lib/site/guides"; -import { - formatDate, - headingIds, - loadGuideMarkdown, - relatedGuides, - withHeadingIds, -} from "@/lib/site/guides-content"; -import { getOutline, renderMarkdown } from "@/lib/markdown/markdown"; +import { formatDate, loadGuideMarkdown, relatedGuides } from "@/lib/site/guides-content"; +import { renderWithToc } from "@/lib/site/render-toc"; import { articleJsonLd, breadcrumbJsonLd, jsonLdScript, pageHead } from "@/lib/site/seo"; export const Route = createFileRoute("/guides/$slug")({ @@ -20,14 +17,7 @@ export const Route = createFileRoute("/guides/$slug")({ const guide = guideBySlug(params.slug); const md = guide ? await loadGuideMarkdown(guide.slug) : null; if (!guide || md === null) throw notFound(); - const sections = getOutline(md).filter((h) => h.depth === 2); - const ids = headingIds(sections.map((s) => s.text)); - return { - guide, - html: withHeadingIds(renderMarkdown(md, "gfm-extended"), ids), - minutes: readingMinutes(md), - toc: sections.map((s, i) => ({ text: s.text, id: ids[i]! })), - }; + return { guide, minutes: readingMinutes(md), ...renderWithToc(md) }; }, head: ({ loaderData, params }) => { const guide = loaderData?.guide ?? guideBySlug(params.slug); @@ -58,7 +48,7 @@ function GuidePage() { return (
    -
    + -
    -

    +
    +

    {guide.title}

    -

    - Updated {formatDate(guide.updated)} · {minutes} min read +

    + Updated {formatDate(guide.updated)} + {minutes} min read

    - {/* sanitized by renderMarkdown (rehype-sanitize) */} -
    +
    -
    -

    - Check your own Markdown -

    -

    - Open source and private. Pick a target platform and see what won’t travel. -

    -
    - + +
    +

    Check your own Markdown

    +

    + Open source and private. Pick a target platform and see what won’t travel. +

    -
    + +
    -
      +
      {relatedGuides(GUIDES, guide.slug).map((g) => ( -
    • - - {g.title} - -

      {g.description}

      -
    • + +

      {g.title}

      +

      {g.description}

      + ))} -
    +

    - + ); diff --git a/src/routes/guides.index.tsx b/src/routes/guides.index.tsx index 6c2e294..467373c 100644 --- a/src/routes/guides.index.tsx +++ b/src/routes/guides.index.tsx @@ -1,6 +1,8 @@ import { createFileRoute, Link } from "@tanstack/react-router"; import { SiteFooter } from "@/components/site/SiteFooter"; import { SiteHeader } from "@/components/site/SiteHeader"; +import { Chip, SITE_WIDTH, TILE } from "@/components/site/SitePieces"; +import { cn } from "@/lib/utils"; import { formatDate } from "@/lib/site/guides-content"; import { GUIDES, guidePath } from "@/lib/site/guides"; import { breadcrumbJsonLd, jsonLdScript, pageHead } from "@/lib/site/seo"; @@ -28,30 +30,32 @@ function GuidesIndex() { return (
    -
    -

    - Markdown guides -

    -

    - Practical, platform-aware guides to writing Markdown that renders the same on GitHub, - dev.to, Obsidian and any CommonMark tool. Each one explains what differs and how to avoid - surprises. -

    -
      +
      +
      +

      + Markdown guides +

      +

      + Practical, platform-aware guides to writing Markdown that renders the same on GitHub, + dev.to, Obsidian and any CommonMark tool. Each one explains what differs and how to + avoid surprises. +

      +
      +
        {GUIDES.map((g) => ( -
      • -

        +
      • + Updated {formatDate(g.updated)} +

        {g.title}

        -

        {g.description}

        -

        Updated {formatDate(g.updated)}

        +

        {g.description}

      • ))}

      diff --git a/src/routes/index.tsx b/src/routes/index.tsx index 567aa36..d666ef5 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -210,7 +210,11 @@ on two lines.
    -
    +

    Everything a Markdown writer needs

    diff --git a/src/routes/privacy.tsx b/src/routes/privacy.tsx index 4917011..61a7d1d 100644 --- a/src/routes/privacy.tsx +++ b/src/routes/privacy.tsx @@ -1,8 +1,8 @@ import { createFileRoute, notFound } from "@tanstack/react-router"; import { LegalPage } from "@/components/site/LegalPage"; -import { renderMarkdown } from "@/lib/markdown/markdown"; import { legalBySlug, legalPath } from "@/lib/site/legal"; import { loadLegalMarkdown } from "@/lib/site/legal-content"; +import { renderWithToc } from "@/lib/site/render-toc"; import { pageHead } from "@/lib/site/seo"; const page = legalBySlug("privacy")!; @@ -11,7 +11,7 @@ export const Route = createFileRoute("/privacy")({ loader: async () => { const md = await loadLegalMarkdown(page.slug); if (md === null) throw notFound(); - return { html: renderMarkdown(md, "gfm-extended") }; + return renderWithToc(md); }, head: () => pageHead({ @@ -23,5 +23,6 @@ export const Route = createFileRoute("/privacy")({ }); function Page() { - return ; + const { html, toc } = Route.useLoaderData(); + return ; } diff --git a/src/routes/reset-password.tsx b/src/routes/reset-password.tsx index fc2df36..26f5ffe 100644 --- a/src/routes/reset-password.tsx +++ b/src/routes/reset-password.tsx @@ -2,7 +2,7 @@ import { Link, createFileRoute } from "@tanstack/react-router"; import { Eye, EyeOff } from "lucide-react"; import { useEffect, useState } from "react"; -import { Logo } from "@/components/Logo"; +import { Standalone, StandaloneBox } from "@/components/site/Standalone"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; @@ -47,12 +47,11 @@ function ResetPassword() { } return ( -
    -
    - + + {done ? (
    -

    Password changed

    +

    Password changed

    Every device was signed out. Sign in with your new password.

    @@ -62,7 +61,7 @@ function ResetPassword() {
    ) : !held ? (
    -

    This link doesn't work

    +

    This link doesn't work

    It's missing its code. Open the link from the email again, or ask for a new one from the sign-in dialog. @@ -79,7 +78,7 @@ function ResetPassword() { void submit(); }} > -

    Choose a new password

    +

    Choose a new password

    @@ -115,12 +114,12 @@ function ResetPassword() { {error}

    )} - )} -
    -
    + + ); } diff --git a/src/routes/s.$slug.tsx b/src/routes/s.$slug.tsx index 5ed5d38..b0d25a9 100644 --- a/src/routes/s.$slug.tsx +++ b/src/routes/s.$slug.tsx @@ -1,10 +1,14 @@ -import { createFileRoute, notFound, useRouter } from "@tanstack/react-router"; +import { createFileRoute, Link, notFound, useRouter } from "@tanstack/react-router"; import { Lock } from "lucide-react"; import { useEffect, useMemo, useRef, useState } from "react"; import { ReaderSignIn } from "@/components/share/ReaderSignIn"; import { ShareComments } from "@/components/share/Comments"; import { SiteFooter } from "@/components/site/SiteFooter"; -import { SiteHeader } from "@/components/site/SiteHeader"; +import { Logo } from "@/components/Logo"; +import { ThemeToggle } from "@/components/ThemeToggle"; +import { Chip, SITE_WIDTH } from "@/components/site/SitePieces"; +import { Standalone, StandaloneBox } from "@/components/site/Standalone"; +import { cn } from "@/lib/utils"; import { Button } from "@/components/ui/button"; import { accountStore } from "@/lib/account/store"; import { hydrateDiagrams, renderDiagramFor } from "@/lib/markdown/diagrams"; @@ -57,27 +61,30 @@ function SharedPage() { if (data.kind === "sign_in") return ( -
    - -
    -
    - +

    + You come straight back here after signing in. +

    + -
    + ); return ; } @@ -113,54 +120,73 @@ function Document({ hydrateDiagrams(body.current, renderDiagramFor(theme)).catch((e) => console.error(e)); }, [html, theme]); + const report = `${SITE.repo}/issues/new?title=${encodeURIComponent("Report a shared page")}&body=${encodeURIComponent(`/s/${slug}`)}`; + // The bar, the text and the footer share one width: wide enough for the comments column while it + // shows, and just the text (centred) when it does not. + const [side, setSide] = useState(false); + const width = side ? "max-w-310" : "max-w-230"; return (
    - -
    -

    - {data.kind === "private" && ( - <> -

    -
    -
    +
    +
    + + + {data.comments ? "Shared for review" : "Shared copy"} + +
    + + +
    +
    +
    +
    +
    +
    +

    + {data.kind === "private" && ( + + + )} + A copy shared with mdstudio on {shareDate(data.publishedAt)}. + Available until {shareDate(data.expiresAt)}. +

    {!/]/.test(html) &&

    {title}

    }
    +

    + Made with mdstudio + + Report this page + +

    - data.kind === "private" && onSignedIn()} - /> + {/* the comments column, while it shows */} +
    + data.kind === "private" && onSignedIn()} + onSideChange={setSide} + /> +
    - +
    ); } diff --git a/src/routes/terms.tsx b/src/routes/terms.tsx index 637d7e4..7af1a3a 100644 --- a/src/routes/terms.tsx +++ b/src/routes/terms.tsx @@ -1,8 +1,8 @@ import { createFileRoute, notFound } from "@tanstack/react-router"; import { LegalPage } from "@/components/site/LegalPage"; -import { renderMarkdown } from "@/lib/markdown/markdown"; import { legalBySlug, legalPath } from "@/lib/site/legal"; import { loadLegalMarkdown } from "@/lib/site/legal-content"; +import { renderWithToc } from "@/lib/site/render-toc"; import { pageHead } from "@/lib/site/seo"; const page = legalBySlug("terms")!; @@ -11,7 +11,7 @@ export const Route = createFileRoute("/terms")({ loader: async () => { const md = await loadLegalMarkdown(page.slug); if (md === null) throw notFound(); - return { html: renderMarkdown(md, "gfm-extended") }; + return renderWithToc(md); }, head: () => pageHead({ @@ -23,5 +23,6 @@ export const Route = createFileRoute("/terms")({ }); function Page() { - return ; + const { html, toc } = Route.useLoaderData(); + return ; } diff --git a/src/styles.css b/src/styles.css index e5db659..6c3c94b 100644 --- a/src/styles.css +++ b/src/styles.css @@ -480,8 +480,9 @@ .cm-editor.cm-focused { outline: none; } -.cm-scroller { - font-family: var(--font-mono); +/* !important: CodeMirror's base theme sets "monospace" on the scroller with a selector that wins otherwise. */ +.cm-editor .cm-scroller { + font-family: var(--font-mono) !important; line-height: 1.7; } .cm-content {