Skip to content

Commit dc8e892

Browse files
authored
Merge pull request #247 from coderoad/ui/error-view
clean up error ui view
2 parents d68f702 + d18d3cf commit dc8e892

File tree

3 files changed

+54
-10
lines changed

3 files changed

+54
-10
lines changed

web-app/src/components/Button/index.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ interface Props {
99
onClick?: () => void
1010
size?: 'small' | 'medium' | 'large'
1111
iconSize?: 'xxs' | 'xs' | 'small' | 'medium' | 'large' | 'xl' | 'xxl' | 'xxxl'
12+
warning?: boolean
1213
}
1314

1415
const Button = (props: Props) => (
@@ -19,6 +20,7 @@ const Button = (props: Props) => (
1920
style={props.style}
2021
size={props.size}
2122
iconSize={props.iconSize}
23+
warning={props.warning}
2224
>
2325
{props.children}
2426
</AlifdButton>

web-app/src/components/Error/index.tsx

+32-10
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,28 @@ import Button from '../../components/Button'
77

88
const styles = {
99
container: {
10-
color: '#D8000C',
11-
backgroundColor: '#FFBABA',
10+
display: 'flex' as 'flex',
11+
flexDirection: 'column' as 'column',
12+
justifyContent: 'center' as 'center',
13+
alignItems: 'center' as 'center',
14+
border: '0.5rem solid #FFBABA',
1215
padding: '1rem',
1316
width: '100%',
1417
height: '100%',
1518
},
19+
content: {
20+
textAlign: 'center' as 'center',
21+
color: 'rgb(40, 40, 40);',
22+
},
23+
options: {
24+
display: 'flex' as 'flex',
25+
flexDirection: 'column' as 'column',
26+
alignItems: 'center',
27+
},
28+
button: {
29+
margin: '0.5rem',
30+
width: '10rem',
31+
},
1632
}
1733

1834
interface Props {
@@ -34,15 +50,21 @@ const ErrorMarkdown = ({ error, send }: Props) => {
3450

3551
return (
3652
<div css={styles.container}>
37-
<h1>Error</h1>
38-
<Markdown>{error.message}</Markdown>
53+
<h1>Oops!</h1>
54+
<div css={styles.content}>
55+
<Markdown>{error.message}</Markdown>
56+
</div>
57+
<br />
58+
<br />
3959
{/* Actions */}
40-
{error.actions &&
41-
error.actions.map((a) => (
42-
<Button type="secondary" onClick={() => send({ type: a.transition })}>
43-
{a.label}
44-
</Button>
45-
))}
60+
<div css={styles.options}>
61+
{error.actions &&
62+
error.actions.map((a) => (
63+
<Button type="normal" warning style={styles.button} onClick={() => send({ type: a.transition })}>
64+
{a.label}
65+
</Button>
66+
))}
67+
</div>
4668
</div>
4769
)
4870
}

web-app/stories/Error.stories.tsx

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import * as E from '../../typings/error'
2+
import { action } from '@storybook/addon-actions'
3+
import { storiesOf } from '@storybook/react'
4+
import React from 'react'
5+
import ErrorView from '../src/components/Error'
6+
import SideBarDecorator from './utils/SideBarDecorator'
7+
8+
storiesOf('Error', module)
9+
.addDecorator(SideBarDecorator)
10+
.add('Error', () => {
11+
const error: E.ErrorMessage = {
12+
type: 'UnknownError',
13+
message: '### Message summary\n\nSome message about what went wrong under here',
14+
actions: [
15+
{ label: 'First', transition: 'FIRST' },
16+
{ label: 'Second', transition: 'SECOND' },
17+
],
18+
}
19+
return <ErrorView error={error} send={action('send')} />
20+
})

0 commit comments

Comments
 (0)