bubble-toolbar 1.1.0 → 1.2.1

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
@@ -249,6 +249,7 @@ Toolbar tokens, set on `:root` or any ancestor:
249
249
 
250
250
  | Token | Default |
251
251
  | :--- | :--- |
252
+ | `--bubble-blur` | `16px` (ignored when `blurAmount` is set) |
252
253
  | `--bubble-glass-bg` / `--bubble-glass-bg-solid` | `rgba(255, 255, 255, 0.65)` / `rgba(255, 255, 255, 0.92)` |
253
254
  | `--bubble-glass-border` / `--bubble-glass-fg` | `rgba(255, 255, 255, 0.4)` / `#09090b` |
254
255
  | `--bubble-glass-shadow` | Default floating shadow |
@@ -315,7 +316,7 @@ Use the `shape` prop on a group to override its automatic shape.
315
316
  | `theme` | `'glass' \| 'light' \| 'dark' \| 'auto'` | `'glass'` | Visual theme. |
316
317
  | `size` | `'sm' \| 'md' \| 'lg' \| number` | `'md'` | Group height and circle diameter: 40px, 48px, 56px, or a custom pixel value. |
317
318
  | `blurred` | `boolean` | `true` | Enables background blur. |
318
- | `blurAmount` | `number \| string` | `16` | Blur radius in pixels or a CSS length. |
319
+ | `blurAmount` | `number \| string` | `--bubble-blur` | Blur radius in pixels or a CSS length. Overrides the `--bubble-blur` token; negative numbers become `0`. |
319
320
  | `groupGap` | `number \| string` | `8` | Space between groups, in pixels or a CSS length. |
320
321
  | `itemGap` | `number \| string` | `8` | Space between children within a pill. |
321
322
  | `bordered` | `boolean` | `true` | Shows subtle borders. |
package/dist/index.d.mts CHANGED
@@ -59,8 +59,8 @@ interface BubbleToolbarProps extends Omit<HTMLAttributes<HTMLDivElement>, 'child
59
59
  */
60
60
  blurred?: boolean;
61
61
  /**
62
- * Amount of backdrop blur in pixels or CSS string.
63
- * @default 16
62
+ * Amount of backdrop blur in pixels or CSS string. Negative numbers are clamped to 0.
63
+ * When omitted, the `--bubble-blur` CSS token is used (16px by default).
64
64
  */
65
65
  blurAmount?: number | string;
66
66
  /**
@@ -402,7 +402,8 @@ interface BubbleToolbarContextValue extends BubbleActivityProps {
402
402
  size: BubbleToolbarSize;
403
403
  theme: BubbleToolbarTheme;
404
404
  blurred: boolean;
405
- blurAmount: number | string;
405
+ /** Undefined falls back to the --bubble-blur token. */
406
+ blurAmount?: number | string;
406
407
  itemGap: number | string;
407
408
  bordered: boolean;
408
409
  shadow: boolean | string;
@@ -430,6 +431,6 @@ declare function getValidChildren(children: ReactNode): ReactNode[];
430
431
 
431
432
  declare function resolveSize(size: BubbleToolbarSize): number;
432
433
  declare function formatPx(val: number | string): string;
433
- declare function getGlassStyles(theme: BubbleToolbarTheme, blurred: boolean, blurAmount: number | string, bordered: boolean, shadow: boolean | string): CSSProperties;
434
+ declare function getGlassStyles(theme: BubbleToolbarTheme, blurred: boolean, blurAmount: number | string | undefined, bordered: boolean, shadow: boolean | string): CSSProperties;
434
435
 
435
436
  export { type BubbleActivityProps, type BubbleActivityValue, BubbleArea, type BubbleAreaProps, type BubbleBreadcrumbItem, BubbleBreadcrumbSearch, type BubbleBreadcrumbSearchLabels, type BubbleBreadcrumbSearchProps, type BubbleBreadcrumbSearchTokens, BubbleGroup, type BubbleGroupProps, BubbleIconButton, type BubbleIconButtonProps, type BubbleLiveActivityController, type BubbleLiveActivityOptions, type BubbleLiveContent, type BubbleLiveLabels, type BubbleLiveRunOptions, type BubbleLiveState, type BubbleLiveTokens, BubbleSearch, type BubbleSearchItem, type BubbleSearchLabels, type BubbleSearchProps, type BubbleSearchTokens, type BubbleShape, BubbleToolbar, type BubbleToolbarComponent, BubbleToolbarContext, type BubbleToolbarPosition, type BubbleToolbarProps, type BubbleToolbarSize, type BubbleToolbarTheme, formatPx, getGlassStyles, getValidChildren, resolveSize, useBubbleActivity, useBubbleLiveActivity, useBubbleToolbar, useBubbleToolbarLiveActivity };
