rajouter le mode auto au dark mode #20

Closed
opened 2025-11-03 16:37:20 +01:00 by admin-backup · 6 comments
admin-backup commented 2025-11-03 16:37:20 +01:00 (Migrated from 172.24.0.1:8928)

Problem Statement

The theme control currently offers only Light and Dark behavior. A user whose preferred appearance is managed by their browser or operating system cannot explicitly select a mode that keeps following that preference.

The current implementation also treats the selected preference and the resulting appearance as one boolean. When the operating-system preference changes, the control state can change without updating the theme applied to the document. Some themed surfaces independently read the operating-system preference, so an explicit Light or Dark choice can produce an inconsistent interface.

Solution

Add System as a third theme preference alongside Light and Dark. System is the default and continuously follows the browser or operating-system color-scheme preference. Explicit Light and Dark selections override later system changes for the current session.

Keep the existing theme button in its current location. Each activation cycles through System → Light → Dark → System. The button shows the selected preference rather than only the resulting appearance, and communicates the selected preference, current effective appearance, and next action accessibly.

Resolve the effective Light or Dark theme centrally and apply it consistently to the entire interface.

User Stories

  1. As a user, I want System to be available alongside Light and Dark, so that I can choose whether the application follows my device or uses an explicit appearance.
  2. As a first-time user, I want the theme preference to start in System, so that the application respects my existing browser or operating-system choice without setup.
  3. As a user in System mode, I want the initial appearance to match my current system preference, so that the first rendered theme is appropriate for my environment.
  4. As a user in System mode, I want the application to become dark when my system changes to dark, so that the application remains synchronized without another interaction.
  5. As a user in System mode, I want the application to become light when my system changes to light, so that synchronization works in both directions.
  6. As a user, I want to select Light explicitly, so that I can use a light appearance regardless of my system preference.
  7. As a user, I want an explicit Light selection to ignore later system changes, so that my manual override remains stable during the session.
  8. As a user, I want to select Dark explicitly, so that I can use a dark appearance regardless of my system preference.
  9. As a user, I want an explicit Dark selection to ignore later system changes, so that my manual override remains stable during the session.
  10. As a user returning from an explicit preference to System, I want the application to immediately use the latest system preference, so that System never applies stale information.
  11. As a user, I want the button to cycle through System, Light, and Dark in a fixed order, so that repeated activations are predictable.
  12. As a user, I want the button icon to represent the selected preference, so that I can distinguish System from an explicit theme even when both currently look identical.
  13. As a user in System mode, I want to know whether the effective appearance is currently Light or Dark, so that the control fully explains the application state.
  14. As a keyboard or assistive-technology user, I want the control to announce the current preference and its next action, so that I can operate the cycle without relying on the icon.
  15. As a user, I want the control's tooltip to explain the current preference, effective appearance, and next action, so that the icon-only interaction is understandable.
  16. As a user, I want every themed surface to use the same effective appearance, so that the interface never mixes Light and Dark styling.
  17. As a user waiting for the calendar to finish processing, I want its loading overlay and text to follow my selected theme preference, so that loading does not temporarily contradict the rest of the interface.
  18. As a user, I want browser-native and Angular Material surfaces to receive the resolved color scheme, so that built-in controls remain visually consistent with the application.

Implementation Decisions

  • Model the selected theme preference as exactly three states: System, Light, and Dark.
  • Treat the selected theme preference and the effective theme as separate concepts. The effective theme is always Light or Dark after resolving System against the current browser or operating-system preference.
  • Keep theme resolution in ThemeService. It owns the selected preference, observes system color-scheme changes, derives the effective theme, and applies that result to the document through one update path.
  • Expose enough state for the control to render the selected preference and effective appearance. Other components must not query the system color-scheme preference independently.
  • Start each fresh session in System. Persistence and restoration are separate work.
  • In System, apply operating-system changes immediately to both reactive UI state and document theme classes. In explicit Light or Dark, retain the chosen effective theme when the operating system changes.
  • Apply exactly one effective Light or Dark document class at a time and keep the document color-scheme aligned with it.
  • Keep the existing single theme button and its current placement. Do not introduce a menu, selector, or settings panel for this issue.
  • Cycle preferences in the fixed order System → Light → Dark → System.
  • Render a distinct icon for each selected preference, including a dedicated System icon. The icon communicates selected state rather than the next state.
  • Give the button an action-oriented accessible label. The label and tooltip communicate the selected preference, the effective appearance when relevant, and the preference selected by the next activation.
  • Route all theme-dependent styling through the centrally resolved effective theme. Existing styles that read the operating-system preference directly must instead consume the application's effective theme so manual overrides remain coherent.
  • Reuse the existing Angular signals, browser media-query API, Angular Material control, document classes, and CSS custom properties. Add no dependency, persistence layer, general settings abstraction, or backend contract.

