diff --git a/client/src/components/CodeCard.tsx b/client/src/components/CodeCard.tsx new file mode 100644 index 0000000..9225dd4 --- /dev/null +++ b/client/src/components/CodeCard.tsx @@ -0,0 +1,128 @@ +import { ContentCopy } from '@mui/icons-material'; +import { + Card, + CardContent, + CardHeader, + IconButton, + Tooltip, +} from '@mui/material'; +import { useEffect, useState } from 'react'; + +type CodeCardProps = { + title: string; + file?: string; + content?: string; + copy?: boolean; +}; + +export default function CodeCard({ + title, + file, + content, + copy, +}: CodeCardProps) { + const [fileContent, setFileContent] = useState(''); + const [clipboardTooltip, setClipboardTooltip] = useState('Copy contents.'); + const [clipboardTooltipOpen, setClipboardTooltipOpen] = useState(false); + const handleClipboardTooltipClose = () => { + setClipboardTooltipOpen(false); + }; + const handleClipboardTooltipOpen = () => { + setClipboardTooltipOpen(true); + }; + useEffect(() => { + if (file) { + fetch(file) + .then((response) => response.text()) + .then((text) => setFileContent(text)) + .catch((error) => setFileContent(error.toString())); + } + }, [file]); + + const copyContentsToClipboard = async (text: string) => { + try { + navigator.clipboard.writeText(text); + setClipboardTooltip('Copied contents!'); + handleClipboardTooltipOpen(); + setTimeout(() => { + handleClipboardTooltipClose(); + setClipboardTooltip('Copy contents.'); + }, 3000); + } catch (error) { + handleClipboardTooltipOpen(); + if (error instanceof Error) { + setClipboardTooltip(error.message); + } else { + setClipboardTooltip('Something went wrong!'); + } + setTimeout(() => { + handleClipboardTooltipClose(); + setClipboardTooltip('Copy contents.'); + }, 3000); + } + }; + + return ( + + + { + event.stopPropagation(); + copyContentsToClipboard(content || fileContent); + }} + disableRipple + > + theme.typography.subtitle1.fontSize, + }} + /> + + + ) + } + className="py-0" + sx={{ backgroundColor: (theme) => theme.palette.background.paper }} + /> + + {file ? ( +
+            {fileContent}
+          
+ ) : ( +
+            {content}
+          
+ )} +
+
+ ); +} + +CodeCard.defaultProps = { + file: '', + content: '', + copy: true, +}; diff --git a/client/src/components/Header/SearchServers.tsx b/client/src/components/Header/SearchServers.tsx index e8329d6..9e14f98 100644 --- a/client/src/components/Header/SearchServers.tsx +++ b/client/src/components/Header/SearchServers.tsx @@ -631,7 +631,7 @@ export default function SearchServers({ alignItems="center" > - + { // setSearchState(SearchStateDefaults); @@ -640,7 +640,12 @@ export default function SearchServers({ - + { setSearchState(SearchStateDefaults); diff --git a/client/src/components/Server/ExpansionsBar.tsx b/client/src/components/Server/ExpansionsBar.tsx index acea673..1b051f7 100644 --- a/client/src/components/Server/ExpansionsBar.tsx +++ b/client/src/components/Server/ExpansionsBar.tsx @@ -1,10 +1,11 @@ -import { AddCircle } from '@mui/icons-material'; +import { AddCircleTwoTone } from '@mui/icons-material'; import { Box, IconButton, ToggleButton, ToggleButtonGroup, Tooltip, + useTheme, } from '@mui/material'; import { ServerData } from '../../data/ServerData'; @@ -60,6 +61,7 @@ type ExpansionBarProps = { server: ServerData }; export default function ExpansionBar({ server }: ExpansionBarProps) { const { expansions } = server; + const theme = useTheme(); const addons = ['acp', 'amk', 'asa', 'abyssea', 'voidwatch', 'rov', 'tvr']; @@ -101,9 +103,10 @@ export default function ExpansionBar({ server }: ExpansionBarProps) { arrow > - diff --git a/client/src/components/Server/ServerCard.tsx b/client/src/components/Server/ServerCard.tsx index ed6a2ad..2ebe0fd 100644 --- a/client/src/components/Server/ServerCard.tsx +++ b/client/src/components/Server/ServerCard.tsx @@ -318,6 +318,7 @@ export default function ServerCard({ server, children }: ServerCardProps) { title={`Server allows ${server.login_limit === 0 ? 'unlimited' : server.login_limit} simultaneous game sessions per IP.`} arrow disableInteractive + placement="top" > @@ -147,25 +173,28 @@ export default function About() { > Create a new file settings/api.lua in your server directory. - -
-                    
-                      {`xi = xi or {}
-xi.settings = xi.settings or {}
-
-xi.settings.api =
-{
-    WEBSITE = '',
-    DO_NOT_TRACK = false,
-}`}
-                    
-                  
-
+ The world server needs to be restarted after any changes to any of the settings. If you set DO_NOT_TRACK to true, your server will be removed on the next update.
+ + + Which settings are used? + + alpha(theme.palette.text.primary, 0.87)} + > + Anything that differs from the default LSB settings will be + displayed in the "Settings Summary" section for a + server. The following settings are always included as part of + the UI: + + + diff --git a/client/vite.config.ts b/client/vite.config.ts index 8a24036..4ed27f4 100644 --- a/client/vite.config.ts +++ b/client/vite.config.ts @@ -16,8 +16,8 @@ export default defineConfig({ strictPort: true, port: 3000, hmr: { - //port: 3010, - host: 'localhost' + // port: 3010, + host: 'localhost', }, }, test: {