@datalayer/primer-addons 1.0.9 → 1.0.10

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,13 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright (c) 2023-2025 Datalayer, Inc.
4
+ * Distributed under the terms of the Modified BSD License.
5
+ */
6
+ import { useEffect } from 'react';
2
7
  import { BaseStyles, ThemeProvider } from '@primer/react';
3
8
  import { useSystemColorMode } from './useSystemColorMode';
4
9
  import { datalayerTheme, datalayerThemeStyles } from './themes/datalayerTheme';
10
+ import { setupPrimerPortals } from '../utils/Portals';
5
11
  /**
6
12
  * Shared typographic rhythm — clean, spacious feel inspired by
7
13
  * modern developer-blog aesthetics (generous line-height, open
@@ -25,6 +31,11 @@ export function DatalayerThemeProvider(props) {
25
31
  const resolvedTheme = theme ?? datalayerTheme;
26
32
  const styles = themeStyles ?? datalayerThemeStyles;
27
33
  const resolvedStyles = isDark ? styles.dark : styles.light;
34
+ // Keep document.body portal-root attributes in sync so that Primer
35
+ // portals (modals, dialogs, overlays) inherit the correct color mode.
36
+ useEffect(() => {
37
+ setupPrimerPortals(resolvedColorMode === 'night' ? 'dark' : resolvedColorMode === 'day' ? 'light' : resolvedColorMode);
38
+ }, [resolvedColorMode]);
28
39
  return (_jsx(ThemeProvider, { colorMode: resolvedColorMode, theme: resolvedTheme, ...rest, children: _jsx(BaseStyles, { style: {
29
40
  lineHeight: '1.7',
30
41
  transition: 'background-color 0.25s ease, color 0.25s ease',
@@ -7,5 +7,6 @@ export * from './themes/spatialTheme';
7
7
  export * from './themes/lovelyTheme';
8
8
  export * from './themes/matrixTheme';
9
9
  export * from './themes-brand/spatialBrandTheme';
10
+ export * from './themeRegistry';
10
11
  export * from './Palette';
11
12
  export * from './useSystemColorMode';
@@ -11,5 +11,6 @@ export * from './themes/spatialTheme';
11
11
  export * from './themes/lovelyTheme';
12
12
  export * from './themes/matrixTheme';
13
13
  export * from './themes-brand/spatialBrandTheme';
14
+ export * from './themeRegistry';
14
15
  export * from './Palette';
15
16
  export * from './useSystemColorMode';
@@ -0,0 +1,30 @@
1
+ import { type CSSProperties } from 'react';
2
+ import { type ColorMode } from './DatalayerBrandThemeProvider';
3
+ /** Available theme variants. */
4
+ export type ThemeVariant = 'datalayer' | 'spatial' | 'lovely' | 'matrix';
5
+ /**
6
+ * Complete configuration for a theme, including the Primer theme object,
7
+ * display metadata, and CSS custom property overrides per color mode.
8
+ */
9
+ export interface ThemeConfig {
10
+ /** Human-readable name for UI display. */
11
+ label: string;
12
+ /** Short description of the theme. */
13
+ description: string;
14
+ /** Brand color for the theme — used for colored swatch buttons. */
15
+ brandColor: string;
16
+ /** Recommended default color mode for this theme. */
17
+ defaultColorMode: ColorMode;
18
+ /** Primer theme object passed to `<ThemeProvider theme={…}>`. */
19
+ primerTheme: Record<string, any>;
20
+ /** Per-mode CSS-property overrides for `<DatalayerThemeProvider themeStyles={…}>`. */
21
+ themeStyles: {
22
+ light: CSSProperties;
23
+ dark: CSSProperties;
24
+ };
25
+ }
26
+ export declare const themeConfigs: Record<ThemeVariant, ThemeConfig>;
27
+ /** All available theme variants in display order. */
28
+ export declare const themeVariants: ThemeVariant[];
29
+ /** Look up a theme config by variant name. */
30
+ export declare function getThemeConfig(variant: ThemeVariant): ThemeConfig;
@@ -0,0 +1,53 @@
1
+ /*
2
+ * Copyright (c) 2023-2025 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ import { datalayerTheme, datalayerThemeStyles } from './themes/datalayerTheme';
6
+ import { spatialTheme, spatialThemeStyles } from './themes/spatialTheme';
7
+ import { lovelyTheme, lovelyThemeStyles } from './themes/lovelyTheme';
8
+ import { matrixTheme, matrixThemeStyles } from './themes/matrixTheme';
9
+ import { datalayerColors } from './colors/datalayerColors';
10
+ import { spatialColors } from './colors/spatialColors';
11
+ import { lovelyColors } from './colors/lovelyColors';
12
+ import { matrixColors } from './colors/matrixColors';
13
+ /* ─── Registry ────────────────────────────────────────────────────────── */
14
+ export const themeConfigs = {
15
+ datalayer: {
16
+ label: 'Datalayer',
17
+ description: 'Default green palette — the classic Datalayer look.',
18
+ brandColor: datalayerColors.greenBrand,
19
+ defaultColorMode: 'auto',
20
+ primerTheme: datalayerTheme,
21
+ themeStyles: datalayerThemeStyles,
22
+ },
23
+ spatial: {
24
+ label: 'Spatial',
25
+ description: 'Cosmic indigo & deep blues — inspired by space.',
26
+ brandColor: spatialColors.indigoBrand,
27
+ defaultColorMode: 'auto',
28
+ primerTheme: spatialTheme,
29
+ themeStyles: spatialThemeStyles,
30
+ },
31
+ lovely: {
32
+ label: 'Lovely',
33
+ description: 'Warm rose & magenta — soft and inviting.',
34
+ brandColor: lovelyColors.roseBrand,
35
+ defaultColorMode: 'auto',
36
+ primerTheme: lovelyTheme,
37
+ themeStyles: lovelyThemeStyles,
38
+ },
39
+ matrix: {
40
+ label: 'Matrix',
41
+ description: 'Phosphor green on black — CRT terminal aesthetic.',
42
+ brandColor: matrixColors.greenPhosphor,
43
+ defaultColorMode: 'dark',
44
+ primerTheme: matrixTheme,
45
+ themeStyles: matrixThemeStyles,
46
+ },
47
+ };
48
+ /** All available theme variants in display order. */
49
+ export const themeVariants = ['datalayer', 'spatial', 'lovely', 'matrix'];
50
+ /** Look up a theme config by variant name. */
51
+ export function getThemeConfig(variant) {
52
+ return themeConfigs[variant];
53
+ }
@@ -31,6 +31,10 @@ export interface ThemeColorDefs {
31
31
  muted: string;
32
32
  subtle?: string;
33
33
  };
