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

SpendingReport: Fixing some display issues #3451

Merged
merged 6 commits into from
Sep 25, 2024

Conversation

carkom
Copy link
Contributor

@carkom carkom commented Sep 16, 2024

Fixing display issues in spending report and adding a legend.

@actual-github-bot actual-github-bot bot changed the title SpendingReport: Fixing some display issues [WIP] SpendingReport: Fixing some display issues Sep 16, 2024
Copy link

netlify bot commented Sep 16, 2024

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 6d105ec
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/66f3d2713ae5b600081f614a
😎 Deploy Preview https://deploy-preview-3451.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 16, 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 (+1.34 kB) +0.02%
Changeset
File Δ Size
src/components/reports/LegendItem.tsx 🆕 +669 B 0 B → 669 B
src/components/reports/reports/Spending.tsx 📈 +1.21 kB (+6.44%) 18.83 kB → 20.05 kB
src/style/themes/development.ts 📈 +31 B (+0.40%) 7.56 kB → 7.59 kB
src/style/themes/dark.ts 📈 +31 B (+0.40%) 7.63 kB → 7.66 kB
src/style/themes/light.ts 📈 +31 B (+0.39%) 7.69 kB → 7.72 kB
src/style/themes/midnight.ts 📈 +29 B (+0.39%) 7.33 kB → 7.36 kB
src/components/reports/graphs/SpendingGraph.tsx 📈 +22 B (+0.27%) 7.93 kB → 7.95 kB
src/components/reports/ReportLegend.tsx 📉 -679 B (-43.67%) 1.52 kB → 876 B
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
static/js/ReportRouter.js 1.5 MB → 1.5 MB (+1.22 kB) +0.08%
static/js/index.js 3.31 MB → 3.31 MB (+122 B) +0.00%

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
static/js/usePreviewTransactions.js 1.59 kB 0%
static/js/AppliedFilters.js 20.97 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 13.5 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/narrow.js 80.41 kB 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/wide.js 225.27 kB 0%

Copy link
Contributor

github-actions bot commented Sep 16, 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%

@carkom carkom changed the title [WIP] SpendingReport: Fixing some display issues SpendingReport: Fixing some display issues Sep 16, 2024
matt-fidd
matt-fidd previously approved these changes Sep 19, 2024
Copy link
Contributor

coderabbitai bot commented Sep 19, 2024

Walkthrough

The changes involve updates to the Spending component, the introduction of a new LegendItem component, and modifications to the SpendingGraph. The Spending component's logic for displaying comparison data has been expanded, and new UI elements have been added. The SpendingGraph now utilizes a theme object for color properties. Additionally, new exports for reportsGray have been introduced in several theme files, utilizing colorPalette.gray400 to enhance the color scheme.

Changes

Files Change Summary
packages/desktop-client/src/components/reports/reports/Spending.tsx, packages/desktop-client/src/components/reports/graphs/SpendingGraph.tsx, packages/desktop-client/src/components/reports/LegendItem.tsx, packages/desktop-client/src/components/reports/ReportLegend.tsx Enhanced comparison data display logic in Spending.tsx, updated stroke and fill properties to use theme.reportsGray in SpendingGraph.tsx, added a new LegendItem component for better UI representation, and refactored ReportLegend to utilize LegendItem.
packages/desktop-client/src/style/themes/dark.ts, packages/desktop-client/src/style/themes/development.ts, packages/desktop-client/src/style/themes/light.ts, packages/desktop-client/src/style/themes/midnight.ts Added export for reportsGray with value colorPalette.gray400.

Possibly related PRs

Suggested labels

:sparkles: Merged, :white_check_mark: Approved


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 1d670b4 and 6d105ec.

