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
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
120 changes: 117 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,130 @@ import '../styles/global.css';
const { frontmatter } = Astro.props;
---

<DocsLayout config={docs} title={frontmatter.title} description={frontmatter.description}>
<DocsLayout
config={docs}
title={frontmatter.title}
description={frontmatter.description}
headings={Astro.props.headings}
>
<slot />
</DocsLayout>
```

`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.'],
];
---

<DocsTable
caption="Deployment settings."
columns={[
{ label: 'Key', width: 'narrow' },
{ label: 'Type', width: 'narrow' },
{ label: 'Default', width: 'narrow' },
{ label: 'Meaning', width: 'prose' },
]}
rows={rows}
/>
```

`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';
---

<CardGrid>
<DocsCard
config={docs}
title="Install"
description="Run the server locally."
href="/docs/install"
icon="M12 3v12m0 0 4-4m-4 4-4-4M5 21h14"
/>
<DocsCard
config={docs}
title="Configuration"
description="Server and deployment settings."
href="/docs/config"
/>
</CardGrid>
```

`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' },
];
---

<DocsLayout config={docs} title="Configuration" headings={headings}>
<h2 id="deployment">Deployment</h2>
<h3 id="database">Database</h3>
</DocsLayout>
```

## Public API

### Core — `import { ... } from '@kolektiv/common-docs-chrome'`

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
Expand Down Expand Up @@ -246,7 +357,10 @@ Every component lives at `@kolektiv/common-docs-chrome/astro/<Name>.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 |
Expand Down
5 changes: 5 additions & 0 deletions playground/src/docs-chrome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
],
},
Expand Down
2 changes: 2 additions & 0 deletions playground/src/layouts/Docs.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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}
>
<slot />
</DocsLayout>
65 changes: 65 additions & 0 deletions playground/src/pages/docs/config.md
Original file line number Diff line number Diff line change
@@ -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.
79 changes: 77 additions & 2 deletions playground/src/pages/docs/index.astro
Original file line number Diff line number Diff line change
@@ -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',
},
];
---

<DocsLayout config={docs} title="Overview">
<DocsLayout config={docs} title="Overview" headings={headings}>
<h1>Kalendee documentation</h1>
<p>
Welcome to the playground. The sidebar, navbar, theme picker and search dialog
above are all components from
<code>@kolektiv/common-docs-chrome</code>.
</p>
<h2>Language and framework panels</h2>

<h2 id="start-here">Start here</h2>
<CardGrid columns={3}>
<DocsCard
config={docs}
title="Install"
description="Run the Kalendee server locally with Gradle and open the web client."
href="/docs/install"
icon="M12 3v12m0 0 4-4m-4 4-4-4M5 21h14"
/>
<DocsCard
config={docs}
title="Configuration"
description="Deployment, database and reverse-proxy settings with defaults."
href="/docs/config"
icon="M4 7h16M4 12h10M4 17h7"
/>
<DocsCard
config={docs}
title="Theming"
description="Site themes, code themes and the theme picker."
href="/docs/theming"
icon="M12 3a9 9 0 1 0 0 18h1a2 2 0 0 0 0-4h-1a2 2 0 0 1 0-4h3a3 3 0 0 0 0-6h-3z"
/>
</CardGrid>

<h2 id="deployment-options">Deployment options</h2>
<p>
This table is rendered with <code>DocsTable</code>. The key, type and default
columns are marked <code>narrow</code>; the meaning column is <code>prose</code>.
</p>
<DocsTable
caption="Common deployment settings and their defaults."
columns={[
{ label: 'Key', width: 'narrow' },
{ label: 'Type', width: 'narrow' },
{ label: 'Default', width: 'narrow' },
{ label: 'Meaning', width: 'prose' },
]}
rows={[
[
'ktor.deployment.port',
'Int',
'8080',
'TCP port the HTTP server binds to. Change it when another process already owns the 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.',
],
[
'ktor.deployment.workers',
'Int',
'4',
'Request worker threads. Keep it at or below the available CPU cores so sync traffic does not oversubscribe them.',
],
]}
/>

<h2 id="language-and-framework-panels">Language and framework panels</h2>
<p>
The pickers switch <code>data-lang</code> and <code>data-framework</code> on the
root element. Panels below use the convention expected by
Expand Down
13 changes: 12 additions & 1 deletion playground/src/pages/docs/install.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,23 @@ import { docs } from '../../docs-chrome';
import '../../styles/global.css';
---

<DocsLayout config={docs} title="Install" description="Run the Kalendee server locally.">
<DocsLayout
config={docs}
title="Install"
description="Run the Kalendee server locally."
toc={false}
>
<h1>Install</h1>
<p>Run the server with Gradle:</p>
<pre class="astro-code"><code>./gradlew :server:run</code></pre>
<p>
Then open <a href="http://localhost:8080">localhost:8080</a>. The default theme
is <strong>{docs.defaultTheme}</strong>.
</p>
<h2 id="requirements">Requirements</h2>
<p>
Install JDK 21 and make sure the working directory is writable: Kalendee keeps
its embedded database under <code>data/</code>. This page passes
<code>toc=&#123;false&#125;</code>, so no table of contents is rendered.
</p>
</DocsLayout>
19 changes: 19 additions & 0 deletions src/astro/CardGrid.astro
Original file line number Diff line number Diff line change
@@ -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;
---

<div
class:list={[
'kdc-card-grid not-prose grid gap-4',
columns === 2 ? 'sm:grid-cols-2' : 'sm:grid-cols-2 lg:grid-cols-3',
className,
]}
>
<slot />
</div>
Loading
Loading