Skip to content

Commit

Permalink
Merge pull request #726 from asuc-octo/feat/theme
Browse files Browse the repository at this point in the history
feat/theme
  • Loading branch information
mathhulk authored Oct 11, 2024
2 parents fbc40d1 + 80e4339 commit ec6fb58
Show file tree
Hide file tree
Showing 82 changed files with 1,202 additions and 477 deletions.
2 changes: 1 addition & 1 deletion apps/backend/src/bootstrap/loaders/apollo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class RedisCache implements KeyValueCache {
const armor = new ApolloArmor({
maxDepth: {
enabled: true,
n: 4,
n: 5,
},
});

Expand Down
3 changes: 2 additions & 1 deletion apps/backend/src/modules/schedule/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export const updateSchedule = async (
) => {
const schedule = await ScheduleModel.findOneAndUpdate(
{ _id: id, createdBy: context.user._id },
input
input,
{ new: true }
);

if (!schedule) throw new Error("Not found");
Expand Down
8 changes: 4 additions & 4 deletions apps/backend/src/modules/schedule/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export const formatSchedule = async (schedule: ScheduleType) => {

for (const selectedClass of schedule.classes) {
const _class = await ClassModel.findOne({
number: selectedClass.classNumber,
number: selectedClass.number,
"course.subjectArea.code": selectedClass.subject,
"course.catalogNumber.formatted": selectedClass.courseNumber,
"session.term.name": `${schedule.term.year} ${schedule.term.semester}`,
"session.term.name": `${schedule.year} ${schedule.semester}`,
}).lean();

if (!_class) continue;
Expand All @@ -33,8 +33,8 @@ export const formatSchedule = async (schedule: ScheduleType) => {
createdBy: schedule.createdBy,
public: schedule.public,
classes,
year: schedule.term.year,
semester: schedule.term.semester,
year: schedule.year,
semester: schedule.semester,
term: null,
events: schedule.events,
} as IntermediateSchedule;
Expand Down
11 changes: 6 additions & 5 deletions apps/backend/src/modules/schedule/typedefs/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ const typedef = gql`
semester: String!
term: Term!
public: Boolean!
classes: [SelectedClass!]
events: [Event!]
classes: [SelectedClass!]!
events: [Event!]!
}
type Query {
schedules: [Schedule] @auth
schedule(id: String!): Schedule
schedule(id: ID!): Schedule
}
input EventInput {
Expand All @@ -44,7 +44,7 @@ const typedef = gql`
input SelectedClassInput {
subject: String!
courseNumber: String!
classNumber: String!
number: String!
sections: [String!]!
}
Expand All @@ -57,7 +57,8 @@ const typedef = gql`
input CreateScheduleInput {
name: String!
term: TermInput!
year: Int!
semester: String!
events: [EventInput!]
classes: [SelectedClassInput!]
public: Boolean
Expand Down
2 changes: 0 additions & 2 deletions apps/frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="/favicon.png" />
<link rel="apple-touch-icon" sizes="76x76" href="/favicon.png" />
<link rel="preconnect" href="https://rsms.me/">
<link rel="stylesheet" href="https://rsms.me/inter/inter.css">
<meta name="description" content="Berkeley's online course discovery platform. Berkeleytime is a platform built, maintained, and run by students, just like you. We work hard to simplify and improve the course discovery experience." />
<title>Berkeleytime</title>
</head>
Expand Down
1 change: 1 addition & 0 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@radix-ui/react-separator": "^1.1.0",
"@radix-ui/react-tabs": "^1.1.0",
"@radix-ui/react-tooltip": "^1.1.2",
"@repo/theme": "*",
"@shopify/draggable": "^1.1.3",
"@tanstack/react-virtual": "^3.8.3",
"classnames": "^2.5.1",
Expand Down
8 changes: 2 additions & 6 deletions apps/frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import { lazy } from "react";
import { ApolloClient, ApolloProvider, InMemoryCache } from "@apollo/client";
import { RouterProvider, createBrowserRouter } from "react-router-dom";

import { ThemeProvider } from "@repo/theme";

import Catalog from "@/app/Catalog";
import Enrollment from "@/app/Enrollment";
import Grades from "@/app/Grades";
import Landing from "@/app/Landing";
import Layout from "@/components/Layout";
import ThemeProvider from "@/components/ThemeProvider";

const About = lazy(() => import("@/app/About"));
const CatalogEnrollment = lazy(() => import("@/components/Class/Enrollment"));
Expand All @@ -22,7 +23,6 @@ const Compare = lazy(() => import("@/app/Schedule/Compare"));
const Manage = lazy(() => import("@/app/Schedule/Manage"));
const Schedules = lazy(() => import("@/app/Schedules"));
const Map = lazy(() => import("@/app/Map"));
const Account = lazy(() => import("@/app/Account"));

const router = createBrowserRouter([
{
Expand Down Expand Up @@ -68,10 +68,6 @@ const router = createBrowserRouter([
element: <About />,
path: "about",
},
{
element: <Account />,
path: "account",
},
],
},
{
Expand Down
7 changes: 0 additions & 7 deletions apps/frontend/src/app/Account/index.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion apps/frontend/src/app/Catalog/Dashboard/Carousel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import classNames from "classnames";
import { ArrowRight, NavArrowLeft, NavArrowRight } from "iconoir-react";
import { Link, To } from "react-router-dom";

import IconButton from "@/components/IconButton";
import { IconButton } from "@repo/theme";

import styles from "./Carousel.module.scss";

Expand Down
11 changes: 4 additions & 7 deletions apps/frontend/src/app/Catalog/Dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import {
Search,
} from "iconoir-react";

import Button from "@/components/Button";
import Container from "@/components/Container";
import IconButton from "@/components/IconButton";
import Tooltip from "@/components/Tooltip";
import { Button, Container, IconButton, Tooltip } from "@repo/theme";

import Carousel from "./Carousel";
import styles from "./Dashboard.module.scss";
Expand All @@ -30,14 +27,14 @@ export default function Dashboard({
}: DashboardProps) {
return (
<div className={styles.root}>
<Container size="small">
<Container size="sm">
<div className={styles.header}>
<Button variant="outline">
<Button>
<ArrowSeparateVertical />
Switch terms
</Button>
<div className={styles.toggle}>
<Button onClick={() => setOpen(false)}>
<Button variant="solid" onClick={() => setOpen(false)}>
Search
<Search />
</Button>
Expand Down
7 changes: 3 additions & 4 deletions apps/frontend/src/app/Catalog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import classNames from "classnames";
import { Xmark } from "iconoir-react";
import { useNavigate, useParams, useSearchParams } from "react-router-dom";

import Boundary from "@/components/Boundary";
import { Boundary, IconButton, LoadingIndicator } from "@repo/theme";

import Class from "@/components/Class";
import ClassBrowser from "@/components/ClassBrowser";
import IconButton from "@/components/IconButton";
import LoadingIndicator from "@/components/LoadingIndicator";
import {
GET_CLASS,
GET_COURSE,
Expand Down Expand Up @@ -114,7 +113,7 @@ export default function Catalog() {

return loading ? (
<Boundary>
<LoadingIndicator size={32} />
<LoadingIndicator size="lg" />
</Boundary>
) : currentTerm ? (
<div
Expand Down
6 changes: 3 additions & 3 deletions apps/frontend/src/app/Discover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { FormEvent, useState } from "react";
import { useApolloClient } from "@apollo/client";
import { ArrowRight, Calendar } from "iconoir-react";

import { Button, Container } from "@repo/theme";

import AverageGrade from "@/components/AverageGrade";
import Button from "@/components/Button";
import Container from "@/components/Container";
import CourseDrawer from "@/components/CourseDrawer";
import Footer from "@/components/Footer";
import NavigationBar from "@/components/NavigationBar";
Expand Down Expand Up @@ -78,7 +78,7 @@ export default function Discover() {
onChange={(event) => setInput(event.target.value)}
/>
<Placeholder className={styles.placeholder} />
<Button className={styles.button}>
<Button className={styles.button} variant="solid">
Search
<ArrowRight />
</Button>
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/src/app/Landing/Features/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import classNames from "classnames";
import { ArrowRight } from "iconoir-react";
import { Link } from "react-router-dom";

import Container from "@/components/Container";
import { Container } from "@repo/theme";

import styles from "./Features.module.scss";
import calendar from "./calendar.png";
Expand Down
5 changes: 3 additions & 2 deletions apps/frontend/src/app/Landing/Hero/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { FormEvent, useEffect, useMemo, useRef, useState } from "react";

import { ArrowRight, Clock } from "iconoir-react";

import Button from "@/components/Button";
import { Button } from "@repo/theme";

import NavigationBar from "@/components/NavigationBar";

import styles from "./Hero.module.scss";
Expand Down Expand Up @@ -112,7 +113,7 @@ export default function Hero() {
autoFocus
placeholder="Search for courses..."
/>
<Button className={styles.button}>
<Button className={styles.button} variant="solid">
Go
<ArrowRight />
</Button>
Expand Down
3 changes: 2 additions & 1 deletion apps/frontend/src/app/Landing/Organization/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Minus, Plus } from "iconoir-react";

import Container from "@/components/Container";
import { Container } from "@repo/theme";

import Footer from "@/components/Footer";

import styles from "./Organization.module.scss";
Expand Down
16 changes: 10 additions & 6 deletions apps/frontend/src/app/Map/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useEffect, useRef, useState } from "react";
import { useEffect, useMemo, useRef, useState } from "react";

import { Position, ZoomIn, ZoomOut } from "iconoir-react";
import mapboxgl from "mapbox-gl";
import "mapbox-gl/dist/mapbox-gl.css";

import IconButton from "@/components/IconButton";
import usePrefersColorScheme from "@/hooks/usePrefersColorScheme";
import { IconButton, usePrefersColorScheme, useTheme } from "@repo/theme";

import { buildings } from "@/lib/location";

import styles from "./Map.module.scss";
Expand All @@ -21,7 +21,11 @@ const DEFAULT_ZOOM = 15.5;
mapboxgl.accessToken = TOKEN;

export default function Map() {
const colorScheme = usePrefersColorScheme();
const { theme } = useTheme();

const scheme = usePrefersColorScheme();

const currentTheme = useMemo(() => theme ?? scheme, [theme, scheme]);

const containerRef = useRef<HTMLDivElement | null>(null);

Expand All @@ -34,7 +38,7 @@ export default function Map() {
const map = new mapboxgl.Map({
container: containerRef.current,
style:
colorScheme === "dark"
currentTheme === "dark"
? "mapbox://styles/mathhulk/clvblbtkd005k01rd1n28b2xt"
: "mapbox://styles/mathhulk/clbznbvgs000314k8gtwa9q60",
center: [-122.2592173, 37.8721508],
Expand Down Expand Up @@ -95,7 +99,7 @@ export default function Map() {
return () => {
mapRef.current?.remove();
};
}, [colorScheme]);
}, [currentTheme]);

return (
<div className={styles.root}>
Expand Down
3 changes: 2 additions & 1 deletion apps/frontend/src/app/Plan/Term/Catalog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import * as Dialog from "@radix-ui/react-dialog";
import { Xmark } from "iconoir-react";
import { useSearchParams } from "react-router-dom";

import { IconButton } from "@repo/theme";

import CourseBrowser from "@/components/CourseBrowser";
import IconButton from "@/components/IconButton";
import { ICourse, Semester } from "@/lib/api";

import styles from "./Catalog.module.scss";
Expand Down
3 changes: 2 additions & 1 deletion apps/frontend/src/app/Plan/Term/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { forwardRef } from "react";

import { Plus } from "iconoir-react";

import IconButton from "@/components/IconButton";
import { IconButton } from "@repo/theme";

import Units from "@/components/Units";
import { ICourse, Semester } from "@/lib/api";

Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/src/app/Schedule/Compare/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { useEffect, useMemo, useRef, useState } from "react";
import { DataTransferBoth, Xmark } from "iconoir-react";
import { Link, useOutletContext } from "react-router-dom";

import IconButton from "@/components/IconButton";
import Tooltip from "@/components/Tooltip";
import { IconButton, Tooltip } from "@repo/theme";

import Units from "@/components/Units";
import Week from "@/components/Week";

Expand Down
22 changes: 15 additions & 7 deletions apps/frontend/src/app/Schedule/Manage/Map/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ import { ArrowSeparateVertical, Walking, ZoomIn, ZoomOut } from "iconoir-react";
import mapboxgl from "mapbox-gl";
import "mapbox-gl/dist/mapbox-gl.css";

import Button from "@/components/Button";
import IconButton from "@/components/IconButton";
import usePrefersColorScheme from "@/hooks/usePrefersColorScheme";
import {
Button,
IconButton,
usePrefersColorScheme,
useTheme,
} from "@repo/theme";

import { ISection } from "@/lib/api";
import { buildings } from "@/lib/location";

Expand All @@ -30,7 +34,11 @@ interface MapProps {
}

export default function Map({ selectedSections }: MapProps) {
const colorScheme = usePrefersColorScheme();
const { theme } = useTheme();

const scheme = usePrefersColorScheme();

const currentTheme = useMemo(() => theme ?? scheme, [theme, scheme]);

const containerRef = useRef<HTMLDivElement | null>(null);
const markersRef = useRef<mapboxgl.Marker[]>([]);
Expand Down Expand Up @@ -58,7 +66,7 @@ export default function Map({ selectedSections }: MapProps) {
const map = new mapboxgl.Map({
container: containerRef.current,
style:
colorScheme === "dark"
currentTheme === "dark"
? "mapbox://styles/mathhulk/clvblbtkd005k01rd1n28b2xt"
: "mapbox://styles/mathhulk/clbznbvgs000314k8gtwa9q60",
center: [-122.2592173, 37.8721508],
Expand Down Expand Up @@ -238,7 +246,7 @@ export default function Map({ selectedSections }: MapProps) {
return () => {
mapRef.current?.remove();
};
}, [colorScheme]);
}, [currentTheme]);

useEffect(() => {
if (!directions) return;
Expand All @@ -264,7 +272,7 @@ export default function Map({ selectedSections }: MapProps) {
return (
<div className={styles.root}>
<div className={styles.toolBar}>
<Button variant="outline" className={styles.button}>
<Button className={styles.button}>
<ArrowSeparateVertical />
Monday
</Button>
Expand Down
Loading

0 comments on commit ec6fb58

Please sign in to comment.