@box/blueprint-web 12.6.0 → 12.7.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.
@@ -1,2 +1,2 @@
1
1
  import { type BrandingStylesProps } from './types';
2
- export declare const BrandingStyles: ({ brandColor }: BrandingStylesProps) => null;
2
+ export declare const BrandingStyles: ({ brandColor, containerSelector }: BrandingStylesProps) => null;
@@ -1,9 +1,10 @@
1
1
  import { useCustomBranding } from './useCustomBranding.js';
2
2
 
3
3
  const BrandingStyles = ({
4
- brandColor
4
+ brandColor,
5
+ containerSelector = ':root[lang]'
5
6
  }) => {
6
- useCustomBranding(brandColor);
7
+ useCustomBranding(brandColor, containerSelector);
7
8
  return null;
8
9
  };
9
10
 
@@ -1,4 +1,6 @@
1
1
  export interface BrandingStylesProps {
2
2
  /** Color value used for generating theme color palette */
3
3
  brandColor: string;
4
+ /** CSS selector for the element where branding tokens will be attached - defaults to :root[lang] */
5
+ containerSelector?: string;
4
6
  }
@@ -1 +1,3 @@
1
- export declare const useCustomBranding: (brandColor: string) => void;
1
+ import { createTheme } from './utils/createTheme';
2
+ export declare const getBrandingTokensCssRule: (buieTheme: ReturnType<typeof createTheme>, isBrandingEnabled: boolean, containerSelector: string, tokenPrefix?: string) => string;
3
+ export declare const useCustomBranding: (brandColor: string, containerSelector?: string) => void;
@@ -1,8 +1,36 @@
1
- import { BoxBlue100, Gray65 } from '@box/blueprint-web-assets/tokens/tokens';
1
+ import { Gray65, BoxBlue100 } from '@box/blueprint-web-assets/tokens/tokens';
2
2
  import { useEnhancedEffect } from '../utils/useEnhancedEffect.js';
3
3
  import { createTheme } from './utils/createTheme.js';
4
4
 
