Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2c09537

Browse files
committed
feat(play.loradb.com): extend playground theme tokens
1 parent e62c842 commit 2c09537

3 files changed

Lines changed: 116 additions & 6 deletions

File tree

apps/play.loradb.com/lib/theme/editor.ts

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,62 @@
1313
* inline and skip the TLA-gated import entirely.
1414
*/
1515

16-
import type { LoraQueryTheme } from "@loradb/lora-query";
16+
import type { LoraJsonTheme, LoraQueryTheme } from "@loradb/lora-query";
1717

1818
import type { Tokens } from "./tokens";
1919
import { hexA } from "./util";
2020

21+
/**
22+
* Derive a `LoraJsonTheme` from our token set. Mirrors
23+
* {@link deriveEditorTheme} but uses the JSON-specific token slots
24+
* (`key`, `string`, `number`, `bool`, `null`, `punct`).
25+
*/
26+
export function deriveJsonEditorTheme(tokens: Tokens): LoraJsonTheme {
27+
const identifier = tokens.syntax.identifier;
28+
return {
29+
background: tokens.bg.editor,
30+
foreground: tokens.fg.primary,
31+
border: tokens.border.subtle,
32+
muted: tokens.fg.muted,
33+
accent: tokens.accent.primary,
34+
activeLine: hexA(tokens.fg.primary, 0.06),
35+
gutterBackground: tokens.bg.editor,
36+
gutterForeground: tokens.fg.subtle,
37+
cursor: tokens.fg.primary,
38+
selectionBackground: hexA(tokens.accent.primary, 0.28),
39+
40+
fontFamily: tokens.font.ui,
41+
monoFontFamily: tokens.font.mono,
42+
fontSize: "13px",
43+
popupFontSize: "12px",
44+
45+
key: identifier,
46+
string: tokens.syntax.string,
47+
number: tokens.syntax.number,
48+
bool: tokens.syntax.keyword,
49+
null: tokens.syntax.keyword,
50+
// `punct` left to fall through to the shared `--lq-color-punct`
51+
// default (inherited text colour with 0.7 opacity).
52+
53+
popupBackground: tokens.bg.panel,
54+
popupForeground: tokens.fg.primary,
55+
popupBorder: tokens.border.subtle,
56+
popupSelectedBackground: tokens.accent.primary,
57+
popupSelectedForeground: tokens.fg.inverse,
58+
popupShadow: `0 6px 16px ${hexA("#000000", 0.35)}`,
59+
60+
errorAccent: tokens.accent.danger,
61+
warningAccent: tokens.accent.warning,
62+
infoAccent: tokens.accent.info,
63+
64+
scrollbarTrack: tokens.bg.editor,
65+
scrollbarThumb: tokens.border.strong,
66+
scrollbarThumbHover: tokens.fg.subtle,
67+
scrollbarWidth: "auto",
68+
scrollbarSize: "10px",
69+
};
70+
}
71+
2172
/** Derive a `LoraQueryTheme` from our token set. */
2273
export function deriveEditorTheme(tokens: Tokens): LoraQueryTheme {
2374
const keyword = tokens.syntax.keyword;
@@ -42,10 +93,10 @@ export function deriveEditorTheme(tokens: Tokens): LoraQueryTheme {
4293
popupFontSize: "12px",
4394

4495
keyword,
45-
variable: identifier,
46-
parameter: identifier,
47-
label: type,
48-
relType: type,
96+
variable: tokens.category.variable,
97+
parameter: tokens.category.parameter,
98+
label: tokens.category.label,
99+
relType: tokens.category.relType,
49100
property: identifier,
50101
functionName: type,
51102
namespace: type,

apps/play.loradb.com/lib/theme/tokens.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,35 @@ export interface Tokens {
5858
linkHighlight: string;
5959
label: string;
6060
};
61+
/**
62+
* Semantic category palette — the colour used to identify a Cypher
63+
* concept wherever it surfaces (outline chips, plan badges, schema
64+
* browser, inspector, table bubbles, graph canvas, summary strips).
65+
*
66+
* `*Bg` variants are pre-computed translucent versions of the same
67+
* hue, suitable for badge / bubble backgrounds.
68+
*
69+
* Hues mirror the `lora-query` editor palette so a `:Person` label
70+
* looks the same in the editor as on a chip below it.
71+
*/
72+
category: {
73+
variable: string;
74+
variableBg: string;
75+
label: string;
76+
labelBg: string;
77+
relType: string;
78+
relTypeBg: string;
79+
parameter: string;
80+
parameterBg: string;
81+
/** Alias for `graph.node` — kept here so node colours can be looked
82+
* up alongside the other categories. */
83+
node: string;
84+
nodeBg: string;
85+
/** Used for the graph-shape "relationship" concept (counts, summary
86+
* chips). Equal to `relType` so chips agree with the rel-type colour. */
87+
relationship: string;
88+
relationshipBg: string;
89+
};
6190
font: {
6291
ui: string;
6392
mono: string;
@@ -119,6 +148,20 @@ export const darkTokens: Tokens = {
119148
linkHighlight: "#9cdcfe",
120149
label: "#d4d4d4",
121150
},
151+
category: {
152+
variable: "#79c0ff",
153+
variableBg: "rgba(121, 192, 255, 0.16)",
154+
label: "#7ee787",
155+
labelBg: "rgba(126, 231, 135, 0.16)",
156+
relType: "#ffa657",
157+
relTypeBg: "rgba(255, 166, 87, 0.16)",
158+
parameter: "#d2a8ff",
159+
parameterBg: "rgba(210, 168, 255, 0.16)",
160+
node: "#6aa3ff",
161+
nodeBg: "rgba(106, 163, 255, 0.16)",
162+
relationship: "#ffa657",
163+
relationshipBg: "rgba(255, 166, 87, 0.16)",
164+
},
122165
font: {
123166
ui: FONT_UI,
124167
mono: FONT_MONO,
@@ -175,6 +218,20 @@ export const lightTokens: Tokens = {
175218
linkHighlight: "#0969da",
176219
label: "#1f2328",
177220
},
221+
category: {
222+
variable: "#1e66f5",
223+
variableBg: "rgba(30, 102, 245, 0.14)",
224+
label: "#40a02b",
225+
labelBg: "rgba(64, 160, 43, 0.14)",
226+
relType: "#df8e1d",
227+
relTypeBg: "rgba(223, 142, 29, 0.16)",
228+
parameter: "#8839ef",
229+
parameterBg: "rgba(136, 57, 239, 0.14)",
230+
node: "#0969da",
231+
nodeBg: "rgba(9, 105, 218, 0.14)",
232+
relationship: "#df8e1d",
233+
relationshipBg: "rgba(223, 142, 29, 0.16)",
234+
},
178235
font: {
179236
ui: FONT_UI,
180237
mono: FONT_MONO,

apps/play.loradb.com/lib/theme/usePlaygroundTheme.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
} from "@mantine/core";
2222

2323
import { deriveCanvasTheme } from "./canvas";
24-
import { deriveEditorTheme } from "./editor";
24+
import { deriveEditorTheme, deriveJsonEditorTheme } from "./editor";
2525
import { deriveGridTheme } from "./grid";
2626
import { darkTokens, lightTokens, tokensFor, type Tokens } from "./tokens";
2727

@@ -33,6 +33,7 @@ interface PlaygroundTheme {
3333
mantine: MantineTheme;
3434
canvas: ReturnType<typeof deriveCanvasTheme>;
3535
editor: ReturnType<typeof deriveEditorTheme>;
36+
jsonEditor: ReturnType<typeof deriveJsonEditorTheme>;
3637
grid: ReturnType<typeof deriveGridTheme>;
3738
}
3839

@@ -70,6 +71,7 @@ export function usePlaygroundTheme(): PlaygroundTheme {
7071
mantine,
7172
canvas: deriveCanvasTheme(tokens),
7273
editor: deriveEditorTheme(tokens),
74+
jsonEditor: deriveJsonEditorTheme(tokens),
7375
grid: deriveGridTheme(tokens),
7476
}),
7577
[tokens, scheme, mantine],

0 commit comments

Comments
 (0)