@@ -47,12 +47,13 @@ const createDataThemeDiv = (elementType, theme) => {
4747 document . body . appendChild ( element )
4848 return element
4949}
50- const generateCSSVarTokens = ( ) => {
50+
51+ const generateCSSVarTokens = ( isSettingIframe = false ) => {
5152 /* NC versus COOL */
5253 const cssVarMap = {
53- '--color-primary-element-text' : '--co-primary-text' ,
54- '--color-primary-element' : '--co-primary-element:--co-text-accent' ,
55- '--color-primary-element-light' : '--co-primary-light:--co-primary-element-light' ,
54+ '--color-primary-element-text' : '--co-primary-text:--co-settings-btn-primary-text ' ,
55+ '--color-primary-element' : '--co-primary-element:--co-text-accent:--co-settings-btn-primary ' ,
56+ '--color-primary-element-light' : '--co-primary-light:--co-primary-element-light:--co-settings-btn-light ' ,
5657 '--color-error' : '--co-color-error' ,
5758 '--color-warning' : '--co-color-warning' ,
5859 '--color-success' : '--co-color-success' ,
@@ -61,18 +62,31 @@ const generateCSSVarTokens = () => {
6162 '--color-loading-light' : '--co-loading-light' ,
6263 '--color-loading-dark' : '--co-loading-dark' ,
6364 '--color-box-shadow' : '--co-box-shadow' ,
64- '--color-border' : '--co-border' ,
65- '--color-border-dark' : '--co-border-dark' ,
65+ '--color-border' : '--co-border:--co-settings-border ' ,
66+ '--color-border-dark' : '--co-border-dark:--co--settings-border-contrast ' ,
6667 '--border-radius-pill' : '--co-border-radius-pill' ,
68+ '--color-primary-element-light-text' : '--co-settings-btn-light-text' ,
69+ '--color-main-text' : '--co-settings-text' ,
70+ '--color-text-maxcontrast' : '--co-settings-text-maxcontrast' ,
71+ '--color-main-background' : '--co-settings-background' ,
72+ '--color-background-hover' : '--co-settings-background-hover' ,
6773 }
6874 let str = ''
6975 const lightElement = createDataThemeDiv ( 'div' , 'light' )
76+ const darkElement = createDataThemeDiv ( 'div' , 'dark' )
77+ let selectedElement = lightElement
78+
79+ // Note: To style the iframe properly, we send appropriate CSS variables based on the current theme.
80+ // For example, if the current theme is dark, we send values corresponding to the dark theme.
81+ if ( isSettingIframe ) {
82+ selectedElement = getUITheme ( ) === 'dark' ? darkElement : lightElement
83+ }
7084 try {
7185 for ( const cssVarKey in cssVarMap ) {
72- let cStyle = window . getComputedStyle ( lightElement ) . getPropertyValue ( cssVarKey )
86+ let cStyle = window . getComputedStyle ( selectedElement ) . getPropertyValue ( cssVarKey )
7387 if ( ! cStyle ) {
7488 // try suffix -dark instead
75- cStyle = window . getComputedStyle ( lightElement ) . getPropertyValue ( cssVarKey + '-dark' )
89+ cStyle = window . getComputedStyle ( selectedElement ) . getPropertyValue ( cssVarKey + '-dark' )
7690 }
7791 if ( ! cStyle ) continue // skip if it is not set
7892 const varNames = cssVarMap [ cssVarKey ] . split ( ':' )
@@ -84,8 +98,11 @@ const generateCSSVarTokens = () => {
8498 // Skip extracting css vars if we cannot access parent
8599 }
86100
87- // New dark mode compatible way to hand over our Nextcloud variables in both light/dark to Collabora
88- const darkElement = createDataThemeDiv ( 'div' , 'dark' )
101+ if ( isSettingIframe ) {
102+ lightElement . remove ( )
103+ darkElement . remove ( )
104+ return str . replace ( / [ " ' ] / g, '\\\'' )
105+ }
89106
90107 const handover = [
91108 '--color-main-background' ,
0 commit comments