1
0
Fork 0
forked from CRSS/Website

feat: Formatting

This commit is contained in:
worldwidepixel 2024-09-04 10:57:01 -07:00
parent 70a173d02b
commit 39e87cffdc
5 changed files with 2767 additions and 3354 deletions

5
.prettierrc Normal file
View file

@ -0,0 +1,5 @@
{
"tabWidth": 2,
"singleQuote": true,
"semi": true
}

6
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,6 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}

View file

@ -12,7 +12,7 @@ import {
LogOut,
LogIn,
Earth,
X
X,
} from 'lucide-react';
import Link from 'next/link';
@ -29,22 +29,19 @@ import { useEffect, useRef, useState } from 'react';
import Dropdown from './Dropdown';
import { useUser } from '@/context/UserContext';
import {
Permission,
hasPermission
} from '@/utils/permissions';
import { Permission, hasPermission } from '@/utils/permissions';
export default function NavBar({ currentPage }: { currentPage: string }) {
const { user, isLoggedIn } = useUser();
const { user, isLoggedIn } = useUser();
const [ navOpen, setNavOpen ] = useState(false);
const [navOpen, setNavOpen] = useState(false);
const { publicRuntimeConfig } = getConfig();
const router = useRouter();
const server = {
version: '1.15.2'
version: '1.15.2',
};
const buildDiscordUrl = (): string => {
@ -52,8 +49,14 @@ export default function NavBar({ currentPage }: { currentPage: string }) {
url.searchParams.append('client_id', publicRuntimeConfig.discord.clientId);
url.searchParams.append('response_type', 'code');
url.searchParams.append('redirect_uri', publicRuntimeConfig.discord.redirectUri);
url.searchParams.append('scope', publicRuntimeConfig.discord.scopes.join(' '));
url.searchParams.append(
'redirect_uri',
publicRuntimeConfig.discord.redirectUri
);
url.searchParams.append(
'scope',
publicRuntimeConfig.discord.scopes.join(' ')
);
url.searchParams.append('state', router.asPath);
@ -72,15 +75,17 @@ export default function NavBar({ currentPage }: { currentPage: string }) {
</div>
<div>
<label htmlFor="ip">
Server Address:
</label>
<label htmlFor="ip">Server Address:</label>
<input type="text" value="play.crss.cc" id="ip" readOnly size={8} />
<input
type="text"
value="play.crss.cc"
id="ip"
readOnly
size={8}
/>
<label htmlFor="ip">
Version: {server.version}
</label>
<label htmlFor="ip">Version: {server.version}</label>
</div>
</div>
</div>
@ -89,139 +94,165 @@ export default function NavBar({ currentPage }: { currentPage: string }) {
<nav className={`${styles.navBar} ${navOpen ? styles.navOpen : ''}`}>
<div className={styles.container}>
<div className={styles.navMobileContainer}>
<button className={styles.navToggle} onClick={() => { setNavOpen(!navOpen); }}>
{ !navOpen ? <Menu /> : <X /> }
<button
className={styles.navToggle}
onClick={() => {
setNavOpen(!navOpen);
}}
>
{!navOpen ? <Menu /> : <X />}
</button>
</div>
<div className={styles.navCollapse}>
<ul>
<li>
<Link href={currentPage == 'home' ? '#' : '/'} className={currentPage == 'home' ? styles.active : ''}>
<Link
href={currentPage == 'home' ? '#' : '/'}
className={currentPage == 'home' ? styles.active : ''}
>
<Home />
Home
</Link>
</li>
<li>
<Link href={currentPage == 'rules' ? '#' : '/rules'} className={currentPage == 'rules' ? styles.active : ''}>
<Link
href={currentPage == 'rules' ? '#' : '/rules'}
className={currentPage == 'rules' ? styles.active : ''}
>
<Scale />
Rules
</Link>
</li>
<li>
<Link href={currentPage == 'about' ? '#' : '/about'} className={currentPage == 'about' ? styles.active : ''}>
<Link
href={currentPage == 'about' ? '#' : '/about'}
className={currentPage == 'about' ? styles.active : ''}
>
<AtSign />
About
</Link>
</li>
<li>
<Link href={currentPage == 'gallery' ? '#' : '/gallery'} className={currentPage == 'gallery' ? styles.active : ''}>
<Link
href={currentPage == 'gallery' ? '#' : '/gallery'}
className={currentPage == 'gallery' ? styles.active : ''}
>
<Images />
Gallery
</Link>
</li>
<li>
<Link href={currentPage == 'map' ? '#' : '/map'} className={currentPage == 'map' ? styles.active : ''}>
<Link
href={currentPage == 'map' ? '#' : '/map'}
className={currentPage == 'map' ? styles.active : ''}
>
<Map />
Map
</Link>
</li>
<li>
<Link href={currentPage == 'nations' ? '#' : '/nations'} className={currentPage == 'nations' ? styles.active : ''}>
<Link
href={currentPage == 'nations' ? '#' : '/nations'}
className={currentPage == 'nations' ? styles.active : ''}
>
<Earth />
Nations
</Link>
</li>
</ul>
<ul>
{(isLoggedIn && user) && (
{isLoggedIn && user && (
<li>
{hasPermission(user.permissions, Permission.Admin) && (
<Dropdown items={[
{
icon: User,
label: 'Profile',
href: `/u/${user ? user.names.username : 'Loading...'}`
},
{
icon: Settings,
label: 'Settings',
href: '/settings'
},
{
divider: true
},
{
icon: LayoutDashboard,
label: 'Admin',
href: '/admin'
},
{
icon: LogOut,
label: 'Logout',
onClick: async (e) => {
e.preventDefault();
{(hasPermission(user.permissions, Permission.Admin) && (
<Dropdown
items={[
{
icon: User,
label: 'Profile',
href: `/u/${
user ? user.names.username : 'Loading...'
}`,
},
{
icon: Settings,
label: 'Settings',
href: '/settings',
},
{
divider: true,
},
{
icon: LayoutDashboard,
label: 'Admin',
href: '/admin',
},
{
icon: LogOut,
label: 'Logout',
onClick: async (e) => {
e.preventDefault();
await fetch('/api/v1/session', {
method: 'DELETE'
});
await fetch('/api/v1/session', {
method: 'DELETE',
});
router.reload();
}
}
]} className={styles.dropDown}>
router.reload();
},
},
]}
className={styles.dropDown}
>
<User />
{user ? user.names.global_name : 'Loading...'}
</Dropdown>
) || (
<Dropdown items={[
{
icon: User,
label: 'Profile',
href: `/u/${user ? user.names.username : 'Loading...'}`
},
{
icon: Settings,
label: 'Settings',
href: '/settings'
},
{
divider: true
},
{
icon: LogOut,
label: 'Logout',
onClick: async (e) => {
e.preventDefault();
)) || (
<Dropdown
items={[
{
icon: User,
label: 'Profile',
href: `/u/${
user ? user.names.username : 'Loading...'
}`,
},
{
icon: Settings,
label: 'Settings',
href: '/settings',
},
{
divider: true,
},
{
icon: LogOut,
label: 'Logout',
onClick: async (e) => {
e.preventDefault();
await fetch('/api/v1/session', {
method: 'DELETE'
});
await fetch('/api/v1/session', {
method: 'DELETE',
});
router.reload();
}
}
]} className={styles.dropDown}>
router.reload();
},
},
]}
className={styles.dropDown}
>
<User />
{user ? user.names.global_name : 'Loading...'}
</Dropdown>
)}
</li>
)}
{(!isLoggedIn && !user) && (
{!isLoggedIn && !user && (
<li>
<Link href={buildDiscordUrl()}>
<LogIn />
Login
</Link>
</li>

View file

@ -6,7 +6,7 @@ import NavBar from '@/components/NavBar';
import PageContent from '@/components/PageContent';
export default function Rules() {
const nations = [ ];
const nations = [];
return (
<>
@ -18,50 +18,62 @@ export default function Rules() {
<ol>
<li>
The use of modified clients that give an unfair advantage to players, such as hacked clients, is not permitted.
The use of modified clients that give an unfair advantage to
players, such as hacked clients, is not permitted.
<ul>
<li>
You are not allowed to use them even for their legitimate features, such as a "fullbright" option.
You are not allowed to use them even for their legitimate
features, such as a &quot;fullbright&quot; option.
</li>
<li>
If admins suspect you are hacking you will be immediately banned.
If admins suspect you are hacking you will be immediately
banned.
</li>
</ul>
</li>
<li>
Do not modify or destroy (grief) other player&apos;s constructions without their consent, or steal any of their items.
Do not modify or destroy (grief) other player&apos;s constructions
without their consent, or steal any of their items.
<ul>
<li>
You are allowed to visit any build, as long as you don&apos;t take anything, and if you do you pay them back.
You are allowed to visit any build, as long as you don&apos;t
take anything, and if you do you pay them back.
</li>
<li>
You should ask permission in the discord or the in-game chat before modifying builds.
You should ask permission in the discord or the in-game chat
before modifying builds.
</li>
</ul>
</li>
<li>
Follow the laws of the nations you are in to avoid issues with other players and making the server not fun to play.
Follow the laws of the nations you are in to avoid issues with other
players and making the server not fun to play.
<ul>
<li>
If you feel the laws are too vague, feel free to ask the people in charge of them what they mean with something, and feel free to contribute to them. Complaining that they don&apos;t make sense won&apos;t get you anywhere.
If you feel the laws are too vague, feel free to ask the people
in charge of them what they mean with something, and feel free
to contribute to them. Complaining that they don&apos;t make
sense won&apos;t get you anywhere.
</li>
<li>
Breaking laws won&apos;t necessarily get you banned, the nation you are in will take measures and punish you for your actions as they see fit.
Breaking laws won&apos;t necessarily get you banned, the nation
you are in will take measures and punish you for your actions as
they see fit.
</li>
</ul>
</li>
<li>
Do not attempt to make nations where the territory is already owned by another nation.
Do not attempt to make nations where the territory is already owned
by another nation.
<ul>
<li>
You can make it near the borders of a nation but never inside one, you can&apos;t just take existing territory as your own.
You can make it near the borders of a nation but never inside
one, you can&apos;t just take existing territory as your own.
</li>
<li>
Other nations are free to claim more territory whenever they feel like it, as long as it doesn't take other nations&apos; territory with it.
Other nations are free to claim more territory whenever they
feel like it, as long as it doesn&apos;t take other
nations&apos; territory with it.
</li>
</ul>
</li>

File diff suppressed because it is too large Load diff