Skip to content

Commit e940fdf

Browse files
committed
feat(neuron-ui): add the story of connection status component, and set the network name to 14px
1 parent 66ac2b1 commit e940fdf

5 files changed

Lines changed: 122 additions & 73 deletions

File tree

packages/neuron-ui/src/containers/Footer/index.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,16 @@ export const NetworkStatus = ({ name, online }: { name: string; online: boolean
5757
iconName={online ? 'Connected' : 'Disconnected'}
5858
styles={{ root: { display: 'flex', alignItems: 'center' } }}
5959
/>
60-
<Text styles={{ root: [theme.fonts.small] }}>{name}</Text>
60+
<Text
61+
styles={{
62+
root: {
63+
fontSize: '14px',
64+
lineHeight: '14px',
65+
},
66+
}}
67+
>
68+
{name}
69+
</Text>
6170
</Stack>
6271
)
6372
}

packages/neuron-ui/src/index.tsx

Lines changed: 1 addition & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,10 @@
11
import React from 'react'
22
import ReactDOM from 'react-dom'
33
import { HashRouter as Router, Route } from 'react-router-dom'
4-
import { loadTheme, getTheme } from 'office-ui-fabric-react'
5-
import {
6-
AddCircle as AddIcon,
7-
Alert as AlertIcon,
8-
Checkmark as SuccessIcon,
9-
Close as DismissIcon,
10-
Copy as CopyIcon,
11-
Down as ArrowDownIcon,
12-
FormClose as ClearIcon,
13-
FormAdd as CreateIcon,
14-
FormPreviousLink as LeaveIcon,
15-
FormUp as ExpandIcon,
16-
FormUpload as ImportIcon,
17-
LinkBottom as LinkBottomIcon,
18-
LinkDown as LinkDownIcon,
19-
LinkTop as LinkTopIcon,
20-
LinkUp as LinkUpIcon,
21-
Nodes as ConnectedIcon,
22-
Scan as ScanIcon,
23-
Search as SearchIcon,
24-
SubtractCircle as RemoveIcon,
25-
Update as UpdateIcon,
26-
} from 'grommet-icons'
274

285
import 'styles/index.scss'
296
import 'utils/i18n'
7+
import 'utils/loadTheme'
308
import * as serviceWorker from 'serviceWorker'
319

3210
import Navbar from 'containers/Navbar'
@@ -35,53 +13,6 @@ import Main from 'containers/Main'
3513
import Footer from 'containers/Footer'
3614
import ErrorBoundary from 'components/ErrorBoundary'
3715
import withProviders from 'states/stateProvider'
38-
import { registerIcons } from 'utils/icons'
39-
40-
loadTheme({
41-
fonts: {
42-
tiny: { fontSize: '11px' },
43-
xSmall: { fontSize: '12px' },
44-
small: { fontSize: '14px' },
45-
smallPlus: { fontSize: '15px' },
46-
medium: { fontSize: '16px' },
47-
mediumPlus: { fontSize: '17px' },
48-
large: { fontSize: '18px' },
49-
xLarge: { fontSize: '22px' },
50-
xxLarge: { fontSize: '28px' },
51-
superLarge: { fontSize: '42px' },
52-
mega: { fontSize: '72px' },
53-
},
54-
})
55-
56-
const theme = getTheme()
57-
const { semanticColors } = theme
58-
59-
registerIcons({
60-
icons: {
61-
errorbadge: <AlertIcon size="16px" />,
62-
completed: <SuccessIcon size="16px" />,
63-
MiniCopy: <CopyIcon size="small" />,
64-
Search: <SearchIcon size="16px" color={semanticColors.menuIcon} />,
65-
FirstPage: <LinkTopIcon size="16px" color={semanticColors.menuIcon} style={{ transform: 'rotate(-90deg)' }} />,
66-
LastPage: <LinkBottomIcon size="16px" color={semanticColors.menuIcon} style={{ transform: 'rotate(-90deg)' }} />,
67-
PrevPage: <LinkUpIcon size="16px" color={semanticColors.menuIcon} style={{ transform: 'rotate(-90deg)' }} />,
68-
NextPage: <LinkDownIcon size="16px" color={semanticColors.menuIcon} style={{ transform: 'rotate(-90deg)' }} />,
69-
ArrowDown: <ArrowDownIcon size="small" />,
70-
ChevronRightMed: <ExpandIcon size="16px" style={{ transform: 'rotate(90deg) translate(2px, 0px)' }} />,
71-
Scan: <ScanIcon />,
72-
Import: <ImportIcon color="white" />,
73-
Create: <CreateIcon />,
74-
Add: <AddIcon />,
75-
Remove: <RemoveIcon color="red" />,
76-
Copy: <CopyIcon />,
77-
Clear: <ClearIcon size="16px" />,
78-
Dismiss: <DismissIcon size="16px" />,
79-
Leave: <LeaveIcon />,
80-
Connected: <ConnectedIcon size="small" color="green" />,
81-
Disconnected: <AlertIcon size="small" color="red" />,
82-
Updating: <UpdateIcon size="16px" style={{ animation: 'rotate360 3s linear infinite' }} />,
83-
},
84-
})
8516

