Skip to content

Commit f8fb393

Browse files
marceloschreiberMarcusNotheis
authored andcommitted
Merge pull request #54 from LuisValgoi/feat-45
[ISSUE-45] Added ReactDeviceDetect
1 parent 5864fa1 commit f8fb393

File tree

6 files changed

+47
-101
lines changed

6 files changed

+47
-101
lines changed

packages/ui5-webcomponents-react-seed/README.md

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,10 @@
2929
- `npx create-react-app PROJECT_NAME --template ui5-webcomponents-react-seed`;
3030
- cd into `PROJECT_NAME`;
3131
- (no need to run `yarn install` since it already installs it for you);
32-
- run `yarn test:ci` or any other;
33-
- have fun with the other scripts;
32+
- run the available scripts;
3433

3534
PS.: It is important to add the `--template ui5-webcomponents-react-seed` at the end to get our template.
3635

37-
# Getting Started
38-
39-
Once you have created your project using the `ui5-webcomponents-react-seed` template, you can start by:
40-
41-
- `yarn mock`: To run this project with json-server.
42-
43-
- `yarn start`: To run this project with backend (⚠️ currently not supported).
44-
4536
# Configuration Included
4637

4738
- JEST Up & Runnning.
@@ -72,10 +63,6 @@ Once you have created your project using the `ui5-webcomponents-react-seed` temp
7263

7364
# Hooks Included
7465

75-
- `useBrowser`: Which identifies the user browser.
76-
77-
- `useIsMobile`: Which identifies the user device perspective.
78-
7966
- `useRequest`: Which includes `get`, `post`, `patch`, `delete`, `put` HTTP helpers.
8067

8168
- `useAuthority`: Which includes `hasAccess` helpers.
@@ -182,6 +169,10 @@ Used to translate strings and text in the application following the Internationa
182169

183170
Used to identify the browsers culture and change the applications text accordingly.
184171

172+
### `react-device-detect``
173+
174+
Used to identify the device, browser, ratios and etc.
175+
185176
### `commitlint`
186177

187178
Used to check the commits before actually commits.