Testing Decisions

  • Tests should assert externally observable behavior: the rendered control state and accessible text, the result of user activations, and the effective theme applied to the document. They should not assert private signals, helper calls, the internal representation of the three states, or stylesheet source text.
  • Use the existing theme-control component test as the primary and highest test seam. Exercise the component with the real ThemeService and a controllable browser media-query test double, then observe the button DOM and document theme classes. This single seam covers the control-to-service-to-document flow.
  • Verify that a fresh instance renders System and applies Light or Dark according to the initial system preference.
  • Verify the complete fixed cycle and its wraparound, including selected-preference icons, tooltip content, accessible next-action labels, and corresponding document theme classes.
  • Verify that system color-scheme changes update the rendered effective appearance and document classes while System is selected.
  • Verify that system color-scheme changes do not alter the rendered or applied appearance while explicit Light or Dark is selected.
  • Verify that switching back to System immediately resolves the latest system preference.
  • Verify after every transition that Light and Dark document classes are mutually exclusive.
  • Retain or simplify focused ThemeService tests only where they cover a browser-event edge that cannot be expressed clearly through the component seam; do not duplicate the same state matrix at both seams.
  • The existing ThemeService tests provide prior art for asserting document classes, and the existing theme-control component test provides the component harness to extend.
  • Do not add a separate test harness for static calendar styling. Once those styles consume the same effective-theme classes or custom properties, they share the document contract covered by the primary seam.

Out of Scope

  • Creating the settings popup tracked by #18.
  • Moving the theme control, tracked by #19.
  • Persisting the selected theme preference, tracked by #21.
  • Loading or applying a persisted preference, tracked by #22.
  • Accounts, backend synchronization, or a general user-settings architecture.
  • A menu or explicit three-option selector; the existing button remains a cycle control for this issue.
  • Scheduled, time-based, location-based, or other meanings of “Auto”; System means the live browser or operating-system preference only.
  • Preventing a pre-bootstrap theme flash.
  • Theme-transition animations, visual redesign, screenshots, and end-to-end browser tests.

Further Notes

  • The issue title's “auto” mode is named System in the product because that term identifies the source of the preference precisely.
  • The current system-change listener updates reactive state without reapplying document classes; the centralized effective-theme path must remove that desynchronization.
  • The calendar loading overlay currently follows the operating-system preference directly and can contradict an explicit application preference; it must consume the effective application theme.
  • This work does not change the Personal Leave Planning domain language or the ordered optimization model.
  • No glossary entry or ADR is warranted: theme selection is a generic, reversible UI decision rather than Personal Leave Planning terminology or a hard-to-reverse architectural trade-off.
