Skip to content

Commit 1108229

Browse files
add back button for PWA (#48)
1 parent 9fe3c03 commit 1108229

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

src/AppHeader.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,11 @@
8585
margin-right: 10px;
8686
}
8787
}
88+
89+
@media all and (display-mode: standalone) {
90+
&__logo {
91+
padding-left: 72px;
92+
padding-right: 10px;
93+
}
94+
}
8895
}

src/Navigation.scss

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@
7878
}
7979
}
8080

81+
&__backbtn {
82+
display: none;
83+
}
84+
8185
@media(max-width: $tabletWidth) {
8286
background-color: $mainBackgroundColor;
8387
text-align: center;
@@ -230,3 +234,22 @@
230234
position: absolute;
231235
}
232236
}
237+
238+
@media all and (display-mode: standalone) {
239+
.toggle-btn {
240+
left: 36px;
241+
}
242+
243+
.navigation__backbtn {
244+
display: inline-block;
245+
position: absolute;
246+
top: 14px;
247+
left: 0;
248+
}
249+
250+
.navigation__backicon {
251+
height: 32px;
252+
width: 32px;
253+
fill: $mainColor;
254+
}
255+
}

src/Navigation.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import './Navigation.scss';
1010
import { NavMenu } from './NavMenu';
1111
import { ReactComponent as MenuIcon } from './images/icons/ic_menu.svg';
1212
import { ReactComponent as CloseIcon } from './images/icons/ic_close.svg';
13+
import { ReactComponent as ArrowIcon } from './images/icons/arrow_left.svg';
1314

1415
export const Navigation: React.FC = () => {
1516
const { t } = useTranslation();
@@ -51,6 +52,10 @@ export const Navigation: React.FC = () => {
5152
setIsOpen(false);
5253
});
5354

55+
const handleGoBack = () => {
56+
window.history.back();
57+
};
58+
5459
function renderTopCategories(categories: Category[]): React.ReactElement {
5560
const topCategories = [
5661
{ name: 'home', displayName: t('home'), url: '/' },
@@ -96,6 +101,11 @@ export const Navigation: React.FC = () => {
96101

97102
return (
98103
<>
104+
{window.matchMedia('(display-mode: standalone)').matches && (
105+
<button className="navigation__backbtn" aria-label="back button" type="button" onClick={handleGoBack}>
106+
<ArrowIcon className="navigation__backicon" />
107+
</button>
108+
)}
99109
<button
100110
className="toggle-btn"
101111
type="button"

0 commit comments

Comments
 (0)