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

Set theme-color at App level instead of per page #3521

Merged
merged 3 commits into from
Sep 30, 2024

Conversation

joel-jeremy
Copy link
Contributor

No description provided.

@actual-github-bot actual-github-bot bot changed the title Set theme-color at App level instead of per page [WIP] Set theme-color at App level instead of per page Sep 27, 2024
Copy link
Contributor

coderabbitai bot commented Sep 27, 2024

Walkthrough

The changes involve the removal of the useSetThemeColor hook from multiple components within the desktop client application. This results in those components no longer setting specific theme colors upon rendering. The overall logic of each component remains intact, with other functionalities preserved.

Changes

File Path Change Summary
packages/desktop-client/src/components/mobile/accounts/Account.tsx, packages/desktop-client/src/components/manager/ConfigServer.tsx, packages/desktop-client/src/components/mobile/accounts/Accounts.jsx, packages/desktop-client/src/components/mobile/budget/Category.tsx, packages/desktop-client/src/components/mobile/budget/index.tsx, packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx, packages/desktop-client/src/components/settings/index.tsx Removed useSetThemeColor import and its invocation from these components, eliminating specific theme color application.
packages/desktop-client/src/components/FinancesApp.tsx, packages/desktop-client/src/components/manager/ManagementApp.jsx Introduced useMetaThemeColor and useResponsive hooks to manage theme color based on screen width.
packages/desktop-client/src/hooks/useMetaThemeColor.ts Renamed useSetThemeColor to useMetaThemeColor and modified its parameter to be optional, updating its internal logic accordingly.

Possibly related PRs

Suggested labels

sparkles: Merged

Suggested reviewers

  • youngcw

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 3be90b6 and fa0765c.

