diff --git a/main/frontend/src/styles/main.scss b/main/frontend/src/styles/main.scss index 174d6e9..8d51e65 100644 --- a/main/frontend/src/styles/main.scss +++ b/main/frontend/src/styles/main.scss @@ -147,3 +147,176 @@ h2 { font-family: Fraunces, Georgia, serif; letter-spacing: -.03em; } .onboarding-tour { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px 24px; max-width: 760px; margin: 0 auto 26px; padding: 21px 23px; border: 1px solid #b8d6c1; border-radius: 17px; color: $ink; background: linear-gradient(135deg, #f3fbf5, $surface); box-shadow: $shadow; }.onboarding-tour .eyebrow { grid-column: 1 / -1; margin: 0; color: $forest; }.onboarding-tour h2 { margin: 0; font-size: 1.3rem; }.onboarding-tour > p:not(.eyebrow) { grid-column: 1 / -1; margin: 0; color: $muted; }.onboarding-tour__actions { display: flex; align-items: center; gap: 16px; }.onboarding-tour__actions form { margin: 0; }.onboarding-tour__actions .text-link { padding: 0; border: 0; background: transparent; }.onboarding-highlight { position: relative; z-index: 2; outline: 3px solid rgba($forest, .52); outline-offset: 4px; border-radius: 12px; box-shadow: 0 0 0 8px rgba($mint, .75), $shadow; }.primary-nav .onboarding-highlight { outline-offset: 3px; border-radius: 5px; } @media (max-width: 560px) { .onboarding-tour { display: block; padding: 19px; }.onboarding-tour > p:not(.eyebrow) { margin-top: 7px; }.onboarding-tour__actions { margin-top: 15px; } } + + +/* Per-user dark appearance ------------------------------------------------ */ +.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; } +.theme-toggle { margin: 0; } +.theme-toggle button { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 1px solid $line; border-radius: 50%; color: $muted; background: $surface; font-size: 1.1rem; line-height: 1; } +.theme-toggle button:hover { color: $forest; border-color: rgba($forest, .35); background: $mint; } +.theme-toggle button:focus-visible { outline: 3px solid rgba($forest, .35); outline-offset: 3px; } + +body[data-theme="dark"] { + color-scheme: dark; + color: #e8eee9; + background: #151b18; +} +html:has(body[data-theme="dark"]) { background: #151b18; } +body[data-theme="dark"] .site-header { border-color: #354039; background: rgba(24, 31, 27, .92); } +body[data-theme="dark"] .brand { color: #f3f7f3; } +body[data-theme="dark"] .primary-nav > a:not(.button), +body[data-theme="dark"] .nav-logout button { color: #bac5bd; } +body[data-theme="dark"] .primary-nav > a:not(.button):hover, +body[data-theme="dark"] .nav-logout button:hover { color: #a9ddba; } +body[data-theme="dark"] .theme-toggle button { border-color: #46544b; color: #e8eee9; background: #27312b; } +body[data-theme="dark"] .theme-toggle button:hover { color: #e8eee9; background: #355a45; } +body[data-theme="dark"] .hero__copy, +body[data-theme="dark"] .muted, +body[data-theme="dark"] .task-card__description, +body[data-theme="dark"] .task-card__meta, +body[data-theme="dark"] .budget-note, +body[data-theme="dark"] .recommendation-card__main > p, +body[data-theme="dark"] .form-layout__intro p:last-child, +body[data-theme="dark"] .settings-card > p, +body[data-theme="dark"] .fasting-widget__copy, +body[data-theme="dark"] .fasting-widget__cycle-copy, +body[data-theme="dark"] .fasting-history li, +body[data-theme="dark"] .checkin-calendar__legend, +body[data-theme="dark"] .sleep-trend header p, +body[data-theme="dark"] .sleep-trend__empty, +body[data-theme="dark"] .onboarding-tour > p:not(.eyebrow) { color: #b8c3bb; } +body[data-theme="dark"] .eyebrow, +body[data-theme="dark"] .text-link, +body[data-theme="dark"] .back-link a, +body[data-theme="dark"] .task-facts a, +body[data-theme="dark"] .checkin-tabs__tab.is-active { color: #9bd5ae; } +body[data-theme="dark"] .checkin-tabs, +body[data-theme="dark"] .checkin-tabs__tab.is-active { border-color: #41614b; } +body[data-theme="dark"] .checkin-tabs__tab { color: #b8c3bb; } +body[data-theme="dark"] .checkin-tabs__tab:hover { color: #b9edc8; } +body[data-theme="dark"] .fasting-widget, +body[data-theme="dark"] .recommendations-panel, +body[data-theme="dark"] .planner-controls, +body[data-theme="dark"] .task-card, +body[data-theme="dark"] .auth-panel, +body[data-theme="dark"] .settings-card, +body[data-theme="dark"] .weather-widget { border-color: #38443d; background: #202923; box-shadow: 0 18px 45px rgba(0, 0, 0, .22); } +body[data-theme="dark"] .weather-widget { background: linear-gradient(145deg, #26352d, #202923); } +body[data-theme="dark"] .task-card--inactive { background: #1c241f; } +body[data-theme="dark"] .task-card--completed { background: #23342a; } +body[data-theme="dark"] .task-filters, +body[data-theme="dark"] .recommendations-panel__header { border-color: #38443d; background: #1b231e; } +body[data-theme="dark"] .task-card__meta span { background: #303b33; } +body[data-theme="dark"] .recommendation-card, +body[data-theme="dark"] .task-facts > div, +body[data-theme="dark"] .subtasks-list, +body[data-theme="dark"] .subtasks-list li, +body[data-theme="dark"] .sleep-trend, +body[data-theme="dark"] .sleep-trend th, +body[data-theme="dark"] .sleep-trend td, +body[data-theme="dark"] .fasting-widget__schedule, +body[data-theme="dark"] .checkin-form { border-color: #3b473f; } +body[data-theme="dark"] .recommendation-card__subtasks, +body[data-theme="dark"] .fasting-widget__windows { background: #29342d; } +body[data-theme="dark"] .recommendation-card__subtasks a, +body[data-theme="dark"] .subtasks-list a, +body[data-theme="dark"] .fasting-widget__cycle-copy time, +body[data-theme="dark"] .fasting-history time { color: #edf5ef; } +body[data-theme="dark"] .prose { color: #d5dfd7; } +body[data-theme="dark"] .field label:not(.checkbox-field), +body[data-theme="dark"] .form-field label, +body[data-theme="dark"] .checkbox-field, +body[data-theme="dark"] .fasting-form .field label:not(.checkbox-field), +body[data-theme="dark"] .checkin-form .field label:not(.checkbox-field) { color: #d5dfd7; } +body[data-theme="dark"] .field input:not([type="checkbox"]), +body[data-theme="dark"] .field select, +body[data-theme="dark"] .field textarea, +body[data-theme="dark"] .form-field input, +body[data-theme="dark"] .form-field select, +body[data-theme="dark"] .planner-controls input, +body[data-theme="dark"] .planner-controls select, +body[data-theme="dark"] .task-filters select, +body[data-theme="dark"] .fasting-form .field input:not([type="checkbox"]), +body[data-theme="dark"] .checkin-form .field input:not([type="checkbox"]) { border-color: #536159; color: #edf5ef; background: #161d19; } +body[data-theme="dark"] .field input:not([type="checkbox"]):focus, +body[data-theme="dark"] .field select:focus, +body[data-theme="dark"] .field textarea:focus { border-color: #79bd8f; box-shadow: 0 0 0 3px rgba(121, 189, 143, .24); } +body[data-theme="dark"] .field small, +body[data-theme="dark"] .form-field small, +body[data-theme="dark"] .fasting-form .field small, +body[data-theme="dark"] .checkin-form .field small, +body[data-theme="dark"] .sleep-trend thead th, +body[data-theme="dark"] .checkin-calendar__weekdays { color: #aebbb2; } +body[data-theme="dark"] .flash-message { color: #c7f0d2; background: #244832; } +body[data-theme="dark"] .task-weather-forecast { color: #c3e8cf; background: #244532; } +body[data-theme="dark"] .category-picker__clear:hover { color: #edf5ef; background: #354039; } +body[data-theme="dark"] .category-picker__suggestions { border-color: #536159; background: #202923; box-shadow: 0 18px 45px rgba(0, 0, 0, .32); } +body[data-theme="dark"] .category-picker__suggestions [role="option"][aria-selected="true"], +body[data-theme="dark"] .category-picker__suggestions [role="option"]:hover { color: #d4f2dc; background: #31523d; } +body[data-theme="dark"] .fasting-timer__track { stroke: #3b473f; } +body[data-theme="dark"] .fasting-state--fasting { color: #c4f0d1; background: #254f37; } +body[data-theme="dark"] .fasting-state--eating { color: #ffe3a0; background: #5b4722; } +body[data-theme="dark"] .checkin-day { color: #e8eee9; background: #303a33; } +body[data-theme="dark"] .checkin-day--unrecorded { color: #aab5ad; background: #242d27; border-color: #58645c; } +body[data-theme="dark"] .checkin-day--zero { color: #c8f3d2; background: #28533a; } +body[data-theme="dark"] .checkin-day--low { color: #eef2b8; background: #536036; } +body[data-theme="dark"] .checkin-day--moderate { color: #ffe5a8; background: #71521c; } +body[data-theme="dark"] .checkin-day--high { color: #ffd0c5; background: #733b31; } +body[data-theme="dark"] .checkin-day--severe { color: #fff; background: #a8463b; } +body[data-theme="dark"] .checkin-day--today { border-color: #8fd2a3; } +body[data-theme="dark"] .checkin-day--selected { box-shadow: inset 0 0 0 2px #e8eee9; } +body[data-theme="dark"] .checkin-legend--unrecorded { border-color: #7a887e; background: #242d27; } +body[data-theme="dark"] .checkin-legend--zero { background: #28533a; } +body[data-theme="dark"] .onboarding-tour { border-color: #497257; color: #e8eee9; background: linear-gradient(135deg, #244631, #202923); box-shadow: 0 18px 45px rgba(0, 0, 0, .25); } +body[data-theme="dark"] .onboarding-highlight { outline-color: rgba(145, 215, 165, .7); box-shadow: 0 0 0 8px rgba(45, 90, 61, .75), 0 18px 45px rgba(0, 0, 0, .25); } + + +/* Complete the dark surface hierarchy for the dashboard panels. */ +body[data-theme="dark"] .task-panel, +body[data-theme="dark"] .workout-panel, +body[data-theme="dark"] .checkin-panel, +body[data-theme="dark"] .detail-card, +body[data-theme="dark"] .task-form, +body[data-theme="dark"] .confirmation-card { border-color: #38443d; background: #202923; box-shadow: 0 18px 45px rgba(0, 0, 0, .22); } +body[data-theme="dark"] .task-filters { border-color: #38443d; background: #1b231e; } +body[data-theme="dark"] .task-card__footer, +body[data-theme="dark"] .workout-list { border-color: #3b473f; } +body[data-theme="dark"] .task-filters label, +body[data-theme="dark"] .loading-indicator, +body[data-theme="dark"] .subtask-count, +body[data-theme="dark"] .status-button, +body[data-theme="dark"] .workout-panel__header p:last-child, +body[data-theme="dark"] .workout-panel__summary span, +body[data-theme="dark"] .workout-panel__note, +body[data-theme="dark"] .workout-entry p, +body[data-theme="dark"] .workout-empty, +body[data-theme="dark"] .checkin-panel__header > div > p:last-child, +body[data-theme="dark"] .checkin-streaks dt, +body[data-theme="dark"] .checkin-streaks__note dd, +body[data-theme="dark"] .checkin-physio-total, +body[data-theme="dark"] .fasting-widget__schedule dt, +body[data-theme="dark"] .fasting-history h3 { color: #b8c3bb; } +body[data-theme="dark"] .workout-panel__summary strong, +body[data-theme="dark"] .checkin-streaks dd, +body[data-theme="dark"] .checkin-physio-total strong, +body[data-theme="dark"] .budget-note strong { color: #9bd5ae; } +body[data-theme="dark"] .status-button__dot, +body[data-theme="dark"] .task-card--completed .task-completion-button .status-button__dot { background: #8fd2a3; } +body[data-theme="dark"] .priority--low { color: #bde7cd; background: #254f37; } +body[data-theme="dark"] .priority--medium { color: #ffe3a0; background: #5b4722; } +body[data-theme="dark"] .priority--high { color: #ffd0c5; background: #6d3931; } + + +/* Secondary controls and compact widgets need their own dark contrast. */ +body[data-theme="dark"] .button--secondary { color: #b9edc8; border-color: #568466; background: #263c2e; } +body[data-theme="dark"] .button--secondary:hover { color: #f4fbf6; border-color: #78bc8d; background: #356448; } +body[data-theme="dark"] .button--secondary:focus-visible { outline-color: rgba(153, 213, 174, .65); } +body[data-theme="dark"] .detail-card__header .button--secondary { color: #fff; border-color: rgba(255, 255, 255, .58); background: transparent; } +body[data-theme="dark"] .detail-card__header .button--secondary:hover { color: #1f4e39; background: #fff; } +body[data-theme="dark"] .weather-widget__reading { color: #edf5ef; } +body[data-theme="dark"] .weather-widget__detail { color: #b8c3bb; } +body[data-theme="dark"] .weather-widget__icon { color: #e4f5e8; } +body[data-theme="dark"] .checkin-tooltip { color: #d9f5e0; background: #315b41; box-shadow: inset 0 0 0 1px #598b69; } +body[data-theme="dark"] .checkin-tooltip:hover { background: #3b704e; } +body[data-theme="dark"] .checkin-tooltip:focus-visible { outline-color: #a9ddba; } +body[data-theme="dark"] .checkin-tooltip__content { color: #edf5ef; background: #101713; box-shadow: 0 8px 20px rgba(0, 0, 0, .38); } diff --git a/main/planner/context_processors.py b/main/planner/context_processors.py new file mode 100644 index 0000000..6bd4348 --- /dev/null +++ b/main/planner/context_processors.py @@ -0,0 +1,14 @@ +"""Template context shared by Tasknest pages.""" + +from .models import UserSettings + + +def appearance(request): + """Expose the signed-in user’s saved colour preference without creating settings.""" + user = getattr(request, "user", None) + if user is not None and user.is_authenticated: + saved_appearance = ( + UserSettings.objects.filter(user=user).values_list("appearance", flat=True).first() + ) + return {"user_appearance": saved_appearance or UserSettings.Appearance.LIGHT} + return {"user_appearance": UserSettings.Appearance.LIGHT} diff --git a/main/planner/management/commands/seed_demo.py b/main/planner/management/commands/seed_demo.py index 2934b13..0a30c45 100644 --- a/main/planner/management/commands/seed_demo.py +++ b/main/planner/management/commands/seed_demo.py @@ -41,6 +41,7 @@ class Command(BaseCommand): profile, _ = UserSettings.objects.get_or_create(user=user) profile.time_zone = DEFAULT_TIME_ZONE + profile.appearance = UserSettings.Appearance.LIGHT profile.latitude = '52.367600' profile.longitude = '4.904100' profile.onboarding_enabled = False diff --git a/main/planner/migrations/0013_usersettings_appearance.py b/main/planner/migrations/0013_usersettings_appearance.py new file mode 100644 index 0000000..c048c32 --- /dev/null +++ b/main/planner/migrations/0013_usersettings_appearance.py @@ -0,0 +1,18 @@ +# Generated by Django 6.1.1 on 2026-09-30 16:08 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('planner', '0012_usersettings_onboarding_enabled_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='usersettings', + name='appearance', + field=models.CharField(choices=[('light', 'Light'), ('dark', 'Dark')], default='light', max_length=5), + ), + ] diff --git a/main/planner/models.py b/main/planner/models.py index 9118750..b04ad62 100644 --- a/main/planner/models.py +++ b/main/planner/models.py @@ -95,6 +95,10 @@ class Task(models.Model): class UserSettings(models.Model): """Private, per-user preferences that do not belong on Django's User model.""" + class Appearance(models.TextChoices): + LIGHT = 'light', 'Light' + DARK = 'dark', 'Dark' + user = models.OneToOneField( settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='planner_settings' ) @@ -107,6 +111,9 @@ class UserSettings(models.Model): validators=[MinValueValidator(-180), MaxValueValidator(180)], ) time_zone = models.CharField(max_length=64, default='Europe/Amsterdam') + appearance = models.CharField( + max_length=5, choices=Appearance.choices, default=Appearance.LIGHT, + ) onboarding_enabled = models.BooleanField(default=True) onboarding_step = models.PositiveSmallIntegerField(default=0) created_at = models.DateTimeField(auto_now_add=True) diff --git a/main/planner/templates/planner/base.html b/main/planner/templates/planner/base.html index e85485a..f4e0877 100644 --- a/main/planner/templates/planner/base.html +++ b/main/planner/templates/planner/base.html @@ -8,7 +8,7 @@ {% block title %}Tasknest{% endblock %} {% vite_asset 'src/main.js' %} - +