Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style: enhance the style of some platform pages #61

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
112 changes: 109 additions & 3 deletions accounts/templates/accounts/login.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,109 @@
{% for provider in providers %}
<a href="{{ provider.login_url }}">Login with {{ provider.name }}</a><br>
{% endfor %}
{% load static %}

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Login</title>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="{% static 'courses.css' %}">

<style>
body {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please move it to the courses.css? and please make sure there are no conflits with the existing styles

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or even better to login.css

font-family: 'Roboto', sans-serif;
display: flex;
flex-direction: column;
min-height: 100vh;
margin: 0;
background-color: #f8f9fa;
}

.login-container {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
}

.login-card {
background-color: #ffffff;
border-radius: 0.5rem;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
padding: 2.5rem;
max-width: 400px;
width: 100%;
}

.login-title {
text-align: center;
margin-bottom: 2rem;
font-size: 1.5rem;
font-weight: bold;
color: #343a40;
}

.login-button {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
padding: 0.75rem 1rem;
margin-bottom: 1rem;
font-size: 1rem;
font-weight: 500;
color: #fff;
background-color: #6c757d;
border: none;
border-radius: 0.25rem;
transition: background-color 0.3s ease, transform 0.3s ease;
text-decoration: none;
}

.login-button:hover {
background-color: #5a6268;
color: #fff;
transform: translateY(-2px);
text-decoration: none;
}

.login-button:active {
transform: translateY(0);
}

.login-button i {
margin-right: 0.5rem;
font-size: 1.25rem;
}

