@@ -20,6 +20,30 @@ export interface NextJsSSRThemeSwitcherProps extends HTMLProps<HTMLElement> {
20
20
styles ?: Record < string , string > ;
21
21
}
22
22
23
+ function getDataProps ( resolvedData : UpdateProps , styles ?: Record < string , string > ) {
24
+ const dataProps : DataProps = { className : "" } ;
25
+ let classeNames = [ ] ;
26
+ if ( resolvedData . resolvedColorScheme !== undefined ) {
27
+ dataProps [ "data-color-scheme" ] = resolvedData . resolvedColorScheme ;
28
+ classeNames . push ( resolvedData . resolvedColorScheme ) ;
29
+ }
30
+ if ( resolvedData . resolvedTheme !== undefined ) {
31
+ dataProps [ "data-theme" ] = resolvedData . resolvedTheme ;
32
+ classeNames . push ( `theme-${ resolvedData . resolvedTheme } ` ) ;
33
+ }
34
+ if ( resolvedData . th ) {
35
+ dataProps [ "data-th" ] = resolvedData . th ;
36
+ classeNames . push ( `th-${ resolvedData . th } ` ) ;
37
+ }
38
+ if ( resolvedData . resolvedColorSchemePref !== undefined ) {
39
+ dataProps [ "data-csp" ] = resolvedData . resolvedColorSchemePref ;
40
+ classeNames . push ( `csp-${ resolvedData . resolvedColorSchemePref } ` ) ;
41
+ }
42
+ if ( styles ) classeNames = classeNames . map ( cls => styles [ cls ] ?? cls ) ;
43
+ dataProps . className = classeNames . join ( " " ) ;
44
+ return dataProps ;
45
+ }
46
+
23
47
function sharedServerComponentRenderer (
24
48
{ children, tag, forcedPages, targetId, styles, ...props } : NextJsSSRThemeSwitcherProps ,
25
49
defaultTag : "div" | "html" ,
@@ -48,30 +72,6 @@ function sharedServerComponentRenderer(
48
72
) ;
49
73
}
50
74
51
- function getDataProps ( resolvedData : UpdateProps , styles ?: Record < string , string > ) {
52
- const dataProps : DataProps = { className : "" } ;
53
- let classeNames = [ ] ;
54
- if ( resolvedData . resolvedColorScheme !== undefined ) {
55
- dataProps [ "data-color-scheme" ] = resolvedData . resolvedColorScheme ;
56
- classeNames . push ( resolvedData . resolvedColorScheme ) ;
57
- }
58
- if ( resolvedData . resolvedTheme !== undefined ) {
59
- dataProps [ "data-theme" ] = resolvedData . resolvedTheme ;
60
- classeNames . push ( `theme-${ resolvedData . resolvedTheme } ` ) ;
61
- }
62
- if ( resolvedData . th ) {
63
- dataProps [ "data-th" ] = resolvedData . th ;
64
- classeNames . push ( `th-${ resolvedData . th } ` ) ;
65
- }
66
- if ( resolvedData . resolvedColorSchemePref !== undefined ) {
67
- dataProps [ "data-csp" ] = resolvedData . resolvedColorSchemePref ;
68
- classeNames . push ( `csp-${ resolvedData . resolvedColorSchemePref } ` ) ;
69
- }
70
- if ( styles ) classeNames = classeNames . map ( cls => styles [ cls ] ?? cls ) ;
71
- dataProps . className = classeNames . join ( " " ) ;
72
- return dataProps ;
73
- }
74
-
75
75
/**
76
76
* @example
77
77
* ```tsx
0 commit comments