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

main
Josue 4 years ago committed by Digimer
parent cd3773f7e0
commit 6e2b787ad3
  1. 51
      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,11 +167,11 @@ const Servers = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => {
</Box> </Box>
</Box> </Box>
{showCheckbox && ( {showCheckbox && (
<>
<Box className={classes.headerPadding} display="flex"> <Box className={classes.headerPadding} display="flex">
<Box flexGrow={1} className={classes.dropdown}> <Box flexGrow={1} className={classes.dropdown}>
<Button <Button
variant="contained" variant="contained"
style={{ backgroundColor: GREY }}
startIcon={<MoreVertIcon />} startIcon={<MoreVertIcon />}
onClick={handleClick} onClick={handleClick}
> >
@ -172,15 +186,12 @@ const Servers = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => {
open={Boolean(anchorEl)} open={Boolean(anchorEl)}
onClose={handleClose} onClose={handleClose}
> >
<MenuItem <MenuItem onClick={handleClose} className={classes.menuItem}>
onClick={handleClose}
style={{ backgroundColor: TEXT, paddingRight: '3em' }}
>
<Typography className={classes.on} variant="subtitle1"> <Typography className={classes.on} variant="subtitle1">
On On
</Typography> </Typography>
</MenuItem> </MenuItem>
<MenuItem onClick={handleClose} style={{ backgroundColor: TEXT }}> <MenuItem onClick={handleClose} className={classes.menuItem}>
<Typography className={classes.off} variant="subtitle1"> <Typography className={classes.off} variant="subtitle1">
Off Off
</Typography> </Typography>
@ -188,6 +199,30 @@ const Servers = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => {
</Menu> </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