## Problem Statement The theme control currently offers only Light and Dark behavior. A user whose preferred appearance is managed by their browser or operating system cannot explicitly select a mode that keeps following that preference. The current implementation also treats the selected preference and the resulting appearance as one boolean. When the operating-system preference changes, the control state can change without updating the theme applied to the document. Some themed surfaces independently read the operating-system preference, so an explicit Light or Dark choice can produce an inconsistent interface. ## Solution Add **System** as a third theme preference alongside Light and Dark. System is the default and continuously follows the browser or operating-system color-scheme preference. Explicit Light and Dark selections override later system changes for the current session. Keep the existing theme button in its current location. Each activation cycles through `System → Light → Dark → System`. The button shows the selected preference rather than only the resulting appearance, and communicates the selected preference, current effective appearance, and next action accessibly. Resolve the effective Light or Dark theme centrally and apply it consistently to the entire interface. ## User Stories 1. As a user, I want System to be available alongside Light and Dark, so that I can choose whether the application follows my device or uses an explicit appearance. 2. As a first-time user, I want the theme preference to start in System, so that the application respects my existing browser or operating-system choice without setup. 3. As a user in System mode, I want the initial appearance to match my current system preference, so that the first rendered theme is appropriate for my environment. 4. As a user in System mode, I want the application to become dark when my system changes to dark, so that the application remains synchronized without another interaction. 5. As a user in System mode, I want the application to become light when my system changes to light, so that synchronization works in both directions. 6. As a user, I want to select Light explicitly, so that I can use a light appearance regardless of my system preference. 7. As a user, I want an explicit Light selection to ignore later system changes, so that my manual override remains stable during the session. 8. As a user, I want to select Dark explicitly, so that I can use a dark appearance regardless of my system preference. 9. As a user, I want an explicit Dark selection to ignore later system changes, so that my manual override remains stable during the session. 10. As a user returning from an explicit preference to System, I want the application to immediately use the latest system preference, so that System never applies stale information. 11. As a user, I want the button to cycle through System, Light, and Dark in a fixed order, so that repeated activations are predictable. 12. As a user, I want the button icon to represent the selected preference, so that I can distinguish System from an explicit theme even when both currently look identical. 13. As a user in System mode, I want to know whether the effective appearance is currently Light or Dark, so that the control fully explains the application state. 14. As a keyboard or assistive-technology user, I want the control to announce the current preference and its next action, so that I can operate the cycle without relying on the icon. 15. As a user, I want the control's tooltip to explain the current preference, effective appearance, and next action, so that the icon-only interaction is understandable. 16. As a user, I want every themed surface to use the same effective appearance, so that the interface never mixes Light and Dark styling. 17. As a user waiting for the calendar to finish processing, I want its loading overlay and text to follow my selected theme preference, so that loading does not temporarily contradict the rest of the interface. 18. As a user, I want browser-native and Angular Material surfaces to receive the resolved color scheme, so that built-in controls remain visually consistent with the application. ## Implementation Decisions - Model the selected theme preference as exactly three states: System, Light, and Dark. - Treat the selected theme preference and the effective theme as separate concepts. The effective theme is always Light or Dark after resolving System against the current browser or operating-system preference. - Keep theme resolution in `ThemeService`. It owns the selected preference, observes system color-scheme changes, derives the effective theme, and applies that result to the document through one update path. - Expose enough state for the control to render the selected preference and effective appearance. Other components must not query the system color-scheme preference independently. - Start each fresh session in System. Persistence and restoration are separate work. - In System, apply operating-system changes immediately to both reactive UI state and document theme classes. In explicit Light or Dark, retain the chosen effective theme when the operating system changes. - Apply exactly one effective Light or Dark document class at a time and keep the document `color-scheme` aligned with it. - Keep the existing single theme button and its current placement. Do not introduce a menu, selector, or settings panel for this issue. - Cycle preferences in the fixed order `System → Light → Dark → System`. - Render a distinct icon for each selected preference, including a dedicated System icon. The icon communicates selected state rather than the next state. - Give the button an action-oriented accessible label. The label and tooltip communicate the selected preference, the effective appearance when relevant, and the preference selected by the next activation. - Route all theme-dependent styling through the centrally resolved effective theme. Existing styles that read the operating-system preference directly must instead consume the application's effective theme so manual overrides remain coherent. - Reuse the existing Angular signals, browser media-query API, Angular Material control, document classes, and CSS custom properties. Add no dependency, persistence layer, general settings abstraction, or backend contract. ## Testing Decisions - Tests should assert externally observable behavior: the rendered control state and accessible text, the result of user activations, and the effective theme applied to the document. They should not assert private signals, helper calls, the internal representation of the three states, or stylesheet source text. - Use the existing theme-control component test as the primary and highest test seam. Exercise the component with the real `ThemeService` and a controllable browser media-query test double, then observe the button DOM and document theme classes. This single seam covers the control-to-service-to-document flow. - Verify that a fresh instance renders System and applies Light or Dark according to the initial system preference. - Verify the complete fixed cycle and its wraparound, including selected-preference icons, tooltip content, accessible next-action labels, and corresponding document theme classes. - Verify that system color-scheme changes update the rendered effective appearance and document classes while System is selected. - Verify that system color-scheme changes do not alter the rendered or applied appearance while explicit Light or Dark is selected. - Verify that switching back to System immediately resolves the latest system preference. - Verify after every transition that Light and Dark document classes are mutually exclusive. - Retain or simplify focused `ThemeService` tests only where they cover a browser-event edge that cannot be expressed clearly through the component seam; do not duplicate the same state matrix at both seams. - The existing `ThemeService` tests provide prior art for asserting document classes, and the existing theme-control component test provides the component harness to extend. - Do not add a separate test harness for static calendar styling. Once those styles consume the same effective-theme classes or custom properties, they share the document contract covered by the primary seam. ## Out of Scope - Creating the settings popup tracked by #18. - Moving the theme control, tracked by #19. - Persisting the selected theme preference, tracked by #21. - Loading or applying a persisted preference, tracked by #22. - Accounts, backend synchronization, or a general user-settings architecture. - A menu or explicit three-option selector; the existing button remains a cycle control for this issue. - Scheduled, time-based, location-based, or other meanings of “Auto”; System means the live browser or operating-system preference only. - Preventing a pre-bootstrap theme flash. - Theme-transition animations, visual redesign, screenshots, and end-to-end browser tests. ## Further Notes - The issue title's “auto” mode is named **System** in the product because that term identifies the source of the preference precisely. - The current system-change listener updates reactive state without reapplying document classes; the centralized effective-theme path must remove that desynchronization. - The calendar loading overlay currently follows the operating-system preference directly and can contradict an explicit application preference; it must consume the effective application theme. - This work does not change the Personal Leave Planning domain language or the ordered optimization model. - No glossary entry or ADR is warranted: theme selection is a generic, reversible UI decision rather than Personal Leave Planning terminology or a hard-to-reverse architectural trade-off.
nessar commented 2026-08-28 14:16:03 +02:00 (Migrated from 172.24.0.1:8928)