📒 Files selected for processing (2)
  • packages/desktop-client/src/components/reports/LegendItem.tsx (1 hunks)
  • packages/desktop-client/src/components/reports/reports/Spending.tsx (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/desktop-client/src/components/reports/LegendItem.tsx
  • packages/desktop-client/src/components/reports/reports/Spending.tsx

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.

@youngcw youngcw added this to the v24.10.0 milestone Sep 23, 2024
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: 2

🧹 Outside diff range and nitpick comments (1)
packages/desktop-client/src/components/reports/reports/Spending.tsx (1)

180-180: Remove unnecessary whitespace

There's extra whitespace on line 180 that should be removed to adhere to code formatting standards.

Suggested fix:

180-
🧰 Tools
GitHub Check: lint

[warning] 180-180:
Delete ··

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 7477dc4 and bfaa0f5.

📒 Files selected for processing (6)
  • packages/desktop-client/src/components/reports/graphs/SpendingGraph.tsx (1 hunks)
  • packages/desktop-client/src/components/reports/reports/Spending.tsx (5 hunks)
  • packages/desktop-client/src/style/themes/dark.ts (1 hunks)
  • packages/desktop-client/src/style/themes/development.ts (1 hunks)
  • packages/desktop-client/src/style/themes/light.ts (1 hunks)
  • packages/desktop-client/src/style/themes/midnight.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • packages/desktop-client/src/components/reports/graphs/SpendingGraph.tsx
  • packages/desktop-client/src/style/themes/dark.ts
  • packages/desktop-client/src/style/themes/development.ts
  • packages/desktop-client/src/style/themes/light.ts
  • packages/desktop-client/src/style/themes/midnight.ts
🧰 Additional context used
GitHub Check: lint
packages/desktop-client/src/components/reports/reports/Spending.tsx

[warning] 180-180:
Delete ··

GitHub Check: typecheck
packages/desktop-client/src/components/reports/reports/Spending.tsx

[failure] 489-489:
Cannot find name 'mode'.


[failure] 491-491:
Cannot find name 'mode'.


[failure] 491-491:
Cannot find name 'mode'.


[failure] 492-492:
Cannot find name 'mode'.

🔇 Additional comments not posted (1)
packages/desktop-client/src/components/reports/reports/Spending.tsx (1)

172-177: Code logic for displaying comparison data looks correct

The conditions for showCompareTo and showCompare are correctly implemented to determine whether comparison data should be displayed based on the current month and data availability.

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 (4)
packages/desktop-client/src/components/reports/LegendItem.tsx (4)

6-6: LGTM: Component declaration is correct. Consider extracting prop types.

The component declaration follows React functional component patterns and uses TypeScript for type safety. For improved readability, especially if the component grows more complex, consider extracting the prop types to a separate interface.

You could refactor it like this:

interface LegendItemProps {
  color: string;
  label: string;
}

export function LegendItem({ color, label }: LegendItemProps) {
  // ...
}

8-14: LGTM: Main container layout is correct. Consider extracting styles.

The main View container correctly sets up a row layout with centered items. However, to improve maintainability, consider extracting the inline styles to a separate styles object or using a styling library if one is already in use in the project.

You could refactor it like this:

const styles = {
  container: {
    paddingBottom: 10,
    flexDirection: 'row' as const,
    alignItems: 'center' as const,
  },
  // ... other styles
};

export function LegendItem({ color, label }: LegendItemProps) {
  return (
    <View style={styles.container}>
      {/* ... */}
    </View>
  );
}

15-23: LGTM: Colored circle implementation is correct. Consider adding accessibility attributes.

The colored circle View is correctly implemented using appropriate styles. The large borderRadius ensures a circular shape, and the dynamic backgroundColor allows for flexible use.

To improve accessibility, consider adding appropriate ARIA attributes or a role to the View. For example:

<View
  style={styles.colorIndicator}
  role="img"
  aria-label={`Color indicator for ${label}`}
>
  {/* ... */}
</View>

This change would help screen readers understand the purpose of this visual element.


24-32: LGTM: Label text styling is appropriate. Consider adding text processing.

The Text component is styled correctly to prevent wrapping and handle overflow with ellipsis. Setting flexShrink to 0 ensures the text doesn't shrink unnecessarily.

Consider adding some text processing to handle potential edge cases:

<Text style={styles.label}>
  {label.trim().length > 0 ? label : 'Unnamed'}
</Text>

This change ensures that empty or whitespace-only labels are replaced with a default value, improving the robustness of the component.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 533274e and 1d670b4.

📒 Files selected for processing (3)
  • packages/desktop-client/src/components/reports/LegendItem.tsx (1 hunks)
  • packages/desktop-client/src/components/reports/ReportLegend.tsx (2 hunks)
  • packages/desktop-client/src/components/reports/reports/Spending.tsx (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/desktop-client/src/components/reports/reports/Spending.tsx
🔇 Additional comments not posted (5)
packages/desktop-client/src/components/reports/LegendItem.tsx (2)

1-4: LGTM: Imports are correct and follow best practices.

The imports are appropriate for the component's needs. Using common components (Text and View) promotes consistency and reusability across the application.


1-35: Overall, the LegendItem component is well-implemented with room for minor enhancements.

The component successfully creates a legend item with a color indicator and label. It follows React best practices and uses TypeScript for type safety. Consider the following enhancements for future iterations:

  1. Extract prop types to a separate interface for better readability.
  2. Move inline styles to a separate styles object or use a styling library for improved maintainability.
  3. Add accessibility attributes to the color indicator View.
  4. Implement basic text processing for the label to handle edge cases.

These suggestions are optimizations that can improve the component's robustness and maintainability without changing its core functionality.

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

7-7: LGTM: New import statement for LegendItem

The import statement for LegendItem is correctly formatted and follows React component naming conventions. This change promotes modularity by separating the legend item rendering logic into its own component.


Line range hint 1-54: Overall assessment: Improved code structure

The changes in this file enhance the code structure by introducing the LegendItem component. This refactoring improves modularity and maintainability without altering the main functionality of the ReportLegend component. The changes are well-implemented and align with React best practices.

🧰 Tools
Biome

[error] 40-49: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


43-47: LGTM: Usage of LegendItem component

The replacement of the inline View component with LegendItem improves code readability and maintainability. The props are correctly passed, including the key prop for list rendering optimization.

To ensure the LegendItem component correctly implements all necessary styling and layout, please run the following script:

matt-fidd
matt-fidd previously approved these changes Sep 25, 2024
Copy link
Contributor

@matt-fidd matt-fidd left a comment

Choose a reason for hiding this comment

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

LGTM!

@matt-fidd
Copy link
Contributor

Retriggered VRT just to make sure it's a flake

@matt-fidd
Copy link
Contributor

Retriggered VRT just to make sure it's a flake

Doesn't look like it, is VRT passing locally?

@carkom
Copy link
Contributor Author

carkom commented Sep 25, 2024

Retriggered VRT just to make sure it's a flake

Doesn't look like it, is VRT passing locally?

Fixed...or so I thought

Copy link
Contributor

@matt-fidd matt-fidd left a comment

Choose a reason for hiding this comment

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

Fixed now, looks like it was just a flake this time round

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.

3 participants