feature(hide-when): add orientation support, recalc on resize event

This commit is contained in:
Dan Bucholtz
2018-02-19 23:15:12 -06:00
parent 60e0d90560
commit 05b2715f77
3 changed files with 25 additions and 4 deletions

View File

@@ -1,9 +1,9 @@
import { Component, Element, Prop } from '@stencil/core';
import { Component, Element, Listen, Prop, State } from '@stencil/core';
import { Config, PlatformConfig } from '../../index';
import {
DisplayWhen,
componentWillLoadImpl,
updateTestResults,
} from '../../utils/show-hide-when-utils';
@Component({
@@ -16,16 +16,18 @@ export class HideWhen implements DisplayWhen {
@Prop({ context: 'config' }) config: Config;
@Prop({ context: 'platforms' }) calculatedPlatforms: PlatformConfig[];
@Prop() orientation: string = null;
@Prop() mediaQuery: string = null;
@Prop() size: string = null;
@Prop() mode: string = null;
@Prop() platform: string = null;
@Prop() or = false;
passesTest = false;
@State() passesTest = false;
@Listen('window:resize')
componentWillLoad() {
return componentWillLoadImpl(this);
return updateTestResults(this);
}
hostData() {

View File

@@ -22,6 +22,11 @@ string
boolean
#### orientation
string
#### platform
string
@@ -49,6 +54,11 @@ string
boolean
#### orientation
string
#### platform
string

View File

@@ -32,6 +32,15 @@
<div>Hides on iOS only</div>
</ion-hide-when>
<h2>Orientation Tests</h2>
<ion-hide-when orientation="portrait">
<div>Hides on portrait orientation</div>
</ion-hide-when>
<ion-hide-when orientation="landscape">
<div>Hides on landscape orientation</div>
</ion-hide-when>
<h2>Platform Tests</h2>
<ion-hide-when platform="android,ios">