@@ -17,6 +17,12 @@ export interface ITabPaneState {
1717 selectedTabIndex : number ;
1818}
1919
20+ const TAB_STYLE : React . CSSProperties = {
21+ padding : '8px' ,
22+ marginLeft : '1px' ,
23+ marginRight : '1px'
24+ } ;
25+
2026export class TabPane extends React . Component < ITabPaneProps , ITabPaneState > {
2127 // Saved bindings of _onClickTab() with a tabIndex parameter, to avoid the react/jsx-no-bind issue
2228 private _onClickTabBindings : React . MouseEventHandler < HTMLAnchorElement > [ ] = [ ] ;
@@ -38,49 +44,42 @@ export class TabPane extends React.Component<ITabPaneProps, ITabPaneState> {
3844 for ( let i : number = 0 ; i < this . props . tabs . length ; ++ i ) {
3945 const tabDefinition : ITabDefinition = this . props . tabs [ i ] ;
4046
41- const style : React . CSSProperties = {
42- padding : '8px' ,
43- marginLeft : '1px' ,
44- marginRight : '1px'
45- } ;
46-
47+ let ariaSelected : boolean = false ;
48+ let tabStyleToUse : React . CSSProperties ;
4749 if ( i === this . state . selectedTabIndex ) {
4850 selectedTabDefinition = tabDefinition ;
51+ ariaSelected = true ;
4952
50- const activeTabStyle : React . CSSProperties = {
51- ...style ,
53+ tabStyleToUse = {
54+ ...TAB_STYLE ,
5255 borderStyle : 'solid' ,
5356 borderWidth : '2px' ,
5457 borderColor : '#c0c0c0' ,
5558 borderBottomStyle : 'none' ,
5659 borderTopLeftRadius : '4px' ,
5760 borderTopRightRadius : '4px'
5861 } ;
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- ) ;
6562 } 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- ) ;
63+ tabStyleToUse = TAB_STYLE ;
8364 }
65+
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+ buttons . push (
71+ < div key = { `tab_${ i } ` } className = "playground-tab-pane-inactive-tab" style = { tabStyleToUse } >
72+ < a
73+ href = "#"
74+ style = { { textDecorationLine : 'none' , color : '#000000' } }
75+ onClick = { this . _onClickTabBindings [ i ] }
76+ role = "tab"
77+ aria-selected = { ariaSelected }
78+ >
79+ { tabDefinition . title }
80+ </ a >
81+ </ div >
82+ ) ;
8483 }
8584
8685 const contentDivStyle : React . CSSProperties = {
0 commit comments