Skip to content

Optimize sidebar transitions, add smart todo cleanup, and improve wea…#135

Open
codeCraft-Ritik wants to merge 2 commits intoprem-k-r:mainfrom
codeCraft-Ritik:main
Open

Optimize sidebar transitions, add smart todo cleanup, and improve wea…#135
codeCraft-Ritik wants to merge 2 commits intoprem-k-r:mainfrom
codeCraft-Ritik:main

Conversation

@codeCraft-Ritik
Copy link

@codeCraft-Ritik codeCraft-Ritik commented Jan 26, 2026

🛠️ Summary of Changes

  1. To-Do List: Smart Daily Cleanup

  2. **File: MaterialYouNewTab/scripts/todo-list.js

  3. Change: Modified the daily reset logic. Instead of permanently deleting unpinned completed tasks every morning, they are now marked as archived: true.

  4. Benefit: Prevents accidental data loss and allows the potential for a "Recently Deleted" view in the future.**

2. Weather: Dynamic Settings Update

  1. **File: MaterialYouNewTab/scripts/weather.js
  2. Change: Removed location.reload() from the Fahrenheit/Celsius and Min-Max temperature toggles.
  3. Benefit: The UI now updates instantly without refreshing the entire extension, providing a much smoother user experience.**

3. Bookmarks: Sidebar & Overlay Synchronization

1. File: MaterialYouNewTab/scripts/bookmarks.js
2. Change: Integrated a unified toggleBookmarkSidebar(open) function that synchronizes the background overlay (bookmarksContainer) with the sidebar slide animation.
3. Benefit: Fixes "jank" where the blur would appear or disappear at a different speed than the sidebar.

Stability: Retained all 500+ lines of original logic, including context menus, sorting, and browser-specific API handling for Firefox and Chromium.

This PR improves UI responsiveness and data safety across bookmarks, the to‑do list, weather, and adds motion polish.

Bookmarks

  • Adds a new public toggleBookmarkSidebar(open) to centralize sidebar open/close behavior and synchronize the overlay (bookmarksContainer) fade with the sidebar slide animation.
  • Permission-guarded bookmark button click: awaits verifyBookmarkPermission before toggling and enabling search clear.
  • Click-to-close is now bound to the overlay element instead of a global document listener.
  • toggleBookmarkSidebar handles overlay opacity/pointer events, sidebar state, button rotation, refocusing the search input when opened, loading bookmarks, and hiding the edit modal when closed.
  • Preserves existing search, display, context-menu, sorting, and browser-specific bookmark logic.

To‑Do List

  • Introduces archived flag handling:
    • New todos include archived: false.
    • Daily reset no longer deletes unpinned completed tasks; they are marked archived: true to avoid data loss and enable a potential "Recently Deleted" view.
    • ShowToDoList filters out archived items and clears the container before rendering.
  • Saves changes to localStorage immediately when adding items.
  • Keeps existing data model and public APIs intact.

Weather

  • Removes full page reloads (location.reload()) in multiple flows and replaces them with targeted UI updates + re-fetch:
    • API key save, manual location save, and GPS toggle now call fetchWeather()/getWeatherData() instead of reloading.
    • Fahrenheit/Celsius and min/max toggles update the UI via UpdateWeather()/in-place rendering without a full refresh.
  • Temperature rendering logic updated to compute and display °F/°C, min/max and feels-like in-place.
  • Preserves location visibility/initialization logic.

Style / Motion

  • Adds Material 3 Expressive Motion animations for to-do items (check-spring, strike-grow) and related hover/active/tactile transitions to improve perceived responsiveness.

Scope & Stability

  • Changes are focused on UI/UX behavior; all core data handling, context menus, and browser-specific APIs remain unchanged.
  • Approximate churn: bookmarks (+97/-257), todo (+12/-8), weather (~+17/-25), style (+74/-0). Estimated review effort: Medium–High.

@coderabbitai
Copy link

coderabbitai bot commented Jan 26, 2026

📝 Walkthrough

Walkthrough

Centralizes bookmark sidebar toggling via a new toggleBookmarkSidebar(open) function with permission checks and overlay handling, introduces archival for todo items (archived flag and daily archival), and replaces full-page reloads in weather flows with targeted UI updates and re-fetches.

