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

Dark mode Implementation #83

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open

Dark mode Implementation #83

wants to merge 15 commits into from

Conversation

hsna674
Copy link

@hsna674 hsna674 commented Sep 5, 2024

Closes #2

  • Adds a new field to the user model called dark_mode
  • Adds the change_theme view to the user views.

tin/apps/users/views.py Outdated Show resolved Hide resolved
tin/apps/users/forms.py Outdated Show resolved Hide resolved
@JasonGrace2282 JasonGrace2282 added enhancement New feature or request labels Sep 12, 2024
Copy link
Member

@JasonGrace2282 JasonGrace2282 left a comment

Choose a reason for hiding this comment

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

As discussed in person, can you add a test for the view to make sure it changes the dark mode?
Information on writing tests can be found on the website: https://tjcsl.github.io/tin/contributing/tests.html

@@ -8,6 +8,10 @@
{% include "meta.html" %}

<link rel="stylesheet" href="{% static 'css/base.css' %}">
{% if request.user.dark_mode %}
<link rel="stylesheet" href="{% static 'css/dark/base.css' %}">
<link rel="stylesheet" href="{% static 'css/dark/edit.css' %}">
Copy link
Member

Choose a reason for hiding this comment

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

dark/edit.css should only be loaded wherever edit.css is loaded. The way I suggest doing this is adding a context processor that adds the context variable dark_mode_enabled to every template, and use that to optionally load themes.
More information here
https://docs.djangoproject.com/en/4.2/ref/templates/api/#using-requestcontext.
Then, wherever edit.css is loaded, just do

{% if dark_mode_enabled %}
  {# link dark/edit.css #}
{% endif %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement dark mode
2 participants