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
34 changes: 28 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ on:
- ".github/workflows/release.yml"
# Required checks must be reported for every PR, including docs-only changes.
pull_request:
branches:
- "main"
merge_group:

concurrency:
Expand All @@ -29,23 +27,41 @@ jobs:
ci_selection:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
# Only a confirmed excluded-files-only PR may skip the core jobs.
full: ${{ github.event_name != 'pull_request' || steps.paths.outputs.full != 'false' }}
# Run the audit when a tag or oversized PR cannot be filtered.
accessibility: ${{ steps.paths.outputs.accessibility != 'false' }}
steps:
- uses: actions/checkout@v7
if: github.event_name != 'pull_request' && github.ref_type != 'tag'
- id: paths
name: Select test jobs
# The PR files API is limited to 3000 files; larger PRs select core jobs.
if: github.event_name == 'pull_request' && github.event.pull_request.changed_files <= 3000
if: github.ref_type != 'tag' && (github.event_name != 'pull_request' || github.event.pull_request.changed_files <= 3000)
uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
with:
predicate-quantifier: every
predicate-quantifier: some-with-excludes
filters: |
full:
- '**'
- '!docs/**'
- '!README.md'
- '!.github/workflows/release.yml'
accessibility:
- 'sqlpage/templates/**'
- 'frontend/**'
- 'src/{dynamic_component,render,template_helpers,templates}.rs'
- 'examples/official-site/**'
- 'configuration.md'
- 'scripts/{build-frontend,site-build}.mjs'
- 'package-lock.json'
- 'package.json'
- 'tests/end-to-end/**'
- '.github/actions/install-frontend-dependencies/**'
- '.github/workflows/ci.yml'

compile_and_lint:
needs: ci_selection
Expand Down Expand Up @@ -233,7 +249,7 @@ jobs:
playwright:
runs-on: ubuntu-latest
timeout-minutes: 10
needs: compile_and_lint
needs: [ci_selection, compile_and_lint]
defaults:
run:
working-directory: ./tests/end-to-end
Expand All @@ -257,9 +273,15 @@ jobs:
name: official-site
path: target/official-site
- name: Run Playwright tests
env:
RUN_ACCESSIBILITY: ${{ needs.ci_selection.outputs.accessibility }}
run: |
chmod +x "${{ runner.temp }}/sqlpage-bin/sqlpage"
SQLPAGE_BINARY="${{ runner.temp }}/sqlpage-bin/sqlpage" npx playwright test
args=()
if [[ "$RUN_ACCESSIBILITY" == false ]]; then
args+=(--grep-invert @accessibility)
fi
SQLPAGE_BINARY="${{ runner.temp }}/sqlpage-bin/sqlpage" npx playwright test "${args[@]}"
- uses: actions/upload-artifact@v7
if: ${{ !cancelled() }}
with:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## unreleased

- Component reference pages accept `theme=light` and `theme=dark` to preview examples with SQLPage's stock themes.
- The first-website tutorial now lets you choose an installation target, copy a command, or download an archive for macOS, Windows, Linux, or AWS Lambda.
- Missing component pages on the official site return HTTP 404 and link to the catalog. Action buttons in colored alerts stay readable.
- The `shell` sidebar now uses `navbar_title` and preserves the colors of the supplied logo in dark mode.
Expand Down
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ built executable. Component suites use `fixtures/<suite>/{index.sql,test.ts}` an
import the shared `fixture.ts` harness; root-level `*.spec.ts` files cover the
official site.

Run `npx playwright test --grep @accessibility` from `tests/end-to-end` to audit
the official site's component documentation and its live examples in SQLPage's
stock light and dark themes with axe-core. CI includes this test when component
templates, frontend code, the official site, or audit inputs change.

To show that an issue exists before you fix it, put the reproduction in a fixture and run it against releases with one command, such as `nix run .#reproduce -- repro_721 postgres v0.35.0 v0.36.1 tree`. The second argument is `sqlite` or `postgres`, and `tree` is your working tree. It prints Playwright's output for each version, then a table you can paste into the issue or pull request. Releases run from their Docker images, from v0.29.0 onwards, and Postgres from `docker compose`. Without Nix, run `npm run reproduce --` in `tests/end-to-end` instead.