Changes

Cohort / File(s) Summary
Bookmark sidebar unification
scripts/bookmarks.js
Added public toggleBookmarkSidebar(open) to centralize open/close behavior, updated bookmark button click to await verifyBookmarkPermission, replaced global document click-close with overlay click handling, adjusted event wiring (search focus, loadBookmarks, edit modal hide). (+97/-257)
To‑Do list archival
scripts/todo-list.js
New archived: false for created items; renderer filters archived items and clears container before render; daily reset archives unpinned/completed items instead of deleting; immediate localStorage saves on add. (+12/-8)
Weather UI update optimization
scripts/weather.js
Replaced full page reloads with targeted updates: saving API key, GPS toggle, manual location save now trigger fetchWeather()/getWeatherData()/UpdateWeather() flows; unit toggles update in-place; preserved location/visibility handling. (+17/-25)
To‑Do styling (presentational)
style.css
Added Material 3 expressive motion animations (check-spring, strike-grow) and hover/active transitions for to-do items and buttons; block duplicated in diff. (+74/-0)

Sequence Diagram(s)

mermaid
sequenceDiagram
participant User
participant PermissionChecker
participant BookmarksModule
participant UIOverlay
participant SearchInput
participant Storage

User->>BookmarksModule: click bookmarkButton
BookmarksModule->>PermissionChecker: verifyBookmarkPermission()
PermissionChecker-->>BookmarksModule: permission granted
BookmarksModule->>UIOverlay: set opacity & pointerEvents (show)
BookmarksModule->>BookmarksModule: set sidebar open state
BookmarksModule->>Storage: loadBookmarks()
Storage-->>BookmarksModule: bookmarks data
BookmarksModule->>SearchInput: focus()
UIOverlay->>BookmarksModule: click (overlay)
BookmarksModule->>UIOverlay: fade out & hide
BookmarksModule->>BookmarksModule: set sidebar closed, hide edit modal

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

refactor, ui/ux

Suggested reviewers

  • itz-rj-here
🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the three main changes with clear benefits, but missing visual evidence and checklist completion required by the template. Add visual changes section with screenshots/videos, complete the checklist items, and verify CHANGELOG.md updates are documented.
Docstring Coverage ⚠️ Warning Docstring coverage is 26.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: sidebar transitions, smart todo cleanup, and weather improvements, matching the core objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Author

@codeCraft-Ritik codeCraft-Ritik left a comment

Choose a reason for hiding this comment

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

To implement Material Design 3 "Expressive" Motion in your project, the following summary outlines the UI/UX enhancements made to the To-Do list:

  1. Spring Animation for Completion: Replaced the static checkbox toggle with a "spring" animation using cubic-bezier(0.175, 0.885, 0.32, 1.275). This allows checked items to slightly overshoot their final size, mimicking physical movement.
  2. Animated Strike-through: Introduced a progressive strike-through effect that grows across the text when a task is completed, providing a clear visual confirmation of the action.
  3. Tactile Feedback Layers: Added a dedicated :hover state that lifts the item slightly and an :active state that scales the item down to simulate a physical press.
  4. Button Transitions: Applied smooth scaling transitions to the Pin, Remove, and Edit buttons, ensuring icons react instantly and smoothly to user interaction.
  5. Interactive Guidance: These micro-interactions are designed to help users understand the interface up to four times faster by providing immediate, expressive feedback for every interaction.

Copy link

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
scripts/weather.js (3)

94-128: Saved API key/location won’t take effect with the current refresh path.

fetchWeather() closes over the initial apiKey and currentUserLocation, so saving a new key or manual location won’t be used until a full re-init. Update the captured values before calling fetchWeather().

