From e46d74567d456aeb2e5eac7763e561b93aef2b3d Mon Sep 17 00:00:00 2001 From: Elizabeth Hazel Ainslie Date: Mon, 26 Oct 2026 05:15:07 -0500 Subject: [PATCH] feat: docs tables, cards, search dialog and ToC (#8, #9, #10, #11) Add DocsTable with explicit narrow/prose columns and a scroll box, plus default Markdown table styles that never scroll the page. Add CardGrid and DocsCard with explicit prose resets so cards have no bullets or underlined text. Rework SearchDialog into a single header row with a themed focus ring, readable results, a 16px input and a full-screen mobile dialog. Generate an On this page ToC in DocsLayout from headings, with a sticky desktop sidebar, a mobile details block, active-section highlighting and a toc={false} opt-out. Closes #8 Closes #9 Closes #10 Closes #11 --- CHANGELOG.md | 20 +++ README.md | 120 ++++++++++++++++- playground/src/docs-chrome.ts | 5 + playground/src/layouts/Docs.astro | 2 + playground/src/pages/docs/config.md | 65 +++++++++ playground/src/pages/docs/index.astro | 79 ++++++++++- playground/src/pages/docs/install.astro | 13 +- src/astro/CardGrid.astro | 19 +++ src/astro/DocsCard.astro | 51 +++++++ src/astro/DocsLayout.astro | 112 +++++++++++++++- src/astro/DocsTable.astro | 52 ++++++++ src/astro/SearchDialog.astro | 30 +++-- src/astro/index.ts | 3 + src/core/config.ts | 10 ++ src/styles/chrome.css | 170 +++++++++++++++++++++++- 15 files changed, 728 insertions(+), 23 deletions(-) create mode 100644 playground/src/pages/docs/config.md create mode 100644 src/astro/CardGrid.astro create mode 100644 src/astro/DocsCard.astro create mode 100644 src/astro/DocsTable.astro diff --git a/CHANGELOG.md b/CHANGELOG.md index 44c1c08..4b386b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- `DocsTable` (`columns`/`rows`, narrow + prose columns, optional caption) and + default Markdown table styles that scroll inside the table instead of the page. +- `CardGrid` and `DocsCard` for overview pages, with prose resets so cards have + no list markers or underlined text. +- Auto-generated "On this page" table of contents in `DocsLayout`: sticky + desktop sidebar at `lg`, collapsible block below `lg`, active-section + highlight, `headings` prop and `toc={false}` opt-out. + +### Fixed + +- `SearchDialog` header is one row with an inline close button, a themed focus + ring replaces the default outline, result titles/breadcrumbs are readable, + the input is at least 16px to stop iOS zoom, and the dialog is full-screen + below 640px. +- Tables with many narrow columns no longer overflow or squeeze prose cells to + one word per line. +- Cards no longer inherit prose bullets or underlines. + ## [0.0.1] - 2026-10-26 ### Changed diff --git a/README.md b/README.md index 3742dc4..03a02f9 100644 --- a/README.md +++ b/README.md @@ -178,11 +178,121 @@ import '../styles/global.css'; const { frontmatter } = Astro.props; --- - + ``` +`Astro.props.headings` is supplied by Astro for Markdown pages; forwarding it +gives every page the automatic table of contents. Add `toc={false}` to a page to +opt out. + +## Content components + +### Tables + +Plain Markdown tables are styled by `chrome.css` with no page changes. Every +column except the last is treated as a key/type/default column: it shrinks to +content and does not wrap. The last column is treated as prose, wraps at a +comfortable measure, and the table scrolls inside its own box when the columns +cannot fit — the page itself never scrolls sideways. + +When a table does not follow that convention, use `DocsTable` and describe each +column explicitly: + +```astro +--- +import DocsTable from '@kolektiv/common-docs-chrome/astro/DocsTable.astro'; + +const rows = [ + ['ktor.deployment.port', 'Int', '8080', 'TCP port the HTTP server binds to.'], + ['ktor.deployment.host', 'String', '0.0.0.0', 'Interface the server binds to.'], +]; +--- + + +``` + +`width` is `narrow` (shrink + nowrap), `prose` (wrap at 16–20ch on mobile and +20–48ch above 640px), or omitted (`prose`). `align` accepts `left`, `center` or +`right`. Cells are plain strings or numbers and are escaped by Astro. + +### Overview cards + +`CardGrid` lays out overview cards at one column on phones, two at `sm`, and +three at `lg` (pass `columns={2}` to stop at two). `DocsCard` renders one link +card and never inherits prose bullets or underlines: + +```astro +--- +import CardGrid from '@kolektiv/common-docs-chrome/astro/CardGrid.astro'; +import DocsCard from '@kolektiv/common-docs-chrome/astro/DocsCard.astro'; +import { docs } from '../docs-chrome'; +--- + + + + + +``` + +`icon` is inline SVG path data for a 24×24 viewBox, matching `NavItem.icon`. +External links are detected with `isExternal`; `external` forces the behaviour. + +### Table of contents + +`DocsLayout` renders an "On this page" table of contents from `headings` by +default. Markdown pages only need to forward `Astro.props.headings` from their +layout wrapper. At 1024px and wider it is a sticky right-hand sidebar with the +active section highlighted; below that it collapses into an "On this page" +block above the content. `toc={false}` opts a page out. + +`.astro` pages have no generated headings, so pass them explicitly and give the +matching elements `id`s: + +```astro +--- +import DocsLayout from '@kolektiv/common-docs-chrome/astro/DocsLayout.astro'; +import { docs } from '../docs-chrome'; +import type { TocHeading } from '@kolektiv/common-docs-chrome'; + +const headings: TocHeading[] = [ + { depth: 2, slug: 'deployment', text: 'Deployment' }, + { depth: 3, slug: 'database', text: 'Database' }, +]; +--- + + +

Deployment

+

Database

+
+``` + ## Public API ### Core — `import { ... } from '@kolektiv/common-docs-chrome'` @@ -190,7 +300,8 @@ const { frontmatter } = Astro.props; Config: - `DocsChromeConfig`, `NavSection`, `NavItem`, `NavbarConfig`, `FooterConfig`, - `FooterLink`, `RepoConfig`, `BuiltByConfig`, `SwitcherConfig`, `SwitcherOption` + `FooterLink`, `RepoConfig`, `BuiltByConfig`, `SwitcherConfig`, `SwitcherOption`, + `TocHeading` - `defineDocsChrome(config)` — fills defaults, returns a normalised config - `pageLabelFor(config, pathname)`, `findNavItem(config, pathname)` - `resolveNavbar(config, override?)` — navbar flags + links, layered over @@ -246,7 +357,10 @@ Every component lives at `@kolektiv/common-docs-chrome/astro/.astro`: | --- | --- | | `BaseHead.astro` | SEO/OG/canonical meta, no-flash script, theme + Shiki CSS | | `BaseLayout.astro` | Marketing/landing shell (navbar + main + footer) | -| `DocsLayout.astro` | Primary docs shell (sidebar lockup, navbar, footer) | +| `DocsLayout.astro` | Primary docs shell (sidebar lockup, navbar, auto ToC, footer) | +| `DocsTable.astro` | Table with explicit narrow/prose columns and an internal scroll box | +| `CardGrid.astro` | Responsive 1/2/3-column grid for overview cards | +| `DocsCard.astro` | Link card with title, description and optional icon | | `Navbar.astro` | Sticky navbar with the current page label and controls | | `Sidebar.astro` | Categorised nav, optional per-item icons, active highlight | | `Footer.astro` | Footer with links, the identity lockup, the built-by mark and copyright | diff --git a/playground/src/docs-chrome.ts b/playground/src/docs-chrome.ts index e4881e4..726266c 100644 --- a/playground/src/docs-chrome.ts +++ b/playground/src/docs-chrome.ts @@ -54,6 +54,11 @@ export const docs = defineDocsChrome({ description: 'Run the server locally', icon: 'M12 3v12m0 0 4-4m-4 4-4-4M5 21h14', }, + { + label: 'Configuration', + href: '/docs/config', + description: 'Server and deployment options', + }, { label: 'Theming', href: '/docs/theming', description: 'Themes and code blocks' }, ], }, diff --git a/playground/src/layouts/Docs.astro b/playground/src/layouts/Docs.astro index 43d1599..91067cf 100644 --- a/playground/src/layouts/Docs.astro +++ b/playground/src/layouts/Docs.astro @@ -11,6 +11,8 @@ const { frontmatter } = Astro.props; config={docs} title={frontmatter.title ?? 'Docs'} description={frontmatter.description ?? docs.description} + headings={Astro.props.headings} + toc={frontmatter.toc ?? Astro.props.toc} >
diff --git a/playground/src/pages/docs/config.md b/playground/src/pages/docs/config.md new file mode 100644 index 0000000..58e23d7 --- /dev/null +++ b/playground/src/pages/docs/config.md @@ -0,0 +1,65 @@ +--- +layout: ../../layouts/Docs.astro +title: Configuration +description: Server, deployment and database options. +--- + +# Configuration + +Kalendee reads a `ktor.deployment.*` block from `application.conf`. Every value +can also be supplied through an environment variable named after the property in +upper snake case. + +## Deployment + +The deployment group controls how the server binds and how many requests it +accepts. Defaults are tuned for a single-node self-hosted install. + +### Server + +| Key | Type | Default | Meaning | +| --- | --- | --- | --- | +| `ktor.deployment.port` | `Int` | `8080` | TCP port the HTTP server binds to. Change this when another process already owns 8080, or when a reverse proxy forwards traffic to a non-default port. | +| `ktor.deployment.host` | `String` | `0.0.0.0` | Interface the server binds to. Use `127.0.0.1` when a local reverse proxy is the only client, so the server is not reachable from the network directly. | +| `ktor.deployment.shutdownGracePeriod` | `Long` | `3000` | Milliseconds to wait for in-flight requests before a graceful shutdown completes. Increase it when large CalDAV exports are common. | +| `ktor.deployment.workers` | `Int` | `4` | Number of request worker threads. Keep it at or below the number of CPU cores available to the container; oversubscribing hurts latency under sync load. | + +### Long property names + +Configuration keys are not capped, so a very long name can exceed the space a +narrow column would normally take. The table below keeps the prose column +readable and scrolls inside its own box when the key does not fit. + +| Key | Note | +| --- | --- | +| `ktor.deployment.veryLongConfigurationPropertyNameWithoutAnySpaces` | A deliberately long key used by the playground to prove the table scrolls inside its own box instead of widening the page. It is not a real Kalendee setting. | + +### Database + +The database group configures the embedded store. Kalendee ships an embedded +SQLite database for small installs and accepts a PostgreSQL connection string for +larger deployments. + +| Key | Type | Default | Meaning | +| --- | --- | --- | --- | +| `ktor.deployment.database.driver` | `String` | `sqlite` | Storage driver. Use `postgres` for multi-node deployments, or keep `sqlite` for a single server with local disk. | +| `ktor.deployment.database.url` | `String` | `jdbc:sqlite:data/kalendee.db` | JDBC URL for the database. Relative paths resolve from the server working directory, so a container must mount a persistent volume at that path. | +| `ktor.deployment.database.maxPoolSize` | `Int` | `10` | Maximum pooled connections. Raise it only when the database itself has headroom; a large pool on a small database increases contention instead of throughput. | +| `ktor.deployment.database.migrateOnStart` | `Boolean` | `true` | Run pending schema migrations at boot. Disable it when migrations are applied by a separate deploy job so several replicas do not race each other. | + +### Reverse proxy + +Set `trustProxy` when Kalendee runs behind a load balancer, otherwise every +request appears to come from the proxy address and rate limits apply globally. + +| Key | Type | Default | Meaning | +| --- | --- | --- | --- | +| `ktor.deployment.trustProxy` | `Boolean` | `false` | Honour `X-Forwarded-For` and `X-Forwarded-Proto` from the immediate peer. Enable it only when the peer is a proxy you control. | +| `ktor.deployment.publicUrl` | `String` | `http://localhost:8080` | Canonical origin used in calendar feeds, invite links and password-reset mail. It must match the URL users actually open. | +| `ktor.deployment.maxRequestSize` | `Long` | `10485760` | Maximum upload size in bytes for `.ics` imports. Large calendar archives need a higher limit and a matching proxy limit. | + +## Verifying the result + +After changing any value, restart the server and open the health endpoint. The +response reports the effective port, database driver and public URL, which is the +quickest way to confirm that an environment variable override took effect. diff --git a/playground/src/pages/docs/index.astro b/playground/src/pages/docs/index.astro index fe4005c..b258fda 100644 --- a/playground/src/pages/docs/index.astro +++ b/playground/src/pages/docs/index.astro @@ -1,18 +1,93 @@ --- import DocsLayout from '@kolektiv/common-docs-chrome/astro/DocsLayout.astro'; +import CardGrid from '@kolektiv/common-docs-chrome/astro/CardGrid.astro'; +import DocsCard from '@kolektiv/common-docs-chrome/astro/DocsCard.astro'; +import DocsTable from '@kolektiv/common-docs-chrome/astro/DocsTable.astro'; +import type { TocHeading } from '@kolektiv/common-docs-chrome'; import { docs } from '../../docs-chrome'; import '../../styles/global.css'; + +const headings: TocHeading[] = [ + { depth: 2, slug: 'start-here', text: 'Start here' }, + { depth: 2, slug: 'deployment-options', text: 'Deployment options' }, + { + depth: 2, + slug: 'language-and-framework-panels', + text: 'Language and framework panels', + }, +]; --- - +

Kalendee documentation

Welcome to the playground. The sidebar, navbar, theme picker and search dialog above are all components from @kolektiv/common-docs-chrome.

-

Language and framework panels

+ +

Start here

+ + + + + + +

Deployment options

+

+ This table is rendered with DocsTable. The key, type and default + columns are marked narrow; the meaning column is prose. +

+ + +

Language and framework panels

The pickers switch data-lang and data-framework on the root element. Panels below use the convention expected by diff --git a/playground/src/pages/docs/install.astro b/playground/src/pages/docs/install.astro index 42c01b7..0218e7f 100644 --- a/playground/src/pages/docs/install.astro +++ b/playground/src/pages/docs/install.astro @@ -5,7 +5,12 @@ import { docs } from '../../docs-chrome'; import '../../styles/global.css'; --- - +

Install

Run the server with Gradle:

./gradlew :server:run
@@ -13,4 +18,10 @@ import '../../styles/global.css'; Then open localhost:8080. The default theme is {docs.defaultTheme}.

+

Requirements

+

+ Install JDK 21 and make sure the working directory is writable: Kalendee keeps + its embedded database under data/. This page passes + toc={false}, so no table of contents is rendered. +

diff --git a/src/astro/CardGrid.astro b/src/astro/CardGrid.astro new file mode 100644 index 0000000..45f72f2 --- /dev/null +++ b/src/astro/CardGrid.astro @@ -0,0 +1,19 @@ +--- +interface Props { + /** Column count at `lg`. Default 3; `sm` is always 2, base is 1. */ + columns?: 2 | 3; + class?: string; +} + +const { columns = 3, class: className } = Astro.props; +--- + +
+ +
diff --git a/src/astro/DocsCard.astro b/src/astro/DocsCard.astro new file mode 100644 index 0000000..146cc54 --- /dev/null +++ b/src/astro/DocsCard.astro @@ -0,0 +1,51 @@ +--- +import { + isExternal, + path, + type DocsChromeConfig, +} from '@kolektiv/common-docs-chrome'; + +interface Props { + config: DocsChromeConfig; + title: string; + description?: string; + href: string; + /** Inline SVG path data for a 24×24 viewBox, matching `NavItem.icon`. */ + icon?: string; + /** Force external rendering; otherwise inferred from the href. */ + external?: boolean; + class?: string; +} + +const { config, title, description, href, icon, class: className } = Astro.props; +const external = Astro.props.external ?? isExternal(href); +const resolvedHref = external ? href : path(href, config.base); +--- + + + {icon && ( + + )} + {title} + {description && ( + {description} + )} + + diff --git a/src/astro/DocsLayout.astro b/src/astro/DocsLayout.astro index 3bb2ef0..7834281 100644 --- a/src/astro/DocsLayout.astro +++ b/src/astro/DocsLayout.astro @@ -12,6 +12,7 @@ import { toggleRelevanceScript, type DocsChromeConfig, type NavbarConfig, + type TocHeading, } from '@kolektiv/common-docs-chrome'; interface Props { @@ -22,6 +23,10 @@ interface Props { pageLabel?: string; /** Per-page navbar override, merged over `config.navbar`. */ navbar?: Partial; + /** Astro Markdown headings, or hand-authored h2/h3 entries for `.astro` pages. */ + headings?: TocHeading[]; + /** Auto ToC on by default; `false` opts a page out. */ + toc?: boolean; } const { config, navbar } = Astro.props; @@ -38,6 +43,10 @@ const switcherAttrs = Object.fromEntries( ]), ); const drawerId = 'kdc-drawer'; +const headings = (Astro.props.headings ?? []).filter( + (heading) => (heading.depth === 2 || heading.depth === 3) && heading.slug && heading.text, +); +const showToc = Astro.props.toc !== false && headings.length > 0; --- @@ -88,8 +97,55 @@ const drawerId = 'kdc-drawer';
-
- +
+
+ { + showToc && ( +
+ On this page + +
+ ) + } +
+ +
+
+ { + showToc && ( + + ) + }