File tree Expand file tree Collapse file tree 4 files changed +21
-6
lines changed
classes/Visualizer/Gutenberg Expand file tree Collapse file tree 4 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ const {
18
18
TextControl
19
19
} = wp . components ;
20
20
21
+ import { getColorCode } from '../../utils.js' ;
22
+
21
23
class HorizontalAxisSettings extends Component {
22
24
constructor ( ) {
23
25
super ( ...arguments ) ;
@@ -87,7 +89,7 @@ class HorizontalAxisSettings extends Component {
87
89
< ColorPalette
88
90
value = { settings . vAxis . baselineColor }
89
91
onChange = { e => {
90
- settings . vAxis . baselineColor = e ;
92
+ settings . vAxis . baselineColor = getColorCode ( e ) ;
91
93
this . props . edit ( settings ) ;
92
94
} }
93
95
/>
@@ -100,7 +102,7 @@ class HorizontalAxisSettings extends Component {
100
102
value = { settings . hAxis . textStyle . color || settings . hAxis . textStyle }
101
103
onChange = { e => {
102
104
settings . hAxis . textStyle = { } ;
103
- settings . hAxis . textStyle . color = e ;
105
+ settings . hAxis . textStyle . color = getColorCode ( e ) ;
104
106
this . props . edit ( settings ) ;
105
107
} }
106
108
/>
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ const {
18
18
TextControl
19
19
} = wp . components ;
20
20
21
+ import { getColorCode } from '../../utils.js' ;
22
+
21
23
class VerticalAxisSettings extends Component {
22
24
constructor ( ) {
23
25
super ( ...arguments ) ;
@@ -87,7 +89,7 @@ class VerticalAxisSettings extends Component {
87
89
< ColorPalette
88
90
value = { settings . hAxis . baselineColor }
89
91
onChange = { e => {
90
- settings . hAxis . baselineColor = e ;
92
+ settings . hAxis . baselineColor = getColorCode ( e ) ;
91
93
this . props . edit ( settings ) ;
92
94
} }
93
95
/>
@@ -100,7 +102,7 @@ class VerticalAxisSettings extends Component {
100
102
value = { settings . vAxis . textStyle . color || settings . vAxis . textStyle }
101
103
onChange = { e => {
102
104
settings . vAxis . textStyle = { } ;
103
- settings . vAxis . textStyle . color = e ;
105
+ settings . vAxis . textStyle . color = getColorCode ( e ) ;
104
106
this . props . edit ( settings ) ;
105
107
} }
106
108
/>
Original file line number Diff line number Diff line change @@ -178,3 +178,14 @@ export const getFormatterForGoogle = ( dataType ) => {
178
178
}
179
179
return null ;
180
180
} ;
181
+
182
+ export const getColorCode = ( color ) => {
183
+ if ( - 1 === color . indexOf ( '#' ) ) {
184
+ let getCssVar = color . match ( / \( ( .* ) \) / ) . pop ( ) ;
185
+ if ( getCssVar ) {
186
+ let style = getComputedStyle ( document . body ) ;
187
+ return style . getPropertyValue ( getCssVar ) ;
188
+ }
189
+ }
190
+ return color ;
191
+ } ;
You can’t perform that action at this time.
0 commit comments