Skip to content

Commit 8d929a3

Browse files
committed
feat(neuron-ui): add a settings icon in the navbar component
1 parent a12b582 commit 8d929a3

2 files changed

Lines changed: 40 additions & 24 deletions

File tree

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

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useMemo } from 'react'
22
import { createPortal } from 'react-dom'
33
import { RouteComponentProps } from 'react-router-dom'
4-
import { Pivot, PivotItem, PivotLinkFormat, PivotLinkSize, getTheme } from 'office-ui-fabric-react'
4+
import { Stack, Pivot, PivotItem, PivotLinkFormat, PivotLinkSize, IconButton, getTheme } from 'office-ui-fabric-react'
55
import { useTranslation } from 'react-i18next'
66
import { useState } from 'states/stateProvider'
77
import { StateWithDispatch } from 'states/stateProvider/reducer'
@@ -63,30 +63,44 @@ const Navbar = ({
6363
}
6464

6565
return (
66-
<Pivot
67-
selectedKey={selectedKey}
68-
onLinkClick={(pivotItem?: PivotItem) => {
69-
if (pivotItem && pivotItem.props) {
70-
const linkDesc = Object.getOwnPropertyDescriptor(pivotItem.props, 'data-link')
71-
if (linkDesc && typeof linkDesc.value === 'string') {
72-
history.push(linkDesc.value)
66+
<Stack horizontal horizontalAlign="space-between" verticalAlign="stretch">
67+
<Pivot
68+
selectedKey={selectedKey}
69+
onLinkClick={(pivotItem?: PivotItem) => {
70+
if (pivotItem && pivotItem.props) {
71+
const linkDesc = Object.getOwnPropertyDescriptor(pivotItem.props, 'data-link')
72+
if (linkDesc && typeof linkDesc.value === 'string') {
73+
history.push(linkDesc.value)
74+
}
7375
}
74-
}
75-
}}
76-
headersOnly
77-
linkFormat={PivotLinkFormat.tabs}
78-
linkSize={PivotLinkSize.large}
79-
styles={styles}
80-
>
81-
{pivotItems.map(pivotItem => (
82-
<PivotItem
83-
headerText={t(pivotItem.name)}
84-
itemKey={pivotItem.key}
85-
key={pivotItem.key}
86-
data-link={pivotItem.url}
87-
/>
88-
))}
89-
</Pivot>
76+
}}
77+
headersOnly
78+
linkFormat={PivotLinkFormat.tabs}
79+
linkSize={PivotLinkSize.large}
80+
styles={styles}
81+
>
82+
{pivotItems.map(pivotItem => (
83+
<PivotItem
84+
headerText={t(pivotItem.name)}
85+
itemKey={pivotItem.key}
86+
key={pivotItem.key}
87+
data-link={pivotItem.url}
88+
/>
89+
))}
90+
</Pivot>
91+
<IconButton
92+
iconProps={{ iconName: 'Settings' }}
93+
onClick={() => history.push(Routes.SettingsGeneral)}
94+
styles={{
95+
root: {
96+
height: 'auto',
97+
},
98+
icon: {
99+
height: '20px',
100+
},
101+
}}
102+
/>
103+
</Stack>
90104
)
91105
}
92106

packages/neuron-ui/src/theme.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
Nodes as ConnectedIcon,
2626
Scan as ScanIcon,
2727
Search as SearchIcon,
28+
SettingsOption as SettingsIcon,
2829
StatusGood as MatchedIcon,
2930
SubtractCircle as RemoveIcon,
3031
Update as UpdateIcon,
@@ -87,6 +88,7 @@ registerIcons({
8788
TransactionPending: <PendingIcon size="14px" style={{ animation: 'rotate360 3s linear infinite' }} />,
8889
Keystore: <KeystoreIcon color="white" style={{ transform: 'scale(0.6)' }} />,
8990
Edit: <EditIcon color="#000" size="20px" />,
91+
Settings: <SettingsIcon size="20px" />,
9092
},
9193
})
9294

0 commit comments

Comments
 (0)