refactor(front-end): add colours to main theme, add select all functionality and fix style errors

main
Josue 4 years ago
parent 809bb1bb32
commit 68765a3408
  1. 103
      striker-ui/components/Servers.tsx
  2. 1
      striker-ui/lib/consts/DEFAULT_THEME.ts

@ -24,6 +24,8 @@ import {
BLUE, BLUE,
RED, RED,
GREY, GREY,
BLACK,
PURPLE,
} from '../lib/consts/DEFAULT_THEME'; } from '../lib/consts/DEFAULT_THEME';
import { AnvilContext } from './AnvilContext'; import { AnvilContext } from './AnvilContext';
import serverState from '../lib/consts/SERVERS'; import serverState from '../lib/consts/SERVERS';
@ -66,6 +68,13 @@ const useStyles = makeStyles((theme) => ({
checkbox: { checkbox: {
paddingTop: '.8em', paddingTop: '.8em',
}, },
menuItem: {
backgroundColor: TEXT,
paddingRight: '3em',
'&:hover': {
backgroundColor: TEXT,
},
},
editButton: { editButton: {
borderRadius: 8, borderRadius: 8,
backgroundColor: GREY, backgroundColor: GREY,
@ -81,7 +90,7 @@ const useStyles = makeStyles((theme) => ({
paddingBottom: '.8em', paddingBottom: '.8em',
}, },
power: { power: {
color: 'black', color: BLACK,
}, },
on: { on: {
color: BLUE, color: BLUE,
@ -89,6 +98,10 @@ const useStyles = makeStyles((theme) => ({
off: { off: {
color: RED, color: RED,
}, },
all: {
paddingTop: '.5em',
paddingLeft: '.3em',
},
})); }));
const selectDecorator = (state: string): Colours => { const selectDecorator = (state: string): Colours => {
@ -107,6 +120,7 @@ const selectDecorator = (state: string): Colours => {
const Servers = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => { const Servers = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => {
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null); const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
const [showCheckbox, setShowCheckbox] = useState<boolean>(false); const [showCheckbox, setShowCheckbox] = useState<boolean>(false);
const [allSelected, setAllSelected] = useState<boolean>(false);
const [selected, setSelected] = useState<string[]>([]); const [selected, setSelected] = useState<string[]>([]);
const { uuid } = useContext(AnvilContext); const { uuid } = useContext(AnvilContext);
const classes = useStyles(); const classes = useStyles();
@ -145,7 +159,7 @@ const Servers = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => {
<Box className={classes.editButtonBox}> <Box className={classes.editButtonBox}>
<IconButton <IconButton
className={classes.editButton} className={classes.editButton}
style={{ color: showCheckbox ? RED : 'black' }} style={{ color: showCheckbox ? PURPLE : BLACK }}
onClick={() => setShowCheckbox(!showCheckbox)} onClick={() => setShowCheckbox(!showCheckbox)}
> >
<EditIcon /> <EditIcon />
@ -153,41 +167,62 @@ const Servers = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => {
</Box> </Box>
</Box> </Box>
{showCheckbox && ( {showCheckbox && (
<Box className={classes.headerPadding} display="flex"> <>
<Box flexGrow={1} className={classes.dropdown}> <Box className={classes.headerPadding} display="flex">
<Button <Box flexGrow={1} className={classes.dropdown}>
variant="contained" <Button
style={{ backgroundColor: GREY }} variant="contained"
startIcon={<MoreVertIcon />} startIcon={<MoreVertIcon />}
onClick={handleClick} onClick={handleClick}
>
<Typography className={classes.power} variant="subtitle1">
Power
</Typography>
</Button>
<Menu
id="simple-menu"
anchorEl={anchorEl}
keepMounted
open={Boolean(anchorEl)}
onClose={handleClose}
>
<MenuItem
onClick={handleClose}
style={{ backgroundColor: TEXT, paddingRight: '3em' }}
> >
<Typography className={classes.on} variant="subtitle1"> <Typography className={classes.power} variant="subtitle1">
On Power
</Typography> </Typography>
</MenuItem> </Button>
<MenuItem onClick={handleClose} style={{ backgroundColor: TEXT }}> <Menu
<Typography className={classes.off} variant="subtitle1"> id="simple-menu"
Off anchorEl={anchorEl}
</Typography> keepMounted
</MenuItem> open={Boolean(anchorEl)}
</Menu> onClose={handleClose}
>
<MenuItem onClick={handleClose} className={classes.menuItem}>
<Typography className={classes.on} variant="subtitle1">
On
</Typography>
</MenuItem>
<MenuItem onClick={handleClose} className={classes.menuItem}>
<Typography className={classes.off} variant="subtitle1">
Off
</Typography>
</MenuItem>
</Menu>
</Box>
</Box> </Box>
</Box> <Box className={classes.headerPadding} display="flex">
<Box>
<Checkbox
style={{ color: TEXT }}
color="secondary"
checked={allSelected}
onChange={() => {
if (!allSelected)
setSelected(
data.servers.map(
(server: AnvilServer) => server.server_uuid,
),
);
else setSelected([]);
setAllSelected(!allSelected);
}}
/>
</Box>
<Box className={classes.all}>
<BodyText text="All" />
</Box>
</Box>
</>
)} )}
{!isLoading ? ( {!isLoading ? (
<Box className={classes.root}> <Box className={classes.root}>

@ -12,5 +12,6 @@ export const UNSELECTED = '#666';
export const DIVIDER = '#888'; export const DIVIDER = '#888';
export const SELECTED_ANVIL = '#00ff00'; export const SELECTED_ANVIL = '#00ff00';
export const DISABLED = '#AAA'; export const DISABLED = '#AAA';
export const BLACK = '#343434';
export const BORDER_RADIUS = '3px'; export const BORDER_RADIUS = '3px';

Loading…
Cancel
Save