@@ -293,26 +293,64 @@ class WorkspaceV2SessionProducer {
293293 }
294294
295295 registerScrollTextColorRule ( ) {
296- const updateColors = ( ) => {
297- const scrollHeight = document . documentElement . scrollHeight - window . innerHeight ;
298- const scrolledPercent = scrollHeight > 0 ? ( window . scrollY / scrollHeight ) * 100 : 0 ;
299- const nextColor = scrolledPercent >= 50 ? "#ffffff" : "#000000" ;
300- const textNodes = document . querySelectorAll (
301- "h1, h2, h3, h4, h5, h6, p, span, div, label, li, strong, code, pre, button, a, small, legend, input, select, option, textarea"
296+ let textLightActive = false ;
297+ let scheduled = false ;
298+ const activateAt = 52 ;
299+ const deactivateAt = 48 ;
300+ const applyColors = ( ) => {
301+ document . body . classList . toggle ( "text-light" , textLightActive ) ;
302+ const textColor = textLightActive ? "#ffffff" : "#000000" ;
303+ document . body . style . transition = "color 180ms ease" ;
304+ document . body . style . color = textColor ;
305+ const contentTextNodes = document . querySelectorAll (
306+ "main h1, main h2, main h3, main h4, main h5, main h6, main p, main span, main div, main li, main strong, main code, main pre, main a, main small, section h1, section h2, section h3, section h4, section h5, section h6, section p, section span, section div, section li, section strong, section code, section pre, section a, section small, article h1, article h2, article h3, article h4, article h5, article h6, article p, article span, article div, article li, article strong, article code, article pre, article a, article small, .hub-panel h1, .hub-panel h2, .hub-panel h3, .hub-panel h4, .hub-panel h5, .hub-panel h6, .hub-panel p, .hub-panel span, .hub-panel div, .hub-panel li, .hub-panel strong, .hub-panel code, .hub-panel pre, .hub-panel a, .hub-panel small"
302307 ) ;
303- textNodes . forEach ( ( node ) => {
308+ contentTextNodes . forEach ( ( node ) => {
304309 if (
305310 node instanceof HTMLElement &&
311+ ! node . closest ( "button, input, select, textarea, label, option" ) &&
306312 window . getComputedStyle ( node ) . display !== "none" &&
307313 window . getComputedStyle ( node ) . visibility !== "hidden"
308314 ) {
309- node . style . color = nextColor ;
315+ node . style . transition = "color 180ms ease" ;
316+ node . style . color = textColor ;
317+ }
318+ } ) ;
319+ const controls = document . querySelectorAll ( "button, input, select, textarea, label, option" ) ;
320+ controls . forEach ( ( control ) => {
321+ if ( control instanceof HTMLElement ) {
322+ control . style . setProperty ( "color" , "#000000" , "important" ) ;
323+ control . style . transition = "color 180ms ease" ;
310324 }
311325 } ) ;
312326 } ;
313- window . addEventListener ( "scroll" , updateColors , { passive : true } ) ;
314- window . addEventListener ( "resize" , updateColors ) ;
315- updateColors ( ) ;
327+ const updateColors = ( ) => {
328+ scheduled = false ;
329+ const scrollHeight = document . documentElement . scrollHeight - window . innerHeight ;
330+ const scrolledPercent = scrollHeight > 0 ? ( window . scrollY / scrollHeight ) * 100 : 0 ;
331+ if ( textLightActive ) {
332+ if ( scrolledPercent <= deactivateAt ) {
333+ textLightActive = false ;
334+ }
335+ } else if ( scrolledPercent >= activateAt ) {
336+ textLightActive = true ;
337+ }
338+ applyColors ( ) ;
339+ } ;
340+ const scheduleUpdate = ( ) => {
341+ if ( scheduled ) {
342+ return ;
343+ }
344+ scheduled = true ;
345+ window . requestAnimationFrame ( updateColors ) ;
346+ } ;
347+ window . addEventListener ( "scroll" , scheduleUpdate , { passive : true } ) ;
348+ window . addEventListener ( "resize" , scheduleUpdate ) ;
349+ const observer = new MutationObserver ( ( ) => {
350+ scheduleUpdate ( ) ;
351+ } ) ;
352+ observer . observe ( document . body , { childList : true , subtree : true } ) ;
353+ scheduleUpdate ( ) ;
316354 }
317355
318356 isPaletteManagerToolId ( toolId ) {
0 commit comments