Skip to content

Commit

Permalink
feat: add school emojis in homepage (#261)
Browse files Browse the repository at this point in the history
* chore(lint): enforce noImplicitReturns and exhaustive switch blocks

* feat: add school emojis in homepage

---------

Co-authored-by: angeousta <[email protected]>
  • Loading branch information
lorenzocorallo and angeousta authored Aug 22, 2024
1 parent 9545155 commit ecf7e50
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 12 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down
32 changes: 20 additions & 12 deletions src/components/custom-ui/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,27 @@ export default function Alert({
}

function GetIcon(level: Level) {
if (level === "error") return <LuAlertCircle />;
if (level === "warning") return <LuAlertTriangle />;
if (level === "info") return <LuInfo />;
if (level === "success") return <LuCheckCircle2 />;
switch (level) {
case "error":
return <LuAlertCircle />;
case "warning":
return <LuAlertTriangle />;
case "info":
return <LuInfo />;
case "success":
return <LuCheckCircle2 />;
}
}

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";
}
};
15 changes: 15 additions & 0 deletions src/routes/homepage/chooseSchool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (<span className="mr-2 text-lg rotate-[270deg]">&#128208;</span>);
case "Design":
return (<span className="mr-2 text-lg">&#128396;&#65039;</span>);
case "Ingegneria":
return (<span className="mr-2 text-lg">&#128736;&#65039;</span>);
case "Urbanistica":
return (<span className="mr-2 text-lg">&#127969;</span>);
}
}

export const chooseSchoolRoute = new Route({
getParentRoute: () => homepageRoute,
Expand Down Expand Up @@ -37,6 +51,7 @@ export const chooseSchoolRoute = new Route({
className="h-full"
>
<Button size="card" variant="secondary" className="h-full w-full">
{getSchoolEmoji(school)}
<span className="text-lg">{school}</span>
</Button>
</Link>
Expand Down
2 changes: 2 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@

/* Linting */
"strict": true,
"strictNullChecks": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,

// for shadcn/ui
"baseUrl": ".",
Expand Down

0 comments on commit ecf7e50

Please sign in to comment.