Skip to content

Commit c61ba0f

Browse files
MT-3256 network offline banner (#29)
* add network offline banner * remove @types/react-router lib
1 parent 370a6b3 commit c61ba0f

File tree

7 files changed

+36
-2
lines changed

7 files changed

+36
-2
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"react": "^16.13.1",
1818
"react-axe": "^3.5.2",
1919
"react-cool-onclickoutside": "^1.5.2",
20+
"react-detect-offline": "^2.4.0",
2021
"react-dom": "^16.13.1",
2122
"react-responsive-modal": "^4.0.1",
2223
"react-router-dom": "^5.2.0",

src/AppHeader.scss

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
@import './theme/common';
12

23
.appheader {
4+
position: relative;
35
display: flex;
46
flex-direction: row;
57
height: 100%;
@@ -21,4 +23,18 @@
2123
&__moltincartcontainer {
2224
flex: 0 0 auto;
2325
}
26+
27+
&__networkoffline {
28+
width: 50%;
29+
padding: 15px;
30+
position: absolute;
31+
top: 100%;
32+
left: 25%;
33+
text-align: center;
34+
z-index: 1;
35+
border-radius: 3px;
36+
color: $secondAccentColor;
37+
background-color: adjust-color($color: $secondAccentColor, $lightness: 65%);
38+
border: 1px solid adjust-color($color: $secondAccentColor, $lightness: 60%);
39+
}
2440
}

src/AppHeader.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React from 'react';
22
import { Link } from "react-router-dom";
3+
// @ts-ignore
4+
import { Offline } from 'react-detect-offline';
35
import { ImageContainer } from './ImageContainer';
46
import { useTranslation } from './app-state';
57
import { LanguageDropdown } from './LanguageDropdown';
@@ -28,6 +30,13 @@ export const AppHeader: React.FC = () => {
2830
<div className="appheader__moltincartcontainer">
2931
<span className="moltin-cart-button"></span>
3032
</div>
33+
<Offline>
34+
<div className="appheader__networkoffline">
35+
<strong>
36+
{t('network-offline')}
37+
</strong>
38+
</div>
39+
</Offline>
3140
</div>
3241
);
3342
};

src/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,6 @@
8585
"email-slash-username": "Email/Username",
8686
"password-confirmation": "Password Confirmation",
8787
"submit": "Submit",
88-
"required": "Required"
88+
"required": "Required",
89+
"network-offline": "Network Offline"
8990
}

src/locales/fr.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,6 @@
8585
"email-slash-username": "ÉÉɱåîîļ⁄Ûššéŕññåɱé",
8686
"password-confirmation": "ÞÞåššŵŵöŕð ÇÇöñƒƒîŕɱɱåţţîöñ",
8787
"submit": "ŠŠûƀɱɱîţ",
88-
"required": "ŔŔéǫûîîŕéð"
88+
"required": "ŔŔéǫûîîŕéð",
89+
"network-offline": "ÑÑéţŵŵöŕķ ÖÖƒƒļļîñé"
8990
}

src/theme/common.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ $fifthComplimentBackground: #C5C5C5;
3030
$accountTreeActive: #E1F0F7;
3131

3232
$firstAccentColor: #78B13F;
33+
$secondAccentColor: #004085;
3334

3435
$mainErrorColor: #E00646;
3536

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9204,6 +9204,11 @@ react-cool-onclickoutside@^1.5.2:
92049204
resolved "https://registry.yarnpkg.com/react-cool-onclickoutside/-/react-cool-onclickoutside-1.5.2.tgz#4a1500b54f3933af2227032975841a5fe3f9a0e8"
92059205
integrity sha512-aOJ3fH9fjQqQ3IASsfXdgH5dmujX/bX4Vj0K6sfsx2dKjBbJ+WmX3nGFfRc3V130onRV93zWjW6WQQrO1Huo6w==
92069206

9207+
react-detect-offline@^2.4.0:
9208+
version "2.4.0"
9209+
resolved "https://registry.yarnpkg.com/react-detect-offline/-/react-detect-offline-2.4.0.tgz#e40f5a588ffb0680bcbcfa33e4d9d39ad805c3ff"
9210+
integrity sha512-OHglQ8bpbM4x8m23RhRCm1e1cYtuCoLQ7NKHsC0zzm1z2vQIrNTq7MvhZTQ7TsbgK1XapMewLxGW9QEW3DXC9A==
9211+
92079212
react-dev-utils@^10.2.1:
92089213
version "10.2.1"
92099214
resolved "https://registry.yarnpkg.com/react-dev-utils/-/react-dev-utils-10.2.1.tgz#f6de325ae25fa4d546d09df4bb1befdc6dd19c19"

0 commit comments

Comments
 (0)