Skip to content

Commit 2765197

Browse files
authored
Merge pull request #59 from duskload/RDD-50-Detect-Electron
#50 update readme. add electron. bump version
2 parents 0f9b04b + c97eb88 commit 2765197

File tree

5 files changed

+22
-1
lines changed

5 files changed

+22
-1
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ const styles = {
142142
| engineVersion | string | returns engine version |
143143
| getUA | string | returns user agent |
144144
| deviceType | string | returns device type (e.g `mobile` or `tablet`) |
145+
| isIOS13 | boolean | returns true/false if device is running on iOS13 |
146+
| isIPhone13 | boolean | returns true/false if device is iPhone and running on iOS13 |
147+
| isIPad13 | boolean | returns true/false if device is iPad and running on iOS13 |
148+
| isIPod13 | boolean | returns true/false if device is iPod and running on iOS13 |
149+
| isElectron | boolean | returns true/false if running on Electron |
145150
| deviceDetect | function | return data object which includes all data about device (e.g version, engine, os etc.) |
146151

147152
### Views

index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ declare module "react-device-detect" {
5555
export import isIPad13 = ReactDeviceDetect.isIPad13;
5656
export import isIPhone13 = ReactDeviceDetect.isIPhone13;
5757
export import isIPod13 = ReactDeviceDetect.isIPod13;
58+
export import isElectron = ReactDeviceDetect.isElectron;
5859
export import withOrientationChange = ReactDeviceDetect.withOrientationChange;
5960
}
6061

@@ -181,4 +182,6 @@ declare namespace ReactDeviceDetect {
181182
export const isIPhone13: boolean;
182183

183184
export const isIPod13: boolean;
185+
186+
export const isElectron: boolean;
184187
}

main.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,11 @@ var isIEType = function isIEType() {
414414
return browser.name === BROWSER_TYPES.INTERNET_EXPLORER || browser.name === BROWSER_TYPES.IE;
415415
};
416416

417+
var isElectronType = function isElectronType() {
418+
var ua = navigator.userAgent.toLowerCase();
419+
return ua.includes('electron');
420+
};
421+
417422
var getIOS13 = function getIOS13() {
418423
return (/iPad|iPhone|iPod/.test(navigator.platform) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1) && !window.MSStream;
419424
};
@@ -508,6 +513,7 @@ var isIOS13 = getIOS13();
508513
var isIPad13 = getIPad13();
509514
var isIPhone13 = getIphone13();
510515
var isIPod13 = getIPod13();
516+
var isElectron = isElectronType();
511517

512518
var AndroidView = function AndroidView(_ref) {
513519
var renderWithFragment = _ref.renderWithFragment,
@@ -737,6 +743,7 @@ exports.isChrome = isChrome;
737743
exports.isChromium = isChromium;
738744
exports.isConsole = isConsole;
739745
exports.isEdge = isEdge;
746+
exports.isElectron = isElectron;
740747
exports.isFirefox = isFirefox;
741748
exports.isIE = isIE;
742749
exports.isIOS = isIOS;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-device-detect",
3-
"version": "1.10.11",
3+
"version": "1.11.11",
44
"description": "Detect device type and render your component according to it",
55
"main": "main.js",
66
"typings": "./index.d.ts",

src/components/helpers/selectors.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ const isOperaType = () => browser.name === BROWSER_TYPES.OPERA;
4242
const isIEType = () =>
4343
browser.name === BROWSER_TYPES.INTERNET_EXPLORER ||
4444
browser.name === BROWSER_TYPES.IE;
45+
const isElectronType = () => {
46+
const ua = navigator.userAgent.toLowerCase()
47+
48+
return ua.includes('electron')
49+
}
4550

4651
const getIOS13 = () => {
4752
return (
@@ -101,3 +106,4 @@ export const isIOS13 = getIOS13()
101106
export const isIPad13 = getIPad13()
102107
export const isIPhone13 = getIphone13()
103108
export const isIPod13 = getIPod13()
109+
export const isElectron = isElectronType()

0 commit comments

Comments
 (0)