Skip to content

Commit

Permalink
feat(core): add check for standalone mode (#15001)
Browse files Browse the repository at this point in the history
* feat(core): add check for standalone mode

* feat(): add check for isStandalone

* feat(core): add check for standalone mode
  • Loading branch information
mhartington authored and manucorporat committed Aug 6, 2018
1 parent 60f5731 commit 0b4b9fe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/src/components/app/app.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, Element, Prop, QueueApi } from '@stencil/core';

import { Config, Mode } from '../../interface';
import { isDevice, isHybrid, needInputShims } from '../../utils/platform';
import { isDevice, isHybrid, isStandaloneMode, needInputShims } from '../../utils/platform';
import { createThemedClasses } from '../../utils/theme';

@Component({
Expand Down Expand Up @@ -35,14 +35,16 @@ export class App {

hostData() {
const hybrid = isHybrid(this.win);
const statusbarPadding = this.config.get('statusbarPadding', hybrid);
const isStandalone = isStandaloneMode(this.win);
const statusbarPadding = this.config.get('statusbarPadding', hybrid || isStandalone);

return {
class: {
...createThemedClasses(this.mode, 'app'),

'is-device': this.isDevice,
'is-hydrid': hybrid,
'is-standalone': isStandalone,
'statusbar-padding': statusbarPadding
}
};
Expand Down
4 changes: 4 additions & 0 deletions core/src/utils/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ export function isElectron(win: Window): boolean {
return testUserAgent(win, /electron/);
}

export function isStandaloneMode(win: Window): boolean {
return win.matchMedia('(display-mode: standalone)').matches;
}

export function needInputShims(win: Window) {
return isIOS(win) && isDevice(win);
}
Expand Down

0 comments on commit 0b4b9fe

Please sign in to comment.