From 380510e307f6317e1a2ec396d3f3fb7a95afe99f Mon Sep 17 00:00:00 2001 From: saltedtea Date: Sat, 30 Sep 2023 12:42:17 +0500 Subject: [PATCH 1/4] Added Dark Mode --- app/src/components/CourseDisplay.tsx | 6 +++--- app/src/components/ScheduleBuilder.tsx | 21 ++++++++++++++++++--- app/src/components/SectionDisplay.tsx | 4 ++-- app/src/index.css | 5 +++++ app/tailwind.config.js | 3 ++- 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/app/src/components/CourseDisplay.tsx b/app/src/components/CourseDisplay.tsx index b17976b..eb0301c 100644 --- a/app/src/components/CourseDisplay.tsx +++ b/app/src/components/CourseDisplay.tsx @@ -20,19 +20,19 @@ export default function CourseDisplay(props: Props) {
{/* Course Code & Name */} -

+

{props.course.code} {props.course.name}

{/* Description */}
-

+

{props.course.description}

{/* Additional Information */} -
+
({props.course.credits.display} Credits)
diff --git a/app/src/components/ScheduleBuilder.tsx b/app/src/components/ScheduleBuilder.tsx index c3f97d5..a0e3716 100644 --- a/app/src/components/ScheduleBuilder.tsx +++ b/app/src/components/ScheduleBuilder.tsx @@ -26,6 +26,7 @@ interface States { selections: Selection[]; schedules: Schedule[]; showAddCourse: boolean; + darkMode: boolean; // Added dark mode state } const defaultState: States = { @@ -36,6 +37,7 @@ const defaultState: States = { selections: getDefaultSelections(), schedules: [], showAddCourse: false, + darkMode: false, // Initialized dark mode state as false }; export default class ScheduleBuilder extends Component { @@ -168,6 +170,11 @@ export default class ScheduleBuilder extends Component { this.setState({ selections: newSelections }); } + // Toggle dark mode method + toggleDarkMode = () => { + this.setState((prevState) => ({ darkMode: !prevState.darkMode })); + } + render() { // Show loading screen if filters/terms haven't been fetched yet if (this.state.filters === null) @@ -185,10 +192,10 @@ export default class ScheduleBuilder extends Component { ); return ( -
+
{/* Title & Term Selector */}
-

+

🐊 Swamp Scheduler 📆

@@ -230,10 +237,18 @@ export default class ScheduleBuilder extends Component { ))} +

