@@ -11,6 +11,74 @@ export default class App extends Component {
11
11
store : this . props . store
12
12
} ;
13
13
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
+
14
82
onSave = ( ) => {
15
83
const { store, notify } = this . props ;
16
84
store . persist ( ) ;
@@ -19,7 +87,6 @@ export default class App extends Component {
19
87
store . toggleFooterShowing ( true ) ;
20
88
} ;
21
89
22
-
23
90
updateState = ( store ) => {
24
91
this . setState ( { store } ) ;
25
92
} ;
@@ -29,8 +96,24 @@ export default class App extends Component {
29
96
store . subscribe ( this . updateState ) ;
30
97
}
31
98
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
+ }
33
111
112
+ store . subscribe ( this . updateCSSPrefs ) ;
113
+ this . updateCSSPrefs ( ) ;
114
+ }
115
+
116
+ render ( props , state ) {
34
117
const { store } = state ;
35
118
const { config } = props ;
36
119
const userLocalization = config . localization [ currentLocale ] ;
@@ -41,15 +124,21 @@ export default class App extends Component {
41
124
store = { store }
42
125
localization = { userLocalization }
43
126
onSave = { this . onSave }
127
+ config = { config }
128
+ updateCSSPrefs = { this . updateCSSPrefs }
44
129
/>
45
130
< PopupFooter
46
131
store = { store }
47
132
localization = { userLocalization }
48
133
onSave = { this . onSave }
134
+ config = { config }
135
+ updateCSSPrefs = { this . updateCSSPrefs }
49
136
/>
50
137
< Footer
51
138
store = { store }
52
139
localization = { userLocalization }
140
+ config = { config }
141
+ updateCSSPrefs = { this . updateCSSPrefs }
53
142
/>
54
143
</ div >
55
144
) ;
0 commit comments