⛔ Files ignored due to path filters (1)
  • upcoming-release-notes/3521.md is excluded by !**/*.md
📒 Files selected for processing (10)
  • packages/desktop-client/src/components/FinancesApp.tsx (2 hunks)
  • packages/desktop-client/src/components/manager/ConfigServer.tsx (0 hunks)
  • packages/desktop-client/src/components/manager/ManagementApp.jsx (2 hunks)
  • packages/desktop-client/src/components/mobile/accounts/Account.tsx (0 hunks)
  • packages/desktop-client/src/components/mobile/accounts/Accounts.jsx (0 hunks)
  • packages/desktop-client/src/components/mobile/budget/Category.tsx (0 hunks)
  • packages/desktop-client/src/components/mobile/budget/index.tsx (0 hunks)
  • packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx (0 hunks)
  • packages/desktop-client/src/components/settings/index.tsx (0 hunks)
  • packages/desktop-client/src/hooks/useMetaThemeColor.ts (1 hunks)
💤 Files with no reviewable changes (7)
  • packages/desktop-client/src/components/manager/ConfigServer.tsx
  • packages/desktop-client/src/components/mobile/accounts/Account.tsx
  • packages/desktop-client/src/components/mobile/accounts/Accounts.jsx
  • packages/desktop-client/src/components/mobile/budget/Category.tsx
  • packages/desktop-client/src/components/mobile/budget/index.tsx
  • packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx
  • packages/desktop-client/src/components/settings/index.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/desktop-client/src/components/FinancesApp.tsx
  • packages/desktop-client/src/components/manager/ManagementApp.jsx
  • packages/desktop-client/src/hooks/useMetaThemeColor.ts

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Sep 27, 2024

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit fa0765c
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/66f97168c03b7b00081f16f4
😎 Deploy Preview https://deploy-preview-3521.demo.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

github-actions bot commented Sep 27, 2024

Bundle Stats — desktop-client

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
9 5.29 MB → 5.29 MB (+186 B) +0.00%
Changeset
File Δ Size
src/hooks/useMetaThemeColor.ts 🆕 +654 B 0 B → 654 B
node_modules/es-define-property/index.js 📈 +210 B (+60.00%) 350 B → 560 B
src/components/manager/ManagementApp.jsx 📈 +124 B (+2.01%) 6.02 kB → 6.15 kB
node_modules/has-property-descriptors/index.js 📈 +9 B (+1.57%) 573 B → 582 B
src/components/FinancesApp.tsx 📈 +112 B (+1.16%) 9.43 kB → 9.54 kB
node_modules/call-bind/index.js 📈 +9 B (+0.85%) 1.04 kB → 1.05 kB
node_modules/define-data-property/index.js 📈 +9 B (+0.39%) 2.24 kB → 2.25 kB
src/components/mobile/transactions/TransactionEdit.jsx 📉 -43 B (-0.13%) 32.54 kB → 32.5 kB
src/components/mobile/budget/index.tsx 📉 -43 B (-0.36%) 11.51 kB → 11.47 kB
src/components/mobile/accounts/Accounts.jsx 📉 -43 B (-0.58%) 7.19 kB → 7.15 kB
src/components/settings/index.tsx 📉 -43 B (-0.69%) 6.1 kB → 6.06 kB
src/components/manager/ConfigServer.tsx 📉 -55 B (-0.72%) 7.45 kB → 7.4 kB
src/components/mobile/accounts/Account.tsx 📉 -43 B (-5.49%) 783 B → 740 B
src/components/mobile/budget/Category.tsx 📉 -43 B (-6.44%) 668 B → 625 B
src/hooks/useSetThemeColor.ts 🔥 -628 B (-100%) 628 B → 0 B
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
static/js/index.js 3.31 MB → 3.31 MB (+315 B) +0.01%

Smaller

Asset File Size % Changed
static/js/narrow.js 82.1 kB → 81.98 kB (-129 B) -0.15%

Unchanged

Asset File Size % Changed
static/js/indexeddb-main-thread-worker-e59fee74.js 13.5 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/AppliedFilters.js 20.96 kB 0%
static/js/usePreviewTransactions.js 1.64 kB 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/wide.js 225.27 kB 0%
static/js/ReportRouter.js 1.5 MB 0%

Copy link
Contributor

github-actions bot commented Sep 27, 2024

Bundle Stats — loot-core

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
1 1.19 MB 0%

Changeset

No files were changed

View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

No assets were bigger

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
kcab.worker.js 1.19 MB 0%

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: 0

🧹 Outside diff range and nitpick comments (3)
packages/desktop-client/src/hooks/useMetaThemeColor.ts (1)

6-11: Consider adding unit tests for the hook.

Given the changes to the hook's signature and behavior, it would be beneficial to add unit tests to ensure its correctness and prevent potential regressions.

Would you like me to generate some example unit tests for this hook or create a GitHub issue to track this task?

packages/desktop-client/src/components/manager/ManagementApp.jsx (1)

57-59: LGTM: Effective use of new hooks for responsive theming

The implementation of useResponsive and useMetaThemeColor hooks enhances the component's ability to adapt its theme based on screen width. This aligns well with the PR objective of setting the theme color at the app level.

Consider adding a brief comment explaining the purpose of the useMetaThemeColor call for better code readability. For example:

// Set theme color based on screen width (mobile vs desktop)
useMetaThemeColor(isNarrowWidth ? theme.mobileConfigServerViewTheme : null);
packages/desktop-client/src/components/FinancesApp.tsx (1)

80-80: LGTM: New constant for responsive width check

The isNarrowWidth constant is well-named and correctly utilizes the useResponsive hook. This addition enhances the component's ability to respond to different screen sizes.

Consider adding a brief comment explaining the threshold for "narrow width" to improve code clarity:

// isNarrowWidth is true for screen widths below [specific value, e.g., 768px]
const { isNarrowWidth } = useResponsive();
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6725d56 and f001c22.

⛔ Files ignored due to path filters (1)
  • upcoming-release-notes/3521.md is excluded by !**/*.md
