Skip to content

Commit

Permalink
Add offline-banner UI
Browse files Browse the repository at this point in the history
  • Loading branch information
brundonsmith committed Sep 24, 2024
1 parent 88231ce commit 9e871ca
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions front-end/src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { FC, useEffect, useMemo } from 'react'

import { exists } from '../../../back-end/utils/misc'
import useHashState from '../hooks/useHashState'
import useIsOffline from '../hooks/useIsOffline'
import { StoreContext, useNewStoreInstance } from '../hooks/useStore'
import useWindowSize from '../hooks/useWindowSize'
import Account from './Account'
Expand Down Expand Up @@ -90,6 +91,7 @@ export default React.memo(() => {

const Nav = React.memo((props: { views: readonly View[] }) => {
const { hashState } = useHashState()
const isOffline = useIsOffline()

return (
<div className='nav'>
Expand All @@ -109,6 +111,10 @@ const Nav = React.memo((props: { views: readonly View[] }) => {
</a>
)
})}

<div className={`offline-banner ${!isOffline ? 'hidden' : ''}`}>
Currently offline
</div>
</div>
)
})
20 changes: 20 additions & 0 deletions front-end/src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ a {
}

.nav {
position: relative;
min-height: 60px;
background: var(--color-background-2);
border-top: var(--controls-border);
Expand All @@ -141,6 +142,25 @@ a {
flex-grow: 0;
flex-shrink: 0;

.offline-banner {
position: absolute;
bottom: 100%;
left: 0;
width: 100vw;
padding: 2px;
font-size: 10px;
text-align: center;
background: var(--color-danger);
color: rgba(255, 255, 255, 0.9);

transition: transform 0.2s ease-out, opacity 0.2s ease-out;

&.hidden {
transform: translateX(-100vw);
opacity: 0;
}
}

a {
appearance: none;
border: none;
Expand Down

0 comments on commit 9e871ca

Please sign in to comment.