To run a whole suite against a release instead, set `SQLPAGE_RELEASE` to its tag, such as `SQLPAGE_RELEASE=v0.47.0 npx playwright test fixtures/tracking`. Both servers then run that release's Docker image against the same fixtures, on ports 18080 and 18081, so the test fails on the release and passes on your working tree. Add `--ui` to watch the page in each step.
Expand Down
4 changes: 4 additions & 0 deletions examples/official-site/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Run SQLPage from that directory, or run
`docker compose -f examples/official-site/docker-compose.yml up --build` from
the repository root.

Add `theme=light` or `theme=dark` to a component reference URL to preview its
live examples using SQLPage's stock theme. For example, visit
`/component.sql?component=form&theme=light`.

## Landing page

The home page is rendered by `index.sql` and the `landing-page` custom template.
Expand Down
68 changes: 38 additions & 30 deletions examples/official-site/assets/docs/examples.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,44 +16,52 @@
display: flow-root;
container-type: inline-size;
padding: var(--tblr-spacer-3);
}

/* The branded previews adjust native components to fit the docs layout. */
:where([data-site-theme="custom-docsite"]) .docs-example-output {
--tblr-carousel-control-icon-filter: none;
--tblr-carousel-indicator-active-bg: var(--tblr-heading-color);
}
/* Tabler sizes columns against the viewport. A card in a preview can have much less room. */
.docs-example-output > .row > * {
flex-grow: 1;
min-width: min(100%, 17rem);
}
.docs-example-output form .row > label {
min-width: min(100%, 12rem);
}
.docs-example-output .card {
max-width: 100%;
}
.docs-example-output .table-freeze-columns tr > :first-child {
width: clamp(7rem, 32cqi, 11rem);
min-width: min(9rem, 40cqi);
white-space: normal;
}
.docs-example-output .pagination {
flex-wrap: wrap;
}
.docs-example-output .markdown table {
display: block;
overflow-x: auto;

/* Preview columns can have much less room than the viewport. */
& > .row > * {
flex-grow: 1;
min-width: min(100%, 17rem);
}
& form .row > label {
min-width: min(100%, 12rem);
}
& .card {
max-width: 100%;
}
& .table-freeze-columns tr > :first-child {
width: clamp(7rem, 32cqi, 11rem);
min-width: min(9rem, 40cqi);
white-space: normal;
}
& .pagination {
flex-wrap: wrap;
}
& .markdown table {
display: block;
overflow-x: auto;
}

@media (max-width: 27rem) {
/* Give charts the full preview width while keeping the titles inset. */
&:has(> .card > .card-body > .chart) {
padding-inline: 0;
}
& > .card > .card-body > .chart {
margin-inline: calc(-1 * var(--tblr-card-spacer-x));
}
}
}
@media (max-width: 27rem) {
.docs-example > .docs-example-source,
.docs-example-layout {
margin-inline: calc(var(--tblr-spacer-1) - var(--docs-gutter));
}
/* A chart card fills the preview. Keep its title inset and give the plot the full width. */
.docs-example-output:has(> .card > .card-body > .chart) {
padding-inline: 0;
}
.docs-example-output > .card > .card-body > .chart {
margin-inline: calc(-1 * var(--tblr-card-spacer-x));
}
}
@container example (min-width: 52rem) {
.docs-example-layout {
Expand Down
4 changes: 4 additions & 0 deletions examples/official-site/sqlpage/docs-shell.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ select 'shell-docs' as component,
$options->>'title' as title,
$options->>'description' as description,
$options->>'css' as css,
case sqlpage.variables('get')->>'theme'
when 'light' then 'light'
when 'dark' then 'dark'
end as stock_theme,
$section as section,
cast($catalog as integer) as catalog,
coalesce($kind || 's', 'guides') as topic_label,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<html lang="en" data-bs-theme="dark">
<html lang="en" data-bs-theme="{{default stock_theme 'dark'}}"{{#unless stock_theme}} data-site-theme="custom-docsite"{{/unless}}>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
Expand All @@ -12,7 +12,9 @@
<meta name="generator" content="SQLPage v{{buildinfo 'CARGO_PKG_VERSION'}}">
<link rel="icon" href="/favicon.ico">
<link rel="stylesheet" href="{{static_path 'sqlpage.css'}}">
<link rel="stylesheet" href="/assets/highlightjs-and-tabler-theme.css">
{{#unless stock_theme}}
<link rel="stylesheet" href="/assets/highlightjs-and-tabler-theme.css">
{{/unless}}
<link rel="stylesheet" href="/assets/docs/shell.css">
{{#if catalog}}
<link rel="canonical" href="{{catalog_link}}">
Expand Down
53 changes: 40 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading