diff --git a/frontend/public/crown.png b/frontend/public/crown.png new file mode 100644 index 0000000..70bef8f Binary files /dev/null and b/frontend/public/crown.png differ diff --git a/frontend/src/app/lobby/page.tsx b/frontend/src/app/lobby/page.tsx index 97abf62..0b02640 100644 --- a/frontend/src/app/lobby/page.tsx +++ b/frontend/src/app/lobby/page.tsx @@ -1,47 +1,104 @@ "use client"; - -import { Vollkorn, Nunito } from "next/font/google"; -import { useState } from "react"; - -const vollkorn = Vollkorn({ - weight: "600", - subsets: ["latin"], -}); +import { useState, useEffect } from "react"; +import { Markazi_Text, Nunito } from "next/font/google"; +import users from "muzak/data/users.json"; +import Image from "next/image"; const nunito = Nunito({ weight: "900", subsets: ["latin"], }); +const MAX_PARTY_SIZE = 8; + export default function Lobby() { - const [userName, setUserName] = useState("Stroop"); + const [partySize, setPartySize] = useState(0); + const [userList, setUserList] = useState([]); + + useEffect(() => { + populateUserList(); + }, [partySize]); + + function populateUserList() { + const mappedUsers = users.slice(0, partySize).map((user) => ({ + id: user.id, + name: user.name, + avatar: user.avatar, + host: user.host, + })); + setUserList(mappedUsers); + } + + function addUserToParty() { + setPartySize((prev) => Math.min(prev + 1, MAX_PARTY_SIZE)); + } + + function deleteUserFromParty() { + setPartySize((prev) => Math.max(prev - 1, 0)); + } + return (

- LOGIN + LOBBY

-
-

Welkom, {userName}!

-
- +
+
+
+ Players: {partySize} +
- +
+ {/*
*/} +
+ {userList.map((user) => ( +
+ {user.name} + {user.name} + {user.host && ( + Crown image + )} +
+ ))} +
+
+ +
+ +
-
); } diff --git a/frontend/src/app/login/page.tsx b/frontend/src/app/login/page.tsx new file mode 100644 index 0000000..b42f16b --- /dev/null +++ b/frontend/src/app/login/page.tsx @@ -0,0 +1,42 @@ +"use client"; + +import { Nunito } from "next/font/google"; +import { useState } from "react"; + +const nunito = Nunito({ + weight: "900", + subsets: ["latin"], +}); + +export default function Login() { + const [userName, setUserName] = useState("Stroop"); + return ( +
+
+

+ LOGIN +

+
+ +
+

Welkom, {userName}!

+
+ + +
+
+
+
+ ); +} diff --git a/frontend/src/data/users.json b/frontend/src/data/users.json new file mode 100644 index 0000000..5e913c3 --- /dev/null +++ b/frontend/src/data/users.json @@ -0,0 +1,50 @@ +[ + { + "id": 1, + "name": "Mark", + "avatar": "https://i.pravatar.cc/300?img=66", + "host": true + }, + { + "id": 2, + "name": "Guus", + "avatar": "https://i.pravatar.cc/300?img=67", + "host": false + }, + { + "id": 3, + "name": "Freek", + "avatar": "https://i.pravatar.cc/300?img=68", + "host": false + }, + { + "id": 4, + "name": "JP", + "avatar": "https://i.pravatar.cc/300?img=69", + "host": false + }, + { + "id": 5, + "name": "Lourens", + "avatar": "https://i.pravatar.cc/300?img=70", + "host": false + }, + { + "id": 6, + "name": "Martijn", + "avatar": "https://i.pravatar.cc/300?img=6", + "host": false + }, + { + "id": 7, + "name": "Hugo", + "avatar": "https://i.pravatar.cc/300?img=7", + "host": false + }, + { + "id": 8, + "name": "Erik", + "avatar": "https://i.pravatar.cc/300?img=8", + "host": false + } +] diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index 290cd52..e3e4f1c 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -7,7 +7,8 @@ "baseUrl": "./", "paths": { "muzak/config/*": ["./src/config/*"], - "muzak/data/*": ["./src/data/*"] + "muzak/data/*": ["./src/data/*"], + "muzak/app/*": ["./src/app/*"] }, "allowJs": false, @@ -27,6 +28,12 @@ } ] }, - "include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"], + "include": [ + "next-env.d.ts", + ".next/types/**/*.ts", + "**/*.ts", + "**/*.tsx", + "src/data/users.json" + ], "exclude": ["node_modules"] }