Improve addons display

This commit is contained in:
Corey 2024-05-12 03:26:02 -04:00
parent b8ebc61213
commit 98fa1cef7a
Signed by: coco
GPG Key ID: 051138DA6AEE3E60
2 changed files with 53 additions and 61 deletions

View File

@ -1,12 +1,4 @@
import { AddCircleTwoTone } from '@mui/icons-material'; import { Box, ToggleButton, ToggleButtonGroup, Tooltip } from '@mui/material';
import {
Box,
IconButton,
ToggleButton,
ToggleButtonGroup,
Tooltip,
useTheme,
} from '@mui/material';
import { ServerData } from '../../data/ServerData'; import { ServerData } from '../../data/ServerData';
const expansionButtons = [ const expansionButtons = [
@ -61,12 +53,9 @@ type ExpansionBarProps = { server: ServerData };
export default function ExpansionBar({ server }: ExpansionBarProps) { export default function ExpansionBar({ server }: ExpansionBarProps) {
const { expansions } = server; const { expansions } = server;
const theme = useTheme();
const addons = ['acp', 'amk', 'asa', 'abyssea', 'voidwatch', 'rov', 'tvr']; const addons = ['acp', 'amk', 'asa', 'abyssea', 'voidwatch', 'rov', 'tvr'];
let enabledAddons = addons.filter((prop) => expansions[prop]); let enabledAddons = addons.filter((prop) => expansions[prop]);
enabledAddons = enabledAddons.map((prop) => { enabledAddons = enabledAddons.map((prop) => {
if (prop === 'abyssea' || prop === 'voidwatch') { if (prop === 'abyssea' || prop === 'voidwatch') {
return prop.charAt(0).toUpperCase() + prop.slice(1); return prop.charAt(0).toUpperCase() + prop.slice(1);
@ -76,6 +65,18 @@ export default function ExpansionBar({ server }: ExpansionBarProps) {
return ( return (
<Box className="my-1 flex items-center"> <Box className="my-1 flex items-center">
<Tooltip
title={
enabledAddons.length !== 0 && (
<div style={{ whiteSpace: 'pre-line' }}>
{enabledAddons.join('\n')}
</div>
)
}
placement="right"
disableInteractive
arrow
>
<ToggleButtonGroup <ToggleButtonGroup
size="small" size="small"
value={ value={
@ -85,33 +86,25 @@ export default function ExpansionBar({ server }: ExpansionBarProps) {
expansions.toau && 'toau', expansions.toau && 'toau',
expansions.wotg && 'wotg', expansions.wotg && 'wotg',
expansions.soa && 'soa', expansions.soa && 'soa',
enabledAddons.length !== 0 && 'addons',
] ]
} }
sx={{ '& button': { maxHeight: '1rem' } }} sx={{ '& button': { maxHeight: '1rem' } }}
> >
{expansionButtons} {expansionButtons}
</ToggleButtonGroup>
{enabledAddons.length !== 0 && ( {enabledAddons.length !== 0 && (
<Tooltip <ToggleButton
title={ key="addons"
<div style={{ whiteSpace: 'pre-line' }}> value="addons"
{enabledAddons.join('\n')} aria-label="addons-enabled"
</div> className="py-0"
} disabled
placement="right"
disableInteractive
arrow
> >
<IconButton className="p-0" disableRipple> +
<AddCircleTwoTone </ToggleButton>
style={{
maxHeight: '1rem',
color: theme.palette.text.primary,
}}
/>
</IconButton>
</Tooltip>
)} )}
</ToggleButtonGroup>
</Tooltip>
</Box> </Box>
); );
} }

View File

@ -144,24 +144,6 @@ MAIN.ENABLE_TVR`;
http://play.myserver.com/api/). http://play.myserver.com/api/).
</Typography> </Typography>
</Box> </Box>
<Box className="mb-3">
<Typography align="center" variant="h6">
What if my server isn&apos;t running LSB?
</Typography>
<Typography
component="p"
variant="body1"
color={(theme) => alpha(theme.palette.text.primary, 0.87)}
>
If you&apos;re not on LSB, you could fake the API response.
Right now the only required settings are <b>MAIN.SERVER_NAME</b>
, <b>MAIN.MAX_LEVEL</b>, and <b>LOGIN.LOGIN_LIMIT</b>.
You&apos;ll want to look at the LSB settings and serve whatever
relevant changes you&apos;ve made using the LSB equivalent.
Settings should be served at <b>/api/settings</b> and total
active sessions should be served at <b>/api/sessions</b>.
</Typography>
</Box>
<Box className="mb-3"> <Box className="mb-3">
<Typography align="center" variant="h6"> <Typography align="center" variant="h6">
How can I add a link to the server website? How can I add a link to the server website?
@ -195,6 +177,23 @@ MAIN.ENABLE_TVR`;
<CodeCard title="Settings" content={recommendedSettings} /> <CodeCard title="Settings" content={recommendedSettings} />
</Typography> </Typography>
</Box> </Box>
<Box className="mb-3">
<Typography align="center" variant="h6">
What if my server isn&apos;t running LSB?
</Typography>
<Typography
component="p"
variant="body1"
color={(theme) => alpha(theme.palette.text.primary, 0.87)}
>
If you&apos;re not running LSB, you could fake the API response.
You&apos;ll want to look at the LSB settings and serve whatever
relevant changes you&apos;ve made using the LSB equivalent, the
above listed settings at minimum. Settings should be served at{' '}
<b>/api/settings</b> and total active sessions should be served
at <b>/api/sessions</b>.
</Typography>
</Box>
</AccordionDetails> </AccordionDetails>
</Accordion> </Accordion>
</Card> </Card>