Skip to content

Commit 3526763

Browse files
authored
Merge pull request #98 from pietrobs/master
Add isMIUI helper
2 parents 1b24e47 + 207a412 commit 3526763

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ declare module "react-device-detect" {
6161
export import isWindows = ReactDeviceDetect.isWindows;
6262
export import isMacOs = ReactDeviceDetect.isMacOs;
6363
export import withOrientationChange = ReactDeviceDetect.withOrientationChange;
64+
export import isMIUI = ReactDeviceDetect.isMIUI;
6465
}
6566

6667
declare namespace ReactDeviceDetect {
@@ -196,4 +197,6 @@ declare namespace ReactDeviceDetect {
196197
export const isWindows: boolean;
197198

198199
export const isMacOs: boolean;
200+
201+
export const isMIUI: boolean;
199202
}

main.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ var BROWSER_TYPES = {
204204
CHROMIUM: "Chromium",
205205
IE: 'IE',
206206
MOBILE_SAFARI: "Mobile Safari",
207-
EDGE_CHROMIUM: "Edge Chromium"
207+
EDGE_CHROMIUM: "Edge Chromium",
208+
MIUI: "MIUI Browser"
208209
};
209210
var OS_TYPES = {
210211
IOS: 'iOS',
@@ -444,6 +445,10 @@ var isIEType = function isIEType() {
444445
return browser.name === BROWSER_TYPES.INTERNET_EXPLORER || browser.name === BROWSER_TYPES.IE;
445446
};
446447

448+
var isMIUIType = function isMIUIType() {
449+
return browser.name === BROWSER_TYPES.MIUI;
450+
};
451+
447452
var isElectronType = function isElectronType() {
448453
var nav = getNavigatorInstance();
449454
var ua = nav && nav.userAgent.toLowerCase();
@@ -550,6 +555,7 @@ var isEdgeChromium = isEdgeChromiumType();
550555
var isLegacyEdge = isEdgeType();
551556
var isWindows = isWindowsType();
552557
var isMacOs = isMacOsType();
558+
var isMIUI = isMIUIType();
553559

554560
var AndroidView = function AndroidView(_ref) {
555561
var renderWithFragment = _ref.renderWithFragment,
@@ -789,6 +795,7 @@ exports.isIPad13 = isIPad13;
789795
exports.isIPhone13 = isIPhone13;
790796
exports.isIPod13 = isIPod13;
791797
exports.isLegacyEdge = isLegacyEdge;
798+
exports.isMIUI = isMIUI;
792799
exports.isMacOs = isMacOs;
793800
exports.isMobile = isMobile;
794801
exports.isMobileOnly = isMobileOnly;

src/components/helpers/selectors.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const isSafariType = () => browser.name === BROWSER_TYPES.SAFARI || browser.name
3636
const isMobileSafariType = () => browser.name === BROWSER_TYPES.MOBILE_SAFARI;
3737
const isOperaType = () => browser.name === BROWSER_TYPES.OPERA;
3838
const isIEType = () => browser.name === BROWSER_TYPES.INTERNET_EXPLORER || browser.name === BROWSER_TYPES.IE;
39+
const isMIUIType = () => browser.name === BROWSER_TYPES.MIUI;
3940
const isElectronType = () => {
4041
const nav = getNavigatorInstance();
4142
const ua = nav && nav.userAgent.toLowerCase();
@@ -107,3 +108,4 @@ export const isEdgeChromium = isEdgeChromiumType();
107108
export const isLegacyEdge = isEdgeType() && !isEdgeChromiumType();
108109
export const isWindows = isWindowsType();
109110
export const isMacOs = isMacOsType();
111+
export const isMIUI = isMIUIType();

src/components/helpers/types.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export const BROWSER_TYPES = {
2020
CHROMIUM: "Chromium",
2121
IE: 'IE',
2222
MOBILE_SAFARI: "Mobile Safari",
23-
EDGE_CHROMIUM: "Edge Chromium"
23+
EDGE_CHROMIUM: "Edge Chromium",
24+
MIUI: "MIUI Browser"
2425
};
2526

2627
export const OS_TYPES = {

0 commit comments

Comments
 (0)