22 CustomizationCorners ,
33 CustomizationHeaderPreset ,
44 CustomizationIconsStyle ,
5- type CustomizationSettings ,
65 CustomizationSidebarBackgroundStyle ,
76 CustomizationSidebarListStyle ,
7+ CustomizationThemeMode ,
88 type CustomizationThemedColor ,
99 type CustomizationTint ,
1010 type SiteCustomizationSettings ,
@@ -41,10 +41,11 @@ import { AnnouncementDismissedScript } from '../Announcement';
4141 * It takes care of setting the theme and the language.
4242 */
4343export async function CustomizationRootLayout ( props : {
44- customization : SiteCustomizationSettings | CustomizationSettings ;
44+ forcedTheme ?: CustomizationThemeMode | null ;
45+ customization : SiteCustomizationSettings ;
4546 children : React . ReactNode ;
4647} ) {
47- const { customization, children } = props ;
48+ const { customization, forcedTheme , children } = props ;
4849
4950 const language = getSpaceLanguage ( customization ) ;
5051 const tintColor = getTintColor ( customization ) ;
@@ -86,7 +87,12 @@ export async function CustomizationRootLayout(props: {
8687 'links' in customization . styling && `links-${ customization . styling . links } ` ,
8788 fontNotoColorEmoji . variable ,
8889 ibmPlexMono . variable ,
89- fontData . type === 'default' ? fontData . variable : 'font-custom'
90+ fontData . type === 'default' ? fontData . variable : 'font-custom' ,
91+
92+ // Set the dark/light class statically to avoid flashing and make it work when JS is disabled
93+ ( forcedTheme ?? customization . themes . default ) === CustomizationThemeMode . Dark
94+ ? 'dark'
95+ : ''
9096 ) }
9197 >
9298 < head >
@@ -181,7 +187,7 @@ export async function CustomizationRootLayout(props: {
181187 * If the tint color is not set or it is a space customization, it will return the default color.
182188 */
183189function getTintColor (
184- customization : CustomizationSettings | SiteCustomizationSettings
190+ customization : SiteCustomizationSettings
185191) : CustomizationTint [ 'color' ] | undefined {
186192 if ( 'tint' in customization . styling && customization . styling . tint ) {
187193 return {
@@ -228,7 +234,7 @@ function getTintMixColor(
228234 * If it is a space customization, it will return the default styles.
229235 */
230236function getSidebarStyles (
231- customization : CustomizationSettings | SiteCustomizationSettings
237+ customization : SiteCustomizationSettings
232238) : SiteCustomizationSettings [ 'styling' ] [ 'sidebar' ] {
233239 if ( 'sidebar' in customization . styling ) {
234240 return {
@@ -248,7 +254,7 @@ function getSidebarStyles(
248254 * If it is a space customization, it will return the default styles.
249255 */
250256function getSemanticColors (
251- customization : CustomizationSettings | SiteCustomizationSettings
257+ customization : SiteCustomizationSettings
252258) : Pick <
253259 SiteCustomizationSettings [ 'styling' ] ,
254260 'infoColor' | 'successColor' | 'warningColor' | 'dangerColor'
0 commit comments