Skip to content
This repository was archived by the owner on Jul 15, 2025. It is now read-only.

hot fix#103

Merged
aum-deriv merged 1 commit intomasterfrom
hot-fix
Mar 21, 2025
Merged

hot fix#103
aum-deriv merged 1 commit intomasterfrom
hot-fix

Conversation

@aum-deriv
Copy link
Contributor

@aum-deriv aum-deriv commented Mar 21, 2025

Summary by Sourcery

Enhancements:

  • Improve the UI and responsiveness of the MarketSelectorButton component.

@devloai
Copy link

devloai bot commented Mar 21, 2025

Unable to perform a code review. You have run out of credits 😔

@sourcery-ai
Copy link

sourcery-ai bot commented Mar 21, 2025

Reviewer's Guide by Sourcery

This pull request modifies the MarketSelectorButton component to improve the display of market information and ensure responsiveness across different screen sizes. It introduces a mobile-specific layout and enhances the desktop version's styling.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Modified the MarketSelectorButton component to improve the display of market information and ensure responsiveness across different screen sizes.
  • Added a displaySubtitle memoized variable to combine price and subtitle for display.
  • Modified the component to render differently based on the isMobile prop.
  • Updated the styling and layout for both mobile and desktop versions to improve information density and visual appeal.
  • Replaced <button> with <div> for the desktop version to allow more flexible styling and avoid default button styles.
src/components/MarketSelector/MarketSelectorButton.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions
Copy link

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

@cloudflare-workers-and-pages
Copy link

Deploying champion-trader with  Cloudflare Pages  Cloudflare Pages

Latest commit: 63c4b4a
Status: ✅  Deploy successful!
Preview URL: https://ff036145.champion-trader.pages.dev
Branch Preview URL: https://hot-fix.champion-trader.pages.dev

View logs

@aum-deriv aum-deriv merged commit ff83d22 into master Mar 21, 2025
3 checks passed
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @aum-deriv - I've reviewed your changes - here's some feedback:

Overall Comments:

  • It looks like you're duplicating a lot of code between the mobile and non-mobile versions - can you extract the common parts into a separate component or function?
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

return (
<div className="h-14 inline-flex cursor-pointer lg:mt-3" data-id="market-info">
<div
className="h14 flex items-center gap-4 px-4 bg-theme-secondary rounded-lg font-medium"
Copy link

Choose a reason for hiding this comment

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

issue (typo): Potential typo in height class name in the mobile branch.

The class name is written as 'h14' instead of 'h-14', which might be a typo. Correcting this would ensure consistent sizing as intended.

Suggested change
className="h14 flex items-center gap-4 px-4 bg-theme-secondary rounded-lg font-medium"
className="h-14 flex items-center gap-4 px-4 bg-theme-secondary rounded-lg font-medium"

}, [price, subtitle]);

if (isMobile) {
return (
Copy link

Choose a reason for hiding this comment

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

issue (complexity): Consider creating a new MarketInfoContent component to avoid duplicating the render logic for the icon, title, closed badge, and subtitle in both mobile and non-mobile views, improving maintainability and readability without changing functionality

You can reduce duplication by extracting the shared UI into a separate, stateless component. For example, create a new component that renders the icon, title, closed badge, and subtitle. Then call it from both the mobile and non-mobile branches. For instance:

// New reusable component
const MarketInfoContent = ({
  instrument,
  symbol,
  isLoading,
  displayName,
  isClosed,
  displaySubtitle,
  iconClass = "w-8 h-8 flex items-center justify-center",
  titleClass = "text-sm font-semibold text-theme leading-6 truncate",
  chevronClass = "w-5 text-theme flex-shrink-0 stroke-[1.5]",
}) => (
  <>
    {instrument ? (
      <div className={iconClass}>
        <MarketIcon symbol={symbol} size="xlarge" showBadge={false} />
      </div>
    ) : (
      <div className={iconClass}>
        {isLoading && (
          <div className="w-6 h-6 border-2 border-t-transparent border-theme rounded-full animate-spin"></div>
        )}
      </div>
    )}
    <div className="min-w-0">
      <div className="flex items-center gap-2">
        <div className={titleClass}>{displayName}</div>
        {isClosed && (
          <span className="text-[10px] px-1.5 py-0.5 bg-rose-500/10 rounded-full text-rose-500">
            Closed
          </span>
        )}
        <ChevronDown className={chevronClass} />
      </div>
      <div className="text-[12px] text-theme leading-5 truncate">{displaySubtitle}</div>
    </div>
  </>
);

Then update the original render logic to use the new component:

if (isMobile) {
  return (
    <div className="h-14 inline-flex cursor-pointer lg:mt-3" data-id="market-info">
      <div className="h14 flex items-center gap-4 px-4 bg-theme-secondary rounded-lg font-medium" onClick={handleClick}>
        <MarketInfoContent
          instrument={instrument}
          symbol={symbol}
          isLoading={isLoading}
          displayName={displayName}
          isClosed={isClosed}
          displaySubtitle={displaySubtitle}
          // Optionally override icon/title/chevron classes if needed for mobile
        />
      </div>
    </div>
  );
}

return (
  <div
    className="h-14 inline-flex cursor-pointer bg-theme-secondary hover:bg-theme-hover active:bg-theme-active rounded-lg transition-colors"
    data-id="market-info"
    onClick={handleClick}
  >
    <div className="h-14 flex items-center gap-4 px-4">
      <MarketInfoContent
        instrument={instrument}
        symbol={symbol}
        isLoading={isLoading}
        displayName={displayName}
        isClosed={isClosed}
        displaySubtitle={displaySubtitle}
      />
    </div>
  </div>
);

By extracting the common UI into MarketInfoContent, you remove duplicate render logic, making the component easier to maintain and read without changing any behavior.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant