Skip to content

Comments

feat(editor): Add theme toggle#66

Open
mslourens wants to merge 4 commits intokrushndayshmookh:mainfrom
mslourens:22-add-theme-toggle
Open

feat(editor): Add theme toggle#66
mslourens wants to merge 4 commits intokrushndayshmookh:mainfrom
mslourens:22-add-theme-toggle

Conversation

@mslourens
Copy link

@mslourens mslourens commented Oct 4, 2025

Implements #22

  • adds a button to the EditorLayout to toggle between dark mode and normal mode
  • adds an effect to app.vue to listen to the state of the darkMode toggle in the editorStore
  • adds a property and method to the editorStore to store the darkMode state

Summary by CodeRabbit

  • New Features

    • Added a dark mode for the editor.
    • Introduced a toolbar button to toggle dark mode instantly.
    • App theme now updates dynamically to reflect the selected mode.
  • Style

    • Enhanced dark theme visuals with a darker canvas background for improved contrast and comfort.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 4, 2025

Walkthrough

Adds a dark mode feature: a state and toggle action in the editor store, a toolbar button to flip dark mode, a reactive effect in App.vue to sync Quasar’s dark mode, and SCSS to adjust canvas background in dark theme.

Changes

Cohort / File(s) Change Summary
Store: Dark mode state and action
src/stores/editor-store.js
Added darkMode boolean state (default false) and toggleDarkMode() action; adjusted import order.
App integration: Quasar dark sync
src/App.vue
Imported editor store and Quasar; created reactive effect to set $q.dark.set(editorStore.darkMode).
UI: Toolbar toggle button
src/layouts/EditorLayout.vue
Added toolbar button (icon: eva-moon-outline, data-test: toolbar-toggle-darkMode) that calls editorStore.toggleDarkMode on click.
Styles: Dark theme canvas
src/css/app.scss
Added .body--dark .canvas-scroll-area { background: #23272a; }.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor U as User
    participant TB as Editor Toolbar Button
    participant ES as Editor Store
    participant APP as App.vue Effect
    participant Q as Quasar Dark Mode
    participant CSS as SCSS Rules

    U->>TB: Click "Toggle Dark Mode"
    TB->>ES: ES.toggleDarkMode()
    ES-->>ES: Flip state: darkMode = !darkMode
    ES-->>APP: darkMode state change (reactive)
    rect rgba(200,220,255,0.25)
    note right of APP: Reactive effect runs
    APP->>Q: $q.dark.set(darkMode)
    end
    Q-->>CSS: Adds body.body--dark class when enabled
    CSS-->>U: Canvas background updates
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

Flip the moon, a nibble of night,
I twitch my ears—the UI turns light to twilight.
A hop to the store, a toggle so bright,
Quasar hums softly, stars come in sight.
On velvet canvas I sketch and delight—
Dark as a burrow, cozy and right. 🌙🐇

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly captures the primary change—adding a theme toggle in the editor—using a clear conventional-commit style prefix without unnecessary detail, and it directly aligns with the PR objectives.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 520d6a8 and ba433a0.

📒 Files selected for processing (1)
  • src/css/app.scss (1 hunks)
🔇 Additional comments (1)
src/css/app.scss (1)

2-5: Dark theme override looks correct

Selector nests under Quasar’s body--dark, so the canvas picks up the darker background only when expected. Nicely scoped.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
src/App.vue (1)

6-15: Consider using watchEffect instead of effect for better idiomaticity.

The low-level effect API from @vue/reactivity works correctly here, but the more conventional and recommended approach in Vue 3's Composition API is to use watchEffect from the main vue package. Both achieve the same result, but watchEffect is the documented standard for reactive effects in components.

Apply this diff to use the more idiomatic API:

-import { effect } from 'vue'
+import { watchEffect } from 'vue'
 import { useQuasar } from 'quasar'
 
 const editorStore = useEditorStore()
 const $q = useQuasar()
 
-effect(() => {
+watchEffect(() => {
   $q.dark.set(editorStore.darkMode)
 })
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c38dcbe and 933e1a7.

📒 Files selected for processing (4)
  • src/App.vue (1 hunks)
  • src/components/editor/EditorCanvas.vue (1 hunks)
  • src/layouts/EditorLayout.vue (1 hunks)
  • src/stores/editor-store.js (3 hunks)
🔇 Additional comments (1)
src/stores/editor-store.js (1)

9-9: LGTM! Dark mode state initialized correctly.

The darkMode state is properly initialized to false, and since persist: true is configured for this store (line 29), the user's dark mode preference will be remembered across sessions, which is good UX.

Comment on lines 428 to 432
.body--dark {
.canvas-scroll-area {
background: #23272a;
}
}
Copy link
Contributor

@coderabbitai coderabbitai bot Oct 4, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Scoped styles prevent the dark mode selector from working.

The .body--dark class is applied by Quasar to the <body> element, which is outside this component's scope. With <style scoped>, Vue's scope isolation will prevent this selector from matching correctly. The dark mode background color will not be applied.

Apply this diff to fix the selector by using Vue's :deep() pseudo-class or moving it to a global style:

Option 1 (Recommended): Use :deep() to pierce scoping:

-.body--dark {
-  .canvas-scroll-area {
+:deep(.body--dark) {
+  & .canvas-scroll-area {
     background: #23272a;
   }
 }

Option 2: Move to a non-scoped style block:

Add a separate <style> block (without scoped) at the end of the file:

<style>
.body--dark .canvas-scroll-area {
  background: #23272a;
}
</style>
🤖 Prompt for AI Agents
In src/components/editor/EditorCanvas.vue around lines 428-432, the .body--dark
.canvas-scroll-area selector is inside a <style scoped> block so it won’t match
the global <body> class; update the styles to pierce component scope by using
Vue’s deep selector (e.g., :deep(.body--dark) .canvas-scroll-area) or move that
rule into a separate non-scoped <style> block at the end of the file so the
.body--dark selector applies globally and the dark background is applied.

Copy link
Owner

Choose a reason for hiding this comment

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

Let's move it to global style.

Copy link
Contributor

Choose a reason for hiding this comment

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

@krushndayshmookh, perfect! Here's the implementation to move the dark mode styles to a global style block:

Remove from the scoped styles (lines 428-432):

.body--dark {
  .canvas-scroll-area {
    background: #23272a;
  }
}

Add a new non-scoped style block at the end of the file (after the closing </style> tag of the scoped section):

<style>
.body--dark .canvas-scroll-area {
  background: #23272a;
}
</style>

This will allow the .body--dark class applied to the <body> element by Quasar to properly target the canvas scroll area and apply the dark background color.

Copy link
Owner

Choose a reason for hiding this comment

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

Global styles are in src/css/app.scss

Copy link
Contributor

Choose a reason for hiding this comment

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

@krushndayshmookh, thank you for clarifying! I'll update the recommendation to use your project's global styles file.

In src/components/editor/EditorCanvas.vue:

Remove the dark mode styles from the scoped section (lines 428-432):

.body--dark {
  .canvas-scroll-area {
    background: #23272a;
  }
}

In src/css/app.scss:

Add the following at an appropriate location in the file:

.body--dark .canvas-scroll-area {
  background: #23272a;
}

This keeps your global styles centralized in the project's designated location and will properly apply the dark background when Quasar's dark mode is active.


✏️ Learnings added
Learnt from: krushndayshmookh
PR: krushndayshmookh/animated-vg#66
File: src/components/editor/EditorCanvas.vue:428-432
Timestamp: 2025-10-07T14:14:45.805Z
Learning: In the animated-vg project, global styles are maintained in src/css/app.scss rather than using non-scoped style blocks within individual components.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 933e1a7 and eacf60f.

📒 Files selected for processing (2)
  • src/layouts/EditorLayout.vue (1 hunks)
  • src/stores/editor-store.js (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/stores/editor-store.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Comment on lines 428 to 432
.body--dark {
.canvas-scroll-area {
background: #23272a;
}
}
Copy link
Owner

Choose a reason for hiding this comment

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

Let's move it to global style.

@mslourens
Copy link
Author

Hi @krushndayshmookh, can you approve my PR so I can merge it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants