From 6e2b787ad356298ca3645b47933f2660ea9d51c1 Mon Sep 17 00:00:00 2001 From: Josue Date: Thu, 24 Jun 2021 12:28:58 -0400 Subject: [PATCH] refactor(front-end): add colours to main theme, add select all functionality and fix style errors --- striker-ui/components/Servers.tsx | 103 +++++++++++++++++-------- striker-ui/lib/consts/DEFAULT_THEME.ts | 1 + 2 files changed, 70 insertions(+), 34 deletions(-) diff --git a/striker-ui/components/Servers.tsx b/striker-ui/components/Servers.tsx index 530bd617..9a525e19 100644 --- a/striker-ui/components/Servers.tsx +++ b/striker-ui/components/Servers.tsx @@ -24,6 +24,8 @@ import { BLUE, RED, GREY, + BLACK, + PURPLE, } from '../lib/consts/DEFAULT_THEME'; import { AnvilContext } from './AnvilContext'; import serverState from '../lib/consts/SERVERS'; @@ -66,6 +68,13 @@ const useStyles = makeStyles((theme) => ({ checkbox: { paddingTop: '.8em', }, + menuItem: { + backgroundColor: TEXT, + paddingRight: '3em', + '&:hover': { + backgroundColor: TEXT, + }, + }, editButton: { borderRadius: 8, backgroundColor: GREY, @@ -81,7 +90,7 @@ const useStyles = makeStyles((theme) => ({ paddingBottom: '.8em', }, power: { - color: 'black', + color: BLACK, }, on: { color: BLUE, @@ -89,6 +98,10 @@ const useStyles = makeStyles((theme) => ({ off: { color: RED, }, + all: { + paddingTop: '.5em', + paddingLeft: '.3em', + }, })); const selectDecorator = (state: string): Colours => { @@ -107,6 +120,7 @@ const selectDecorator = (state: string): Colours => { const Servers = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => { const [anchorEl, setAnchorEl] = useState(null); const [showCheckbox, setShowCheckbox] = useState(false); + const [allSelected, setAllSelected] = useState(false); const [selected, setSelected] = useState([]); const { uuid } = useContext(AnvilContext); const classes = useStyles(); @@ -145,7 +159,7 @@ const Servers = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => { setShowCheckbox(!showCheckbox)} > @@ -153,41 +167,62 @@ const Servers = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => { {showCheckbox && ( - - - - - + + + + + + + + On + + + + + Off + + + + - + + + { + if (!allSelected) + setSelected( + data.servers.map( + (server: AnvilServer) => server.server_uuid, + ), + ); + else setSelected([]); + + setAllSelected(!allSelected); + }} + /> + + + + + + )} {!isLoading ? ( diff --git a/striker-ui/lib/consts/DEFAULT_THEME.ts b/striker-ui/lib/consts/DEFAULT_THEME.ts index 820fbc23..2419d4ce 100644 --- a/striker-ui/lib/consts/DEFAULT_THEME.ts +++ b/striker-ui/lib/consts/DEFAULT_THEME.ts @@ -12,5 +12,6 @@ export const UNSELECTED = '#666'; export const DIVIDER = '#888'; export const SELECTED_ANVIL = '#00ff00'; export const DISABLED = '#AAA'; +export const BLACK = '#343434'; export const BORDER_RADIUS = '3px';