@@ -17,6 +17,12 @@ export interface ITabPaneState {
17
17
selectedTabIndex : number ;
18
18
}
19
19
20
+ const TAB_STYLE : React . CSSProperties = {
21
+ padding : '8px' ,
22
+ marginLeft : '1px' ,
23
+ marginRight : '1px'
24
+ } ;
25
+
20
26
export class TabPane extends React . Component < ITabPaneProps , ITabPaneState > {
21
27
// Saved bindings of _onClickTab() with a tabIndex parameter, to avoid the react/jsx-no-bind issue
22
28
private _onClickTabBindings : React . MouseEventHandler < HTMLAnchorElement > [ ] = [ ] ;
@@ -38,49 +44,39 @@ export class TabPane extends React.Component<ITabPaneProps, ITabPaneState> {
38
44
for ( let i : number = 0 ; i < this . props . tabs . length ; ++ i ) {
39
45
const tabDefinition : ITabDefinition = this . props . tabs [ i ] ;
40
46
41
- const style : React . CSSProperties = {
42
- padding : '8px' ,
43
- marginLeft : '1px' ,
44
- marginRight : '1px'
45
- } ;
46
-
47
+ let tabStyleToUse : React . CSSProperties ;
47
48
if ( i === this . state . selectedTabIndex ) {
48
49
selectedTabDefinition = tabDefinition ;
49
50
50
- const activeTabStyle : React . CSSProperties = {
51
- ...style ,
51
+ tabStyleToUse = {
52
+ ...TAB_STYLE ,
52
53
borderStyle : 'solid' ,
53
54
borderWidth : '2px' ,
54
55
borderColor : '#c0c0c0' ,
55
56
borderBottomStyle : 'none' ,
56
57
borderTopLeftRadius : '4px' ,
57
58
borderTopRightRadius : '4px'
58
59
} ;
59
-
60
- buttons . push (
61
- < div key = { `tab_${ i } ` } className = "playground-tab-pane-active-tab" style = { activeTabStyle } role = "tab" >
62
- { tabDefinition . title }
63
- </ div >
64
- ) ;
65
60
} else {
66
- if ( ! this . _onClickTabBindings [ i ] ) {
67
- // Bind _onClickTab() with i as the tabIndex parameter
68
- this . _onClickTabBindings [ i ] = this . _onClickTab . bind ( this , i ) ;
69
- }
70
-
71
- buttons . push (
72
- < div key = { `tab_${ i } ` } className = "playground-tab-pane-inactive-tab" style = { style } >
73
- < a
74
- href = "#"
75
- style = { { textDecorationLine : 'none' , color : '#000000' } }
76
- onClick = { this . _onClickTabBindings [ i ] }
77
- role = "tab"
78
- >
79
- { tabDefinition . title }
80
- </ a >
81
- </ div >
82
- ) ;
61
+ tabStyleToUse = TAB_STYLE ;
83
62
}
63
+
64
+ if ( ! this . _onClickTabBindings [ i ] ) {
65
+ // Bind _onClickTab() with i as the tabIndex parameter
66
+ this . _onClickTabBindings [ i ] = this . _onClickTab . bind ( this , i ) ;
67
+ }
68
+ buttons . push (
69
+ < div key = { `tab_${ i } ` } className = "playground-tab-pane-inactive-tab" style = { tabStyleToUse } >
70
+ < a
71
+ href = "#"
72
+ style = { { textDecorationLine : 'none' , color : '#000000' } }
73
+ onClick = { this . _onClickTabBindings [ i ] }
74
+ role = "tab"
75
+ >
76
+ { tabDefinition . title }
77
+ </ a >
78
+ </ div >
79
+ ) ;
84
80
}
85
81
86
82
const contentDivStyle : React . CSSProperties = {
0 commit comments