@@ -14,6 +14,10 @@ import {
14
14
colorScale ,
15
15
type ColorScaleOptions ,
16
16
DEFAULT_TINT_COLOR ,
17
+ DEFAULT_HINT_INFO_COLOR ,
18
+ DEFAULT_HINT_SUCCESS_COLOR ,
19
+ DEFAULT_HINT_DANGER_COLOR ,
20
+ DEFAULT_HINT_WARNING_COLOR ,
17
21
hexToRgb ,
18
22
} from '@gitbook/colors' ;
19
23
import { IconsProvider , IconStyle } from '@gitbook/icons' ;
@@ -42,6 +46,7 @@ export async function CustomizationRootLayout(props: {
42
46
const tintColor = getTintColor ( customization ) ;
43
47
const mixColor = getTintMixColor ( customization . styling . primaryColor , tintColor ) ;
44
48
const sidebarStyles = getSidebarStyles ( customization ) ;
49
+ const { infoColor, successColor, warningColor, dangerColor } = getSemanticColors ( customization ) ;
45
50
46
51
return (
47
52
< html
@@ -86,10 +91,10 @@ export async function CustomizationRootLayout(props: {
86
91
} ;
87
92
--header-link: ${ hexToRgb ( customization . header . linkColor ?. light ?? colorContrast ( tintColor ?. light ?? customization . styling . primaryColor . light ) ) } ;
88
93
89
- ${ generateColorVariable ( 'info' , '#ff0000' ) }
90
- ${ generateColorVariable ( 'warning' , '#ff0000' ) }
91
- ${ generateColorVariable ( 'danger' , '#ff0000' ) }
92
- ${ generateColorVariable ( 'success' , '#ff0000' ) }
94
+ ${ generateColorVariable ( 'info' , infoColor . light ) }
95
+ ${ generateColorVariable ( 'warning' , warningColor . light ) }
96
+ ${ generateColorVariable ( 'danger' , dangerColor . light ) }
97
+ ${ generateColorVariable ( 'success' , successColor . light ) }
93
98
}
94
99
95
100
.dark {
@@ -100,10 +105,10 @@ export async function CustomizationRootLayout(props: {
100
105
--header-background: ${ hexToRgb ( customization . header . backgroundColor ?. dark ?? tintColor ?. dark ?? customization . styling . primaryColor . dark ) } ;
101
106
--header-link: ${ hexToRgb ( customization . header . linkColor ?. dark ?? colorContrast ( tintColor ?. dark ?? customization . styling . primaryColor . dark ) ) } ;
102
107
103
- ${ generateColorVariable ( 'info' , '#ff0000' , { darkMode : true } ) }
104
- ${ generateColorVariable ( 'warning' , '#ff0000' , { darkMode : true } ) }
105
- ${ generateColorVariable ( 'danger' , '#ff0000' , { darkMode : true } ) }
106
- ${ generateColorVariable ( 'success' , '#ff0000' , { darkMode : true } ) }
108
+ ${ generateColorVariable ( 'info' , infoColor . dark , { darkMode : true } ) }
109
+ ${ generateColorVariable ( 'warning' , warningColor . dark , { darkMode : true } ) }
110
+ ${ generateColorVariable ( 'danger' , dangerColor . dark , { darkMode : true } ) }
111
+ ${ generateColorVariable ( 'success' , successColor . dark , { darkMode : true } ) }
107
112
}
108
113
` } </ style >
109
114
</ head >
@@ -208,6 +213,33 @@ function getSidebarStyles(
208
213
} ;
209
214
}
210
215
216
+ /**
217
+ * Get the semnatic color customization settings.
218
+ * If it is a space customization, it will return the default styles.
219
+ */
220
+ function getSemanticColors (
221
+ customization : CustomizationSettings | SiteCustomizationSettings ,
222
+ ) : Pick <
223
+ SiteCustomizationSettings [ 'styling' ] ,
224
+ 'infoColor' | 'successColor' | 'warningColor' | 'dangerColor'
225
+ > {
226
+ if ( 'infoColor' in customization . styling ) {
227
+ return {
228
+ infoColor : customization . styling . infoColor ,
229
+ successColor : customization . styling . successColor ,
230
+ warningColor : customization . styling . warningColor ,
231
+ dangerColor : customization . styling . dangerColor ,
232
+ } ;
233
+ }
234
+
235
+ return {
236
+ infoColor : DEFAULT_HINT_INFO_COLOR ,
237
+ successColor : DEFAULT_HINT_SUCCESS_COLOR ,
238
+ warningColor : DEFAULT_HINT_WARNING_COLOR ,
239
+ dangerColor : DEFAULT_HINT_DANGER_COLOR ,
240
+ } ;
241
+ }
242
+
211
243
type ColorInput = string ;
212
244
function generateColorVariable (
213
245
name : string ,
0 commit comments