Add Obsidian Toolbox — 4 syntax generators under /tools
Inside-LMS toolbox for registered students: callout-CSS, YAML-frontmatter, theme CSS-variables, Style Settings generators. Auth inherited from (student) route group; no public surface, no email gate. - Pure generators in src/lib/tools/* with Vitest (33 tests) - Shared YAML-safe scalar quoter (_shared/yaml.ts) used by frontmatter + style-settings: unquoted user input was silently breaking YAML (tags '#x' -> null, color default '#7C3AED' -> null, 'a: b' -> parse error) - hex validation in callout (no NaN), date input constrained, clipboard + analytics calls guarded - Prisma ToolUsage model + migration; logToolUsage Server Action (auth-first, 10-min dedup window per user/tool) - Tool index /tools + ToolCard (explicit lucide map, no import *) + header link Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { buildThemeCss } from "@/lib/tools/theme";
|
||||
|
||||
describe("buildThemeCss", () => {
|
||||
const input = { background: "#0F0F0F", text: "#EAEAEA", accent: "#7C3AED", link: "#4EA1FF", border: "#333333" };
|
||||
it("оборачивает в body { }", () => {
|
||||
const css = buildThemeCss(input);
|
||||
expect(css.startsWith("body {")).toBe(true);
|
||||
expect(css.trim().endsWith("}")).toBe(true);
|
||||
});
|
||||
it("мапит accent в --interactive-accent", () => {
|
||||
expect(buildThemeCss(input)).toContain("--interactive-accent: #7C3AED;");
|
||||
});
|
||||
it("содержит все 5 переменных", () => {
|
||||
const css = buildThemeCss(input);
|
||||
["--background-primary", "--text-normal", "--interactive-accent", "--link-color", "--background-modifier-border"]
|
||||
.forEach((v) => expect(css).toContain(v));
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user