@@ -9,8 +9,8 @@ const StyledHeader = styled.div(({ height, styles }) => [
99 {
1010 display : 'block' ,
1111 width : '100%' ,
12- height
13- }
12+ height,
13+ } ,
1414] ) ;
1515
1616const StyledSpan = styled . span ( ( { scale, lineHeight, styles } ) => [
@@ -21,31 +21,34 @@ const StyledSpan = styled.span(({ scale, lineHeight, styles }) => [
2121 padding : '0' ,
2222 lineHeight,
2323 transform : `scale(${ scale } )` ,
24- transformOrigin : 'center top'
24+ transformOrigin : 'center top' ,
2525 } ,
2626 styles . typeface ,
27- styles . user
27+ styles . user ,
2828] ) ;
2929
3030const dynamicHeaderStyles = ( { lineHeight, styles } ) => [
3131 styles . context ,
3232 styles . base ,
3333 { lineHeight } ,
3434 styles . typeface ,
35- styles . user
35+ styles . user ,
3636] ;
37- const dynamicStyledHeaders = [ 'h1' , 'h2' , 'h3' , 'h4' , 'h5' , 'h6' ]
38- . reduce ( ( memo , tag ) => ( {
39- ...memo , [ tag ] : styled ( tag ) ( dynamicHeaderStyles )
40- } ) , { } ) ;
37+ const dynamicStyledHeaders = [ 'h1' , 'h2' , 'h3' , 'h4' , 'h5' , 'h6' ] . reduce (
38+ ( memo , tag ) => ( {
39+ ...memo ,
40+ [ tag ] : styled ( tag ) ( dynamicHeaderStyles ) ,
41+ } ) ,
42+ { }
43+ ) ;
4144
4245export default class Heading extends Component {
4346 constructor ( ) {
4447 super ( ) ;
4548 this . resize = this . resize . bind ( this ) ;
4649 this . state = {
4750 scale : 1 ,
48- height : 16
51+ height : 16 ,
4952 } ;
5053 }
5154 componentDidMount ( ) {
@@ -65,12 +68,12 @@ export default class Heading extends Component {
6568 const text = this . textRef ;
6669 const container = this . containerRef ;
6770 text . style . display = 'inline-block' ;
68- const scale = ( container . offsetWidth / text . offsetWidth ) ;
69- const height = ( text . offsetHeight * scale ) || 0 ;
71+ const scale = container . offsetWidth / text . offsetWidth ;
72+ const height = text . offsetHeight * scale || 0 ;
7073 text . style . display = 'block' ;
7174 this . setState ( {
7275 scale,
73- height
76+ height,
7477 } ) ;
7578 }
7679 }
@@ -83,15 +86,19 @@ export default class Heading extends Component {
8386 return (
8487 < StyledHeader
8588 className = { this . props . className }
86- innerRef = { ( c ) => { this . containerRef = c ; } }
89+ innerRef = { c => {
90+ this . containerRef = c ;
91+ } }
8792 height = { this . state . height }
8893 styles = { {
8994 context : this . context . styles . components . heading [ `h${ size } ` ] ,
90- base : getStyles . call ( this )
95+ base : getStyles . call ( this ) ,
9196 } }
9297 >
9398 < StyledSpan
94- innerRef = { ( t ) => { this . textRef = t ; } }
99+ innerRef = { t => {
100+ this . textRef = t ;
101+ } }
95102 scale = { this . state . scale }
96103 lineHeight = { lineHeight }
97104 styles = { { user : style , typeface : typefaceStyle } }
@@ -102,22 +109,26 @@ export default class Heading extends Component {
102109 ) ;
103110 }
104111
105- return createElement ( dynamicStyledHeaders [ Tag ] , {
106- className : this . props . className ,
107- lineHeight,
108- styles : {
109- context : this . context . styles . components . heading [ `h${ size } ` ] ,
110- base : getStyles . call ( this ) ,
111- user : style ,
112- typeface : typefaceStyle
113- }
114- } , children ) ;
112+ return createElement (
113+ dynamicStyledHeaders [ Tag ] ,
114+ {
115+ className : this . props . className ,
116+ lineHeight,
117+ styles : {
118+ context : this . context . styles . components . heading [ `h${ size } ` ] ,
119+ base : getStyles . call ( this ) ,
120+ user : style ,
121+ typeface : typefaceStyle ,
122+ } ,
123+ } ,
124+ children
125+ ) ;
115126 }
116127}
117128
118129Heading . defaultProps = {
119130 size : 1 ,
120- lineHeight : 1
131+ lineHeight : 1 ,
121132} ;
122133
123134Heading . propTypes = {
@@ -126,11 +137,11 @@ Heading.propTypes = {
126137 fit : PropTypes . bool ,
127138 lineHeight : PropTypes . number ,
128139 size : PropTypes . number ,
129- style : PropTypes . object
140+ style : PropTypes . object ,
130141} ;
131142
132143Heading . contextTypes = {
133144 styles : PropTypes . object ,
134145 store : PropTypes . object ,
135- typeface : PropTypes . object
146+ typeface : PropTypes . object ,
136147} ;
0 commit comments