@@ -17,7 +17,10 @@ export interface DataProps {
1717 /**
1818 * toogle desktopBackground show.
1919 */
20- enableDesktopBackground ?: boolean ;
20+ desktopBackgroundConfig ?: {
21+ enableRender ?: boolean ;
22+ renderToScreen ?: boolean ;
23+ } ;
2124 /**
2225 * set theme will update callback.
2326 */
@@ -30,11 +33,15 @@ export interface ThemeState {
3033 currTheme ?: ThemeType ;
3134}
3235
36+ const desktopBgDefaultConfig = {
37+ enableRender : true ,
38+ renderToScreen : true
39+ }
3340const themeCallback : ( theme ?: ThemeType ) => void = ( ) => { } ;
3441
3542export class Theme extends React . Component < ThemeProps , ThemeState > {
3643 static defaultProps : ThemeProps = {
37- enableDesktopBackground : true ,
44+ desktopBackgroundConfig : desktopBgDefaultConfig ,
3845 themeWillUpdate : themeCallback
3946 } ;
4047 static childContextTypes = {
@@ -149,32 +156,32 @@ export class Theme extends React.Component<ThemeProps, ThemeState> {
149156 }
150157
151158 render ( ) {
152- const {
159+ let {
153160 theme,
154- enableDesktopBackground ,
161+ desktopBackgroundConfig ,
155162 children,
156163 style,
157164 className,
158165 themeWillUpdate,
159166 ...attributes
160167 } = this . props ;
161168 const { currTheme } = this . state ;
169+ desktopBackgroundConfig = desktopBackgroundConfig || desktopBgDefaultConfig ;
170+ const { enableRender, renderToScreen } = desktopBackgroundConfig
162171
163172 const styles = getStyles ( this ) ;
164173 const classes = currTheme . prepareStyles ( {
165174 className : "theme" ,
166175 styles
167176 } ) ;
168177
169- // if (this.styleEl) {
170- // console.log("rule length: ", this.styleEl.sheet["rules"].length);
171- // }
172-
173178 return (
174179 < div { ...attributes } { ...classes . root } >
175180 < link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/react-uwp/1.1.0/css/segoe-mdl2-assets.css" />
176181 < style type = "text/css" scoped ref = { styleEl => this . styleEl = styleEl } />
177- { enableDesktopBackground && < RenderToBody { ...classes . desktopBackground } /> }
182+ { enableRender && (
183+ renderToScreen ? < RenderToBody { ...classes . desktopBackground } /> : < div { ...classes . desktopBackground } />
184+ ) }
178185 < RenderToBody >
179186 < ToastWrapper
180187 toastEls = { Array . from ( currTheme . toasts . keys ( ) ) . map ( toast => toast . virtualRender ( ) ) }
@@ -189,9 +196,15 @@ export class Theme extends React.Component<ThemeProps, ThemeState> {
189196
190197function getStyles ( context : Theme ) {
191198 const { currTheme } = context . state ;
192- const { style } = context . props ;
199+ let { style, desktopBackgroundConfig } = context . props ;
200+ desktopBackgroundConfig = desktopBackgroundConfig || desktopBgDefaultConfig ;
201+ const { enableRender, renderToScreen } = desktopBackgroundConfig
202+ const isInsideBg = enableRender && ! renderToScreen ;
203+
193204 return {
194205 root : {
206+ position : "relative" ,
207+ overflow : isInsideBg ? "hidden" : void 0 ,
195208 fontSize : 14 ,
196209 fontFamily : currTheme . fonts . sansSerifFonts ,
197210 color : currTheme . baseHigh ,
@@ -203,7 +216,7 @@ function getStyles(context: Theme) {
203216 ...style
204217 } as React . CSSProperties ,
205218 desktopBackground : {
206- position : "fixed" ,
219+ position : isInsideBg ? "absolute" : "fixed" ,
207220 zIndex : - 1 ,
208221 top : 0 ,
209222 left : 0 ,
0 commit comments