@tansy/theme-halo 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DESIGN.md +89 -0
- package/LICENSE +21 -0
- package/README.md +12 -2
- package/client.d.ts +30 -0
- package/client.js +142 -0
- package/fonts/GeistVF.woff +0 -0
- package/fonts/README.md +1 -0
- package/index.d.ts +20 -0
- package/index.js +92 -0
- package/package.json +34 -4
- package/render.d.ts +4 -0
- package/render.js +369 -0
- package/schema.json +110 -0
- package/theme.css +1093 -0
package/DESIGN.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Halo — design system
|
|
2
|
+
|
|
3
|
+
A news front page for the blog plugin: dense, quiet panels on a pale lavender page, with one
|
|
4
|
+
iridescent "halo" as the only decoration. Built from the owner's reference screens, not from
|
|
5
|
+
UXKIN examples. The values below are the tokens in `index.ts` and the variables in `theme.css`;
|
|
6
|
+
pages use the names, never the raw values.
|
|
7
|
+
|
|
8
|
+
## Feeling
|
|
9
|
+
|
|
10
|
+
Calm, current, information-first. Many stories on one screen without looking busy: white
|
|
11
|
+
panels do the grouping, so there are no borders between cards and almost no shadows.
|
|
12
|
+
|
|
13
|
+
## Colour
|
|
14
|
+
|
|
15
|
+
| Token | Light | Dark | Role |
|
|
16
|
+
|---|---|---|---|
|
|
17
|
+
| `color.page` | `#eef1f8` | `#0b0c14` | The page behind every panel |
|
|
18
|
+
| `color.panel` | `#ffffff` | `#141622` | Panels: the lead, the latest list, the sidebar |
|
|
19
|
+
| `color.surface` | `#e9edf6` | `#1d2030` | Chips, the search field, quiet buttons, empty images |
|
|
20
|
+
| `color.text` | `#0e1020` | `#eceef7` | Headlines and body |
|
|
21
|
+
| `color.muted` | `#5d6478` | `#9da3b8` | Times, tags, excerpts. 5.9:1 on panel |
|
|
22
|
+
| `color.border` | `#e1e5ef` | `#262a3c` | Hairlines between rows, the field's edge |
|
|
23
|
+
| `color.accent` | `#3450d1` | `#3450d1` (lightened in CSS) | Category names, links, focus rings. The Settings accent replaces it |
|
|
24
|
+
| `color.on-accent` | `#ffffff` | — | Text on the accent |
|
|
25
|
+
| `color.glow` | `#a995ff` | — | The halo, the section marker, the wash over feature images |
|
|
26
|
+
| `color.ink` | `#10111a` | `#eceef7` | The one solid button: the pager's "next" |
|
|
27
|
+
|
|
28
|
+
At most one accent (blue) and one decorative colour (lavender). Lavender never carries text.
|
|
29
|
+
Dark mode changes neutrals only; the owner's accent stays theirs.
|
|
30
|
+
|
|
31
|
+
## Typography
|
|
32
|
+
|
|
33
|
+
Geist (variable, served from the site). One family; weight and size make the hierarchy.
|
|
34
|
+
|
|
35
|
+
| Step | Size / line height | Weight | Use |
|
|
36
|
+
|---|---|---|---|
|
|
37
|
+
| `display` | clamp(2rem → 3rem) / 1.1 | 600 | The lead story's headline |
|
|
38
|
+
| `h2` | clamp(1.6rem → 2.25rem) / 1.15 | 600 | Spotlight, post title |
|
|
39
|
+
| `h3` | 1.125rem / 1.3 | 600 | Card titles in the trending grid |
|
|
40
|
+
| `row` | 0.9rem / 1.35 | 600 | Titles in lists beside a thumbnail |
|
|
41
|
+
| `body` | 1.0625rem / 1.75 | 400 | Article text, 42rem measure (≈70 characters) |
|
|
42
|
+
| `small` | 0.8125rem / 1.5 | 400 | Excerpts in panels, tags |
|
|
43
|
+
| `meta` | 0.75rem / 1.4 | 500 | Category · time, section labels (caps, 0.06em tracking) |
|
|
44
|
+
|
|
45
|
+
Headlines track at −0.03em and wrap balanced.
|
|
46
|
+
|
|
47
|
+
## Spacing
|
|
48
|
+
|
|
49
|
+
4px base. Gaps between panels `space.gap` 1rem, inside a panel 1.5rem–2.5rem, between
|
|
50
|
+
sections `space.section` 3.5rem, page edge `space.gutter` 1rem. Content width `size.wide`
|
|
51
|
+
86rem; sidebar `size.aside` 22rem; reading column `size.measure` 42rem.
|
|
52
|
+
|
|
53
|
+
## Shape and depth
|
|
54
|
+
|
|
55
|
+
| Token | Value | Use |
|
|
56
|
+
|---|---|---|
|
|
57
|
+
| `radius.panel` | 1.5rem | Panels and the large feature card |
|
|
58
|
+
| `radius.card` | 0.875rem | Images in cards and rows |
|
|
59
|
+
| `radius.control` | 999px | Chips, buttons, pager circles |
|
|
60
|
+
| `radius.field` | 0.875rem | The search field and its results |
|
|
61
|
+
| `shadow.float` | soft lavender drop | Only things that float: menus, search results, the "Readers' choice" badge |
|
|
62
|
+
|
|
63
|
+
## Components
|
|
64
|
+
|
|
65
|
+
- **Section label**: caps `meta` text with a 3px lavender bar on its start side, and
|
|
66
|
+
"View more →" at the other end when the section has an archive.
|
|
67
|
+
- **Meta line**: category in the accent, a dot, then the time ("4 hours ago", worked out in the
|
|
68
|
+
visitor's browser so cached pages stay true).
|
|
69
|
+
- **Tags**: `#Name` in muted text, each a link to the tag.
|
|
70
|
+
- **Buttons**: *primary pill* (surface background, text, a circled arrow) for "Read article";
|
|
71
|
+
*ink circle* for the pager's next; *outline circle* for previous. Hover darkens the surface,
|
|
72
|
+
focus shows a 2px accent ring, a disabled pager arrow is 40% opacity and not a link.
|
|
73
|
+
- **Chips** (header menu): surface pills; an item with children shows "+" and opens a panel.
|
|
74
|
+
- **Row**: title and meta at the start, a square thumbnail at the end, a hairline between rows.
|
|
75
|
+
- **Card**: image 16:10, meta, title clamped to 3 lines, tags.
|
|
76
|
+
- **Feature card**: cover with a lavender wash rising from the bottom, white text over it.
|
|
77
|
+
- **Search field**: surface field with the icon at the end; results open in a floating panel.
|
|
78
|
+
|
|
79
|
+
## Imagery and icons
|
|
80
|
+
|
|
81
|
+
Covers come from posts and are cropped by their focal point. A post with no cover gets a
|
|
82
|
+
lavender-to-surface placeholder, never a broken image. The halo orb is CSS only (radial and
|
|
83
|
+
conic gradients), so it costs no request and follows the accent. Icons are inline 20px
|
|
84
|
+
strokes (search, arrow, chevron, globe), drawn in `currentColor`. No emoji.
|
|
85
|
+
|
|
86
|
+
## Avoided on purpose
|
|
87
|
+
|
|
88
|
+
Gradient text, glass on every surface, identical three-card rows, centred everything. The
|
|
89
|
+
gradient lives in one place (the halo and the feature wash) and does not spread.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mohamed Salah
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- Generated by scripts/package-metadata.mjs. Change that script, not this file. -->
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# @tansy/theme-halo
|
|
4
|
+
|
|
5
|
+
A news front page for the blog plugin: an editor-curated lead story, recommended and trending picks, readers' choice and a popular carousel, on quiet panels.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @tansy/theme-halo
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Add it to `tansy.config.ts`. See [the halo theme documentation](https://github.com/mhmdsalahsebai/tansy/blob/main/docs/themes/halo.md) for what it adds and the options it takes.
|
|
12
|
+
|
|
13
|
+
A first-party theme for [tansy](https://github.com/mhmdsalahsebai/tansy), a self-hosted, runtime-schema CMS for Next.js. MIT licensed.
|
package/client.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type SiteWords } from "tansy/react";
|
|
3
|
+
/**
|
|
4
|
+
* A date that reads "4 hours ago" in the visitor's browser. The server renders the date
|
|
5
|
+
* itself, so a cached page, or one read with no script, is never wrong, only less friendly.
|
|
6
|
+
*/
|
|
7
|
+
export declare function TimeAgo({ date, label, locale }: {
|
|
8
|
+
date: string;
|
|
9
|
+
label: string;
|
|
10
|
+
locale: string;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
12
|
+
/**
|
|
13
|
+
* A row of cards that scrolls sideways, with previous and next buttons. Without script it is
|
|
14
|
+
* still a row that scrolls by touch, trackpad or keyboard; the buttons only move it further.
|
|
15
|
+
*/
|
|
16
|
+
export declare function Carousel({ children, previous, next, label }: {
|
|
17
|
+
children: ReactNode;
|
|
18
|
+
previous: string;
|
|
19
|
+
next: string;
|
|
20
|
+
label: string;
|
|
21
|
+
}): import("react").JSX.Element;
|
|
22
|
+
/**
|
|
23
|
+
* The header's search field. It looks up published posts as the visitor types, through the
|
|
24
|
+
* records API, as whoever is looking, so the posts collection's list rule decides what can be
|
|
25
|
+
* found. Pass `pickWords(words, "halo")`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function HeaderSearch({ words, showDates }: {
|
|
28
|
+
words?: SiteWords;
|
|
29
|
+
showDates: boolean;
|
|
30
|
+
}): import("react").JSX.Element;
|
package/client.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
4
|
+
import { apiPath, contentLocale, sitePath, siteWords } from "tansy/react";
|
|
5
|
+
const text = (value) => (typeof value === "string" ? value : "");
|
|
6
|
+
/* ---------------------------------------------------------------- time ago */
|
|
7
|
+
const UNITS = [["day", 86_400], ["hour", 3_600], ["minute", 60]];
|
|
8
|
+
const WEEK = 7 * 86_400;
|
|
9
|
+
/** "4 hours ago" for the last week, else null, so the date stays. */
|
|
10
|
+
function relative(date, locale) {
|
|
11
|
+
const at = new Date(date).getTime();
|
|
12
|
+
if (Number.isNaN(at))
|
|
13
|
+
return null;
|
|
14
|
+
const seconds = (at - Date.now()) / 1000;
|
|
15
|
+
if (Math.abs(seconds) >= WEEK)
|
|
16
|
+
return null;
|
|
17
|
+
const format = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
|
|
18
|
+
for (const [unit, size] of UNITS)
|
|
19
|
+
if (Math.abs(seconds) >= size)
|
|
20
|
+
return format.format(Math.round(seconds / size), unit);
|
|
21
|
+
return format.format(0, "minute");
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A date that reads "4 hours ago" in the visitor's browser. The server renders the date
|
|
25
|
+
* itself, so a cached page, or one read with no script, is never wrong, only less friendly.
|
|
26
|
+
*/
|
|
27
|
+
export function TimeAgo({ date, label, locale }) {
|
|
28
|
+
const [shown, setShown] = useState(label);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
const update = () => setShown(relative(date, locale) ?? label);
|
|
31
|
+
update();
|
|
32
|
+
const timer = setInterval(update, 60_000);
|
|
33
|
+
return () => clearInterval(timer);
|
|
34
|
+
}, [date, label, locale]);
|
|
35
|
+
return _jsx("time", { dateTime: date, title: label, children: shown });
|
|
36
|
+
}
|
|
37
|
+
/* ---------------------------------------------------------------- carousel */
|
|
38
|
+
/**
|
|
39
|
+
* A row of cards that scrolls sideways, with previous and next buttons. Without script it is
|
|
40
|
+
* still a row that scrolls by touch, trackpad or keyboard; the buttons only move it further.
|
|
41
|
+
*/
|
|
42
|
+
export function Carousel({ children, previous, next, label }) {
|
|
43
|
+
const track = useRef(null);
|
|
44
|
+
const [ends, setEnds] = useState({ start: true, end: false });
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
const element = track.current;
|
|
47
|
+
if (!element)
|
|
48
|
+
return;
|
|
49
|
+
const measure = () => {
|
|
50
|
+
// Negative in right-to-left layouts, so compare sizes rather than signs.
|
|
51
|
+
const travelled = Math.abs(element.scrollLeft);
|
|
52
|
+
setEnds({ start: travelled < 4, end: travelled + element.clientWidth >= element.scrollWidth - 4 });
|
|
53
|
+
};
|
|
54
|
+
measure();
|
|
55
|
+
element.addEventListener("scroll", measure, { passive: true });
|
|
56
|
+
window.addEventListener("resize", measure);
|
|
57
|
+
return () => {
|
|
58
|
+
element.removeEventListener("scroll", measure);
|
|
59
|
+
window.removeEventListener("resize", measure);
|
|
60
|
+
};
|
|
61
|
+
}, []);
|
|
62
|
+
function move(direction) {
|
|
63
|
+
const element = track.current;
|
|
64
|
+
if (!element)
|
|
65
|
+
return;
|
|
66
|
+
const rtl = getComputedStyle(element).direction === "rtl";
|
|
67
|
+
element.scrollBy({ left: direction * (rtl ? -1 : 1) * element.clientWidth * 0.85, behavior: "smooth" });
|
|
68
|
+
}
|
|
69
|
+
return (_jsxs("div", { className: "ha-carousel", children: [_jsx("div", { ref: track, className: "ha-carousel-track", role: "region", "aria-label": label, tabIndex: 0, children: children }), _jsxs("div", { className: "ha-carousel-controls", children: [_jsx("button", { type: "button", className: "ha-round", onClick: () => move(-1), disabled: ends.start, "aria-label": previous, children: _jsx(Arrow, { back: true }) }), _jsx("button", { type: "button", className: "ha-round ha-round-ink", onClick: () => move(1), disabled: ends.end, "aria-label": next, children: _jsx(Arrow, {}) })] })] }));
|
|
70
|
+
}
|
|
71
|
+
const Arrow = ({ back = false }) => (_jsx("svg", { className: back ? "ha-arrow ha-arrow-back" : "ha-arrow", "aria-hidden": "true", viewBox: "0 0 20 20", width: "16", height: "16", children: _jsx("path", { fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round", d: "M4 10h12m-5-5 5 5-5 5" }) }));
|
|
72
|
+
const MIN_LENGTH = 2;
|
|
73
|
+
const WAIT_MS = 250;
|
|
74
|
+
/**
|
|
75
|
+
* The header's search field. It looks up published posts as the visitor types, through the
|
|
76
|
+
* records API, as whoever is looking, so the posts collection's list rule decides what can be
|
|
77
|
+
* found. Pass `pickWords(words, "halo")`.
|
|
78
|
+
*/
|
|
79
|
+
export function HeaderSearch({ words, showDates }) {
|
|
80
|
+
const { t, formatDate } = siteWords(words);
|
|
81
|
+
const id = useId();
|
|
82
|
+
const [query, setQuery] = useState("");
|
|
83
|
+
const [results, setResults] = useState(null);
|
|
84
|
+
const [state, setState] = useState("idle");
|
|
85
|
+
const pending = useRef(null);
|
|
86
|
+
async function run(value) {
|
|
87
|
+
pending.current?.abort();
|
|
88
|
+
const terms = value.trim();
|
|
89
|
+
if (terms.length < MIN_LENGTH) {
|
|
90
|
+
setResults(null);
|
|
91
|
+
setState("idle");
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const controller = new AbortController();
|
|
95
|
+
pending.current = controller;
|
|
96
|
+
setState("busy");
|
|
97
|
+
// Published only, so staff who may list drafts find what visitors find, and every link opens.
|
|
98
|
+
const params = new URLSearchParams({ search: terms, filter: 'status = "published"', perPage: "6", fields: "id,title,publishedAt,cover", urls: "1" });
|
|
99
|
+
const locale = contentLocale(words);
|
|
100
|
+
if (locale)
|
|
101
|
+
params.set("locale", locale);
|
|
102
|
+
try {
|
|
103
|
+
const response = await fetch(apiPath(`/collections/blog-posts/records?${params}`), { signal: controller.signal, headers: { accept: "application/json" } });
|
|
104
|
+
const json = await response.json().catch(() => null);
|
|
105
|
+
if (controller.signal.aborted)
|
|
106
|
+
return;
|
|
107
|
+
if (!response.ok || !Array.isArray(json?.items)) {
|
|
108
|
+
setState("failed");
|
|
109
|
+
setResults(null);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
setResults(json.items);
|
|
113
|
+
setState("idle");
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
if (!controller.signal.aborted)
|
|
117
|
+
setState("failed");
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
const timer = setTimeout(() => void run(query), WAIT_MS);
|
|
122
|
+
return () => clearTimeout(timer);
|
|
123
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- searches again only when the words typed change
|
|
124
|
+
}, [query]);
|
|
125
|
+
useEffect(() => () => pending.current?.abort(), []);
|
|
126
|
+
function submit(event) {
|
|
127
|
+
event.preventDefault();
|
|
128
|
+
void run(query);
|
|
129
|
+
}
|
|
130
|
+
const open = results !== null || state === "failed";
|
|
131
|
+
const status = state === "busy"
|
|
132
|
+
? t("halo.searching")
|
|
133
|
+
: state === "failed"
|
|
134
|
+
? t("halo.searchFailed")
|
|
135
|
+
: results === null ? "" : results.length ? t("halo.found", { count: results.length }) : t("halo.noResults", { query: query.trim() });
|
|
136
|
+
return (_jsxs("div", { className: "ha-search", children: [_jsxs("form", { role: "search", onSubmit: submit, children: [_jsx("label", { className: "ha-visually-hidden", htmlFor: `${id}-q`, children: t("halo.searchLabel") }), _jsx("input", { id: `${id}-q`, type: "search", name: "q", autoComplete: "off", maxLength: 200, placeholder: t("halo.searchPlaceholder"), value: query, onChange: (event) => setQuery(event.target.value), onKeyDown: (event) => { if (event.key === "Escape")
|
|
137
|
+
setQuery(""); }, "aria-controls": `${id}-results`, "aria-describedby": `${id}-status` }), _jsx("button", { type: "submit", "aria-label": t("halo.searchLabel"), children: _jsx("svg", { "aria-hidden": "true", viewBox: "0 0 20 20", width: "18", height: "18", children: _jsx("path", { fill: "none", stroke: "currentColor", strokeWidth: "1.7", strokeLinecap: "round", d: "M9 15.5a6.5 6.5 0 1 0 0-13 6.5 6.5 0 0 0 0 13Zm4.7-1.8 3.8 3.8" }) }) })] }), _jsx("p", { id: `${id}-status`, className: "ha-visually-hidden", role: "status", "aria-live": "polite", children: status }), _jsx("div", { id: `${id}-results`, className: "ha-search-results", hidden: !open, children: results && results.length > 0 ? (_jsx("ul", { children: results.map((post) => {
|
|
138
|
+
const path = text(post.recordPath);
|
|
139
|
+
const date = text(post.publishedAt);
|
|
140
|
+
return (_jsx("li", { children: _jsxs("a", { href: path ? sitePath(words, path) : undefined, children: [text(post.cover) ? _jsx("img", { src: apiPath(`/files/${encodeURIComponent(text(post.cover))}?thumb=100x100`), alt: "", width: 44, height: 44, loading: "lazy" }) : _jsx("span", { className: "ha-thumb-empty", "aria-hidden": "true" }), _jsxs("span", { children: [_jsx("span", { className: "ha-search-title", children: text(post.title) }), showDates && date && _jsx("time", { dateTime: date, children: formatDate(date, "medium") })] })] }) }, post.id));
|
|
141
|
+
}) })) : _jsx("p", { className: "ha-search-empty", children: status }) })] }));
|
|
142
|
+
}
|
|
Binary file
|
package/fonts/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Geist by Vercel and basement.studio, under the SIL Open Font License 1.1: https://github.com/vercel/geist-font
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface HaloOptions {
|
|
2
|
+
/** Shown under the name in the footer. Owners can also change the theme's words per language under Languages → Site text. */
|
|
3
|
+
tagline?: string;
|
|
4
|
+
showDates: boolean;
|
|
5
|
+
/** "4 hours ago" rather than a date, worked out in the visitor's browser so a cached page stays true. */
|
|
6
|
+
relativeDates: boolean;
|
|
7
|
+
/** Sign in and Register links in the header, for sites whose visitors have accounts, such as for comments. */
|
|
8
|
+
accountLinks: boolean;
|
|
9
|
+
/** The search field in the header. It searches posts through the records API, as a visitor. */
|
|
10
|
+
search: boolean;
|
|
11
|
+
/** "auto" follows the visitor's light or dark setting. "light" always shows the light colours. */
|
|
12
|
+
colorScheme: "auto" | "light";
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A news front page for the blog plugin. The home page's sections are chosen by editors on a
|
|
16
|
+
* Front page record and filled from featured and recent posts where they chose nothing; the
|
|
17
|
+
* post page is built from the plugin's parts, so comments, tags and bylines behave as on the
|
|
18
|
+
* plugin's own page.
|
|
19
|
+
*/
|
|
20
|
+
export declare const halo: ({ tagline, showDates, relativeDates, accountLinks, search, colorScheme }?: Partial<HaloOptions>) => import("tansy/theme").ThemeManifest<HaloOptions>;
|
package/index.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { defineTheme } from "tansy/theme";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import schema from "./schema.json";
|
|
4
|
+
const options = z.object({
|
|
5
|
+
tagline: z.string().max(300).optional(),
|
|
6
|
+
showDates: z.boolean(),
|
|
7
|
+
relativeDates: z.boolean(),
|
|
8
|
+
accountLinks: z.boolean(),
|
|
9
|
+
search: z.boolean(),
|
|
10
|
+
colorScheme: z.enum(["auto", "light"]),
|
|
11
|
+
});
|
|
12
|
+
/** What every story on a front page shows. Kept short, as these lists are read on every visit. */
|
|
13
|
+
const STORY_FIELDS = "id,title,excerpt,publishedAt,cover,categories,tags,readingMinutes";
|
|
14
|
+
const STORY = { collection: "blog-posts", sort: "-publishedAt", fields: STORY_FIELDS, urls: "1" };
|
|
15
|
+
/** Names and addresses, so a story's category and tags are links. */
|
|
16
|
+
const LOOKUPS = {
|
|
17
|
+
categories: { collection: "blog-categories", perPage: 200, fields: "id,name", urls: "1" },
|
|
18
|
+
tags: { collection: "blog-tags", perPage: 200, fields: "id,name", urls: "1" },
|
|
19
|
+
// Where "View more" goes: the blog's own address, from its URL pattern.
|
|
20
|
+
blogHome: { collection: "blog-home", perPage: 1, fields: "id", urls: "1" },
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The front page. The `pick*` lists are the stories an editor chose on the Front page record,
|
|
24
|
+
* bound from its reference fields; on a site that hasn't made that record they return nothing.
|
|
25
|
+
* `featured` and `recent` fill whatever an editor left empty.
|
|
26
|
+
*/
|
|
27
|
+
const FRONT = {
|
|
28
|
+
pickLead: { ...STORY, filter: "id = @record.lead", perPage: 1 },
|
|
29
|
+
pickRecommended: { ...STORY, filter: "id ?= @record.recommended", perPage: 5 },
|
|
30
|
+
pickSpotlight: { ...STORY, filter: "id = @record.spotlight", perPage: 1 },
|
|
31
|
+
pickTrending: { ...STORY, filter: "id ?= @record.trending", perPage: 7 },
|
|
32
|
+
pickReaders: { ...STORY, filter: "id ?= @record.readersChoice", perPage: 9 },
|
|
33
|
+
pickPopular: { ...STORY, filter: "id ?= @record.popular", perPage: 10 },
|
|
34
|
+
featured: { ...STORY, filter: "featured = true", perPage: 10 },
|
|
35
|
+
recent: { ...STORY, perPage: 30 },
|
|
36
|
+
...LOOKUPS,
|
|
37
|
+
};
|
|
38
|
+
/** Seven a page: the first leads, the other six fill the grid beside it. */
|
|
39
|
+
const PER_PAGE = 7;
|
|
40
|
+
/** A paged archive: the blog's home, a category, a tag. */
|
|
41
|
+
const archive = (filter) => ({
|
|
42
|
+
posts: { ...STORY, ...(filter ? { filter } : {}), perPage: PER_PAGE, paged: true },
|
|
43
|
+
...LOOKUPS,
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* A news front page for the blog plugin. The home page's sections are chosen by editors on a
|
|
47
|
+
* Front page record and filled from featured and recent posts where they chose nothing; the
|
|
48
|
+
* post page is built from the plugin's parts, so comments, tags and bylines behave as on the
|
|
49
|
+
* plugin's own page.
|
|
50
|
+
*/
|
|
51
|
+
export const halo = ({ tagline, showDates = true, relativeDates = true, accountLinks = true, search = true, colorScheme = "auto" } = {}) => defineTheme({
|
|
52
|
+
name: "halo",
|
|
53
|
+
version: "0.1.0",
|
|
54
|
+
apiVersion: 1,
|
|
55
|
+
render: "@tansy/theme-halo/render",
|
|
56
|
+
requires: { plugins: ["blog"] },
|
|
57
|
+
options: { schema: options, value: { tagline, showDates, relativeDates, accountLinks, search, colorScheme } },
|
|
58
|
+
schema,
|
|
59
|
+
tokens: {
|
|
60
|
+
color: {
|
|
61
|
+
page: "#eef1f8",
|
|
62
|
+
panel: "#ffffff",
|
|
63
|
+
surface: "#e9edf6",
|
|
64
|
+
text: "#0e1020",
|
|
65
|
+
muted: "#5d6478",
|
|
66
|
+
border: "#e1e5ef",
|
|
67
|
+
accent: "#3450d1",
|
|
68
|
+
"on-accent": "#ffffff",
|
|
69
|
+
glow: "#a995ff",
|
|
70
|
+
ink: "#10111a",
|
|
71
|
+
},
|
|
72
|
+
font: { body: "var(--halo-font), system-ui, sans-serif" },
|
|
73
|
+
size: { wide: "86rem", aside: "22rem", measure: "42rem" },
|
|
74
|
+
space: { gutter: "1rem", gap: "1rem", section: "3.5rem" },
|
|
75
|
+
radius: { panel: "1.5rem", card: "0.875rem", control: "999px", field: "0.875rem" },
|
|
76
|
+
shadow: { float: "0 18px 40px rgba(76, 64, 160, 0.14)" },
|
|
77
|
+
},
|
|
78
|
+
singletons: ["site-menu"],
|
|
79
|
+
queries: {
|
|
80
|
+
home: FRONT,
|
|
81
|
+
"halo-front": FRONT,
|
|
82
|
+
"blog-home": archive(),
|
|
83
|
+
"blog-posts": {
|
|
84
|
+
// Beside the plugin's own lists (categories, tags, comments), which its parts read.
|
|
85
|
+
sideStories: { ...STORY, filter: "id != @record.id", perPage: 5 },
|
|
86
|
+
moreStories: { ...STORY, filter: "tags ?= @record.tags && id != @record.id", perPage: 4 },
|
|
87
|
+
blogHome: LOOKUPS.blogHome,
|
|
88
|
+
},
|
|
89
|
+
"blog-categories": archive("categories ?= @record.id"),
|
|
90
|
+
"blog-tags": archive("tags ?= @record.id"),
|
|
91
|
+
},
|
|
92
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tansy/theme-halo",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A news front page for the blog plugin: an editor-curated lead story, recommended and trending picks, readers' choice and a popular carousel, on quiet panels.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"tansy-theme"
|
|
7
|
+
],
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"author": "Mohamed Salah <mohamedsalahsebai@gmail.com>",
|
|
10
|
+
"homepage": "https://github.com/mhmdsalahsebai/tansy",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/mhmdsalahsebai/tansy.git",
|
|
14
|
+
"directory": "themes/halo"
|
|
15
|
+
},
|
|
16
|
+
"bugs": "https://github.com/mhmdsalahsebai/tansy/issues",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./index.d.ts",
|
|
20
|
+
"default": "./index.js"
|
|
21
|
+
},
|
|
22
|
+
"./render": {
|
|
23
|
+
"types": "./render.d.ts",
|
|
24
|
+
"default": "./render.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@tansy/blog": "^0.1.0",
|
|
29
|
+
"next": "^16.4.6",
|
|
30
|
+
"react": "^19.3.0",
|
|
31
|
+
"tansy": "^0.1.0"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"zod": "^4.6.7"
|
|
35
|
+
}
|
|
36
|
+
}
|
package/render.d.ts
ADDED