package/dist/index.d.ts CHANGED
@@ -59,8 +59,8 @@ interface BubbleToolbarProps extends Omit<HTMLAttributes<HTMLDivElement>, 'child
59
59
  */
60
60
  blurred?: boolean;
61
61
  /**
62
- * Amount of backdrop blur in pixels or CSS string.
63
- * @default 16
62
+ * Amount of backdrop blur in pixels or CSS string. Negative numbers are clamped to 0.
63
+ * When omitted, the `--bubble-blur` CSS token is used (16px by default).
64
64
  */
65
65
  blurAmount?: number | string;
66
66
  /**
@@ -402,7 +402,8 @@ interface BubbleToolbarContextValue extends BubbleActivityProps {
402
402
  size: BubbleToolbarSize;
403
403
  theme: BubbleToolbarTheme;
404
404
  blurred: boolean;
405
- blurAmount: number | string;
405
+ /** Undefined falls back to the --bubble-blur token. */
406
+ blurAmount?: number | string;
406
407
  itemGap: number | string;
407
408
  bordered: boolean;
408
409
  shadow: boolean | string;
@@ -430,6 +431,6 @@ declare function getValidChildren(children: ReactNode): ReactNode[];
430
431
 
431
432
  declare function resolveSize(size: BubbleToolbarSize): number;
432
433
  declare function formatPx(val: number | string): string;
433
- declare function getGlassStyles(theme: BubbleToolbarTheme, blurred: boolean, blurAmount: number | string, bordered: boolean, shadow: boolean | string): CSSProperties;
434
+ declare function getGlassStyles(theme: BubbleToolbarTheme, blurred: boolean, blurAmount: number | string | undefined, bordered: boolean, shadow: boolean | string): CSSProperties;
434
435
 
435
436
  export { type BubbleActivityProps, type BubbleActivityValue, BubbleArea, type BubbleAreaProps, type BubbleBreadcrumbItem, BubbleBreadcrumbSearch, type BubbleBreadcrumbSearchLabels, type BubbleBreadcrumbSearchProps, type BubbleBreadcrumbSearchTokens, BubbleGroup, type BubbleGroupProps, BubbleIconButton, type BubbleIconButtonProps, type BubbleLiveActivityController, type BubbleLiveActivityOptions, type BubbleLiveContent, type BubbleLiveLabels, type BubbleLiveRunOptions, type BubbleLiveState, type BubbleLiveTokens, BubbleSearch, type BubbleSearchItem, type BubbleSearchLabels, type BubbleSearchProps, type BubbleSearchTokens, type BubbleShape, BubbleToolbar, type BubbleToolbarComponent, BubbleToolbarContext, type BubbleToolbarPosition, type BubbleToolbarProps, type BubbleToolbarSize, type BubbleToolbarTheme, formatPx, getGlassStyles, getValidChildren, resolveSize, useBubbleActivity, useBubbleLiveActivity, useBubbleToolbar, useBubbleToolbarLiveActivity };