5
- const useCustomBranding = brandColor => {
5
+ const getBrandingTokensCssRule = (buieTheme, isBrandingEnabled, containerSelector, tokenPrefix = '--') => {
6
+ return `
7
+ ${containerSelector} {
8
+ /* Button branding tokens */
9
+ ${tokenPrefix}text-text-brand-on-color: ${buieTheme.primary.buttonForeground};
10
+ ${tokenPrefix}surface-surface-brand: ${buieTheme.primary.buttonBackground};
11
+ ${tokenPrefix}surface-surface-brand-hover: ${buieTheme.primary.buttonBackgroundHover};
12
+ ${tokenPrefix}surface-surface-brand-pressed: ${buieTheme.primary.buttonBackgroundActive};
13
+ /* BUIE Theme has no token for disabled and busy button. Setting to default TODO: Confirm with designers */
14
+ ${tokenPrefix}surface-surface-brand-disabled: ${buieTheme.primary.buttonBackground};
15
+ ${tokenPrefix}surface-surface-brand-busy: ${buieTheme.primary.buttonBackground};
16
+
17
+ /* Nav branding tokens */
18
+ ${tokenPrefix}surface-nav-surface-brand-selected-focus: ${buieTheme.primary.backgroundActive};
19
+ ${tokenPrefix}surface-nav-surface-brand-selected: ${buieTheme.primary.backgroundActive};
20
+ ${tokenPrefix}surface-nav-surface-brand-focus: ${buieTheme.primary.backgroundActive};
21
+ ${tokenPrefix}surface-nav-surface-brand-hover: ${buieTheme.primary.backgroundHover};
22
+ ${tokenPrefix}surface-nav-surface-brand: ${buieTheme.primary.background};
23
+ ${tokenPrefix}surface-nav-surface-brand-foreground: ${buieTheme.primary.foreground};
24
+ ${tokenPrefix}surface-nav-surface-brand-divider: ${buieTheme.primary.dividerBackground};
25
+
26
+ /* Illustrations branding tokens */
27
+ ${tokenPrefix}surface-illustration-surface-box-neutral: ${isBrandingEnabled ? Gray65 : BoxBlue100};
28
+
29
+ /* Progress bar branding tokens */
30
+ ${tokenPrefix}surface-progress-bar-surface-brand-background: ${buieTheme.primary.progressBarBackground};
31
+ }`;
32
+ };
33
+ const useCustomBranding = (brandColor, containerSelector = ':root[lang]') => {
6
34
  useEnhancedEffect(() => {
7
35
  const buieTheme = createTheme(brandColor);
8
36
  const isBrandingEnabled = brandColor.toLowerCase() !== BoxBlue100.toLowerCase();
@@ -11,37 +39,13 @@ const useCustomBranding = brandColor => {
11
39
  // add data-blueprint property for debugging
12
40
  stylesheet.dataset.blueprint = '';
13
41
  document.head.appendChild(stylesheet);
14
- stylesheet.sheet?.insertRule(
15
- // "lang" attribute selector for increased specificity
16
- `:root[lang] {
17
- /* Button branding tokens */
18
- --text-text-brand-on-color: ${buieTheme.primary.buttonForeground};
19
- --surface-surface-brand: ${buieTheme.primary.buttonBackground};
20
- --surface-surface-brand-hover: ${buieTheme.primary.buttonBackgroundHover};
21
- --surface-surface-brand-pressed: ${buieTheme.primary.buttonBackgroundActive};
22
- /* BUIE Theme has no token for disabled and busy button. Setting to default TODO: Confirm with designers */
23
- --surface-surface-brand-disabled: ${buieTheme.primary.buttonBackground};
24
- --surface-surface-brand-busy: ${buieTheme.primary.buttonBackground};
25
-
26
- /* Nav branding tokens */
27
- --surface-nav-surface-brand-selected-focus: ${buieTheme.primary.backgroundActive};
28
- --surface-nav-surface-brand-selected: ${buieTheme.primary.backgroundActive};
29
- --surface-nav-surface-brand-focus: ${buieTheme.primary.backgroundActive};
30
- --surface-nav-surface-brand-hover: ${buieTheme.primary.backgroundHover};
31
- --surface-nav-surface-brand: ${buieTheme.primary.background};
32
- --surface-nav-surface-brand-foreground: ${buieTheme.primary.foreground};
33
- --surface-nav-surface-brand-divider: ${buieTheme.primary.dividerBackground};
34
-
35
- /* Illustrations branding tokens */
36
- --surface-illustration-surface-box-neutral: ${isBrandingEnabled ? Gray65 : BoxBlue100};
37
-
38
- /* Progress bar branding tokens */
39
- --surface-progress-bar-surface-brand-background: ${buieTheme.primary.progressBarBackground};
40
- }`, 0);
42
+ stylesheet.sheet?.insertRule(getBrandingTokensCssRule(buieTheme, isBrandingEnabled, containerSelector), 0);
43
+ // Blueprint 2.0 tokens
44
+ stylesheet.sheet?.insertRule(getBrandingTokensCssRule(buieTheme, isBrandingEnabled, containerSelector, '--bp-'), 0);
41
45
  return () => {
42
46
  document.head.removeChild(stylesheet);
43
47
  };
44
48
  }, [brandColor]);
45
49
  };
46
50
 
47
- export { useCustomBranding };
51
+ export { getBrandingTokensCssRule, useCustomBranding };
@@ -1759,20 +1759,17 @@
1759
1759
  .bp_text_area_module_textAreaContainer--e7ad7 .bp_text_area_module_inlineError--e7ad7{
1760
1760
  margin-block-start:var(--space-2);
1761
1761
  }
1762
- .bp_labelable_module_required--23e9d{
1762
+ .bp_labelable_module_required--25dbc{
1763
1763
  align-items:center;
1764
1764
  display:inline-flex;
1765
1765
  gap:var(--space-1);
1766
1766
  }
1767
- .bp_labelable_module_required--23e9d::before{
1767
+ .bp_labelable_module_required--25dbc::before{
1768
1768
  color:var(--icon-icon-required-on-light);
1769
1769
  content:"*";
1770
1770
  font-family:monospace;
1771
1771
  transform:scale(1.2);
1772
1772
  }
1773
- .bp_labelable_module_required--23e9d::before *{
1774
- fill:var(--icon-icon-required-on-light);
1775
- }
1776
1773
 
1777
1774
  .bp_combobox_module_container--25995{
1778
1775
  display:flex;
@@ -7,7 +7,7 @@ export { StatusBadge } from './badge/status-badge.js';
7
7
  export { BlueprintModernizationProvider } from './blueprint-modernization-context/blueprint-modernization-context.js';
8
8
  export { useBlueprintModernization } from './blueprint-modernization-context/useBlueprintModernization.js';
9
9
  export { BrandingStyles } from './branding-styles/branding-styles.js';
10
- export { useCustomBranding } from './branding-styles/useCustomBranding.js';
10
+ export { getBrandingTokensCssRule, useCustomBranding } from './branding-styles/useCustomBranding.js';
11
11
  export { Button } from './button/button.js';
12
12
  export { ButtonWrapper } from './button-wrapper/button-wrapper.js';
13
13
  export { Card } from './card/card.js';
@@ -1,4 +1,4 @@
1
1
  import '../../index.css';
2
- var styles = {"required":"bp_labelable_module_required--23e9d"};
2
+ var styles = {"required":"bp_labelable_module_required--25dbc"};
3
3
 
4
4
  export { styles as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/blueprint-web",
3
- "version": "12.6.0",
3
+ "version": "12.7.1",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "publishConfig": {