From ecf7e50778d4146e4232473c471f09bb7f3c8281 Mon Sep 17 00:00:00 2001
From: Lorenzo Corallo <66379281+lorenzocorallo@users.noreply.github.com>
Date: Thu, 22 Aug 2024 17:07:19 +0200
Subject: [PATCH] feat: add school emojis in homepage (#261)
* chore(lint): enforce noImplicitReturns and exhaustive switch blocks
* feat: add school emojis in homepage
---------
Co-authored-by: angeousta <132761637+angeousta@users.noreply.github.com>
---
.eslintrc.cjs | 1 +
src/components/custom-ui/Alert.tsx | 32 +++++++++++++++++-----------
src/routes/homepage/chooseSchool.tsx | 15 +++++++++++++
tsconfig.json | 2 ++
4 files changed, 38 insertions(+), 12 deletions(-)
diff --git a/.eslintrc.cjs b/.eslintrc.cjs
index 869e9ccd..43da3a12 100644
--- a/.eslintrc.cjs
+++ b/.eslintrc.cjs
@@ -10,6 +10,7 @@ module.exports = {
parserOptions: { ecmaVersion: "latest", sourceType: "module" },
plugins: ["react-refresh", "prettier"],
rules: {
+ "@typescript-eslint/switch-exhaustiveness-check": "error",
"react-refresh/only-export-components": "warn",
"prettier/prettier": "warn",
},
diff --git a/src/components/custom-ui/Alert.tsx b/src/components/custom-ui/Alert.tsx
index 347fe1a3..37a8394f 100644
--- a/src/components/custom-ui/Alert.tsx
+++ b/src/components/custom-ui/Alert.tsx
@@ -38,19 +38,27 @@ export default function Alert({
}
function GetIcon(level: Level) {
- if (level === "error") return ;
- if (level === "warning") return ;
- if (level === "info") return ;
- if (level === "success") return ;
+ switch (level) {
+ case "error":
+ return ;
+ case "warning":
+ return ;
+ case "info":
+ return ;
+ case "success":
+ return ;
+ }
}
const getColors = (level: Level) => {
- if (level === "error")
- return "bg-red-300/5 border-red-600 text-red-600 dark:bg-red-100/5 dark:border-red-300 dark:text-red-300";
- if (level === "warning")
- return "bg-amber-300/5 border-amber-600 text-amber-600 dark:bg-amber-100/5 dark:border-amber-200 dark:text-amber-200";
- if (level === "info")
- return "bg-sky-300/5 border-sky-600 text-sky-600 dark:bg-sky-100/5 dark:border-sky-200 dark:text-sky-200";
- if (level === "success")
- return "bg-green-300/5 border-green-600 text-green-600 dark:bg-green-100/5 dark:border-green-200 dark:text-green-200";
+ switch (level) {
+ case "error":
+ return "bg-red-300/5 border-red-600 text-red-600 dark:bg-red-100/5 dark:border-red-300 dark:text-red-300";
+ case "warning":
+ return "bg-amber-300/5 border-amber-600 text-amber-600 dark:bg-amber-100/5 dark:border-amber-200 dark:text-amber-200";
+ case "info":
+ return "bg-sky-300/5 border-sky-600 text-sky-600 dark:bg-sky-100/5 dark:border-sky-200 dark:text-sky-200";
+ case "success":
+ return "bg-green-300/5 border-green-600 text-green-600 dark:bg-green-100/5 dark:border-green-200 dark:text-green-200";
+ }
};
diff --git a/src/routes/homepage/chooseSchool.tsx b/src/routes/homepage/chooseSchool.tsx
index 06e821a0..d82afda9 100644
--- a/src/routes/homepage/chooseSchool.tsx
+++ b/src/routes/homepage/chooseSchool.tsx
@@ -3,6 +3,20 @@ import { Button } from "@/components/ui/button";
import { homepageRoute } from ".";
import { ButtonGrid } from "@/components/Homepage/ButtonGrid";
import DevSettings from "@/components/DevSettings";
+import School from "@/utils/types/data/School";
+
+function getSchoolEmoji(school: School) {
+ switch (school) {
+ case "Architettura":
+ return (📐);
+ case "Design":
+ return (🖌️);
+ case "Ingegneria":
+ return (🛠️);
+ case "Urbanistica":
+ return (🏡);
+ }
+}
export const chooseSchoolRoute = new Route({
getParentRoute: () => homepageRoute,
@@ -37,6 +51,7 @@ export const chooseSchoolRoute = new Route({
className="h-full"
>
diff --git a/tsconfig.json b/tsconfig.json
index ea0727c5..ad6b6e1c 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -15,9 +15,11 @@
/* Linting */
"strict": true,
+ "strictNullChecks": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
+ "noImplicitReturns": true,
// for shadcn/ui
"baseUrl": ".",