📒 Files selected for processing (10)
  • packages/desktop-client/src/components/FinancesApp.tsx (2 hunks)
  • packages/desktop-client/src/components/manager/ConfigServer.tsx (0 hunks)
  • packages/desktop-client/src/components/manager/ManagementApp.jsx (2 hunks)
  • packages/desktop-client/src/components/mobile/accounts/Account.tsx (0 hunks)
  • packages/desktop-client/src/components/mobile/accounts/Accounts.jsx (0 hunks)
  • packages/desktop-client/src/components/mobile/budget/Category.tsx (0 hunks)
  • packages/desktop-client/src/components/mobile/budget/index.tsx (0 hunks)
  • packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx (0 hunks)
  • packages/desktop-client/src/components/settings/index.tsx (0 hunks)
  • packages/desktop-client/src/hooks/useMetaThemeColor.ts (1 hunks)
💤 Files not reviewed due to no reviewable changes (7)
  • packages/desktop-client/src/components/manager/ConfigServer.tsx
  • packages/desktop-client/src/components/mobile/accounts/Account.tsx
  • packages/desktop-client/src/components/mobile/accounts/Accounts.jsx
  • packages/desktop-client/src/components/mobile/budget/Category.tsx
  • packages/desktop-client/src/components/mobile/budget/index.tsx
  • packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx
  • packages/desktop-client/src/components/settings/index.tsx
🔇 Additional comments (9)
packages/desktop-client/src/hooks/useMetaThemeColor.ts (3)

8-10: Approve conditional check in useEffect.

The addition of the conditional check before calling setThemeColor is a good improvement. It prevents unnecessary side effects when color is undefined or null, which aligns with React best practices for hooks.


6-11: Summary: Changes align well with PR objectives.

The modifications to useMetaThemeColor (formerly useSetThemeColor) align well with the PR objective of setting the theme color at the App level instead of per page. The hook now provides more flexibility with its optional parameter and prevents unnecessary theme color updates. These changes should facilitate a more centralized approach to managing the theme color in the application.


6-6: Approve renaming and signature change, but verify usage.

The renaming of useSetThemeColor to useMetaThemeColor and making the color parameter optional are good improvements. This change allows for more flexible usage of the hook and aligns better with the file name.

Please verify that all usages of this hook across the codebase have been updated accordingly. Run the following script to check for any remaining occurrences of useSetThemeColor:

packages/desktop-client/src/components/manager/ManagementApp.jsx (3)

11-12: LGTM: New imports added correctly

The new imports for useMetaThemeColor and useResponsive are correctly placed and follow the existing import structure. These custom hooks will enhance the component's functionality for theme management and responsiveness.


Line range hint 1-186: Summary: Effective implementation of app-level theme color management

The changes to ManagementApp.jsx successfully introduce app-level theme color management with responsiveness considerations. The implementation is clean, follows React best practices, and aligns well with the PR objectives.

Key points:

  1. New hooks useMetaThemeColor and useResponsive are correctly imported and used.
  2. Theme color is now set dynamically based on screen width.
  3. The changes are localized and don't disrupt the existing component structure.

To ensure a smooth integration:

  1. Verify theme color consistency across the application using the provided script.
  2. Consider adding a brief comment explaining the useMetaThemeColor usage for better readability.

Overall, this is a solid improvement to the application's theming system.


57-59: Verify theme color consistency across the application

The introduction of dynamic theme color setting at the app level is a significant change. While the implementation looks correct, it's important to ensure consistency across the entire application.

Please run the following script to check for any potential conflicts or inconsistencies with theme color usage:

This script will help identify any potential conflicts or inconsistencies in theme color usage across the application. Please review the results to ensure that this change doesn't adversely affect other components.

✅ Verification successful

[/run_scripts]


Theme color consistency verified successfully

The dynamic theme color setting has been implemented correctly and does not conflict with other parts of the application.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for potential theme color conflicts across the application

# Search for theme color usage in other components
echo "Checking for theme color usage in other components:"
rg --type js --type jsx 'theme.*Color|setThemeColor|useSetThemeColor' packages/desktop-client/src

# Search for any remaining useSetThemeColor hooks
echo "Checking for any remaining useSetThemeColor hooks:"
rg --type js --type jsx 'useSetThemeColor' packages/desktop-client/src

