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
5 changes: 4 additions & 1 deletion packages/jaamd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
"./styles.css": "./src/styles/markdown.css",
"./shiki-dual": "./src/styles/shiki-dual.css",
"./shiki-dual.css": "./src/styles/shiki-dual.css",
"./themes": "./src/themes/index.ts",
"./themes": {
"types": "./src/themes/index.d.ts",
"default": "./src/themes/index.js"
},
"./themes/*/dark.css": "./src/themes/*/dark.css",
"./themes/*/dark": "./src/themes/*/dark.css",
"./themes/*.css": "./src/themes/*/index.css",
Expand Down
20 changes: 20 additions & 0 deletions packages/jaamd/src/themes/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* `light` and `dark` are single palettes that apply in both modes; `dual` carries
* both, a `:root` block and an `html.dark` one, and follows whatever decides the
* mode. A `dual` theme has no `/dark` variant — its own file already does that.
*/
export type JaamdThemeMode = "light" | "dark" | "dual";

export interface JaamdTheme {
/** Directory name, and the value a `data-jaamd-theme` attribute would carry. */
slug: string;
/** Human-readable name, for pickers. */
name: string;
mode: JaamdThemeMode;
/** Shiki theme that pairs with this palette, or a pair for a `dual` one. */
shiki: string | { light: string; dark: string };
}

export declare const themes: JaamdTheme[];

export declare const REQUIRED_TOKENS: string[];
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
/*
* Theme manifest. Consumers build pickers from this instead of hardcoding a
* list; `tests/unit/themes.mjs` checks each entry against a directory that
* honours the token contract.
*/

/**
* `light` and `dark` are single palettes applying in both modes. `dual` carries
* both a `:root` block and an `html.dark` one, and follows the mode; it has no
* `/dark` variant.
* What every theme declares about itself. Consumers build theme pickers from
* this instead of hardcoding a list, and `tests/unit/themes.mjs` checks that
* each entry matches a directory that honours the token contract.
*
* Plain JavaScript on purpose: Node refuses to strip types from files under
* node_modules, so a TypeScript manifest would be readable by bundlers and by
* nothing else — tooling and test runners included. Types live in index.d.ts.
*/
export type JaamdThemeMode = "light" | "dark" | "dual";

export interface JaamdTheme {
/** Directory name, and the value a `data-jaamd-theme` attribute would carry. */
slug: string;
/** Human-readable name, for pickers. */
name: string;
mode: JaamdThemeMode;
/** Shiki theme that pairs with this palette, or a pair for a `dual` one. */
shiki: string | { light: string; dark: string };
}

export const themes: JaamdTheme[] = [
/** @type {import("./index.d.ts").JaamdTheme[]} */
export const themes = [
{
slug: "catppuccin",
name: "Catppuccin",
Expand Down Expand Up @@ -63,4 +51,4 @@ export const REQUIRED_TOKENS = [
"--jaamd-alert-important-color",
"--jaamd-alert-warning-color",
"--jaamd-alert-caution-color",
] as const;
];
2 changes: 1 addition & 1 deletion scripts/build-themes.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { readdirSync, readFileSync, writeFileSync, rmSync, existsSync } from "no
import { join } from "node:path";
import { fileURLToPath } from "node:url";

import { themes } from "../packages/jaamd/src/themes/index.ts";
import { themes } from "../packages/jaamd/src/themes/index.js";

const THEMES = join(process.cwd(), "packages", "jaamd", "src", "themes");

Expand Down
2 changes: 1 addition & 1 deletion tests/build/smoke.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { readFileSync, existsSync } from "node:fs";
import { join } from "node:path";

import { themes } from "../../packages/jaamd/src/themes/index.ts";
import { themes } from "../../packages/jaamd/src/themes/index.js";

const DIST = join(process.cwd(), "www", "dist");
const PAGE = join(DIST, "index.html");
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/themes.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { readdirSync, readFileSync, existsSync } from "node:fs";
import { join } from "node:path";
import { bundledThemes } from "shiki";

import { themes, REQUIRED_TOKENS } from "../../packages/jaamd/src/themes/index.ts";
import { themes, REQUIRED_TOKENS } from "../../packages/jaamd/src/themes/index.js";
import { darkVariant } from "../../scripts/build-themes.mjs";

const THEMES = join(process.cwd(), "packages", "jaamd", "src", "themes");
Expand All @@ -30,7 +30,7 @@ for (const slug of slugs) {
check(
`${slug}: declared in the manifest`,
entry,
"add it to packages/jaamd/src/themes/index.ts, or pickers will never show it",
"add it to packages/jaamd/src/themes/index.js, or pickers will never show it",
);
if (!entry) continue;

Expand Down
Loading