diff --git a/web/components/status-indicator.css b/web/components/status-indicator.css new file mode 100644 --- /dev/null +++ b/web/components/status-indicator.css @@ -0,0 +1,30 @@ +.indicatorOuter { + border-radius: 50%; + height: 18px; + width: 18px; + display: flex; + justify-content: center; + align-items: center; +} + +.indicatorInner { + border-radius: 50%; + height: 8px; + width: 8px; +} + +.outerActive { + background-color: var(--statusIndicator-background-outer-active); +} + +.innerActive { + background-color: var(--statusIndicator-background-inner-active); +} + +.outerInactive { + background-color: var(--statusIndicator-background-outer-inactive); +} + +.innerInactive { + background-color: var(--statusIndicator-background-inner-inactive); +} diff --git a/web/components/status-indicator.react.js b/web/components/status-indicator.react.js new file mode 100644 --- /dev/null +++ b/web/components/status-indicator.react.js @@ -0,0 +1,38 @@ +// @flow + +import classNames from 'classnames'; +import * as React from 'react'; + +import type { ConnectionInfo } from 'lib/types/socket-types.js'; + +import css from './status-indicator.css'; + +type Props = { + +connectionInfo: ConnectionInfo, +}; + +function StatusIndicator(props: Props): React.Node { + const { connectionInfo } = props; + + const isConnected = connectionInfo.status === 'connected'; + + const outerClassName = classNames({ + [css.indicatorOuter]: true, + [css.outerActive]: isConnected, + [css.outerInactive]: !isConnected, + }); + + const innerClassName = classNames({ + [css.indicatorInner]: true, + [css.innerActive]: isConnected, + [css.innerInactive]: !isConnected, + }); + + return ( +