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

feat: Dashboard > Home: Expense and Report Stats display the exact amount #3365

Merged
merged 4 commits into from
Dec 18, 2024

Conversation

SahilK-027
Copy link
Contributor

@SahilK-027 SahilK-027 commented Dec 17, 2024

Clickup

clickup link

UI Preview

Screen.Recording.2024-12-17.at.2.44.23.PM.mov

Summary by CodeRabbit

  • New Features

    • Enhanced display logic for currency values based on screen size.
    • Improved responsiveness of the dashboard component.
  • Bug Fixes

    • Adjusted grid layout for better visual alignment.
  • Style

    • Updated styling for various elements, including font sizes and colors.
    • Simplified padding properties for consistent spacing.
  • Tests

    • Added ExactCurrencyPipe to the test declarations for improved testing coverage.

Copy link

coderabbitai bot commented Dec 17, 2024

Walkthrough

The stat-badge component now performs like a superstar! Changes span multiple files, showcasing responsive screen size detection, enhanced currency display logic, and refined styling. The component adapts dynamically to screen sizes, employing smart pipes to render currency values with precision. This transformation is not just a change; it's a code revolution, my friend!

Changes

File Change Summary
stat-badge.component.html - Grid layout modified (column sizes adjusted)
- Conditional currency display logic implemented
stat-badge.component.scss - Removed padding from count column
- Updated font sizes and colors
stat-badge.component.spec.ts - Added ExactCurrencyPipe to test declarations
stat-badge.component.ts - Added screen size detection
- Updated method signature for onBadgeClicked
stats.component.scss - Updated header color
- Consolidated row padding declarations

Possibly related PRs

Suggested labels

size/M

Suggested reviewers

  • Dimple16
  • Chethan-Fyle

Poem

🌟 In the realm of code, a star takes flight,
Stat badges shine, oh what a sight!
Currencies dance, responsive and bright,
A coding saga, pure delight!
With every line, the magic ignites! 🚀

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


🪧 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@github-actions github-actions bot added the size/S Small PR label Dec 17, 2024
@github-actions github-actions bot added size/M Medium PR and removed size/S Small PR labels Dec 17, 2024
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: 5

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cb9cd69 and 6f644d4.

📒 Files selected for processing (5)
  • src/app/fyle/dashboard/stat-badge/stat-badge.component.html (3 hunks)
  • src/app/fyle/dashboard/stat-badge/stat-badge.component.scss (1 hunks)
  • src/app/fyle/dashboard/stat-badge/stat-badge.component.spec.ts (2 hunks)
  • src/app/fyle/dashboard/stat-badge/stat-badge.component.ts (2 hunks)
  • src/app/fyle/dashboard/stats/stats.component.scss (2 hunks)
🔇 Additional comments (4)
src/app/fyle/dashboard/stats/stats.component.scss (1)

23-23: Mind-blowing color enhancement, boss!

The color change from grey-light to black-light is a superstar move! Better contrast means better readability. When numbers speak, they must speak with style and clarity!

src/app/fyle/dashboard/stat-badge/stat-badge.component.ts (1)

37-44: 🧹 Nitpick (assertive)

Let's make this code as strong as my stunts, partner!

The click handler is working well, but we can make it more powerful with proper TypeScript types!

-  @Output() badgeClicked = new EventEmitter();
+  @Output() badgeClicked = new EventEmitter<ReportStates | string>();

Likely invalid or redundant comment.

src/app/fyle/dashboard/stat-badge/stat-badge.component.scss (1)

79-80: 🧹 Nitpick (assertive)

Mind it! The font size might be too small for some users!

The 12px font size might be challenging for users with visual impairments. Let's make it more accessible!

Consider these style improvements:

  1. Use relative units (rem) instead of pixels
  2. Ensure color contrast meets WCAG guidelines
  3. Add a minimum touch target size for better mobile interaction
 &--amount {
   font-weight: 500;
-  font-size: 12px;
+  font-size: 0.875rem; /* 14px */
   color: $black;
 }

 &--name {
-  font-size: 12px;
+  font-size: 0.875rem; /* 14px */
   line-height: 18px;

Also applies to: 84-84

src/app/fyle/dashboard/stat-badge/stat-badge.component.spec.ts (1)

Line range hint 1-89: Thalaiva says: Let's verify all test files, partner!

Let's make sure we haven't missed updating any related test files that might need the ExactCurrencyPipe.

✅ Verification successful

Thalaiva's verdict: All test files are in perfect harmony, partner!

After scanning the entire codebase like a bullet train, I can see that the StatBadgeComponent is only used in its own spec file, and that file already has the ExactCurrencyPipe properly imported and declared. The other test files that use currency-related functionality have their own specific currency pipe implementations based on their needs.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find all spec files that might be using currency pipes
echo "Looking for other test files that might need ExactCurrencyPipe..."
rg -l "CurrencyPipe|currency" --glob "**/*.spec.ts" --type ts

# Check for potential missing imports
echo "Checking for files that might be missing ExactCurrencyPipe..."
rg -l "StatBadgeComponent" --glob "**/*.spec.ts" --type ts | xargs rg -L "ExactCurrencyPipe"

Length of output: 7082

Copy link
Contributor

@Dimple16 Dimple16 left a comment

Choose a reason for hiding this comment

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

one imp comment

src/app/fyle/dashboard/stat-badge/stat-badge.component.ts Outdated Show resolved Hide resolved
@github-actions github-actions bot added size/S Small PR and removed size/M Medium PR labels Dec 17, 2024
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: 2

♻️ Duplicate comments (1)
src/app/fyle/dashboard/stat-badge/stat-badge.component.ts (1)

28-29: ⚠️ Potential issue

Listen carefully! The screen size detection needs more power!

The previous review's suggestion about BreakpointObserver is still valid, mind it! Using window directly is not the style of a superstar!

-  // To track if the screen is small (360px or below)
-  isSmallScreen = false;
+  private readonly SMALL_SCREEN_BREAKPOINT = 360;
+  isSmallScreen$ = this.breakpointObserver
+    .observe(`(max-width: ${this.SMALL_SCREEN_BREAKPOINT}px)`)
+    .pipe(map(result => result.matches));
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6f644d4 and c8b950f.

📒 Files selected for processing (1)
  • src/app/fyle/dashboard/stat-badge/stat-badge.component.ts (2 hunks)
🔇 Additional comments (1)
src/app/fyle/dashboard/stat-badge/stat-badge.component.ts (1)

1-1: Mind it! Let's implement interfaces properly!

The OnInit implementation is stylish, macha! But remember, in the world of TypeScript, explicit is better than implicit!

Also applies to: 9-9

src/app/fyle/dashboard/stat-badge/stat-badge.component.ts Outdated Show resolved Hide resolved
src/app/fyle/dashboard/stat-badge/stat-badge.component.ts Outdated Show resolved Hide resolved
@SahilK-027 SahilK-027 requested a review from Dimple16 December 17, 2024 10:16
Copy link
Contributor

@Dimple16 Dimple16 left a comment

Choose a reason for hiding this comment

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

added comments

src/app/fyle/dashboard/stat-badge/stat-badge.component.ts Outdated Show resolved Hide resolved
src/app/fyle/dashboard/stat-badge/stat-badge.component.ts Outdated Show resolved Hide resolved
src/app/fyle/dashboard/stat-badge/stat-badge.component.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@Dimple16 Dimple16 left a comment

Choose a reason for hiding this comment

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

added comments

@SahilK-027 SahilK-027 requested a review from Dimple16 December 18, 2024 06:13
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

🔭 Outside diff range comments (1)
src/app/fyle/dashboard/stat-badge/stat-badge.component.ts (1)

Line range hint 31-39: Style it up with some powerful documentation, thalaiva!

The method is strong like Rajini, but let's make it legendary with proper JSDoc!

Add this documentation style:

+  /**
+   * Handles badge click events and emits state based on type
+   * @fires badgeClicked - Emits reportState or expenseState if not loading
+   */
   onBadgeClicked(): void {
♻️ Duplicate comments (2)
src/app/fyle/dashboard/stat-badge/stat-badge.component.ts (1)

28-29: ⚠️ Potential issue

Mind it! Mobile apps don't play the window resize game!

Listen here, macha! For a mobile app, we don't need to check window size - mobile is always small screen! Let's keep it simple and powerful!

Here's the style we need:

-  // To track if the screen is small (370px or below)
-  isSmallScreen = window.innerWidth <= 370;
+  // Mobile apps are always considered small screen
+  isSmallScreen = true;
src/app/fyle/dashboard/stat-badge/stat-badge.component.html (1)

5-5: 🧹 Nitpick (assertive)

The grid game needs some Rajini style simplification!

Why use complex grid when flexbox can do the job with style? Let's make it simple and powerful!

Transform it like this:

-<ion-grid class="stat-badge--grid">
-  <ion-row>
-    <ion-col class="stat-badge--count-col" size="3">
+<div class="stat-badge--flex-container">
+  <div class="stat-badge--count-wrapper">

Add this style power to your SCSS:

.stat-badge {
  &--flex-container {
    display: flex;
    gap: 8px;
  }
  
  &--count-wrapper {
    flex: 0 0 25%;
  }
}

Also applies to: 26-26

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c8b950f and df152b0.

📒 Files selected for processing (2)
  • src/app/fyle/dashboard/stat-badge/stat-badge.component.html (3 hunks)
  • src/app/fyle/dashboard/stat-badge/stat-badge.component.ts (1 hunks)
🔇 Additional comments (1)
src/app/fyle/dashboard/stat-badge/stat-badge.component.html (1)

47-52: 🛠️ Refactor suggestion

The billion-dollar magic needs some explanation, mind it!

Those magic numbers are like my punch dialogues - they need proper introduction!

Let's add some style to the component:

+const CURRENCY_HUMANIZE_THRESHOLD = 1_000_000_000;
+
+/**
+ * Values beyond ±1 billion are humanized (e.g., "1B") 
+ * for better readability on mobile screens
+ */
-<ng-container *ngIf="!isSmallScreen && value > -1000000000 && value < 1000000000; else humanize">
+<ng-container *ngIf="!isSmallScreen && value > -CURRENCY_HUMANIZE_THRESHOLD && value < CURRENCY_HUMANIZE_THRESHOLD; else humanize">

Likely invalid or redundant comment.

Copy link

Unit Test Coverage % values
Statements 96% ( 19302 / 20106 )
Branches 91.12% ( 10664 / 11703 )
Functions 94.28% ( 5740 / 6088 )
Lines 96.04% ( 18432 / 19192 )

@SahilK-027 SahilK-027 merged commit 6aaac4c into FYLE-86cx5a7fe Dec 18, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/S Small PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants