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
2 changes: 1 addition & 1 deletion packages/jaad/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@astrojs/sitemap": "^3.7.3",
"@tailwindcss/vite": "^4.3.3",
"github-slugger": "^2.0.0",
"@lancher-dev/jaamd": "^0.8.1",
"@lancher-dev/jaamd": "^0.9.2",
"tailwindcss": "^4.3.3"
},
"scripts": {
Expand Down
19 changes: 14 additions & 5 deletions packages/jaad/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
SessionDriverConfig,
} from "astro";
import { existsSync } from "node:fs";
import { createRequire } from "node:module";
import { join } from "node:path";
import { fileURLToPath } from "node:url";
import {
Expand Down Expand Up @@ -203,20 +204,28 @@ export function resolveConfig(
};
}

const requireFrom = createRequire(import.meta.url);

const styleInPackage = (name: string) =>
fileURLToPath(new URL(`./styles/${name}`, import.meta.url));

/** Absolute paths, kept off the resolved config, which gets serialised. */
export function resolveStylesheets(
config: JaadConfig,
cwd: string = process.cwd(),
): { user: string | null; theme: string | null } {
): { user: string | null; theme: string | null; bridge: string } {
const userCss = join(cwd, "src", "jaad.css");
const preset =
typeof config.theme === "string" ? PRESETS[config.theme].css : null;
const slug =
typeof config.theme === "string" ? PRESETS[config.theme].theme : null;

return {
user: existsSync(userCss) ? userCss : null,
theme: preset
? fileURLToPath(new URL(`./themes/${preset}`, import.meta.url))
// Resolved through JAAMD's export map rather than by path.
theme: slug
? requireFrom.resolve(`@lancher-dev/jaamd/themes/${slug}.css`)
: null,
// A preset supplies the palette, so the colours travel the other way.
bridge: styleInPackage(slug ? "jaamd-reverse.css" : "jaamd-forward.css"),
};
}

Expand Down
2 changes: 2 additions & 0 deletions packages/jaad/src/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
interface Stylesheets {
user: string | null;
theme: string | null;
bridge: string;
}

export interface IntegrationState {
Expand Down Expand Up @@ -124,6 +125,7 @@ export function createCoreIntegration(
config,
stylesheets.user,
stylesheets.theme,
stylesheets.bridge,
() => state.docsFrame,
),
],
Expand Down
1 change: 1 addition & 0 deletions packages/jaad/src/layouts/Docs.astro
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import "../styles/docs.css";
import "../styles/jaamd.css";
import "@lancher-dev/jaamd/styles.css";
import "virtual:jaad/theme.css";
import "virtual:jaad/bridge.css";
import "virtual:jaad/user.css";