8617
export const containers: CustomRouter.Route[] = [
8718
{
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import React from 'react'
2+
import { storiesOf } from '@storybook/react'
3+
import { withKnobs, text, boolean } from '@storybook/addon-knobs'
4+
import { NetworkStatus } from 'containers/Footer'
5+
6+
const states = {
7+
Online: {
8+
name: 'network name',
9+
online: true,
10+
},
11+
Offline: {
12+
name: 'network',
13+
online: false,
14+
},
15+
}
16+
17+
const stories = storiesOf('Connection Status', module).addDecorator(withKnobs)
18+
19+
Object.entries(states).forEach(([title, props]) => {
20+
stories.add(title, () => {
21+
return <NetworkStatus {...props} />
22+
})
23+
})
24+
25+
stories.add('With knobs', () => {
26+
const props = {
27+
name: text('Network name', 'network name'),
28+
online: boolean('online', false),
29+
}
30+
return <NetworkStatus {...props} />
31+
})

packages/neuron-ui/src/stories/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import 'styles/index.scss'
2+
import './styles.scss'
3+
import 'utils/i18n'
4+
import 'utils/loadTheme'
15
import './Overview.stories'
26
import './Addresses.stories'
37
import './History.stories'
@@ -9,5 +13,4 @@ import './NetworkSetting.stories'
913
import './PasswordRequest.stories'
1014
import './TransactionFeePanel.stories'
1115
import './SyncStatus.stories'
12-
import 'styles/index.scss'
13-
import './styles.scss'
16+
import './NetworkStatus.stories'
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import React from 'react'
2+
import { loadTheme, getTheme } from 'office-ui-fabric-react'
3+
4+
import {
5+
AddCircle as AddIcon,
6+
Alert as AlertIcon,
7+
Checkmark as SuccessIcon,
8+
Close as DismissIcon,
9+
Copy as CopyIcon,
10+
Down as ArrowDownIcon,
11+
FormClose as ClearIcon,
12+
FormAdd as CreateIcon,
13+
FormPreviousLink as LeaveIcon,
14+
FormUp as ExpandIcon,
15+
FormUpload as ImportIcon,
16+
LinkBottom as LinkBottomIcon,
17+
LinkDown as LinkDownIcon,
18+
LinkTop as LinkTopIcon,
19+
LinkUp as LinkUpIcon,
20+
Nodes as ConnectedIcon,
21+
Scan as ScanIcon,
22+
Search as SearchIcon,
23+
SubtractCircle as RemoveIcon,
24+
Update as UpdateIcon,
25+
} from 'grommet-icons'
26+
27+
import { registerIcons } from 'utils/icons'
28+
29+
loadTheme({
30+
fonts: {
31+
tiny: { fontSize: '11px' },
32+
xSmall: { fontSize: '12px' },
33+
small: { fontSize: '14px' },
34+
smallPlus: { fontSize: '15px' },
35+
medium: { fontSize: '16px' },
36+
mediumPlus: { fontSize: '17px' },
37+
large: { fontSize: '18px' },
38+
xLarge: { fontSize: '22px' },
39+
xxLarge: { fontSize: '28px' },
40+
superLarge: { fontSize: '42px' },
41+
mega: { fontSize: '72px' },
42+
},
43+
})
44+
45+
const theme = getTheme()
46+
const { semanticColors } = theme
47+
48+
registerIcons({
49+
icons: {
50+
errorbadge: <AlertIcon size="16px" />,
51+
completed: <SuccessIcon size="16px" />,
52+
MiniCopy: <CopyIcon size="small" />,
53+
Search: <SearchIcon size="16px" color={semanticColors.menuIcon} />,
54+
FirstPage: <LinkTopIcon size="16px" color={semanticColors.menuIcon} style={{ transform: 'rotate(-90deg)' }} />,
55+
LastPage: <LinkBottomIcon size="16px" color={semanticColors.menuIcon} style={{ transform: 'rotate(-90deg)' }} />,
56+
PrevPage: <LinkUpIcon size="16px" color={semanticColors.menuIcon} style={{ transform: 'rotate(-90deg)' }} />,
57+
NextPage: <LinkDownIcon size="16px" color={semanticColors.menuIcon} style={{ transform: 'rotate(-90deg)' }} />,
58+
ArrowDown: <ArrowDownIcon size="small" />,
59+
ChevronRightMed: <ExpandIcon size="16px" style={{ transform: 'rotate(90deg) translate(2px, 0px)' }} />,
60+
Scan: <ScanIcon />,
61+
Import: <ImportIcon color="white" />,
62+
Create: <CreateIcon />,
63+
Add: <AddIcon />,
64+
Remove: <RemoveIcon color="red" />,
65+
Copy: <CopyIcon />,
66+
Clear: <ClearIcon size="16px" />,
67+
Dismiss: <DismissIcon size="16px" />,
68+
Leave: <LeaveIcon />,
69+
Connected: <ConnectedIcon size="small" color="green" />,
70+
Disconnected: <AlertIcon size="small" color="red" />,
71+
Updating: <UpdateIcon size="16px" style={{ animation: 'rotate360 3s linear infinite' }} />,
72+
},
73+
})
74+
75+
export default undefined

0 commit comments

Comments
 (0)