packages/ui5-webcomponents-react-seed/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
"@ui5/webcomponents-react": "^0.10.0",
4848
"axios": "^0.20.0",
4949
"env-cmd": "^10.1.0",
50+
"eslint-config-prettier": "^6.11.0",
51+
"eslint-plugin-prettier": "^3.1.4",
5052
"husky": "^4.2.5",
5153
"i18next": "^19.7.0",
5254
"i18next-browser-languagedetector": "^6.0.1",
@@ -55,17 +57,16 @@
5557
"msw": "^0.20.5",
5658
"nodemon": "^2.0.4",
5759
"npm-run-all": "^4.1.5",
60+
"prettier": "^2.1.1",
5861
"react": "^16.13.1",
5962
"react-app-polyfill": "^1.0.6",
63+
"react-device-detect": "^1.13.1",
6064
"react-dom": "^16.13.1",
6165
"react-helmet": "^6.1.0",
6266
"react-i18next": "^11.7.2",
6367
"react-query": "^2.17.2",
6468
"react-router-dom": "^5.2.0",
65-
"react-scripts": "3.4.3",
66-
"eslint-config-prettier": "^6.11.0",
67-
"eslint-plugin-prettier": "^3.1.4",
68-
"prettier": "^2.1.1"
69+
"react-scripts": "3.4.3"
6970
},
7071
"scripts": {
7172
"build": "react-scripts build",

packages/ui5-webcomponents-react-seed/src/hooks/useBrowser.js

Lines changed: 0 additions & 47 deletions
This file was deleted.

packages/ui5-webcomponents-react-seed/src/hooks/useIsMobile.js

Lines changed: 0 additions & 34 deletions
This file was deleted.

packages/ui5-webcomponents-react-seed/src/pages/Todo/List/TodoList.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
2-
import { useHistory } from 'react-router-dom';
32
import { Helmet } from 'react-helmet';
3+
import { useHistory } from 'react-router-dom';
4+
import { MobileView, BrowserView, IEView, isMobile, isTablet, isDesktop, isIE, isChrome, isOpera } from 'react-device-detect';
45

56
import HyperLink from '../../../components/HyperLink/HyperLink';
67
import BrowserURL from '../../../util/BrowserURL';
@@ -12,13 +13,35 @@ export default function TodoList() {
1213
return (
1314
<>
1415
<Helmet title="List - TodoList App" />
16+
<h1>Routing</h1>
1517
<HyperLink onClick={() => history.push('/dontexist')} text="Test NotFound Page" />
1618
<br />
1719
<HyperLink onClick={() => history.push(BrowserURL.BUGGY)} text="Test Error Page" />
1820
<br />
21+
1922
<ComponentValidator allowedAuthorities={['canAccessDropApplication']} authorityKey="permissions">
20-
<HyperLink text="Drop Application (this is a restricted text and you should not see unless you have access)" />
23+
<h1>Component Validator</h1>
24+
<p>Drop Application (this is a restricted text and you should not see unless you have access)</p>
2125
</ComponentValidator>
26+
27+
<h1>Device Detect</h1>
28+
<MobileView>
29+
<p>This is a text visible only for MOBILE</p>
30+
</MobileView>
31+
<BrowserView>
32+
<p>This is a text visible only for DESKTOP</p>
33+
</BrowserView>
34+
<p>{isMobile ? 'This text appears when is MOBILE' : 'This text appears when is not MOBILE'}</p>
35+
<p>{isTablet ? 'This text appears when is TABLET' : 'This text appears when is not TABLET'}</p>
36+
<p>{isDesktop ? 'This text appears when is DESKTOP' : 'This text appears when is not DESKTOP'}</p>
37+
38+
<h1>Browser Detect</h1>
39+
<IEView>
40+
<p>This is a text visible only for INTERNET EXPLORER</p>
41+
</IEView>
42+
<p>{isChrome ? 'This Text is rendered only for CHROME' : 'This Text is rendered only when is NOT CHROME'}</p>
43+
<p>{isIE ? 'This Text is rendered only for IE' : 'This Text is rendered only when is NOT IE'}</p>
44+
<p>{isOpera ? 'This Text is rendered only for OPERA' : 'This Text is rendered only when is NOT OPERA'}</p>
2245
</>
2346
);
2447
}

packages/ui5-webcomponents-react-seed/yarn.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10164,6 +10164,13 @@ react-dev-utils@^10.2.1:
1016410164
strip-ansi "6.0.0"
1016510165
text-table "0.2.0"
1016610166

10167+
react-device-detect@^1.13.1:
10168+
version "1.13.1"
10169+
resolved "https://registry.yarnpkg.com/react-device-detect/-/react-device-detect-1.13.1.tgz#27ac0e86a03969e440e973d179aaa19e80a5ba66"
10170+
integrity sha512-XTPgAMsUVHC5lMNUGiAeO2UfAfhMfjq0CBUM67eHnc9XfO7iESh6h/cffKV8VGgrZBX+dyuqJl23bLLHoav5Ig==
10171+
dependencies:
10172+
ua-parser-js "^0.7.21"
10173+
1016710174
react-display-name@^0.2.4:
1016810175
version "0.2.5"
1016910176
resolved "https://registry.yarnpkg.com/react-display-name/-/react-display-name-0.2.5.tgz#304c7cbfb59ee40389d436e1a822c17fe27936c6"
@@ -12051,6 +12058,11 @@ typedarray@^0.0.6:
1205112058
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
1205212059
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
1205312060

12061+
ua-parser-js@^0.7.21:
12062+
version "0.7.22"
12063+
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.22.tgz#960df60a5f911ea8f1c818f3747b99c6e177eae3"
12064+
integrity sha512-YUxzMjJ5T71w6a8WWVcMGM6YWOTX27rCoIQgLXiWaxqXSx9D7DNjiGWn1aJIRSQ5qr0xuhra77bSIh6voR/46Q==
12065+
1205412066
undefsafe@^2.0.2:
1205512067
version "2.0.3"
1205612068
resolved "https://registry.yarnpkg.com/undefsafe/-/undefsafe-2.0.3.tgz#6b166e7094ad46313b2202da7ecc2cd7cc6e7aae"

0 commit comments

Comments
 (0)