Skip to content

Commit

Permalink
feat: updated the settings page design (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtechsimetka committed Oct 7, 2021
1 parent b666cd2 commit 32e5ea9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 61 deletions.
1 change: 1 addition & 0 deletions src/components/ExpandableListItemActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const useStyles = makeStyles((theme: Theme) =>
createStyles({
action: {
marginTop: theme.spacing(0.75),
marginBottom: theme.spacing(1),
marginRight: theme.spacing(1),
},
}),
Expand Down
68 changes: 7 additions & 61 deletions src/pages/settings/index.tsx
Original file line number Diff line number Diff line change
@@ -1,69 +1,15 @@
import { ReactElement, useState, useContext } from 'react'
import { makeStyles, createStyles, Theme } from '@material-ui/core/styles'
import { TextField, Typography, Button } from '@material-ui/core'
import { ReactElement, useContext } from 'react'
import { Context as SettingsContext } from '../../providers/Settings'

const useStyles = makeStyles((theme: Theme) =>
createStyles({
item: {
margin: 0,
marginTop: theme.spacing(4),
},
}),
)
import ExpandableList from '../../components/ExpandableList'
import ExpandableListItemInput from '../../components/ExpandableListItemInput'

export default function Settings(): ReactElement {
const classes = useStyles()
const { apiUrl, apiDebugUrl, setApiUrl, setDebugApiUrl } = useContext(SettingsContext)
const [host, setHost] = useState(apiUrl)
const [debugHost, setDebugHost] = useState(apiDebugUrl)

const submit = () => {
if (host !== apiUrl) setApiUrl(host)

if (debugHost !== apiDebugUrl) setDebugApiUrl(debugHost)
}

const touched = host !== apiUrl || debugHost !== apiDebugUrl

return (
<>
<Typography variant="h4" gutterBottom>
Settings
</Typography>
<TextField
label="API Endpoint"
className={classes.item}
placeholder="ex: 127.0.0.0.1:1633"
fullWidth
defaultValue={apiUrl}
margin="normal"
InputLabelProps={{
shrink: true,
}}
onChange={e => {
setHost(e.target.value)
}}
/>
<TextField
label="Debug API Endpoint"
className={classes.item}
placeholder="ex: 127.0.0.0.1:1635"
fullWidth
defaultValue={apiDebugUrl}
onChange={e => {
setDebugHost(e.target.value)
}}
margin="normal"
InputLabelProps={{
shrink: true,
}}
/>
{touched && (
<Button variant="outlined" color="primary" className={classes.item} onClick={submit}>
Save
</Button>
)}
</>
<ExpandableList label="API Settings" defaultOpen>
<ExpandableListItemInput label="Bee API" value={apiUrl} onConfirm={setApiUrl} />
<ExpandableListItemInput label="Bee Debug API" value={apiDebugUrl} onConfirm={setDebugApiUrl} />
</ExpandableList>
)
}

0 comments on commit 32e5ea9

Please sign in to comment.