.github { background-color: #24292e; }
.github:hover { background-color: #1b1f23; }
.google { background-color: #dd4b39; }
.google:hover { background-color: #c23321; }
.slack { background-color: #4A154B; }
.slack:hover { background-color: #3b1139; }
</style>
</head>

<body>
<div class="login-container">
<div class="login-card">
<h2 class="login-title">Continue with Your Account</h2>
{% for provider in providers %}
<a href="{{ provider.login_url }}" class="login-button {{ provider.name|lower }}">
<i class="fab fa-{{ provider.name|lower }}"></i>
Continue with {{ provider.name }}
</a>
{% endfor %}

</div>
</div>

<script src="{% static 'local_date.js' %}"></script>
</body>
</html>
141 changes: 106 additions & 35 deletions courses/templates/courses/course.html
Original file line number Diff line number Diff line change
@@ -1,43 +1,117 @@
{% extends 'base.html' %}
{% load tz %}

{% block styles %}
.course-header {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here - please don't keep css in html

background-color: #f8f9fa;
border-bottom: 2px solid #e9ecef;
padding: 20px 0;
margin-bottom: 30px;
}

.course-title {
color: #343a40;
margin-bottom: 10px;
}

.course-description {
color: #6c757d;
font-size: 1.1em;
margin-bottom: 20px;
}

.action-buttons {
margin-bottom: 30px;
}

.action-buttons .btn {
margin-right: 10px;
}

.section-title {
color: #495057;
border-bottom: 2px solid #dee2e6;
padding-bottom: 10px;
margin-bottom: 20px;
}

.homework-item, .project-item {
background-color: #fff;
border: 1px solid #dee2e6;
border-radius: 5px;
padding: 15px;
margin-bottom: 15px;
transition: all 0.3s ease;
}

.homework-item:hover, .project-item:hover {
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.item-title {
font-weight: bold;
color: #007bff;
}

.item-title a {
color: inherit;
text-decoration: none;
}

.item-title a:hover {
text-decoration: underline;
}

.item-date {
font-style: italic;
color: #6c757d;
}

.badge {
font-size: 0.9em;
padding: 5px 10px;
}

.alert-info {
background-color: #e1f5fe;
border-color: #b3e5fc;
color: #01579b;
}
{% endblock %}

{% block breadcrumbs %}
<li><a href="{% url 'course' course.slug %}">{{ course.title }}</a></li>
<li class="breadcrumb-item active" aria-current="page"><a href="{% url 'course' course.slug %}">{{ course.title }}</a></li>
{% endblock %}

{% block content %}
<h2>{{ course.title }}</h2>

<div>
<p>{{ course.description }}</p>
<div class="course-header">
<h2 class="course-title">{{ course.title }}</h2>
<p class="course-description">{{ course.description }}</p>
</div>

<div>
<p>
{% if course.first_homework_scored %}
<a class="btn btn-primary" href="{% url 'leaderboard' course.slug %}" role="button">Course leaderboard</a>
{% endif %}
{% if is_authenticated %}
<a class="btn btn-info" href="{% url 'enrollment' course.slug %}" role="button">Edit course profile</a>
{% endif %}
</p>
<div class="action-buttons">
{% if course.first_homework_scored %}
<a class="btn btn-primary" href="{% url 'leaderboard' course.slug %}" role="button">Course leaderboard</a>
{% endif %}
{% if is_authenticated %}
<a class="btn btn-info" href="{% url 'enrollment' course.slug %}" role="button">Edit course profile</a>
{% endif %}
</div>


{% if is_authenticated and course.first_homework_scored %}
<div class="alert alert-info" role="alert">
<p>Total score: {{ total_score }}</p>
<p class="mb-0">Total score: {{ total_score }}</p>
</div>
{% endif %}

{% if homeworks %}
<div class="pb-3">
<h2>Homework</h2>
<h3 class="section-title">Homeworks</h3>

{% for hw in homeworks %}
<div class="p-2 {% cycle 'bg-white' '' %}">
<div class="homework-item">
<div class="row align-items-center">
<div class="col-5">
<div class="col-md-5 item-title">
{% if hw.state == 'CL' %}
{{ hw.title }}
{% else %}
Expand All @@ -46,20 +120,20 @@ <h2>Homework</h2>
</a>
{% endif %}
</div>
<div class="col-4 text-md-right" data-toggle="tooltip" data-placement="right" title="{{ hw.days_until_due }} days left">
<div class="col-md-4 text-md-right item-date" data-toggle="tooltip" data-placement="right" title="{{ hw.days_until_due }} days left">
<span class="local-date">{{ hw.due_date | date:"c" }}</span>
</div>
<div class="col-3 text-md-right">
<div class="col-md-3 text-md-right">
{% if hw.state == 'CL' %}
<span class="badge bg-secondary">Closed</span>
<span class="badge badge-secondary">Closed</span>
{% elif hw.is_scored and hw.submitted %}
<span class="badge bg-success">Scored ({{ hw.score }})</span>
<span class="badge badge-success">Scored ({{ hw.score }})</span>
{% elif hw.is_scored %}
<span class="badge bg-secondary">Scored</span>
<span class="badge badge-secondary">Scored</span>
{% elif not hw.is_scored and hw.submitted %}
<span class="badge bg-info">Submitted</span>
<span class="badge badge-info">Submitted</span>
{% else %}
<span class="badge bg-warning">Open</span>
<span class="badge badge-warning">Open</span>
{% endif %}
</div>
</div>
Expand All @@ -70,11 +144,11 @@ <h2>Homework</h2>

{% if projects %}
<div class="pb-3">
<h2>Projects</h2>
<h3 class="section-title">Projects</h3>
{% for project in projects %}
<div class="p-2 {% cycle 'bg-white' '' %}">
<div class="project-item">
<div class="row align-items-center">
<div class="col-5">
<div class="col-md-5 item-title">
{% if project.state == 'CS' %}
<a href="{% url 'project' course_slug=course.slug project_slug=project.slug %}">
{{ project.title }}
Expand All @@ -91,14 +165,14 @@ <h2>Projects</h2>
{{ project.title }}
{% endif %}
</div>
<div class="col-4 text-md-right" data-toggle="tooltip" data-placement="right" title="{{ project.days_until_due }} days left">
<div class="col-md-4 text-md-right item-date" data-toggle="tooltip" data-placement="right" title="{{ project.days_until_due }} days left">
{% if project.state == 'CS' %}
<span class="local-date">{{ project.submission_due_date | date:"c" }}</span>
{% else %}
<span class="local-date">{{ project.peer_review_due_date | date:"c" }}</span>
{% endif %}
</div>
<div class="col-3 text-md-right">
<div class="col-md-3 text-md-right">
<span class="badge {{ project.status_badge_class }}">{{ project.get_project_state_name }}</span>
</div>
</div>
Expand All @@ -107,18 +181,15 @@ <h2>Projects</h2>
</div>
{% endif %}


{% if not homeworks and not projects %}
<div class="alert alert-info" role="alert">
<p>There are no homeworks or projects available for this course yet. Come back later.</p>
<p class="mb-0">There are no homeworks or projects available for this course yet. Come back later.</p>
</div>
{% endif %}


<script>
$(function() {
$('[data-toggle="tooltip"]').tooltip()
})
</script>

{% endblock %}
25 changes: 20 additions & 5 deletions courses/templates/courses/course_list.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
{% extends 'base.html' %}

{% block content %}
<h2>Courses</h2>
<ul>
<div class="container-fluid px-4">
<h2 class="my-5 text-center">Courses</h2>
<div class="row row-cols-1 row-cols-md-2 row-cols-xl-3 g-4">
{% for course in courses %}
<li><a href="{% url 'course' course.slug %}">{{ course.title }}</a></li>
<div class="col mb-4">
<div class="card h-100 shadow hover-effect">
<img src="https://via.placeholder.com/400x250/1E448B/FFF?text={{ course.title|urlencode }}" class="card-img-top" alt="{{ course.title }}" decoding="async">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this website? I'm wondering if it's a good idea to rely on something external

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want the course card to have images like those images images so I came up with 3 approaches

  1. add ImageField to the course model and use it on the course card but this approach needs a lot of work

    • migrations and expected problems that may happen because of courses that exist and don't have an image
    • a lot of configurations are needed for Django so that Django can serve images correctly on deployment
  2. create static/imgs folder and add those images by hand and on templates and this requires

    • we should name images using the course name or course slug so that we can add them easily on templates
    • every future course we need to add an image for it on the static/imgs folder
  3. the third approach and the easiest one use third-party websites that create placeholder images that can be added to a course card

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do this in a separate PR please. I'd do it via uploading the image to S3 but it's a bigger change for now

<div class="card-body d-flex flex-column">
<h5 class="card-title fs-4">{{ course.title }}</h5>
<div class="d-flex justify-content-between align-items-center mt-3">
<a href="{% url 'course' course.slug %}" class="btn btn-primary">View Course</a>
<div class="student-enrollment">
<i class="fas fa-users me-1"></i> {{ course.students.count }}
</div>
</div>
</div>
</div>
</div>
{% endfor %}
</ul>
{% endblock %}
</div>
</div>
{% endblock %}
2 changes: 1 addition & 1 deletion courses/templates/courses/enrollment.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends 'base.html' %}

{% block breadcrumbs %}
<li><a href="{% url 'course' course.slug %}">{{ course.title }}</a></li>
<li class="breadcrumb-item active" aria-current="page"><a href="{% url 'course' course.slug %}">{{ course.title }}</a></li>
{% endblock %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion courses/templates/courses/leaderboard.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends 'base.html' %}

{% block breadcrumbs %}
<li><a href="{% url 'course' course.slug %}">{{ course.title }}</a></li>
<li class="breadcrumb-item active" aria-current="page"><a href="{% url 'course' course.slug %}">{{ course.title }}</a></li>
{% endblock %}

{% block content %}
Expand Down
4 changes: 2 additions & 2 deletions courses/templates/courses/leaderboard_score_breakdown.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{% extends 'base.html' %}

{% block breadcrumbs %}
<li><a href="{% url 'course' enrollment.course.slug %}">{{ enrollment.course.title }}</a></li>
<li><a href="{% url 'leaderboard' enrollment.course.slug %}">Leaderboard</a></li>
<li class="breadcrumb-item active" aria-current="page"><a href="{% url 'course' enrollment.course.slug %}">{{ enrollment.course.title }}</a></li>
<li class="breadcrumb-item active" aria-current="page"><a href="{% url 'leaderboard' enrollment.course.slug %}">Leaderboard</a></li>
{% endblock %}

{% block content %}
Expand Down
Loading