package/dist/index.js CHANGED
@@ -82,7 +82,6 @@ var defaultContextValue = {
82
82
  size: "md",
83
83
  theme: "glass",
84
84
  blurred: true,
85
- blurAmount: 16,
86
85
  itemGap: 8,
87
86
  bordered: true,
88
87
  shadow: true
@@ -128,7 +127,7 @@ function formatPx(val) {
128
127
  return typeof val === "number" ? `${val}px` : val;
129
128
  }
130
129
  function getGlassStyles(theme, blurred, blurAmount, bordered, shadow) {
131
- const blurVal = formatPx(blurAmount);
130
+ const blurVal = blurAmount === void 0 ? "var(--bubble-blur, 16px)" : formatPx(typeof blurAmount === "number" ? Math.max(0, blurAmount) : blurAmount);
132
131
  let background;
133
132
  let borderColor;
134
133
  let color;
@@ -144,7 +143,7 @@ function getGlassStyles(theme, blurred, blurAmount, bordered, shadow) {
144
143
  color = "var(--bubble-light-fg, #18181b)";
145
144
  break;
146
145
  case "auto":
147
- background = "var(--bubble-bg, var(--bubble-light-bg, rgba(255, 255, 255, 0.75)))";
146
+ background = blurred ? "var(--bubble-bg, var(--bubble-light-bg, rgba(255, 255, 255, 0.75)))" : "var(--bubble-bg-solid, var(--bubble-light-bg-solid, rgba(255, 255, 255, 0.95)))";
148
147
  borderColor = "var(--bubble-border, var(--bubble-light-border, rgba(0, 0, 0, 0.08)))";
149
148
  color = "var(--bubble-fg, var(--bubble-light-fg, #18181b))";
150
149
  break;
@@ -162,7 +161,10 @@ function getGlassStyles(theme, blurred, blurAmount, bordered, shadow) {
162
161
  border: bordered ? `1px solid ${borderColor}` : "none",
163
162
  boxShadow,
164
163
  color,
165
- transition: "all 0.25s cubic-bezier(0.16, 1, 0.3, 1)"
164
+ // backdrop-filter is left out: animating a blur is expensive.
165
+ transitionProperty: "background-color, border-color, box-shadow, color",
166
+ transitionDuration: "0.25s",
167
+ transitionTimingFunction: "cubic-bezier(0.16, 1, 0.3, 1)"
166
168
  };
167
169
  }
168
170
 
@@ -747,7 +749,9 @@ var LiveSlot = ({ controller, toolbarRef, children }) => {
747
749
  if (active && (visual === "idle" || visual === "leave")) {
748
750
  if (visual === "idle") {
749
751
  const toolbar = toolbarRef.current;
750
- fromWidth.current = toolbar ? Math.max(0, toolbar.getBoundingClientRect().width - 8) : 0;
752
+ const toolbarStyle = toolbar ? getComputedStyle(toolbar) : null;
753
+ const horizontalPadding = toolbarStyle ? (parseFloat(toolbarStyle.paddingLeft) || 0) + (parseFloat(toolbarStyle.paddingRight) || 0) : 0;
754
+ fromWidth.current = toolbar ? Math.max(0, toolbar.getBoundingClientRect().width - horizontalPadding) : 0;
751
755
  const focused = document.activeElement;
752
756
  savedFocus.current = focused instanceof HTMLElement && groupsRef.current?.contains(focused) ? focused : null;
753
757
  }
@@ -1486,7 +1490,7 @@ var BubbleToolbar = (0, import_react13.forwardRef)(
1486
1490
  theme = "glass",
1487
1491
  size = "md",
1488
1492
  blurred = true,
1489
- blurAmount = 16,
1493
+ blurAmount,
1490
1494
  groupGap = 8,
1491
1495
  itemGap = 8,
1492
1496
  bordered = true,
@@ -1547,7 +1551,7 @@ var BubbleToolbar = (0, import_react13.forwardRef)(
1547
1551
  case "bottom":
1548
1552
  return {
1549
1553
  position: "fixed",
1550
- bottom: "24px",
1554
+ bottom: "-4px",
1551
1555
  left: "50%",
1552
1556
  transform: "translateX(-50%)",
1553
1557
  zIndex: 1e3
@@ -1555,7 +1559,7 @@ var BubbleToolbar = (0, import_react13.forwardRef)(
1555
1559
  case "top":
1556
1560
  return {
1557
1561
  position: "fixed",
1558
- top: "24px",
1562
+ top: "-4px",
1559
1563
  left: "50%",
1560
1564
  transform: "translateX(-50%)",
1561
1565
  zIndex: 1e3
@@ -1576,7 +1580,8 @@ var BubbleToolbar = (0, import_react13.forwardRef)(
1576
1580
  maxWidth: "calc(100vw - 32px)",
1577
1581
  overflowX: "auto",
1578
1582
  overflowY: "hidden",
1579
- padding: "4px",
1583
+ // Scroll containers clip shadows; leave room for their falloff and the hover lift.
1584
+ padding: "32px",
1580
1585
  boxSizing: "border-box",
1581
1586
  scrollbarWidth: "none",
1582
1587
  // Firefox