@datalayer/primer-addons 1.0.46 → 1.0.47

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.
package/README.md CHANGED
@@ -116,6 +116,42 @@ const config = getThemeConfig(app.interface.theme.variant);
116
116
 
117
117
  The source: `src/theme/colors/themeAccents.ts`.
118
118
 
119
+ ## The color palette
120
+
121
+ `useColorPalette()` returns one `ColorPalette` object, resolved for the current theme and color mode (a new one when either changes); `getColorPalette(theme, mode)` gives the same without a hook. It holds two categories of colors, and `isLight`, whether the mode is light. The [gallery](examples/gallery)'s *Color Palette* page shows both in whatever theme and mode the gallery wears.
122
+
123
+ - **Roles**, what each theme's own design uses, by role (`paletteRoleNames`, type `PaletteRoleName`): `bg`, `bgPanel`, `bgAlt`, `primary`, `secondary`, `accent`, `glow`, `pop`, `spark`, `blaze`, `surge`, `flame`, `gold`, `textLight`, `textMuted`. What a role is changes with the theme (`surge` is blue in one theme and sage in another). Use them for a page's own design.
124
+ - **Hues**, named colors a spec or a person picks, the same names in every theme (`hueNames`, type `HueName`): `red`, `orange`, `amber`, `yellow`, `lime`, `green`, `emerald`, `teal`, `cyan`, `sky`, `blue`, `indigo`, `violet`, `purple`, `fuchsia`, `pink`, `rose`, `slate`, `gray`, `stone`. A hue keeps its hue in every theme: deep on a light background, bright on a dark one. Use them for a color a spec or a person picks, such as an agent's color.
125
+
126
+ `paletteColorNames` lists both, roles first (type `PaletteColorName`).
127
+
128
+ Roles, for a page's own design:
129
+
130
+ ```tsx
131
+ import { useColorPalette } from '@datalayer/primer-addons';
132
+
133
+ const palette = useColorPalette();
134
+ <Box style={{ background: palette.bgPanel, color: palette.textLight }}>
135
+ <Text style={{ color: palette.primary }}>Title</Text>
136
+ </Box>
137
+ ```
138
+
139
+ Hues, for a color that is picked: a spec gives a palette name (an agent's `color: indigo`), or a hex where no name fits. `usePaletteColor()` returns a function that resolves it in the current theme and mode; `resolvePaletteColor(value, palette)` does the same with a palette in hand. A palette name gives its value, a hex is returned as is, and nothing or anything else is `undefined`, so the caller draws its own default. `isPaletteColorName` and `isHexColor` (`#RGB` or `#RRGGBB`) check a value first.
140
+
141
+ ```tsx
142
+ import { isHexColor, isPaletteColorName, resolvePaletteColor, usePaletteColor } from '@datalayer/primer-addons';
143
+
144
+ const colorOf = usePaletteColor();
145
+ const agentColor = colorOf(agent.color) ?? 'var(--fgColor-accent)';
146
+ // 'indigo' -> the theme's indigo, '#0969da' -> '#0969da', 'nope' -> undefined
147
+
148
+ resolvePaletteColor('teal', palette);
149
+ isPaletteColorName('rose'); // true
150
+ isHexColor('#abc'); // true
151
+ ```
152
+
153
+ The source: `src/theme/palettes/ColorPalette.tsx` and `src/theme/colors/hueColors.ts`.
154
+
119
155
  ## The `loop` theme
120
156
 
121
157
  `loop` is one of the variants of the theme registry (`ThemeVariant`, `themeConfigs`), beside `datalayer`, `spatial`, `lovely`, `matrix`, `earth`, `sand`, `ivory` and `sun`: the look of an application built in LOOP — **one accent, neutral everything else**. A white (near-black in dark mode) canvas, a deep-grey ink, hairlines, soft shadows, round corners and one filled button in the accent. Success, attention and danger are kept for verdicts and rules only. The [gallery](examples/gallery) shows it on the *Theme Accents* page when the gallery wears it. Its accent is mint, `green` of the [theme accents](#theme-accents).
@@ -39,7 +39,7 @@ export function HoverCardDetails({ label, onClose, width = 880, closeLabel = 'Cl
39
39
  : `${leaving ? 'dlaHoverCardVeilOut' : 'dlaHoverCardVeilIn'} ${HOVER_CARD_MOTION_MS}ms ease-out both`, sx: {
40
40
  '@keyframes dlaHoverCardVeilIn': { from: { opacity: 0 }, to: { opacity: 1 } },
41
41
  '@keyframes dlaHoverCardVeilOut': { from: { opacity: 1 }, to: { opacity: 0 } },
42
- }, children: _jsxs(Card, { role: "dialog", "aria-modal": "true", "aria-label": label, onClick: (event) => event.stopPropagation(), shadow: "extraLarge", width: width, maxWidth: "100%", borderRadius: [0, 'card'], overflow: "hidden", position: "relative", display: "block",
42
+ }, children: _jsxs(Card, { role: "dialog", "aria-modal": "true", "aria-label": label, onClick: (event) => event.stopPropagation(), shadow: "extraLarge", width: width, maxWidth: "100%", borderRadius: [0, 'overlay'], overflow: "hidden", position: "relative", display: "block",
43
43
  // Rises into place and sinks back out, at the hover card's speed: the
44
44
  // third size arrives the way the second one did.
45
45
  animation: reduced
@@ -108,25 +108,10 @@ export function FloatingToolbar({ items, extraItems, anchorElement, isVisible, c
108
108
  return null;
109
109
  }
110
110
  const container = portalContainer || anchorElement || document.body;
111
- const toolbar = (_jsx(Box, { ref: floatingRef, className: className, role: "toolbar", "aria-label": ariaLabel, sx: {
112
- display: 'flex',
113
- alignItems: 'center',
114
- gap: '2px',
115
- px: 1,
116
- py: '4px',
117
- bg: 'var(--overlay-bgColor, var(--bgColor-default))',
118
- border: '1px solid',
119
- borderColor: 'var(--borderColor-muted, transparent)',
120
- borderRadius: 2,
121
- boxShadow: 'shadow.large',
122
- position: 'absolute',
123
- zIndex: 10,
124
- top: '-10000px',
125
- left: '-10000px',
126
- opacity: 0,
127
- transition: 'opacity 0.15s ease, transform 0.15s ease',
128
- transform: 'translateY(-4px)',
129
- }, children: _jsx(ToolbarRenderer, { items: allItems, disabled: disabled, size: "small" }) }));
111
+ // Drawn as this package's `Card` draws itself, from the theme's tokens
112
+ // only: the theme's card corner, Primer's overlay ground and hairline, and
113
+ // the floating shadow each colour mode sets for itself.
114
+ const toolbar = (_jsx(Box, { ref: floatingRef, className: className, role: "toolbar", "aria-label": ariaLabel, display: "flex", alignItems: "center", gap: "2px", px: 1, py: "4px", bg: "canvas.overlay", color: "fg.default", border: "1px solid", borderColor: "border.default", borderRadius: "overlay", boxShadow: "shadow.large", position: "absolute", zIndex: 10, top: "-10000px", left: "-10000px", opacity: 0, transition: "opacity 0.15s ease, transform 0.15s ease", transform: "translateY(-4px)", children: _jsx(ToolbarRenderer, { items: allItems, disabled: disabled, size: "small" }) }));
130
115
  return createPortal(toolbar, container);
131
116
  }
132
117
  export default FloatingToolbar;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalayer/primer-addons",
3
- "version": "1.0.46",
3
+ "version": "1.0.47",
4
4
  "license": "BSD-3-Clause",
5
5
  "scripts": {
6
6
  "build": "npm run build:lib",