@@ -10,7 +10,7 @@ import merge from 'lodash/merge'
10
10
import get from 'lodash/get'
11
11
import set from 'lodash/set'
12
12
13
- const textProps = [
13
+ const textPropsWithInheritance = [
14
14
'axis.ticks.text' ,
15
15
'axis.legend.text' ,
16
16
'legends.title.text' ,
@@ -23,6 +23,16 @@ const textProps = [
23
23
'annotations.text' ,
24
24
]
25
25
26
+ /**
27
+ * @param {Partial<TextStyle> } partialStyle
28
+ * @param {TextStyle } rootStyle
29
+ * @returns {TextStyle }
30
+ */
31
+ export const inheritRootThemeText = ( partialStyle , rootStyle ) => ( {
32
+ ...rootStyle ,
33
+ ...partialStyle ,
34
+ } )
35
+
26
36
/**
27
37
* @param {ThemeWithoutInheritance } defaultTheme
28
38
* @param {Theme } customTheme
@@ -31,22 +41,8 @@ const textProps = [
31
41
export const extendDefaultTheme = ( defaultTheme , customTheme ) => {
32
42
const theme = merge ( { } , defaultTheme , customTheme )
33
43
34
- textProps . forEach ( prop => {
35
- if ( get ( theme , `${ prop } .fontFamily` ) === undefined ) {
36
- set ( theme , `${ prop } .fontFamily` , theme . text . fontFamily )
37
- }
38
- if ( get ( theme , `${ prop } .fontSize` ) === undefined ) {
39
- set ( theme , `${ prop } .fontSize` , theme . text . fontSize )
40
- }
41
- if ( get ( theme , `${ prop } .fill` ) === undefined ) {
42
- set ( theme , `${ prop } .fill` , theme . text . fill )
43
- }
44
- if ( get ( theme , `${ prop } .outlineWidth` ) === undefined ) {
45
- set ( theme , `${ prop } .outlineWidth` , theme . text . outlineWidth )
46
- }
47
- if ( get ( theme , `${ prop } .outlineColor` ) === undefined ) {
48
- set ( theme , `${ prop } .outlineColor` , theme . text . outlineColor )
49
- }
44
+ textPropsWithInheritance . forEach ( prop => {
45
+ set ( theme , prop , inheritRootThemeText ( get ( theme , prop ) , theme . text ) )
50
46
} )
51
47
52
48
return theme
0 commit comments