🐛 Suggested fix
-    const savedApiKey = localStorage.getItem("weatherApiKey");
+    let savedApiKey = localStorage.getItem("weatherApiKey");
...
-    const apiKey = savedApiKey || defaultApiKey;
+    let apiKey = savedApiKey || defaultApiKey;
...
     saveAPIButton.addEventListener("click", () => {
-        const apiKey = userAPIInput.value.trim();
-        localStorage.setItem("weatherApiKey", apiKey);
+        const apiKeyInput = userAPIInput.value.trim();
+        localStorage.setItem("weatherApiKey", apiKeyInput);
+        savedApiKey = apiKeyInput;
+        apiKey = apiKeyInput || defaultApiKey;
         userAPIInput.value = "";
         fetchWeather(); // Refresh data without full reload
     });
...
     saveLocButton.addEventListener("click", () => {
         const userLocation = userLocInput.value.trim();
         localStorage.setItem("weatherLocation", userLocation);
         localStorage.setItem("useGPS", false);
+        currentUserLocation = userLocation;
         userLocInput.value = "";
         fetchWeather();
     });

101-118: Avoid re-running getWeatherData() on GPS toggle.

Calling getWeatherData() here re-binds all listeners each time, so toggling GPS can stack handlers and duplicate fetches/prompts. Extract a refresh-only path (e.g., re-evaluate location + call fetchWeather) or guard against multiple initializations.


455-503: Min/Max toggle uses a stale snapshot of isMinMaxEnabled.

updateTemperatureDisplay() reads the initial value, so UI won’t reflect checkbox changes without reload. Read the current checkbox state each render.

🐛 Suggested fix
-                    if (isMinMaxEnabled) {
+                    const minMaxEnabled = minMaxTempCheckbox?.checked ?? isMinMaxEnabled;
+                    if (minMaxEnabled) {
...
-                        if (isMinMaxEnabled) {
+                        if (minMaxEnabled) {
🤖 Fix all issues with AI agents
In `@scripts/weather.js`:
- Around line 591-610: The event handlers at module scope reference
UpdateWeather and minMaxTempCheckbox which are defined only inside
getWeatherData, causing a ReferenceError; either move the fahrenheitCheckbox,
hideWeatherCard and minMaxTempCheckbox addEventListener blocks into
getWeatherData after UpdateWeather and minMaxTempCheckbox are declared, or hoist
the declarations of UpdateWeather (function) and minMaxTempCheckbox
(element/variable) to module scope and update
saveCheckboxState/loadCheckboxState calls to use those hoisted symbols so the
listeners can safely reference UpdateWeather, fahrenheitCheckbox,
hideWeatherCard and minMaxTempCheckbox at runtime.

Copy link

@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

🤖 Fix all issues with AI agents
In `@style.css`:
- Around line 5401-5412: The .todolistitem.checked::after pseudo-element is
adding an animated strike-through on top of the existing text-decoration:
line-through in the .todolistitem.checked rule, producing a double
strike-through; decide which effect you want and either remove the
text-decoration from the existing .todolistitem.checked rule or remove/disable
the .todolistitem.checked::after block (or guard it with a modifier class like
.animated-strike) so only a single strike-through is rendered (reference
.todolistitem.checked and .todolistitem.checked::after to locate and modify the
rules).
- Around line 5433-5435: The CSS rule for selectors .todopinbtn:hover,
.todoremovebtn:hover, .todoeditbtn:hover is missing its closing brace which
causes a parse error; fix it by adding the missing closing curly brace '}' to
terminate that rule (ensure the rule block wrapping transform: scale(1.2); is
properly closed) so subsequent CSS is parsed correctly.
- Around line 5393-5426: The CSS uses undefined Material3 variables
(--md-sys-color-outline, --md-sys-color-surface-container-high,
--md-sys-color-surface-container-highest) inside the .todolistitem.checked,
.todolistitem.checked::after, .todolistitem:hover and .todolistitem:active
rules; fix by either defining these tokens in :root or replacing them with your
project's existing variables (e.g., --darkColor-blue, --textColorDark-blue) so
the color/background values have valid fallbacks—update all occurrences in the
.todolistitem selectors to use the chosen project variables consistently.

Copy link
Owner

@prem-k-r prem-k-r left a comment

Choose a reason for hiding this comment

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

Hi @codeCraft-Ritik, could you please split this PR into three separate PRs, each with an independent improvement?
This will help speed up review and merging.

@prem-k-r prem-k-r added the invalid This doesn't seem right label Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

invalid This doesn't seem right

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants