-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add network connection status to ui and redux
- Loading branch information
1 parent
bad8e44
commit 20047af
Showing
7 changed files
with
116 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { CSSTransition, TransitionGroup } from 'react-transition-group' | ||
import { FormattedMessage } from 'react-intl' | ||
import React, { useRef } from 'react' | ||
import styled from 'styled-components' | ||
|
||
import { RED_ON_WHITE } from '../util/colors' | ||
|
||
const containerClassname = 'network-connection-banner' | ||
const timeout = 200 | ||
|
||
const TransitionStyles = styled.div` | ||
.${containerClassname} { | ||
background: ${RED_ON_WHITE}; | ||
border-left: 1px solid #e7e7e7; | ||
border-right: 1px solid #e7e7e7; | ||
color: #fff; | ||
font-weight: 600; | ||
padding: 5px; | ||
position: absolute; | ||
text-align: center; | ||
top: 50px; | ||
width: 100%; | ||
z-index: 1; | ||
} | ||
.${containerClassname}-enter { | ||
opacity: 0; | ||
transform: translateY(-100%); | ||
} | ||
.${containerClassname}-enter-active { | ||
opacity: 1; | ||
transform: translateY(0); | ||
transition: opacity ${timeout}ms ease-in; | ||
} | ||
.${containerClassname}-exit { | ||
opacity: 1; | ||
transform: translateY(0); | ||
} | ||
.${containerClassname}-exit-active { | ||
opacity: 0; | ||
transform: translateY(-100%); | ||
transition: opacity ${timeout}ms ease-in, transform ${timeout}ms ease-in; | ||
} | ||
` | ||
export const NetworkConnectionLostBanner = styled.div`` | ||
|
||
export const NetworkConnectionBanner = ({ | ||
networkConnectionLost | ||
}: { | ||
networkConnectionLost: boolean | ||
}): JSX.Element => { | ||
const connectionLostBannerRef = useRef<HTMLDivElement>(null) | ||
return ( | ||
<TransitionStyles> | ||
<TransitionGroup style={{ display: 'content' }}> | ||
{networkConnectionLost && ( | ||
<CSSTransition | ||
classNames={containerClassname} | ||
nodeRef={connectionLostBannerRef} | ||
timeout={timeout} | ||
> | ||
<NetworkConnectionLostBanner | ||
aria-live="assertive" | ||
className={containerClassname} | ||
ref={connectionLostBannerRef} | ||
role="status" | ||
> | ||
{networkConnectionLost ? ( | ||
<FormattedMessage id="components.AppMenu.networkConnectionLost" /> | ||
) : ( | ||
<FormattedMessage id="components.AppMenu.networkConnectionRestored" /> | ||
)} | ||
</NetworkConnectionLostBanner> | ||
</CSSTransition> | ||
)} | ||
</TransitionGroup> | ||
</TransitionStyles> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters