Skip to content

Commit 0b8fc9e

Browse files
committed
MAJOR UI UPDATE cookie based theme switch added
1 parent 72600aa commit 0b8fc9e

18 files changed

+2236
-29
lines changed
File renamed without changes.

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@
9999

100100
| Color | Hex |
101101
| ----------------- | ------------------------------------------------------------------ |
102-
| Primary Color | ![#222831](https://via.placeholder.com/10/222831?text=+) #222831 |
103-
| Secondary Color | ![#393E46](https://via.placeholder.com/10/393E46?text=+) #393E46 |
104-
| Accent Color | ![#00ADB5](https://via.placeholder.com/10/00ADB5?text=+) #00ADB5 |
105-
| Text Color | ![#EEEEEE](https://via.placeholder.com/10/EEEEEE?text=+) #EEEEEE |
102+
| Accent Color | ![#6320ee](https://via.placeholder.com/10/6320ee?text=+) #6320ee |
103+
| Text Color | ![#f8f0fb](https://via.placeholder.com/10/f8f0fb?text=+) #f8f0fb |
104+
| Background Color | ![#00000d](https://via.placeholder.com/10/00000d?text=+) #00000d |
105+
| Foreground Color | ![#01111d](https://via.placeholder.com/10/01111d?text=+) #01111d |
106106

107107

108108
<!-- Usage -->
@@ -114,7 +114,10 @@
114114
<!-- Roadmap -->
115115
## :compass: Roadmap
116116

117+
* [x] Complete Frontend
117118
* [x] Complete Free Courses Library
119+
* [ ] Light/Dark Mode
120+
* [ ] Sign in with Google
118121
* [ ] Build Certify (Certification engine)
119122

120123
<!-- Contributing -->

app.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
app = Flask(__name__)
99

10+
def get_theme_css():
11+
# Implement logic to retrieve the user's theme preference and return the corresponding CSS path
12+
theme_preference = "light" # Replace with your actual logic
13+
return f"static/{theme_preference}_theme.css"
14+
1015
# Register the Blueprints from separate files
1116
app.register_blueprint(index_blueprint)
1217
app.register_blueprint(browse_blueprint)

routes/browse_routes.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import data, menuData
33
from lecturesData import lecturesData
44

5+
56
browse_blueprint = Blueprint('browse', __name__)
67

78
# Map the course_name parameter to the corresponding course data using a dictionary
@@ -49,6 +50,8 @@ def details(course_name):
4950
def browse():
5051
trending = menuData.trending
5152
allCourses = menuData.all
53+
theme_preference = request.cookies.get('theme', 'light') # Default to 'light' if cookie not found
54+
theme_css = f"static/assets/sass/{theme_preference}_theme.css"
5255

5356
# If the form is submitted (POST request), get the search keyword from the form
5457
if request.method == 'POST':
@@ -58,7 +61,7 @@ def browse():
5861
for course_name, course_data in course_mapping.items():
5962
if search_keyword.lower() in course_name.lower():
6063
filtered_courses.append(course_data)
61-
return render_template('browse.html', trending=trending, allCourses=allCourses, search_keyword=search_keyword, search_results=filtered_courses)
64+
return render_template('browse.html',theme_css=theme_css, trending=trending, allCourses=allCourses, search_keyword=search_keyword, search_results=filtered_courses)
6265

6366
# If it's a GET request, show the regular browse page without search results
64-
return render_template('browse.html', trending=trending, allCourses=allCourses)
67+
return render_template('browse.html', trending=trending, allCourses=allCourses, theme_css=theme_css)

routes/error_routes.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
from flask import Blueprint, render_template
1+
from flask import Blueprint, render_template,request
2+
23

34
error_blueprint = Blueprint('error', __name__)
45

56
@error_blueprint.errorhandler(404)
67
def page_not_found(e):
7-
return render_template('components/error.html'), 404
8+
theme_preference = request.cookies.get('theme', 'light') # Default to 'light' if cookie not found
9+
theme_css = f"static/assets/sass/{theme_preference}_theme.css"
10+
return render_template('components/error.html', theme_css=theme_css), 404

routes/index_routes.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
from flask import Blueprint, render_template
1+
from flask import Blueprint, render_template, request
22
import menuData,data
33

4+
45
index_blueprint = Blueprint('index', __name__)
56

67
@index_blueprint.route('/',endpoint='index')
78
def index():
89
trending = menuData.trending
9-
return render_template('index.html', trending=trending)
10+
theme_preference = request.cookies.get('theme', 'light') # Default to 'light' if cookie not found
11+
theme_css = f"static/assets/sass/{theme_preference}_theme.css"
12+
return render_template('index.html', trending=trending, theme_css=theme_css)

routes/login_routes.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
from flask import Blueprint, render_template
1+
from flask import Blueprint, render_template, request
2+
23

34
login_blueprint = Blueprint('login', __name__)
45

56
@login_blueprint.route('/login')
67
def login():
7-
return render_template('login.html')
8+
theme_preference = request.cookies.get('theme', 'light') # Default to 'light' if cookie not found
9+
theme_css = f"static/assets/sass/{theme_preference}_theme.css"
10+
return render_template('login.html', theme_css=theme_css)

routes/profile_routes.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

static/assets/js/theme.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function setCookie(name, value) {
2+
document.cookie = `${name}=${value};path=/`;
3+
}
4+
5+
function toggleTheme() {
6+
const currentTheme = document.querySelector("link[href*='theme']").getAttribute("href");
7+
const newTheme = currentTheme.includes("light") ? "dark" : "light";
8+
document.querySelector("link[href*='theme']").setAttribute("href", `/static/assets/sass/${newTheme}_theme.css`);
9+
10+
// Set the theme preference as a cookie
11+
setCookie("theme", newTheme);
12+
}

static/assets/sass/style.css renamed to static/assets/sass/dark_theme.css

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@100 200 300 400 500 600 700 800 900");
2+
/**
3+
* $primary-color: #007AFF
4+
* $main-font-color: #00000d
5+
* $background-color: #D7EEFF
6+
* $dimText-color: #666
7+
* $darkblue-color: #FAFAFA
8+
* $cardBody-color: #F8F9FB
9+
* $yellow-color: #ffec51
10+
* $banner-gradient: linear-gradient(310deg, rgba(83,141,255,1) 0%, rgba(215,238,255,1) 100%) */
211
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, div pre, a, abbr, acronym, address,
312
big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl,
413
dt, dd, ol, ul, li, figure, header, nav, section, article, aside, footer,
@@ -671,7 +680,7 @@ section {
671680
}
672681
}
673682
.main-banner {
674-
background-image: url(../images/card.png);
683+
background: linear-gradient(310deg, #18033e 0%, #081b42 100%);
675684
background-position: center center;
676685
background-size: cover;
677686
min-height: 380px;
@@ -1033,4 +1042,4 @@ body {
10331042
.gaming-library .item ul li {
10341043
width: 16%;
10351044
}
1036-
}/*# sourceMappingURL=style.css.map */
1045+
}/*# sourceMappingURL=dark_theme.css.map */

static/assets/sass/dark_theme.css.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

static/assets/sass/style.sass renamed to static/assets/sass/dark_theme.sass

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@100 200 300 400 500 600 700 800 900")
2+
/**
3+
$primary-color: #007AFF
4+
$main-font-color: #00000d
5+
$background-color: #D7EEFF
6+
$dimText-color: #666
7+
$darkblue-color: #FAFAFA
8+
$cardBody-color: #F8F9FB
9+
$yellow-color: #ffec51
10+
$banner-gradient: linear-gradient(310deg, rgba(83,141,255,1) 0%, rgba(215,238,255,1) 100%)
211
312
$primary-color: #6320ee // accent color
413
$main-font-color: #f8f0fb // white font throughout
514
$background-color: #00000d //dark container color
615
$dimText-color: #666 //dim text in navbar
716
$darkblue-color: #01111d // layout inside blockcontent color
8-
$cardBody-color: #010b13 // card body color
17+
$cardBody-color: #010b13 // card body color #18033e
918
$yellow-color: #ffec51 // star color
10-
19+
$banner-gradient: linear-gradient(310deg, #18033e 0%, #081b42 100%)
1120

1221
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,div pre,a,abbr,acronym,address,
1322
big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,
@@ -738,8 +747,9 @@ section
738747

739748

740749

741-
.main-banner
742-
background-image: url(../images/card.png)
750+
.main-banner
751+
background: $banner-gradient
752+
//background-image: url(../images/card.png)
743753
background-position: center center
744754
background-size: cover
745755
min-height: 380px

0 commit comments

Comments
 (0)