diff --git a/src/components/Low/Button.tsx b/src/components/Low/Button.tsx new file mode 100644 index 00000000..4b7b0db7 --- /dev/null +++ b/src/components/Low/Button.tsx @@ -0,0 +1,23 @@ +import clsx from "clsx"; +import {ReactNode} from "react"; + +interface Props { + children: ReactNode; + color?: "orange" | "green" | "blue"; + variant?: "outline" | "solid"; + onClick: () => void; +} + +export default function Button({color = "green", variant = "solid", children, onClick}: Props) { + const colorClassNames: {[key in typeof color]: string} = { + green: "bg-mti-green hover:bg-mti-green-dark disabled:text-mti-green disabled:bg-mti-green-ultralight", + blue: "bg-mti-blue hover:bg-mti-blue-dark disabled:text-mti-blue disabled:bg-mti-blue-ultralight", + orange: "bg-mti-orange hover:bg-mti-orange-dark disabled:text-mti-orange disabled:bg-mti-orange-ultralight", + }; + + return ( + + ); +} diff --git a/src/components/Low/ProgressBar.tsx b/src/components/Low/ProgressBar.tsx new file mode 100644 index 00000000..4e6d1886 --- /dev/null +++ b/src/components/Low/ProgressBar.tsx @@ -0,0 +1,17 @@ +import clsx from "clsx"; + +interface Props { + label: string; + percentage: number; + color: "blue" | "orange" | "green"; + className?: string; +} + +export default function ProgressBar({label, percentage, color, className}: Props) { + return ( +
+
+ {label} +
+ ); +} diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index 62e22121..b59d1027 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -24,11 +24,11 @@ const Nav = ({Icon, label, path, keyPath}: NavProps) => ( - {label} + {label} ); diff --git a/src/pages/index.tsx b/src/pages/index.tsx index a0662b2b..3d205ded 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -3,6 +3,7 @@ import Head from "next/head"; import SingleDatasetChart from "@/components/UserResultChart"; import Navbar from "@/components/Navbar"; import ProfileCard from "@/components/ProfileCard"; +import {BsFileEarmarkText, BsPencil, BsStar} from "react-icons/bs"; import {withIronSessionSsr} from "iron-session/next"; import {sessionOptions} from "@/lib/session"; import {User} from "@/interfaces/user"; @@ -17,6 +18,7 @@ import {ToastContainer} from "react-toastify"; import {capitalize} from "lodash"; import {Module} from "@/interfaces"; import clsx from "clsx"; +import ProgressBar from "@/components/Low/ProgressBar"; export const getServerSideProps = withIronSessionSsr(({req, res}) => { const user = req.session.user; @@ -40,6 +42,7 @@ export const getServerSideProps = withIronSessionSsr(({req, res}) => { export default function Home() { const [showDiagnostics, setShowDiagnostics] = useState(false); const {user} = useUser({redirectTo: "/login"}); + const {stats} = useStats(user?.id); useEffect(() => { if (user) setShowDiagnostics(user.isFirstLogin); @@ -87,21 +90,48 @@ export default function Home() {
- {user.name} -
+ {user.name} +
-
+

{user.name}

{capitalize(user.type)}
-
-
- - Level {calculateAverageLevel().toFixed(1)} - + +
+ +
+
+
+ +
+
+ {totalExams(stats)} + Exams +
+
+
+
+ +
+
+ {stats.length} + Exercises +
+
+
+
+ +
+
+ {averageScore(stats)}% + Average Score +
diff --git a/tailwind.config.js b/tailwind.config.js index 45726584..3e1f0897 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -5,16 +5,16 @@ module.exports = { extend: { colors: { mti: { - orange: "#FF6000", - green: "#51C21A", - blue: "#007FF8", + orange: {DEFAULT: "#FF6000", dark: "#cc4402", light: "#ff790a", ultralight: "#ffdaa5"}, + green: {DEFAULT: "#307912", dark: "#2a6014", light: "#3d9f11", ultralight: "#c6edaf"}, + blue: {DEFAULT: "#0696ff", dark: "#007ff8", light: "#1eb3ff", ultralight: "#b5edff"}, gray: {light: "#F9F9F9", dark: "#E0E0E0"}, }, ielts: { - reading: {DEFAULT: "#FF6384", transparent: "rgba(255, 99, 132, 0.5)"}, - listening: {DEFAULT: "#36A2EB", transparent: "rgba(54, 162, 235, 0.5)"}, - writing: {DEFAULT: "#FFCE56", transparent: "rgba(255, 206, 86, 0.5)"}, - speaking: {DEFAULT: "#4bc0c0", transparent: "rgba(75, 192, 192, 0.5)"}, + reading: {DEFAULT: "#1EB3FF", transparent: "rgba(255, 99, 132, 0.5)"}, + listening: {DEFAULT: "#FF790A", transparent: "rgba(54, 162, 235, 0.5)"}, + writing: {DEFAULT: "#3D9F11", transparent: "rgba(255, 206, 86, 0.5)"}, + speaking: {DEFAULT: "#EF5DA8", transparent: "rgba(75, 192, 192, 0.5)"}, }, }, },