1
1
import { css } from '@emotion/core' ;
2
2
import vars from '../../../../materials/custom-properties' ;
3
3
4
- const baseStyles = `
5
- font-family: ${ vars . fontFamilyDefault } ;
6
- color: ${ vars . colorSolid } ;
4
+ const getBaseStyles = ( props , theme ) => {
5
+ const overwrittenVars = {
6
+ ...vars ,
7
+ ...theme ,
8
+ } ;
9
+
10
+ return `
11
+ font-family: ${ vars . fontFamilyDefault } ;
12
+ color: ${ overwrittenVars . colorSolid } ;
7
13
` ;
14
+ } ;
8
15
9
16
const truncate = `
10
17
white-space: nowrap;
@@ -24,22 +31,26 @@ const inline = `
24
31
display: inline-block;
25
32
` ;
26
33
27
- const getTone = tone => {
34
+ const getTone = ( tone , theme ) => {
35
+ const overwrittenVars = {
36
+ ...vars ,
37
+ ...theme ,
38
+ } ;
28
39
switch ( tone ) {
29
40
case 'information' :
30
- return `color: ${ vars . colorInfo } ;` ;
41
+ return `color: ${ overwrittenVars . colorInfo } ;` ;
31
42
case 'secondary' :
32
- return `color: ${ vars . colorNeutral60 } ;` ;
43
+ return `color: ${ overwrittenVars . colorNeutral60 } ;` ;
33
44
case 'positive' :
34
- return `color: ${ vars . colorPrimary25 } ;` ;
45
+ return `color: ${ overwrittenVars . colorPrimary25 } ;` ;
35
46
case 'primary' :
36
- return `color: ${ vars . colorPrimary } ;` ;
47
+ return `color: ${ overwrittenVars . colorPrimary } ;` ;
37
48
case 'negative' :
38
- return `color: ${ vars . colorError } ;` ;
49
+ return `color: ${ overwrittenVars . colorError } ;` ;
39
50
case 'inverted' :
40
- return `color: ${ vars . colorSurface } ;` ;
51
+ return `color: ${ overwrittenVars . colorSurface } ;` ;
41
52
case 'warning' :
42
- return `color: ${ vars . colorWarning } ;` ;
53
+ return `color: ${ overwrittenVars . colorWarning } ;` ;
43
54
default :
44
55
return `` ;
45
56
}
@@ -62,47 +73,47 @@ const getElementFontSize = elementType => {
62
73
}
63
74
} ;
64
75
65
- export const bodyStyles = props => css `
66
- ${ baseStyles }
76
+ export const bodyStyles = ( props , theme ) => css `
77
+ ${ getBaseStyles ( props , theme ) }
67
78
margin : 0 ;
68
79
font-size : 1rem ;
69
80
${ props . isBold && bold }
70
81
${ props . isItalic && italic }
71
- ${ props . tone && getTone ( props . tone ) }
82
+ ${ props . tone && getTone ( props . tone , theme ) }
72
83
${ props . truncate && truncate }
73
84
` ;
74
85
75
- export const headlineStyles = props => css `
76
- ${ baseStyles }
86
+ export const headlineStyles = ( props , theme ) => css `
87
+ ${ getBaseStyles ( props , theme ) }
77
88
margin : 0 ;
78
89
font-size : ${ getElementFontSize ( props . elementType ) } ;
79
90
font-weight : 300 ;
80
91
${ props . truncate && truncate }
81
92
` ;
82
93
83
- export const subheadlineStyles = props => css `
84
- ${ baseStyles }
94
+ export const subheadlineStyles = ( props , theme ) => css `
95
+ ${ getBaseStyles ( props , theme ) }
85
96
margin : 0 ;
86
97
font-size : ${ getElementFontSize ( props . elementType ) } ;
87
98
font-weight : normal;
88
99
${ props . truncate && truncate }
89
100
${ props . isBold && bold }
90
- ${ props . tone && getTone ( props . tone ) }
101
+ ${ props . tone && getTone ( props . tone , theme ) }
91
102
` ;
92
103
93
- export const wrapStyles = ( ) => css `
94
- ${ baseStyles }
104
+ export const wrapStyles = ( props , theme ) => css `
105
+ ${ getBaseStyles ( props , theme ) }
95
106
font-size : 1rem ;
96
107
white-space : pre-wrap;
97
108
` ;
98
109
99
- export const detailStyles = props => css `
100
- ${ baseStyles }
110
+ export const detailStyles = ( props , theme ) => css `
111
+ ${ getBaseStyles ( props , theme ) }
101
112
display : block;
102
113
font-size : 0.9231rem ;
103
114
${ props . isInline && inline }
104
115
${ props . isBold && bold }
105
116
${ props . isItalic && italic }
106
- ${ props . tone && getTone ( props . tone ) }
117
+ ${ props . tone && getTone ( props . tone , theme ) }
107
118
${ props . truncate && truncate }
108
119
` ;
0 commit comments