# Search for other meta theme color related code
echo "Checking for other meta theme color related code:"
rg --type js --type jsx 'metaThemeColor|useMetaThemeColor' packages/desktop-client/src

Length of output: 676


Script:

#!/bin/bash
# Description: Re-run theme color usage search in .js and .jsx files

# Search for theme color usage in other components
echo "Checking for theme color usage in other components:"
rg 'theme.*Color|setThemeColor|useSetThemeColor' packages/desktop-client/src -g '*.js' -g '*.jsx'

# Search for any remaining useSetThemeColor hooks
echo "Checking for any remaining useSetThemeColor hooks:"
rg 'useSetThemeColor' packages/desktop-client/src -g '*.js' -g '*.jsx'

# Search for other meta theme color related code
echo "Checking for other meta theme color related code:"
rg 'metaThemeColor|useMetaThemeColor' packages/desktop-client/src -g '*.js' -g '*.jsx'

Length of output: 868

packages/desktop-client/src/components/FinancesApp.tsx (3)

19-19: LGTM: New import for useMetaThemeColor

The import statement for useMetaThemeColor is correctly placed and follows the existing import structure. This import is necessary for the theme color management changes implemented in this component.


80-82: Summary: Theme color management implementation

The changes in this file successfully implement theme color management at the app level, which aligns well with the PR objective. The implementation considers responsive design by applying different themes based on screen width, which is a good practice.

Key points:

  1. The isNarrowWidth constant provides a clear way to determine the current layout.
  2. The useMetaThemeColor hook is used to set the theme color conditionally based on the screen width.

These changes appear to be well-implemented and should provide a more consistent theme color experience across the application. Great job on meeting the PR objective while considering responsive design!


81-81: Confirm behavior: useMetaThemeColor implementation

The implementation of useMetaThemeColor looks good and aligns with the PR objective of setting the theme color at the app level. The conditional logic for applying theme.mobileViewTheme on narrow widths is a solid approach for responsive design.

Could you please clarify the behavior when null is passed to useMetaThemeColor? Does this revert to a default theme, or does it mean no theme color is set? It might be helpful to add a comment explaining this behavior.

To verify the implementation of useMetaThemeColor, let's check its definition:

✅ Verification successful

Clarification on useMetaThemeColor when null is passed

When useMetaThemeColor is called with null, it does not modify the theme-color meta tag, leaving it set to the initial value defined in index.html (#8812E1). If this is the intended fallback behavior, no further action is required. Otherwise, consider handling the default theme color explicitly within the hook.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find the implementation of useMetaThemeColor hook
rg --type typescript -A 10 'export function useMetaThemeColor'

Length of output: 99


Script:

#!/bin/bash
# Description: Find the implementation of useMetaThemeColor hook without specifying file type
rg 'export function useMetaThemeColor' -A 10

Length of output: 995


Script:

#!/bin/bash
# Description: Find the implementation of setThemeColor function
rg 'function setThemeColor' -A 10

Length of output: 1089


Script:

#!/bin/bash
# Description: Find all definitions and settings of the theme-color meta tag
rg '<meta\s+name=["\']theme-color["\']' -A 5
rg 'themeTag\.setAttribute\("content",\s*' -A 2

Length of output: 93


Script:

#!/bin/bash
# Description: Find all definitions and settings of the theme-color meta tag

# Search for meta tag definitions
rg '<meta\s+name=["'\'']theme-color["'\'']' -A 5

# Search for setAttribute calls on themeTag
rg 'themeTag\.setAttribute\("content",\s*' -A 2

Length of output: 433

@joel-jeremy joel-jeremy changed the title [WIP] Set theme-color at App level instead of per page Set theme-color at App level instead of per page Sep 27, 2024
@joel-jeremy joel-jeremy force-pushed the centralize-use-meta-theme-color branch from 74eb106 to fa0765c Compare September 29, 2024 15:25
@joel-jeremy joel-jeremy merged commit 92980ab into master Sep 30, 2024
19 checks passed
@joel-jeremy joel-jeremy deleted the centralize-use-meta-theme-color branch September 30, 2024 03:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants