Skip to content

Commit

Permalink
consolidate network connection status regions into one
Browse files Browse the repository at this point in the history
  • Loading branch information
amy-corson-ibigroup committed Dec 2, 2024
1 parent f8141fd commit 27bd548
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 25 deletions.
9 changes: 1 addition & 8 deletions lib/components/app/desktop-nav.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { connect } from 'react-redux'
import { FormattedMessage, useIntl } from 'react-intl'
import { isMobile } from '@opentripplanner/core-utils/lib/ui'
import { Nav, Navbar } from 'react-bootstrap'
import { useIntl } from 'react-intl'
import React from 'react'
import styled from 'styled-components'

Expand Down Expand Up @@ -169,13 +169,6 @@ const DesktopNav = ({
</StyledNav>
</Navbar.Header>
</Navbar>
<InvisibleA11yLabel aria-live="assertive" role="status">
{networkConnectionLost ? (
<FormattedMessage id="components.AppMenu.networkConnectionLost" />
) : (
<FormattedMessage id="components.AppMenu.networkConnectionRestored" />
)}
</InvisibleA11yLabel>
<NetworkConnectionBanner networkConnectionLost={networkConnectionLost} />
</header>
)
Expand Down
18 changes: 10 additions & 8 deletions lib/components/app/network-connection-banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ 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
Expand Down Expand Up @@ -48,7 +49,6 @@ const TransitionStyles = styled.div`
z-index: 20;
}
`
export const NetworkConnectionLostBanner = styled.div``

export const NetworkConnectionBanner = ({
networkConnectionLost
Expand All @@ -58,21 +58,23 @@ export const NetworkConnectionBanner = ({
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}
>
<NetworkConnectionLostBanner
aria-live="assertive"
className={containerClassname}
ref={connectionLostBannerRef}
role="alert"
>
<div className={containerClassname} ref={connectionLostBannerRef}>
<FormattedMessage id="components.AppMenu.networkConnectionLost" />
</NetworkConnectionLostBanner>
</div>
</CSSTransition>
)}
</TransitionGroup>
Expand Down
10 changes: 1 addition & 9 deletions lib/components/mobile/navigation-bar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ArrowLeft } from '@styled-icons/fa-solid/ArrowLeft'
import { connect } from 'react-redux'
import { FormattedMessage, injectIntl } from 'react-intl'
import { injectIntl } from 'react-intl'
import { Navbar } from 'react-bootstrap'
import PropTypes from 'prop-types'
import React, { Component } from 'react'
Expand All @@ -12,7 +12,6 @@ import { ComponentContext } from '../../util/contexts'
import { NetworkConnectionBanner } from '../app/network-connection-banner'
import { StyledIconWrapper } from '../util/styledIcon'
import AppMenu from '../app/app-menu'
import InvisibleA11yLabel from '../util/invisible-a11y-label'
import LocaleSelector from '../app/locale-selector'
import NavLoginButtonAuth0 from '../../components/user/nav-login-button-auth0'
import PageTitle from '../util/page-title'
Expand Down Expand Up @@ -115,13 +114,6 @@ class MobileNavigationBar extends Component {
)}
</MobileBar>
</Navbar>
<InvisibleA11yLabel aria-live="assertive" role="status">
{networkConnectionLost ? (
<FormattedMessage id="components.AppMenu.networkConnectionLost" />
) : (
<FormattedMessage id="components.AppMenu.networkConnectionRestored" />
)}
</InvisibleA11yLabel>
<NetworkConnectionBanner
networkConnectionLost={networkConnectionLost}
/>
Expand Down

0 comments on commit 27bd548

Please sign in to comment.