-
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.
Merge pull request #1312 from opentripplanner/network-connection-banner
feat: add network connection status to ui and redux
- Loading branch information
Showing
12 changed files
with
378 additions
and
253 deletions.
There are no files selected for viewing
496 changes: 248 additions & 248 deletions
496
__tests__/components/viewers/__snapshots__/nearby-view.js.snap
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,83 @@ | ||
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' | ||
import InvisibleA11yLabel from '../util/invisible-a11y-label' | ||
|
||
const containerClassname = 'network-connection-banner' | ||
const timeout = 250 | ||
|
||
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%; | ||
// When banner is fully loaded, set z-index higher than nav so we're not seeing the nav border. | ||
z-index: 26; | ||
@media (max-width: 768px) { | ||
border: 0; | ||
} | ||
} | ||
.${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); | ||
z-index: 20; | ||
} | ||
.${containerClassname}-exit-active { | ||
opacity: 0; | ||
transform: translateY(-100%); | ||
transition: opacity ${timeout}ms ease-in, transform ${timeout}ms ease-in; | ||
z-index: 20; | ||
} | ||
` | ||
|
||
export const NetworkConnectionBanner = ({ | ||
networkConnectionLost | ||
}: { | ||
networkConnectionLost: boolean | ||
}): JSX.Element => { | ||
const connectionLostBannerRef = useRef<HTMLDivElement>(null) | ||
return ( | ||
<TransitionStyles> | ||
<InvisibleA11yLabel aria-live="assertive" role="status"> | ||
{networkConnectionLost ? ( | ||
<FormattedMessage id="components.AppMenu.networkConnectionLost" /> | ||
) : ( | ||
<FormattedMessage id="components.AppMenu.networkConnectionRestored" /> | ||
)} | ||
</InvisibleA11yLabel> | ||
<TransitionGroup style={{ display: 'content' }}> | ||
{networkConnectionLost && ( | ||
<CSSTransition | ||
classNames={containerClassname} | ||
nodeRef={connectionLostBannerRef} | ||
timeout={timeout} | ||
> | ||
<div className={containerClassname} ref={connectionLostBannerRef}> | ||
<FormattedMessage id="components.AppMenu.networkConnectionLost" /> | ||
</div> | ||
</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
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