changed the description

changed the description
nessar commented 2026-08-28 17:00:15 +02:00 (Migrated from 172.24.0.1:8928)

mentioned in commit c19b62ff85

mentioned in commit c19b62ff857090a90bb0980daac69878aa664855
nessar commented 2026-10-02 14:54:44 +02:00 (Migrated from 172.24.0.1:8928)

mentioned in issue #21

mentioned in issue #21
nessar commented 2026-10-02 14:54:44 +02:00 (Migrated from 172.24.0.1:8928)

Completion audit — 2026-10-02

ThemeService implements System → Light → Dark → System, follows live system changes only in System mode, and applies mutually exclusive document classes. The existing control exposes the selected preference, effective appearance and next action through its accessible label and tooltip. Native and Material styling inherit the effective color scheme. All four theme-control tests pass.

Evidence: reviewed issue requirements/discussions and f1f0835 (published application source; live main 57a39c81 only adds Renovate configuration). Tested an isolated checkout of the published source: 20 test files, 157/157 tests passed, including the five benchmark scenarios. Local commit 51978f7 and uncommitted edits were inspected separately and are not evidence of published completion.

Completion audit — 2026-10-02 ThemeService implements System → Light → Dark → System, follows live system changes only in System mode, and applies mutually exclusive document classes. The existing control exposes the selected preference, effective appearance and next action through its accessible label and tooltip. Native and Material styling inherit the effective color scheme. All four theme-control tests pass. Evidence: reviewed issue requirements/discussions and f1f0835 (published application source; live main 57a39c81 only adds Renovate configuration). Tested an isolated checkout of the published source: 20 test files, 157/157 tests passed, including the five benchmark scenarios. Local commit 51978f7 and uncommitted edits were inspected separately and are not evidence of published completion.
nessar (Migrated from 172.24.0.1:8928) closed this issue 2026-10-02 14:54:45 +02:00
nessar commented 2026-10-04 21:18:02 +02:00 (Migrated from 172.24.0.1:8928)

mentioned in issue #19

mentioned in issue #19

Preserved GitLab #20 history: source attribution, exact timestamps, discussion grouping and review positions. Historical diff snapshots: 1; visible source notes: 5.

gitlab-35-issue-20.md (SHA-256 f365509d4960972e8a51e0bcc21f530d5a2812b246f2ee3b197ae9ff7b276728)

gitlab-35-issue-20.json (SHA-256 f43b859100b317414d937bba5189a8a5f700f4ce9b1cca0e7387d1c025ecbba2)

Old CI job execution and reports are omitted. Original source files and rollback backups remain protected.

<!-- gitlab-to-gitea-history:35:Issue:20 --> Preserved GitLab #20 history: source attribution, exact timestamps, discussion grouping and review positions. Historical diff snapshots: 1; visible source notes: 5. [gitlab-35-issue-20.md](https://gitea.nessar.fr/attachments/4a9d1789-2b14-49fd-ac17-c3b16b7786f0) (SHA-256 `f365509d4960972e8a51e0bcc21f530d5a2812b246f2ee3b197ae9ff7b276728`) [gitlab-35-issue-20.json](https://gitea.nessar.fr/attachments/d083c0b2-e87f-414d-8f4a-af98e44406ad) (SHA-256 `f43b859100b317414d937bba5189a8a5f700f4ce9b1cca0e7387d1c025ecbba2`) Old CI job execution and reports are omitted. Original source files and rollback backups remain protected.
gitea-emergency added this to the Development project 2026-10-11 22:14:31 +02:00
gitea-emergency moved this to Closed in Development on 2026-10-11 22:14:31 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: nessar/vac-optimizer#20