@opencode/theme 0.0.0-dev-197 → 0.0.0-dev-210

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.
@@ -1,7 +1,7 @@
1
1
  import { RGBA } from "@opentui/core";
2
2
  import { oklchToHex } from "./color.js";
3
3
  import { HueStep } from "./schema.js";
4
- import { base, byte, categoricalTokens, chromaticHues, detectMode, hex, inferHues, referenceHues, resolveV1, selectedForeground, toOklch, } from "./v1-migrate.js";
4
+ import { base, byte, categoricalTokens, chromaticHues, detectMode, dialogBackground, hex, inferHues, referenceHues, resolveV1, selectedForeground, toOklch, } from "./v1-migrate.js";
5
5
  // Temporary V1 migration for the "new-designs" experiment. It lays V1 colors out on the opencode2 steps and
6
6
  // replaces migrateV1 once the experiment ships.
7
7
  export function migrateV1NewDesigns(theme) {
@@ -13,7 +13,7 @@ export function migrateV1NewDesigns(theme) {
13
13
  if (lightMode === darkMode) {
14
14
  const definition = migrateMode(lightMode === "light" ? light : dark, lightMode);
15
15
  if (lightMode === "light")
16
- return { base: base(definition), light: lightOverrides(definition) };
16
+ return { base: base(definition), light: lightOverrides(definition, light) };
17
17
  return { base: base(definition), dark: { hue: definition.hue } };
18
18
  }
19
19
  }
@@ -21,7 +21,7 @@ export function migrateV1NewDesigns(theme) {
21
21
  const darkDefinition = migrateMode(dark, "dark");
22
22
  return {
23
23
  base: base(lightDefinition),
24
- light: lightOverrides(lightDefinition),
24
+ light: lightOverrides(lightDefinition, light),
25
25
  dark: darkDefinition,
26
26
  };
27
27
  }
@@ -36,8 +36,13 @@ const lightDialog = {
36
36
  },
37
37
  },
38
38
  };
39
- function lightOverrides(definition) {
40
- return { hue: definition.hue, "@dialog": lightDialog };
39
+ function lightOverrides(definition, theme) {
40
+ if (theme.backgroundPanel.a === 1)
41
+ return { hue: definition.hue, "@dialog": lightDialog };
42
+ return {
43
+ hue: definition.hue,
44
+ "@dialog": { ...lightDialog, background: { ...lightDialog.background, base: dialogBackground(theme) } },
45
+ };
41
46
  }
42
47
  // Mirrors the opencode2 token layout: text at 100/200/300, the page at 900, raised surfaces at 700/600/500,
43
48
  // and each V1 color anchored at 400 with quieter steps around it.
@@ -106,7 +111,7 @@ function migrateMode(theme, mode) {
106
111
  ...paletteTokens(theme),
107
112
  "@dialog": {
108
113
  background: {
109
- base: "$background.raised.base",
114
+ base: dialogBackground(theme),
110
115
  action: {
111
116
  primary: { $hovered: "$background.raised.max" },
112
117
  secondary: { $hovered: "$background.raised.max" },
@@ -9,6 +9,7 @@ export declare const categoricalTokens: readonly V1HueToken[];
9
9
  export declare function migrateV1(theme: ThemeV1Json): ThemeDocument;
10
10
  export declare function base(definition: ThemeDefinition): BaseThemeDefinition;
11
11
  export declare function detectMode(theme: Theme): Mode;
12
+ export declare function dialogBackground(theme: Theme): string;
12
13
  export declare function referenceHues(theme: ThemeDefinition): ThemeDefinition;
13
14
  export declare function inferHues(theme: Theme): {
14
15
  byHue: Partial<Record<ChromaticHue, {
@@ -200,12 +200,23 @@ function migrateMode(theme, mode) {
200
200
  },
201
201
  "@dialog": {
202
202
  background: {
203
- base: "$background.raised.base",
203
+ base: dialogBackground(theme),
204
204
  action: { primary: { $hovered: "$background.raised.high" } },
205
205
  },
206
206
  },
207
207
  });
208
208
  }
209
+ // Dialogs float over the session, so a see-through panel would let the content underneath show through them.
210
+ // Fall back to the first visible surface color, made opaque.
211
+ export function dialogBackground(theme) {
212
+ if (theme.backgroundPanel.a === 1)
213
+ return "$background.raised.base";
214
+ const visible = [theme.backgroundPanel, theme.backgroundMenu, theme.backgroundElement, theme.background].find((color) => color.a > 0);
215
+ if (!visible)
216
+ return luminance(theme.text) > 0.5 ? "#000000" : "#ffffff";
217
+ const [red, green, blue] = visible.toInts();
218
+ return hexInts(red, green, blue, 255);
219
+ }
209
220
  export function referenceHues(theme) {
210
221
  const definitions = theme.hue;
211
222
  if (!definitions)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@opencode/theme",
4
- "version": "0.0.0-dev-197",
4
+ "version": "0.0.0-dev-210",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {