@odla-ai/chapter 0.18.0 → 0.19.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/README.md +26 -2
- package/dist/chunk-D3QMK3ED.js +781 -0
- package/dist/chunk-D3QMK3ED.js.map +1 -0
- package/dist/{chunk-ZCZK6QLC.js → chunk-GWY2ZTN7.js} +25 -9
- package/dist/{chunk-ZCZK6QLC.js.map → chunk-GWY2ZTN7.js.map} +1 -1
- package/dist/index.cjs +24 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -5
- package/dist/index.d.ts +14 -5
- package/dist/index.js +24 -8
- package/dist/index.js.map +1 -1
- package/dist/ui/admin/index.d.ts +20 -3
- package/dist/ui/admin/index.js +9 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +10 -2
- package/dist/ui/member/index.d.ts +6 -1
- package/dist/ui/member/index.js +1 -1
- package/dist/worker/index.d.cts +6 -1
- package/dist/worker/index.d.ts +6 -1
- package/package.json +1 -1
- package/dist/chunk-K6BDIFCJ.js +0 -801
- package/dist/chunk-K6BDIFCJ.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -56,8 +56,13 @@ type DbRules = Record<string, Rule>;
|
|
|
56
56
|
/** Brand tokens that theme the site: palette, fonts, wordmark, nav, logos. */
|
|
57
57
|
interface ChapterBrand {
|
|
58
58
|
/** Palette overrides written into styles.css :root (e.g. `{ moss: "#2F3E34" }`
|
|
59
|
-
* or `--ui-*` token names).
|
|
59
|
+
* or `--ui-*` token names). Applies in BOTH light and dark unless overridden
|
|
60
|
+
* by {@link paletteDark}. */
|
|
60
61
|
palette?: Record<string, string>;
|
|
62
|
+
/** Dark-mode palette overrides. Same shape as {@link palette}; emitted under
|
|
63
|
+
* `:root[data-theme="dark"]` and `@media (prefers-color-scheme: dark)`, so a
|
|
64
|
+
* site brands both modes. */
|
|
65
|
+
paletteDark?: Record<string, string>;
|
|
61
66
|
fonts?: {
|
|
62
67
|
display?: string;
|
|
63
68
|
body?: string;
|
|
@@ -1095,10 +1100,14 @@ declare function memberSession(user: SessionUser, opts: {
|
|
|
1095
1100
|
}): MemberSession;
|
|
1096
1101
|
|
|
1097
1102
|
/**
|
|
1098
|
-
* Build the
|
|
1099
|
-
*
|
|
1100
|
-
* (display/body/numeral) map to
|
|
1101
|
-
* `--ui-font-
|
|
1103
|
+
* Build the CSS that maps a chapter's brand onto the design tokens the UI reads:
|
|
1104
|
+
* each `palette` entry becomes a custom property (light, and dark unless
|
|
1105
|
+
* `paletteDark` overrides), and `fonts` (display/body/numeral) map to
|
|
1106
|
+
* `--ui-font-display` / `--ui-font-sans` / `--ui-font-numeral`. The dark block is
|
|
1107
|
+
* emitted under both `:root[data-theme="dark"]` (the odla-ui theme toggle) and
|
|
1108
|
+
* `@media (prefers-color-scheme: dark)`. Returns "" when there is nothing to
|
|
1109
|
+
* theme. These are brand OVERRIDES on top of a base theme — they do not replace
|
|
1110
|
+
* the theme layer the components need (see {@link brandTokens} usage in the docs).
|
|
1102
1111
|
*/
|
|
1103
1112
|
declare function brandTokens(brand: ChapterBrand | undefined): string;
|
|
1104
1113
|
|
package/dist/index.d.ts
CHANGED
|
@@ -56,8 +56,13 @@ type DbRules = Record<string, Rule>;
|
|
|
56
56
|
/** Brand tokens that theme the site: palette, fonts, wordmark, nav, logos. */
|
|
57
57
|
interface ChapterBrand {
|
|
58
58
|
/** Palette overrides written into styles.css :root (e.g. `{ moss: "#2F3E34" }`
|
|
59
|
-
* or `--ui-*` token names).
|
|
59
|
+
* or `--ui-*` token names). Applies in BOTH light and dark unless overridden
|
|
60
|
+
* by {@link paletteDark}. */
|
|
60
61
|
palette?: Record<string, string>;
|
|
62
|
+
/** Dark-mode palette overrides. Same shape as {@link palette}; emitted under
|
|
63
|
+
* `:root[data-theme="dark"]` and `@media (prefers-color-scheme: dark)`, so a
|
|
64
|
+
* site brands both modes. */
|
|
65
|
+
paletteDark?: Record<string, string>;
|
|
61
66
|
fonts?: {
|
|
62
67
|
display?: string;
|
|
63
68
|
body?: string;
|
|
@@ -1095,10 +1100,14 @@ declare function memberSession(user: SessionUser, opts: {
|
|
|
1095
1100
|
}): MemberSession;
|
|
1096
1101
|
|
|
1097
1102
|
/**
|
|
1098
|
-
* Build the
|
|
1099
|
-
*
|
|
1100
|
-
* (display/body/numeral) map to
|
|
1101
|
-
* `--ui-font-
|
|
1103
|
+
* Build the CSS that maps a chapter's brand onto the design tokens the UI reads:
|
|
1104
|
+
* each `palette` entry becomes a custom property (light, and dark unless
|
|
1105
|
+
* `paletteDark` overrides), and `fonts` (display/body/numeral) map to
|
|
1106
|
+
* `--ui-font-display` / `--ui-font-sans` / `--ui-font-numeral`. The dark block is
|
|
1107
|
+
* emitted under both `:root[data-theme="dark"]` (the odla-ui theme toggle) and
|
|
1108
|
+
* `@media (prefers-color-scheme: dark)`. Returns "" when there is nothing to
|
|
1109
|
+
* theme. These are brand OVERRIDES on top of a base theme — they do not replace
|
|
1110
|
+
* the theme layer the components need (see {@link brandTokens} usage in the docs).
|
|
1102
1111
|
*/
|
|
1103
1112
|
declare function brandTokens(brand: ChapterBrand | undefined): string;
|
|
1104
1113
|
|
package/dist/index.js
CHANGED
|
@@ -1199,20 +1199,36 @@ function paletteVar(key) {
|
|
|
1199
1199
|
function cleanValue(value) {
|
|
1200
1200
|
return value.replace(/[<>{};]/g, "").trim();
|
|
1201
1201
|
}
|
|
1202
|
-
function
|
|
1203
|
-
if (!brand) return "";
|
|
1202
|
+
function paletteDecls(palette) {
|
|
1204
1203
|
const decls = [];
|
|
1205
|
-
for (const [key, value] of Object.entries(
|
|
1204
|
+
for (const [key, value] of Object.entries(palette ?? {})) {
|
|
1206
1205
|
if (typeof value === "string" && value.trim()) decls.push(`${paletteVar(key)}: ${cleanValue(value)};`);
|
|
1207
1206
|
}
|
|
1207
|
+
return decls;
|
|
1208
|
+
}
|
|
1209
|
+
function brandTokens(brand) {
|
|
1210
|
+
if (!brand) return "";
|
|
1211
|
+
const light = paletteDecls(brand.palette);
|
|
1208
1212
|
const fonts = brand.fonts;
|
|
1209
|
-
if (fonts?.display)
|
|
1210
|
-
if (fonts?.body)
|
|
1211
|
-
if (fonts?.numeral)
|
|
1212
|
-
|
|
1213
|
-
|
|
1213
|
+
if (fonts?.display) light.push(`--ui-font-display: ${cleanValue(fonts.display)};`);
|
|
1214
|
+
if (fonts?.body) light.push(`--ui-font-sans: ${cleanValue(fonts.body)};`);
|
|
1215
|
+
if (fonts?.numeral) light.push(`--ui-font-numeral: ${cleanValue(fonts.numeral)};`);
|
|
1216
|
+
const dark = paletteDecls(brand.paletteDark);
|
|
1217
|
+
let css = light.length ? `:root {
|
|
1218
|
+
${light.join("\n ")}
|
|
1214
1219
|
}
|
|
1215
1220
|
` : "";
|
|
1221
|
+
if (dark.length) {
|
|
1222
|
+
const block = `{
|
|
1223
|
+
${dark.join("\n ")}
|
|
1224
|
+
}`;
|
|
1225
|
+
css += `:root[data-theme="dark"] ${block}
|
|
1226
|
+
@media (prefers-color-scheme: dark) {
|
|
1227
|
+
:root:not([data-theme="light"]) ${block}
|
|
1228
|
+
}
|
|
1229
|
+
`;
|
|
1230
|
+
}
|
|
1231
|
+
return css;
|
|
1216
1232
|
}
|
|
1217
1233
|
|
|
1218
1234
|
// src/reconcile.ts
|