Browse Source

Cleaner design for error desc on device interaction

master
meriadec 7 years ago
parent
commit
32c691d3c2
No known key found for this signature in database GPG Key ID: 1D2FC2305E2CB399
  1. 50
      src/components/DeviceInteraction/components.js
  2. 12
      src/components/DeviceInteraction/index.js

50
src/components/DeviceInteraction/components.js

@ -2,17 +2,17 @@
import React from 'react' import React from 'react'
import styled from 'styled-components' import styled from 'styled-components'
import Tooltip from 'components/base/Tooltip'
import { radii, colors } from 'styles/theme' import { radii } from 'styles/theme'
import { rgba } from 'styles/helpers' import { rgba } from 'styles/helpers'
import TranslatedError from 'components/TranslatedError' import TranslatedError from 'components/TranslatedError'
import Box from 'components/base/Box' import Box from 'components/base/Box'
import FakeLink from 'components/base/FakeLink'
import Spinner from 'components/base/Spinner' import Spinner from 'components/base/Spinner'
import IconCheck from 'icons/Check' import IconCheck from 'icons/Check'
import IconCross from 'icons/Cross' import IconCross from 'icons/Cross'
import IconRecover from 'icons/Recover' import IconExclamationCircle from 'icons/ExclamationCircle'
export const DeviceInteractionStepContainer = styled(Box).attrs({ export const DeviceInteractionStepContainer = styled(Box).attrs({
horizontal: true, horizontal: true,
@ -92,25 +92,6 @@ export const ErrorContainer = ({ isVisible }: { isVisible: boolean }) => (
</ErrorContainerWrapper> </ErrorContainerWrapper>
) )
const ErrorRetryContainer = styled(Box).attrs({
bg: rgba(colors.alertRed, 0.1),
borderRadius: 1,
grow: 1,
color: 'alertRed',
cursor: 'pointer',
p: 1,
align: 'center',
justify: 'center',
overflow: 'hidden',
})`
&:hover {
background-color: ${() => rgba(colors.alertRed, 0.1)};
}
&:active {
background-color: ${() => rgba(colors.alertRed, 0.15)};
}
`
export const ErrorDescContainer = ({ export const ErrorDescContainer = ({
error, error,
onRetry, onRetry,
@ -119,26 +100,13 @@ export const ErrorDescContainer = ({
error: Error, error: Error,
onRetry: void => void, onRetry: void => void,
}) => ( }) => (
<Box <Box horizontal fontSize={3} color="alertRed" align="center" cursor="text" {...p}>
pl={0} <IconExclamationCircle size={16} />
fontSize={3} <Box ml={1}>
color="alertRed"
align="flex-start"
justify="center"
style={{
cursor: 'text',
}}
{...p}
>
<Box horizontal>
<Box p={1} pl={2}>
<TranslatedError error={error} /> <TranslatedError error={error} />
</Box> </Box>
<Tooltip render={() => 'Retry'} style={{ display: 'flex', alignItems: 'center' }}> <FakeLink ml={1} underline color="alertRed" onClick={onRetry}>
<ErrorRetryContainer onClick={onRetry}> {'Retry'}
<IconRecover size={12} /> </FakeLink>
</ErrorRetryContainer>
</Tooltip>
</Box>
</Box> </Box>
) )

12
src/components/DeviceInteraction/index.js

@ -5,14 +5,11 @@ import React, { PureComponent } from 'react'
import { delay } from 'helpers/promise' import { delay } from 'helpers/promise'
import Box from 'components/base/Box' import Box from 'components/base/Box'
import Space from 'components/base/Space'
import DeviceInteractionStep from './DeviceInteractionStep' import DeviceInteractionStep from './DeviceInteractionStep'
import { ErrorDescContainer } from './components'
import type { Step } from './DeviceInteractionStep' import type { Step } from './DeviceInteractionStep'
import { ErrorDescContainer } from './components'
type Props = { type Props = {
steps: Step[], steps: Step[],
onSuccess?: any => void, onSuccess?: any => void,
@ -109,12 +106,7 @@ class DeviceInteraction extends PureComponent<Props, State> {
) )
})} })}
{error && {error &&
shouldRenderRetry && ( shouldRenderRetry && <ErrorDescContainer error={error} onRetry={this.reset} mt={2} />}
<Box align="flex-end">
<Space of={0} />
<ErrorDescContainer error={error} onRetry={this.reset} mt={2} />
</Box>
)}
</Box> </Box>
) )
} }

Loading…
Cancel
Save