interface Props {
Expand Down
4 changes: 0 additions & 4 deletions packages/jaad/src/styles/docs.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ html {
scroll-padding-top: 8rem;
}

.markdown-content h2[id] {
scroll-margin-top: 8rem;
}

.docs-sidebar-left::-webkit-scrollbar,
.docs-sidebar-right::-webkit-scrollbar {
width: 6px;
Expand Down
16 changes: 16 additions & 0 deletions packages/jaad/src/styles/jaamd-forward.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* JAAD's palette drives JAAMD's. Used when the colours come from JAAD — its own
identity, or a custom theme written in src/jaad.css. */

:root {
--jaamd-bg: var(--color-background);
--jaamd-color-fg: var(--color-foreground);
--jaamd-color-fg-bright: var(--color-foreground-bright);
--jaamd-color-primary: var(--color-primary);
--jaamd-color-success: var(--color-success);

--jaamd-alert-note-color: var(--color-info);
--jaamd-alert-tip-color: var(--color-success);
--jaamd-alert-important-color: var(--color-primary);
--jaamd-alert-warning-color: var(--color-warning);
--jaamd-alert-caution-color: var(--color-error);
}
21 changes: 21 additions & 0 deletions packages/jaad/src/styles/jaamd-reverse.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* JAAMD's palette drives JAAD's. Used when a JAAMD preset supplies the colours —
the opposite direction to jaamd-forward.css, and never both at once: together
they would be a cycle, and CSS drops both sides of one.

Only the seeds: global.css derives borders, surfaces and muted text from them
with color-mix(). `:root, html.dark` matches the specificity global.css uses,
and this sheet is loaded after it. */

:root,
html.dark {
--color-background: var(--jaamd-bg);
--color-surface: var(--jaamd-surface-1);
--color-foreground: var(--jaamd-color-fg);
--color-foreground-bright: var(--jaamd-color-fg-bright);
--color-primary: var(--jaamd-color-primary);

--color-info: var(--jaamd-alert-note-color);
--color-success: var(--jaamd-alert-tip-color);
--color-warning: var(--jaamd-alert-warning-color);
--color-error: var(--jaamd-alert-caution-color);
}
12 changes: 1 addition & 11 deletions packages/jaad/src/styles/jaamd.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,5 @@
--jaamd-font-size: 1.125rem;
--jaamd-line-height: 1.6;

--jaamd-bg: var(--color-background);
--jaamd-color-fg: var(--color-foreground);
--jaamd-color-fg-bright: var(--color-foreground-bright);
--jaamd-color-primary: var(--color-primary);
--jaamd-color-success: var(--color-success);

--jaamd-alert-note-color: var(--color-info);
--jaamd-alert-tip-color: var(--color-success);
--jaamd-alert-important-color: var(--color-primary);
--jaamd-alert-warning-color: var(--color-warning);
--jaamd-alert-caution-color: var(--color-error);
--jaamd-scroll-margin-top: 0;
}
31 changes: 0 additions & 31 deletions packages/jaad/src/themes/catppuccin.css

This file was deleted.

23 changes: 0 additions & 23 deletions packages/jaad/src/themes/dracula.css

This file was deleted.

33 changes: 0 additions & 33 deletions packages/jaad/src/themes/gruvbox.css

This file was deleted.

42 changes: 20 additions & 22 deletions packages/jaad/src/themes/index.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
import { themes } from "@lancher-dev/jaamd/themes";

export interface Preset {
/** Shiki theme, or a light/dark pair, for code blocks. */
shiki: string | { light: string; dark: string };
/** Stylesheet next to this file, or null when the defaults already apply. */
css: string | null;
/** JAAMD theme slug, or null when JAAD's own identity already applies. */
theme: string | null;
/** `dual` carries a light and a dark palette; the others apply in both modes. */
mode: "light" | "dark" | "dual";
}

/**
* The palettes come from JAAMD, which ships them with a manifest; JAAD adds only
* `default`, its own identity, which needs no stylesheet.
*/
export const PRESETS: Record<string, Preset> = {
default: { shiki: { light: "github-light", dark: "github-dark" }, css: null },
dracula: { shiki: "dracula", css: "dracula.css" },
nord: { shiki: "nord", css: "nord.css" },
"one-dark": { shiki: "one-dark-pro", css: "one-dark.css" },
"tokyo-night": { shiki: "tokyo-night", css: "tokyo-night.css" },
gruvbox: {
shiki: { light: "gruvbox-light-medium", dark: "gruvbox-dark-medium" },
css: "gruvbox.css",
},
"rose-pine": {
shiki: { light: "rose-pine-dawn", dark: "rose-pine" },
css: "rose-pine.css",
},
"rose-pine-moon": {
shiki: { light: "rose-pine-dawn", dark: "rose-pine-moon" },
css: "rose-pine-moon.css",
},
catppuccin: {
shiki: { light: "catppuccin-latte", dark: "catppuccin-mocha" },
css: "catppuccin.css",
default: {
shiki: { light: "github-light", dark: "github-dark" },
theme: null,
mode: "dual",
},
...Object.fromEntries(
themes.map((theme) => [
theme.slug,
{ shiki: theme.shiki, theme: theme.slug, mode: theme.mode },
]),
),
};

export const PRESET_NAMES = Object.keys(PRESETS);
Expand Down
23 changes: 0 additions & 23 deletions packages/jaad/src/themes/nord.css

This file was deleted.

23 changes: 0 additions & 23 deletions packages/jaad/src/themes/one-dark.css

This file was deleted.

33 changes: 0 additions & 33 deletions packages/jaad/src/themes/rose-pine-moon.css

This file was deleted.

Loading
Loading