mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 04:14:21 +08:00
tabs aria
This commit is contained in:
@ -9,6 +9,7 @@ import {
|
|||||||
import {NavViewport} from 'ionic2/components/nav-viewport/nav-viewport'
|
import {NavViewport} from 'ionic2/components/nav-viewport/nav-viewport'
|
||||||
import {NavPane} from 'ionic2/components/nav-pane/nav-pane'
|
import {NavPane} from 'ionic2/components/nav-pane/nav-pane'
|
||||||
import {Tabs} from 'ionic2/components/tabs/tabs'
|
import {Tabs} from 'ionic2/components/tabs/tabs'
|
||||||
|
import * as util from 'ionic2/util'
|
||||||
import {IonicComponent} from 'ionic2/config/component'
|
import {IonicComponent} from 'ionic2/config/component'
|
||||||
|
|
||||||
|
|
||||||
@ -33,12 +34,20 @@ export class Tab extends NavViewport {
|
|||||||
constructor(
|
constructor(
|
||||||
element: NgElement,
|
element: NgElement,
|
||||||
@Ancestor() tabs: Tabs,
|
@Ancestor() tabs: Tabs,
|
||||||
@PropertySetter('class.hide') setHidden: Function
|
@PropertySetter('class.hide') setHidden: Function,
|
||||||
|
@PropertySetter('attr.role') setRole: Function,
|
||||||
|
@PropertySetter('attr.id') setId: Function,
|
||||||
|
@PropertySetter('attr.aria-labelledby') setLabelby: Function
|
||||||
) {
|
) {
|
||||||
super(element)
|
super(element)
|
||||||
this.config = Tab.config.invoke(this)
|
this.config = Tab.config.invoke(this)
|
||||||
this.setHidden = setHidden
|
this.setHidden = setHidden
|
||||||
|
|
||||||
|
this.tabId = util.uid()
|
||||||
|
setId('tab-content-' + this.tabId)
|
||||||
|
setLabelby('tab-item-' + this.tabId)
|
||||||
|
setRole('tabpanel')
|
||||||
|
|
||||||
this.setSelected(false)
|
this.setSelected(false)
|
||||||
tabs.addTab(this)
|
tabs.addTab(this)
|
||||||
}
|
}
|
||||||
|
@ -16,18 +16,23 @@ import {IonicComponent} from 'ionic2/config/component'
|
|||||||
<!-- TOOLBARS FOR EACH VIEW SHOULD HAVE THE SAME CONTEXT AS ITS VIEW -->
|
<!-- TOOLBARS FOR EACH VIEW SHOULD HAVE THE SAME CONTEXT AS ITS VIEW -->
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<nav class="tab-bar-container">
|
<nav class="tab-bar-container"
|
||||||
|
role="tablist"
|
||||||
|
[attr.aria-activedescendant]="'tab-content-' + selectedTab.tabId">
|
||||||
<div class="tab-bar">
|
<div class="tab-bar">
|
||||||
<a *for="#tab of tabs"
|
<button *for="#tab of tabs"
|
||||||
|
role="tab"
|
||||||
class="tab-bar-item"
|
class="tab-bar-item"
|
||||||
[class.tab-active]="tab.isSelected"
|
[attr.id]="'tab-item-' + tab.tabId"
|
||||||
|
[attr.aria-controls]="'tab-content-' + tab.tabId"
|
||||||
|
[attr.aria-selected]="tab.isSelected"
|
||||||
(^click)="onClickTabItem($event, tab)">
|
(^click)="onClickTabItem($event, tab)">
|
||||||
<icon class="tab-bar-item-icon ion-home"
|
<icon class="tab-bar-item-icon ion-home"
|
||||||
[hidden]="tabBarIcons=='none'"
|
[hidden]="tabBarIcons=='none'"
|
||||||
[class.tab-bar-icon-bottom]="tabBarIcons=='bottom'"
|
[class.tab-bar-icon-bottom]="tabBarIcons=='bottom'"
|
||||||
[class.tab-bar-icon-top]="tabBarIcons=='top'"></icon>
|
[class.tab-bar-icon-top]="tabBarIcons=='top'"></icon>
|
||||||
<span class="tab-bar-item-text" [hidden]="tabBarText=='none'">{{tab.title}}</span>
|
<span class="tab-bar-item-text" [hidden]="tabBarText=='none'">{{tab.title}}</span>
|
||||||
</a>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ $tab-bar-item-max-width: 160px !default;
|
|||||||
@include flex-direction(column);
|
@include flex-direction(column);
|
||||||
@include flex(1);
|
@include flex(1);
|
||||||
@include flex-align-self(center);
|
@include flex-align-self(center);
|
||||||
|
@include flex-align-items(center);
|
||||||
|
|
||||||
padding: $tab-bar-item-padding;
|
padding: $tab-bar-item-padding;
|
||||||
min-width: $tab-bar-item-min-width;
|
min-width: $tab-bar-item-min-width;
|
||||||
@ -52,6 +53,10 @@ $tab-bar-item-max-width: 160px !default;
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@include user-select(none);
|
@include user-select(none);
|
||||||
|
outline: 0;
|
||||||
|
|
||||||
|
border: 0;
|
||||||
|
background: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab-bar-icon-bottom .tab-bar-item {
|
.tab-bar-icon-bottom .tab-bar-item {
|
||||||
@ -100,6 +105,6 @@ $tab-bar-item-max-width: 160px !default;
|
|||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab-bar-item.tab-active {
|
.tab-bar-item[aria-selected="true"] {
|
||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,11 @@ export function pascalCaseToDashCase(str = '') {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let _uid = 0
|
||||||
|
export function uid() {
|
||||||
|
return _uid++
|
||||||
|
}
|
||||||
|
|
||||||
export class Log {
|
export class Log {
|
||||||
static log(...args) {
|
static log(...args) {
|
||||||
console.log.apply(console, args)
|
console.log.apply(console, args)
|
||||||
|
Reference in New Issue
Block a user