@datalayer/primer-addons 1.0.41 → 1.0.42

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.
@@ -26,19 +26,6 @@ export declare const setupPrimerPortals: (colormode?: Colormode) => void;
26
26
  * answers `null` rather than inventing one.
27
27
  */
28
28
  export declare const getPrimerPortalRoot: () => HTMLElement | null;
29
- /**
30
- * Sync a set of CSS properties (including CSS custom properties) to
31
- * `document.body` so that Primer portal content — which is a DOM child
32
- * of `<body>`, not of the React-tree `<BaseStyles>` element — inherits
33
- * the same theme tokens and cascade properties (font, color, background)
34
- * as the rest of the application.
35
- *
36
- * This function is **idempotent**: calling it again replaces the
37
- * properties from the previous call and removes any stale ones.
38
- *
39
- * Typical usage: call from `DatalayerThemeProvider`'s `useEffect` so
40
- * portals stay in sync whenever theme or color-mode changes.
41
- */
42
29
  export declare function syncPortalThemeStyles(styles: CSSProperties): void;
43
30
  /**
44
31
  * The attribute every theme provider stamps on its own element, its value
@@ -137,6 +137,26 @@ const camelToKebab = (s) => s.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
137
137
  * Typical usage: call from `DatalayerThemeProvider`'s `useEffect` so
138
138
  * portals stay in sync whenever theme or color-mode changes.
139
139
  */
140
+ /**
141
+ * What the body and the portal root take of a theme's styles, besides its
142
+ * custom properties: what a portal inherits or paints with — colour, type,
143
+ * background — and nothing of layout. A provider's `baseStyles` may size its
144
+ * own box (`height: 100%`, `display: contents`); written on the portal root,
145
+ * a fixed layer at the top of the page with the theme's background, the same
146
+ * height covered the whole page.
147
+ */
148
+ const PORTAL_PROPERTIES = new Set([
149
+ 'color',
150
+ 'backgroundColor',
151
+ 'fontFamily',
152
+ 'fontSize',
153
+ 'fontWeight',
154
+ 'lineHeight',
155
+ 'letterSpacing',
156
+ 'colorScheme',
157
+ 'WebkitFontSmoothing',
158
+ 'textRendering',
159
+ ]);
140
160
  export function syncPortalThemeStyles(styles) {
141
161
  /*
142
162
  * On the portal root as well as on the body, and that is the point.
@@ -171,6 +191,8 @@ export function syncPortalThemeStyles(styles) {
171
191
  for (const [key, value] of Object.entries(styles)) {
172
192
  if (value == null)
173
193
  continue;
194
+ if (!key.startsWith('--') && !PORTAL_PROPERTIES.has(key))
195
+ continue;
174
196
  const strVal = String(value);
175
197
  if (key.startsWith('--')) {
176
198
  // CSS custom property — must use setProperty
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalayer/primer-addons",
3
- "version": "1.0.41",
3
+ "version": "1.0.42",
4
4
  "license": "BSD-3-Clause",
5
5
  "scripts": {
6
6
  "build": "npm run build:lib",