+ + {/* Main of Builder */}
{/* Picker */} @@ -266,4 +281,4 @@ export default class ScheduleBuilder extends Component {
); } -} +} \ No newline at end of file diff --git a/app/src/components/SectionDisplay.tsx b/app/src/components/SectionDisplay.tsx index 565f700..25e3e23 100644 --- a/app/src/components/SectionDisplay.tsx +++ b/app/src/components/SectionDisplay.tsx @@ -47,7 +47,7 @@ export default function SectionDisplay({ {" "} {/* SECTION */}
-
+
{section.number} @@ -65,7 +65,7 @@ export default function SectionDisplay({
-
+

{section.deptControlled && ( diff --git a/app/src/index.css b/app/src/index.css index b5c61c9..601141f 100644 --- a/app/src/index.css +++ b/app/src/index.css @@ -1,3 +1,8 @@ @tailwind base; @tailwind components; @tailwind utilities; + +.dark { + background-color: #1a1a1a; + color: #ffffff; +} \ No newline at end of file diff --git a/app/tailwind.config.js b/app/tailwind.config.js index 0b5a598..cf225d1 100644 --- a/app/tailwind.config.js +++ b/app/tailwind.config.js @@ -1,6 +1,7 @@ /** @type {import('tailwindcss').Config} */ -export default { +module.exports = { content: ["./src/**/*.{js,jsx,ts,tsx}"], + darkMode: "class", theme: { extend: {}, }, From b12f6d1c140331a4465b18bb5c883aed3bce1edb Mon Sep 17 00:00:00 2001 From: saltedtea Date: Mon, 9 Oct 2023 02:42:55 +0500 Subject: [PATCH 2/4] Changes to Dark Mode --- app/src/components/CourseDisplay.tsx | 6 +-- .../components/MultipleScheduleDisplay.tsx | 4 +- app/src/components/ScheduleBuilder.tsx | 25 +++--------- app/src/components/SectionDisplay.tsx | 2 +- app/src/components/SectionPicker.tsx | 6 +-- app/src/components/SelectionDisplay.tsx | 2 +- app/src/components/ThemeToggle.tsx | 39 +++++++++++++++++++ app/src/index.css | 10 +++-- 8 files changed, 61 insertions(+), 33 deletions(-) create mode 100644 app/src/components/ThemeToggle.tsx diff --git a/app/src/components/CourseDisplay.tsx b/app/src/components/CourseDisplay.tsx index eb0301c..3792a64 100644 --- a/app/src/components/CourseDisplay.tsx +++ b/app/src/components/CourseDisplay.tsx @@ -20,19 +20,19 @@ export default function CourseDisplay(props: Props) {

{/* Course Code & Name */} -

+

{props.course.code} {props.course.name}

{/* Description */}
-

+

{props.course.description}

{/* Additional Information */} -
+
({props.course.credits.display} Credits)
diff --git a/app/src/components/MultipleScheduleDisplay.tsx b/app/src/components/MultipleScheduleDisplay.tsx index 13472c4..28d6251 100644 --- a/app/src/components/MultipleScheduleDisplay.tsx +++ b/app/src/components/MultipleScheduleDisplay.tsx @@ -16,7 +16,7 @@ export default function MultipleScheduleDisplay(props: Props) { const schedulesToShow = props.schedules.slice(0, maxSchedulesToShow); return (
-

+

{props.schedules.length.toLocaleString()} Schedules Generated @@ -25,7 +25,7 @@ export default function MultipleScheduleDisplay(props: Props) { {schedulesToShow.map((schedule: Schedule, s) => (

- Schedule #{s + 1} + Schedule #{s + 1}
))} diff --git a/app/src/components/ScheduleBuilder.tsx b/app/src/components/ScheduleBuilder.tsx index a0e3716..56d79e3 100644 --- a/app/src/components/ScheduleBuilder.tsx +++ b/app/src/components/ScheduleBuilder.tsx @@ -6,6 +6,7 @@ import { Selection, } from "@scripts/scheduleGenerator"; import SectionPicker from "@components/SectionPicker"; +import ThemeToggle from "./ThemeToggle"; import MultipleSelectionDisplay from "@components/MultipleSelectionDisplay"; import MultipleScheduleDisplay from "@components/MultipleScheduleDisplay"; import { UF_SOC_API } from "@scripts/api"; @@ -26,7 +27,6 @@ interface States { selections: Selection[]; schedules: Schedule[]; showAddCourse: boolean; - darkMode: boolean; // Added dark mode state } const defaultState: States = { @@ -37,7 +37,6 @@ const defaultState: States = { selections: getDefaultSelections(), schedules: [], showAddCourse: false, - darkMode: false, // Initialized dark mode state as false }; export default class ScheduleBuilder extends Component { @@ -170,11 +169,6 @@ export default class ScheduleBuilder extends Component { this.setState({ selections: newSelections }); } - // Toggle dark mode method - toggleDarkMode = () => { - this.setState((prevState) => ({ darkMode: !prevState.darkMode })); - } - render() { // Show loading screen if filters/terms haven't been fetched yet if (this.state.filters === null) @@ -192,10 +186,10 @@ export default class ScheduleBuilder extends Component { ); return ( -
+
{/* Title & Term Selector */}
-

+

🐊 Swamp Scheduler 📆

@@ -203,7 +197,7 @@ export default class ScheduleBuilder extends Component { this.setState({ limit: Number(e.target.value) }) @@ -237,18 +231,11 @@ export default class ScheduleBuilder extends Component { ))} - +

- - {/* Main of Builder */}
{/* Picker */} diff --git a/app/src/components/SectionDisplay.tsx b/app/src/components/SectionDisplay.tsx index 25e3e23..c90e194 100644 --- a/app/src/components/SectionDisplay.tsx +++ b/app/src/components/SectionDisplay.tsx @@ -47,7 +47,7 @@ export default function SectionDisplay({ {" "} {/* SECTION */}
-
+
{section.number} diff --git a/app/src/components/SectionPicker.tsx b/app/src/components/SectionPicker.tsx index 7f2ffcc..6fc9caa 100644 --- a/app/src/components/SectionPicker.tsx +++ b/app/src/components/SectionPicker.tsx @@ -49,7 +49,7 @@ export default function SectionPicker(props: Props) { this.setSOC(e.target.value, defaultProgram) @@ -218,7 +218,7 @@ export default class ScheduleBuilder extends Component { setSearchByString(e.target.value)} @@ -83,7 +83,7 @@ export default function SectionPicker(props: Props) { diff --git a/app/src/components/SelectionDisplay.tsx b/app/src/components/SelectionDisplay.tsx index a5414a5..ebd7727 100644 --- a/app/src/components/SelectionDisplay.tsx +++ b/app/src/components/SelectionDisplay.tsx @@ -30,16 +30,16 @@ export default function SelectionDisplay(props: Props) { return (
-
+
- Course {props.ind + 1} + Course {props.ind + 1}
diff --git a/app/src/components/ThemeToggle.tsx b/app/src/components/ThemeToggle.tsx index 028b6c2..77a9e5e 100644 --- a/app/src/components/ThemeToggle.tsx +++ b/app/src/components/ThemeToggle.tsx @@ -28,7 +28,7 @@ const ThemeToggle = () => { return (