From 1b336e2e80f9a0732fe751dcba77e47a113d46eb Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 11 Jun 2019 20:27:02 +0200 Subject: [PATCH] version number fixes * add loading state * add error state * handle connection errors * backwards compatibility for all components * small spinner variant --- .../src/components/atoms/Spinner.module.scss | 14 ++ client/src/components/atoms/Spinner.tsx | 32 +++-- .../VersionNumbers/VersionTable.module.scss | 5 + .../atoms/VersionNumbers/VersionTable.tsx | 58 +++++--- .../components/atoms/VersionNumbers/index.tsx | 131 ++++++++++++------ library.json | 4 +- 6 files changed, 171 insertions(+), 73 deletions(-) diff --git a/client/src/components/atoms/Spinner.module.scss b/client/src/components/atoms/Spinner.module.scss index 2fd9507..22e4117 100644 --- a/client/src/components/atoms/Spinner.module.scss +++ b/client/src/components/atoms/Spinner.module.scss @@ -29,6 +29,20 @@ padding-top: $spacer / 4; } +.small { + composes: spinner; + margin: 0; + display: inline-block; + + &:before { + width: $font-size-small; + height: $font-size-small; + margin-top: -($font-size-small); + margin-left: -($font-size-small / 2); + border-width: .1rem; + } +} + @keyframes spinner { to { transform: rotate(360deg); diff --git a/client/src/components/atoms/Spinner.tsx b/client/src/components/atoms/Spinner.tsx index 0759275..b8013f3 100644 --- a/client/src/components/atoms/Spinner.tsx +++ b/client/src/components/atoms/Spinner.tsx @@ -1,15 +1,27 @@ import React from 'react' import styles from './Spinner.module.scss' -const Spinner = ({ message }: { message?: string }) => ( -
- {message && ( -
- )} -
-) +const Spinner = ({ + message, + small, + className +}: { + message?: string + small?: boolean + className?: string +}) => { + const classes = className || (small ? styles.small : styles.spinner) + + return ( +
+ {message && ( +
+ )} +
+ ) +} export default Spinner diff --git a/client/src/components/atoms/VersionNumbers/VersionTable.module.scss b/client/src/components/atoms/VersionNumbers/VersionTable.module.scss index 23e31f2..06f9b2e 100644 --- a/client/src/components/atoms/VersionNumbers/VersionTable.module.scss +++ b/client/src/components/atoms/VersionNumbers/VersionTable.module.scss @@ -52,3 +52,8 @@ } } } + +.spinner { + composes: spinner, small from '../Spinner.module.scss'; + margin-right: $spacer; +} diff --git a/client/src/components/atoms/VersionNumbers/VersionTable.tsx b/client/src/components/atoms/VersionNumbers/VersionTable.tsx index 4533fa0..fcab197 100644 --- a/client/src/components/atoms/VersionNumbers/VersionTable.tsx +++ b/client/src/components/atoms/VersionNumbers/VersionTable.tsx @@ -2,6 +2,7 @@ import React, { Fragment } from 'react' import { VersionNumbersState as VersionTableProps } from '.' import styles from './VersionTable.module.scss' import slugify from '@sindresorhus/slugify' +import Spinner from '../Spinner' const VersionTableContracts = ({ contracts, @@ -12,23 +13,24 @@ const VersionTableContracts = ({ }) => ( - {Object.keys(contracts).map(key => ( - - - - - ))} + {contracts && + Object.keys(contracts).map(key => ( + + + + + ))}
- {key} - - - {contracts[key]} - -
+ {key} + + + {contracts[key]} + +
) @@ -42,18 +44,30 @@ const VersionTable = ({ data }: { data: VersionTableProps }) => ( {value.software} - v{value.version} + {value.isLoading ? ( + + ) : value.version ? ( + <> + v{value.version} + {value.network && `(${value.network})`} + + ) : ( + 'Could not get version' + )} - {key === 'keeperContracts' && ( + {key === 'keeperContracts' && data.brizo.contracts && ( - v{commons.version} ({brizo.network}) + v{commons.version} {brizo.network && `(${brizo.network})`}

) : ( diff --git a/library.json b/library.json index 1eadf34..653a471 100644 --- a/library.json +++ b/library.json @@ -11,7 +11,7 @@ }, { "name": "brizo", - "version": "~0.3.6" + "version": "~0.3.9" }, { "name": "aquarius", @@ -23,7 +23,7 @@ }, { "name": "faucet", - "version": "~0.2.0" + "version": "~0.2.4" } ] }