34
+ border?: {
35
+ default: string;
36
+ muted: string;
37
+ };
34
38
  btn: {
35
39
  text: string;
36
40
  bg: string;
@@ -64,8 +64,8 @@ export function colorDefsToCSS(defs) {
64
64
  '--borderColor-success-emphasis': defs.success.emphasis,
65
65
  '--borderColor-success-muted': defs.success.muted,
66
66
  /* ── Border (generic) ────────────────────────────────────────── */
67
- '--borderColor-default': defs.btn.border,
68
- '--borderColor-muted': defs.btn.border,
67
+ '--borderColor-default': defs.border?.default ?? defs.btn.border,
68
+ '--borderColor-muted': defs.border?.muted ?? defs.btn.border,
69
69
  /* ── Default button ──────────────────────────────────────────── */
70
70
  '--button-default-fgColor-rest': defs.btn.text,
71
71
  '--button-default-bgColor-rest': defs.btn.bg,
@@ -34,6 +34,10 @@ const datalayerLight = {
34
34
  emphasis: datalayerColors.greenBrand,
35
35
  muted: datalayerColors.greenAccent,
36
36
  },
37
+ border: {
38
+ default: '#d1d9e0',
39
+ muted: '#e0e6eb',
40
+ },
37
41
  btn: {
38
42
  text: datalayerColors.black,
39
43
  bg: datalayerColors.white,
@@ -1089,5 +1089,8 @@ export declare const matrixTheme: {
1089
1089
  }>;
1090
1090
  };
1091
1091
  /** Comprehensive Primer CSS-variable overrides for light & dark mode. */
1092
- export declare const matrixThemeStyles: import("./createThemeCSSVars").ThemeStyles;
1092
+ export declare const matrixThemeStyles: {
1093
+ light: import("react").CSSProperties;
1094
+ dark: import("react").CSSProperties;
1095
+ };
1093
1096
  export default matrixTheme;
@@ -185,6 +185,18 @@ const matrixDark = {
185
185
  * default Primer theme kept for backward compatibility.
186
186
  */
187
187
  export const matrixTheme = primerTheme;
188
+ /**
189
+ * Monospace font stack for the Matrix terminal aesthetic.
190
+ * Uses fonts pre-installed across macOS / Windows / Linux so no
191
+ * web-font loading is required.
192
+ */
193
+ const matrixFontFamily = '"SF Mono", "Cascadia Code", "Fira Code", Menlo, Consolas, "Liberation Mono", "Courier New", monospace';
188
194
  /** Comprehensive Primer CSS-variable overrides for light & dark mode. */
189
- export const matrixThemeStyles = buildThemeStyles(matrixLight, matrixDark);
195
+ export const matrixThemeStyles = (() => {
196
+ const base = buildThemeStyles(matrixLight, matrixDark);
197
+ return {
198
+ light: { ...base.light, fontFamily: matrixFontFamily },
199
+ dark: { ...base.dark, fontFamily: matrixFontFamily },
200
+ };
201
+ })();
190
202
  export default matrixTheme;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalayer/primer-addons",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "license": "BSD-3-Clause",
5
5
  "scripts": {
6
6
  "build": "tsc && vite build",