@@ -11,6 +11,74 @@ export default class App extends Component {
1111 store : this . props . store
1212 } ;
1313
14+ elementsWithReplaceableCss = {
15+ // Tables
16+ "thead tr" : { "background-color" : this . props . config . css [ "color-table-background" ] } ,
17+ "tr[class*=even]" : { "background-color" : this . props . config . css [ "color-table-background" ] } ,
18+
19+ // Purposes
20+ "div[class*=purposes_purposeItem]" : {
21+ "background-color" : this . props . config . css [ "color-secondary" ] ,
22+ "color" : this . props . config . css [ "color-text-secondary" ]
23+ } ,
24+ "div[class*=selectedPurpose]" : {
25+ "background-color" : this . props . config . css [ "color-primary" ] ,
26+ "color" : this . props . config . css [ "color-background" ] ,
27+ } ,
28+
29+ // Footer
30+ "div[class*=footer_footer]" : {
31+ "border-top" : "3px solid " + this . props . config . css [ "color-border" ] ,
32+ "background-color" : this . props . config . css [ "color-background" ]
33+ } ,
34+ "div[class*=footerV2_extended]" : { "border-top" : "3px solid " + this . props . config . css [ "color-border" ] } ,
35+ "div[class*=footerV2_container]" : { "background-color" : this . props . config . css [ "color-background" ] } ,
36+ "svg" : {
37+ "background-color" : this . props . config . css [ "color-background" ] ,
38+ "fill" : this . props . config . css [ "color-primary" ]
39+ } ,
40+
41+ // Vendors
42+ "[class*=active]" : { "color" : this . props . config . css [ "color-primary" ] } ,
43+
44+ // Application wide
45+ "div[name^=content]" : {
46+ "box-shadow" : "0 0 0 3px " + this . props . config . css [ "color-border" ] ,
47+ "background-color" : this . props . config . css [ "color-background" ]
48+ } ,
49+ ":not([name*=ctrl])" : {
50+ "font-family" : this . props . config . css [ "font-family" ]
51+ } ,
52+ "[class*=primaryText]" : { "color" : this . props . config . css [ "color-text-primary" ] } ,
53+ "[class*=secondaryText]" : { "color" : this . props . config . css [ "color-text-secondary" ] } ,
54+ "a" : { "color" : this . props . config . css [ "color-linkColor" ] } ,
55+ "span[class*=isSelected] [class*=visualizationGlow]" : { "background-color" : this . props . config . css [ "color-primary" ] } ,
56+ "span[class*=isSelected] [class*=visualizationContainer]" : { "background-color" : this . props . config . css [ "color-primary" ] } ,
57+ "[class*=button]" : {
58+ "color" : this . props . config . css [ "color-background" ] ,
59+ "background-color" : this . props . config . css [ "color-primary" ] ,
60+ } ,
61+ "[class*=button_invert]" : {
62+ "color" : this . props . config . css [ "color-primary" ] ,
63+ "border" : "2px solid " + this . props . config . css [ "color-primary" ] ,
64+ "background-color" : this . props . config . css [ "color-background" ]
65+ } ,
66+ } ;
67+
68+ updateCSSPrefs = ( ) => {
69+ const elems = this . elementsWithReplaceableCss ;
70+ const base = this . base ;
71+ for ( let elem in elems ) {
72+ let cssRules = elems [ elem ] ;
73+ let selectedEls = base . querySelectorAll ( elem ) || [ ] ;
74+ selectedEls . forEach ( function ( currentEl ) {
75+ for ( let cssProp in cssRules ) {
76+ currentEl . style [ cssProp ] = cssRules [ cssProp ] ;
77+ }
78+ } )
79+ }
80+ } ;
81+
1482 onSave = ( ) => {
1583 const { store, notify } = this . props ;
1684 store . persist ( ) ;
@@ -19,7 +87,6 @@ export default class App extends Component {
1987 store . toggleFooterShowing ( true ) ;
2088 } ;
2189
22-
2390 updateState = ( store ) => {
2491 this . setState ( { store } ) ;
2592 } ;
@@ -29,8 +96,24 @@ export default class App extends Component {
2996 store . subscribe ( this . updateState ) ;
3097 }
3198
32- render ( props , state ) {
99+ componentDidMount ( ) {
100+ const { store } = this . state ;
101+ const { config } = this . props ;
102+
103+ if ( config . css [ "custom-font-url" ] ) {
104+ let head = document . head ;
105+ let link = document . createElement ( "link" ) ;
106+ link . type = "text/css" ;
107+ link . rel = "stylesheet" ;
108+ link . href = config . css [ "custom-font-url" ] ;
109+ head . appendChild ( link ) ;
110+ }
33111
112+ store . subscribe ( this . updateCSSPrefs ) ;
113+ this . updateCSSPrefs ( ) ;
114+ }
115+
116+ render ( props , state ) {
34117 const { store } = state ;
35118 const { config } = props ;
36119 const userLocalization = config . localization [ currentLocale ] ;
@@ -41,15 +124,21 @@ export default class App extends Component {
41124 store = { store }
42125 localization = { userLocalization }
43126 onSave = { this . onSave }
127+ config = { config }
128+ updateCSSPrefs = { this . updateCSSPrefs }
44129 />
45130 < PopupFooter
46131 store = { store }
47132 localization = { userLocalization }
48133 onSave = { this . onSave }
134+ config = { config }
135+ updateCSSPrefs = { this . updateCSSPrefs }
49136 />
50137 < Footer
51138 store = { store }
52139 localization = { userLocalization }
140+ config = { config }
141+ updateCSSPrefs = { this . updateCSSPrefs }
53142 />
54143 </ div >
55144 ) ;
0 commit comments