fix(all): accesibility and global styles for hidden nodes

This commit is contained in:
Manu Mtz.-Almeida
2018-07-22 12:02:51 +02:00
parent 0ed9406e8b
commit 4b844ef1c3
17 changed files with 75 additions and 42 deletions

View File

@ -26,13 +26,11 @@ ion-app,
justify-content: space-between;
}
.hide-page {
.ion-page-invisible {
opacity: 0;
}
[hidden] {
// TODO can we remove important here or remove this entirely
// since it is also in structure.scss
.ion-page-hidden {
/* stylelint-disable-next-line declaration-no-important */
display: none !important;
}

View File

@ -6,11 +6,11 @@
:host {
--ion-color-base: #{$background-color};
--ion-color-contrast: #{$text-color};
--padding-top: 0;
--padding-bottom: 0;
--padding-start: 0;
--padding-end: 0;
--keyboard-offset: 0;
--padding-top: 0px;
--padding-bottom: 0px;
--padding-start: 0px;
--padding-end: 0px;
--keyboard-offset: 0px;
display: block;
position: relative;

View File

@ -0,0 +1,4 @@
:host(.menu-toggle-hidden) {
/* stylelint-disable-next-line declaration-no-important */
display: none;
}

View File

@ -2,6 +2,8 @@ import { Component, Listen, Prop, State } from '@stencil/core';
@Component({
tag: 'ion-menu-toggle',
styleUrl: 'menu-toggle.scss',
shadow: true
})
export class MenuToggle {
@Prop({ context: 'document' })
@ -54,9 +56,16 @@ export class MenuToggle {
hostData() {
const hidden = this.autoHide && !this.visible;
return {
'hidden': hidden
'aria-hidden': hidden ? 'true' : null,
class: {
'menu-toggle-hidden': hidden,
}
};
}
render() {
return <slot></slot>;
}
}
function getMenuController(doc: Document): Promise<HTMLIonMenuControllerElement|undefined> {

View File

@ -2,7 +2,7 @@ import { Build, Component, Element, Event, EventEmitter, Method, Prop, QueueApi,
import { ViewLifecycle } from '../..';
import { Animation, ComponentProps, Config, FrameworkDelegate, GestureDetail, Mode, NavComponent, NavOptions, NavOutlet, NavResult, RouteID, RouteWrite, TransitionDoneFn, TransitionInstruction, ViewController } from '../../interface';
import { assert } from '../../utils/helpers';
import { TransitionOptions, lifecycle, transition } from '../../utils/transition';
import { TransitionOptions, lifecycle, setPageHidden, transition } from '../../utils/transition';
import { ViewState, convertToViews, matches } from './view-controller';
@Component({
@ -850,15 +850,16 @@ export class Nav implements NavOutlet {
for (let i = views.length - 1; i >= 0; i--) {
const view = views[i];
const element = view.element;
if (i > activeViewIndex) {
// this view comes after the active view
// let's unload it
lifecycle(this.win, view.element, ViewLifecycle.WillUnload);
lifecycle(this.win, element, ViewLifecycle.WillUnload);
this.destroyView(view);
} else if (i < activeViewIndex) {
// this view comes before the active view
// and it is not a portal then ensure it is hidden
view.element!.hidden = true;
setPageHidden(element!, true);
}
}
}

View File

@ -29,7 +29,7 @@ export class ViewController {
if (!this.element) {
const component = this.component;
this.element = await attachComponent(this.delegate, container, component, ['ion-page', 'hide-page'], this.params);
this.element = await attachComponent(this.delegate, container, component, ['ion-page', 'ion-page-invisible'], this.params);
}
}

View File

@ -55,7 +55,7 @@ export class RouterOutlet implements NavOutlet {
this.activeComponent = component;
// attach entering view to DOM
const enteringEl = await attachComponent(this.delegate, this.el, component, ['ion-page', 'hide-page'], params);
const enteringEl = await attachComponent(this.delegate, this.el, component, ['ion-page', 'ion-page-invisible'], params);
const leavingEl = this.activeEl;
// commit animation

View File

@ -36,7 +36,8 @@
}
:host(.tab-hidden) {
display: none;
/* stylelint-disable-next-line declaration-no-important */
display: none !important;
}
a {

View File

@ -0,0 +1,4 @@
:host(.tab-hidden) {
/* stylelint-disable-next-line declaration-no-important */
display: none !important;
}

View File

@ -3,7 +3,9 @@ import { Color, ComponentRef, FrameworkDelegate } from '../../interface';
import { attachComponent } from '../../utils/framework-delegate';
@Component({
tag: 'ion-tab'
tag: 'ion-tab',
styleUrl: 'tab.scss',
shadow: true
})
export class Tab {
@ -136,13 +138,19 @@ export class Tab {
}
hostData() {
const { btnId, active, component } = this;
return {
'aria-labelledby': this.btnId,
'aria-labelledby': btnId,
'aria-hidden': !active ? 'true' : null,
'role': 'tabpanel',
'hidden': !this.active,
'class': {
'ion-page': !this.component
'ion-page': !component,
'tab-hidden': !active
}
};
}
render() {
return <slot></slot>;
}
}

View File

@ -24,7 +24,8 @@
}
:host(.tabbar-hidden) {
display: none;
/* stylelint-disable-next-line declaration-no-important */
display: none !important;
}
:host(.placement-top) {

View File

@ -24,7 +24,7 @@ export class Tabbar {
@State() canScrollLeft = false;
@State() canScrollRight = false;
@State() hidden = false;
@State() keyboardVisible = false;
/**
* Set the layout of the text and icon in the tabbar. Available options: `"icon-top"`, `"icon-start"`, `"icon-end"`, `"icon-bottom"`, `"icon-hide"`, `"label-hide"`.
@ -68,13 +68,13 @@ export class Tabbar {
@Listen('body:keyboardWillHide')
protected onKeyboardWillHide() {
setTimeout(() => this.hidden = false, 50);
setTimeout(() => this.keyboardVisible = false, 50);
}
@Listen('body:keyboardWillShow')
protected onKeyboardWillShow() {
if (this.placement === 'bottom') {
this.hidden = true;
this.keyboardVisible = true;
}
}
@ -182,15 +182,17 @@ export class Tabbar {
}
hostData() {
const { color, translucent, layout, placement, keyboardVisible, scrollable } = this;
return {
role: 'tablist',
'aria-hidden': keyboardVisible ? 'true' : null,
class: {
...createColorClasses(this.color),
'tabbar-translucent': this.translucent,
[`layout-${this.layout}`]: true,
[`placement-${this.placement}`]: true,
'tabbar-hidden': this.hidden,
'scrollable': this.scrollable
...createColorClasses(color),
'tabbar-translucent': translucent,
[`layout-${layout}`]: true,
[`placement-${placement}`]: true,
'tabbar-hidden': keyboardVisible,
'scrollable': scrollable
}
};
}
@ -209,6 +211,7 @@ export class Tabbar {
selected={selectedTab === tab}
mode={this.mode}
color={this.color}
aria-hidden={ !tab.show ? 'true' : null }
class={{ 'tab-hidden': !tab.show }}
onClick={(ev) => {
if (!tab.disabled) {