@box/blueprint-web 12.6.0 → 12.7.0
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/dist/lib-esm/branding-styles/branding-styles.d.ts +1 -1
- package/dist/lib-esm/branding-styles/branding-styles.js +3 -2
- package/dist/lib-esm/branding-styles/types.d.ts +2 -0
- package/dist/lib-esm/branding-styles/useCustomBranding.d.ts +3 -1
- package/dist/lib-esm/branding-styles/useCustomBranding.js +34 -30
- package/dist/lib-esm/index.js +1 -1
- package/package.json +1 -1
|
@@ -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 +1,3 @@
|
|
|
1
|
-
|
|
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 {
|
|
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
|
|
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
|
-
//
|
|
16
|
-
|
|
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 };
|
package/dist/lib-esm/index.js
CHANGED
|
@@ -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';
|