Skip to content

Commit

Permalink
Change course colors, fix course overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
DCRepublic committed Nov 4, 2024
1 parent ecbfae8 commit 875f7ad
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 47 deletions.
13 changes: 1 addition & 12 deletions app/calendar/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,12 @@ import prisma from "../../lib/prisma";
import { auth } from "../../lib/auth";
import { getPlanCookie } from "../actions";
import { BorderColor } from "@mui/icons-material";
import { courseColors } from "../../components/primitives";

import { generateColorFromName } from "../../components/primitives";
export default async function CalendarPage() {
async function getEvents() {
let output: any = [];
let planCookie: any = await getPlanCookie();

function generateColorFromName(name: string) {
let hash = 0;

for (let i = 0; i < name.length; i++) {
hash += name.charCodeAt(i);
}

return courseColors[hash % courseColors.length];
}

let courses;
if (planCookie) {
let plan = await prisma.coursePlan.findUnique({
Expand Down
2 changes: 1 addition & 1 deletion app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async function Home(props: any) {
<div className="row-start-1">
<Search />
</div>
<div className="row-start-2 h-[62vh] overflow-scroll">
<div className="row-start-2 h-[62vh] overflow-y-scroll overflow-x-clip">
{props.fullCourseList}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion components/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function Calendar(props: any) {
console.log(eventInfo);
return (
<Card
className=" fc-event-main-frame w-[100%] rounded-md hover:h-[20vh] z-0 hover:z-10 hover:transition-all duration-700 "
className="fc-event-main-frame w-[100%] rounded-md hover:h-[20vh] ease-in-out z-0 hover:z-10 hover:transition-all duration-700 "
style={{ backgroundColor: eventInfo.event.extendedProps.daColor }}
>
{/*
Expand Down
12 changes: 1 addition & 11 deletions components/CourseCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
Button,
} from "@nextui-org/react";
import { tv } from "tailwind-variants";
import { courseColors } from "../components/primitives";
import { generateColorFromName } from "../components/primitives";

import { InstructorCard } from "./InstructorCard";
import AddIcon from "@mui/icons-material/Add";
Expand All @@ -29,16 +29,6 @@ const {
role,
} = card();

function generateColorFromName(name: string) {
let hash = 0;

for (let i = 0; i < name.length; i++) {
hash += name.charCodeAt(i);
}

return courseColors[hash % courseColors.length];
}

async function updatePlan(course: any) {
console.log("updating");
await axios
Expand Down
12 changes: 1 addition & 11 deletions components/CreatePlan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { useEffect, useState } from "react";
import useSWR from "swr";
import { setPlanCookie } from "../app/actions";
import { useCookies } from "next-client-cookies";
import { courseColors } from "../components/primitives";
import { generateColorFromName } from "../components/primitives";
export default function CreatePlan(props: any) {
const cookies = useCookies();
const router = useRouter();
Expand Down Expand Up @@ -117,16 +117,6 @@ export default function CreatePlan(props: any) {
setPlanCookie(e.target.value);
};

function generateColorFromName(name: string) {
let hash = 0;

for (let i = 0; i < name.length; i++) {
hash += name.charCodeAt(i);
}

return courseColors[hash % courseColors.length];
}

useEffect(() => {
// Update the document title using the browser API
setSelectedCoursePlan([cookies.get("plan")]);
Expand Down
1 change: 0 additions & 1 deletion components/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import InputIcon from "@mui/icons-material/Input";

import { siteConfig } from "../config/site";
import { ThemeSwitch } from "../components/theme-switch";
import { SearchIcon } from "../components/icons";
import { title } from "../components/primitives";

import HomeIcon from "@mui/icons-material/Home";
Expand Down
7 changes: 5 additions & 2 deletions components/primitives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,26 @@ export const courseColors = [
"#093145",
"#107896",
"#829356",

"#5A5A66",
"#4A6D7C",
"#C2571A",
"#9A2617",
"#201335",
"#636363",
"#087E8B",
"#590925",
"#034748",
"#19381F",
"#631D76",
"#4B4E6D",
"#590004",
];

export function generateColorFromName(name: string) {
let hash = 0;

for (let i = 0; i < name.length; i++) {
hash += name.charCodeAt(i);
hash += name.charCodeAt(i) * i;
}

return courseColors[hash % courseColors.length];
Expand Down
10 changes: 3 additions & 7 deletions components/theme-switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { useTheme } from "next-themes";
import { useIsSSR } from "@react-aria/ssr";
import clsx from "clsx";

import { SunFilledIcon, MoonFilledIcon } from "../components/icons";

import Brightness4Icon from "@mui/icons-material/Brightness4";
import BedtimeIcon from "@mui/icons-material/Bedtime";
export interface ThemeSwitchProps {
className?: string;
classNames?: SwitchProps["classNames"];
Expand Down Expand Up @@ -70,11 +70,7 @@ export const ThemeSwitch: FC<ThemeSwitchProps> = ({
),
})}
>
{!isSelected || isSSR ? (
<SunFilledIcon size={22} />
) : (
<MoonFilledIcon size={22} />
)}
{!isSelected || isSSR ? <Brightness4Icon /> : <BedtimeIcon />}
</div>
</Component>
);
Expand Down
2 changes: 1 addition & 1 deletion swatscraper
Submodule swatscraper updated 5 files
+1 −2 .gitignore
+1 −2 README.md
+15 −0 go.mod
+52 −0 go.sum
+79 −81 main.go

0 comments on commit 875f7ad

Please sign in to comment.