Skip to content

fix: width bug with ad and remove old ad code#4382

Merged
brunobesson merged 1 commit into
masterfrom
bug-ad
Aug 4, 2025
Merged

fix: width bug with ad and remove old ad code#4382
brunobesson merged 1 commit into
masterfrom
bug-ad

Conversation

@flob38

@flob38 flob38 commented Aug 2, 2025

Copy link
Copy Markdown
Contributor

When screen > desktop but not large enough, the ad was cropped.
And delete Advertisement.vue and code in SideMenu.vue

Summary by CodeRabbit

  • Bug Fixes

    • Removed the advertisement component and its display from the side menu.
  • Style

    • Updated styles for large advertisement elements to ensure a minimum width.
  • Chores

    • Cleaned up unused advertisement-related code and styles.

@github-actions github-actions Bot added the bug Something isn't working label Aug 2, 2025
@coderabbitai

coderabbitai Bot commented Aug 2, 2025

Copy link
Copy Markdown

Walkthrough

The changes remove the Advertisement Vue component and all references to it from the codebase. The advertisement display logic and related styles are deleted from the side menu. Additionally, a scoped CSS rule is added to the DfmAdLarge component to enforce a minimum width for a specific element.

Changes

Cohort / File(s) Change Summary
Advertisement Component Removal
src/views/Advertisement.vue
Entire Advertisement Vue component deleted, including template, script, and styles.
Side Menu Cleanup
src/views/SideMenu.vue
Removed import, registration, and usage of Advertisement component; deleted related CSS rules.
Ad Large Style Update
src/views/DfmAdLarge.vue
Added scoped CSS to set a minimum width for #camptocamp_htad; no logic or template changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Poem

A hop, a skip, the ad is gone,
No more banners lingering on.
The menu’s neat, the code is light,
A single style tweak set just right.
With every change, the garden grows—
A cleaner path, the rabbit knows! 🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bug-ad

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
🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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/views/DfmAdLarge.vue (1)

8-13: Move DOM-injection to a lifecycle hook to prevent SSR / timing issues

The script tag is injected at module-eval time, which runs even during server-side rendering or unit tests where document is undefined. Relocate the logic to mounted() so it executes only in the browser and after the component is in the DOM:

 export default {};
 
-if (!document.getElementById('ad_script')) {
-  const s = document.createElement('script');
-  s.id = 'ad_script';
-  s.src = 'https://static.admysports.com/hb/site/camptocamp/hb_camptocamp.js';
-  document.getElementsByTagName('head')[0].appendChild(s);
-}
+export default {
+  mounted() {
+    if (!document.getElementById('ad_script')) {
+      const s = document.createElement('script');
+      s.id = 'ad_script';
+      s.src =
+        'https://static.admysports.com/hb/site/camptocamp/hb_camptocamp.js';
+      document.head.appendChild(s);
+    }
+  },
+};

This also avoids repeated DOM walks for every import.

🧹 Nitpick comments (1)
src/views/SideMenu.vue (1)

195-201: Delete now-unused .menu-ad style block

The template no longer renders any element with menu-ad, so these lines are dead CSS:

.menu-ad {
  margin-bottom: 15px !important;
  line-height: 1;
}

Removing them (and any associated variables) simplifies maintenance and prevents future confusion.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 27a661e and 97b925a.

📒 Files selected for processing (3)
  • src/views/Advertisement.vue (0 hunks)
  • src/views/DfmAdLarge.vue (1 hunks)
  • src/views/SideMenu.vue (1 hunks)
💤 Files with no reviewable changes (1)
  • src/views/Advertisement.vue
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build (lts/*)
  • GitHub Check: CodeQL-Build
🔇 Additional comments (1)
src/views/SideMenu.vue (1)

105-107: Remove dead component registration

Advertisement was deleted, yet components: { IconYeti } still contains no reference to it—good. Double-check that no other deleted ad-related imports or mixins linger ($screen.hasHeightForAd, etc.) to keep bundle size minimal.

Comment thread src/views/DfmAdLarge.vue
Comment on lines +17 to +19
#camptocamp_htad {
min-width: 728px;
}

@coderabbitai coderabbitai Bot Aug 2, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Avoid hard-coding a desktop-only min-width

min-width: 728px forces horizontal scrolling or clipping on viewports narrower than 728 px (e.g. tablets in portrait, small laptop split-screen). Consider constraining the rule with a media query or falling back gracefully:

+#camptocamp_htad {
-  min-width: 728px;
+  min-width: 728px;   /* full leaderboard */
+  max-width: 100%;    /* never overflow container */
+}
+
+@media (max-width: 767px) {
+  #camptocamp_htad {
+    min-width: auto;  /* let small screens shrink */
+  }
 }

This keeps the fix for larger screens while avoiding layout breakage on smaller ones.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In src/views/DfmAdLarge.vue around lines 17 to 19, the CSS rule sets a fixed
min-width of 728px which causes layout issues on smaller viewports. To fix this,
wrap the min-width: 728px rule inside a media query targeting larger screens
only, so smaller screens do not get forced to that width and avoid horizontal
scrolling or clipping.

@flob38 flob38 Aug 2, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The DfmAdLarge component is used only on large screen (widescreen mini so >= 1216 px)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@flob38 Thank you for the clarification! That makes perfect sense. Since the DfmAdLarge component is only rendered on screens >= 1216px, the min-width: 728px is appropriate and won't cause any layout issues on smaller viewports. My previous suggestion about adding responsive behavior was based on the assumption that this component could be used on smaller screens, but your explanation clarifies that it's specifically designed for large screens only.

The fix directly addresses the width bug mentioned in the PR objectives without any risk of causing overflow or horizontal scrolling issues.


✏️ Learnings added
Learnt from: flob38
PR: c2corg/c2c_ui#4382
File: src/views/DfmAdLarge.vue:17-19
Timestamp: 2025-08-02T19:55:04.798Z
Learning: The DfmAdLarge component in src/views/DfmAdLarge.vue is only used on large screens (width >= 1216px), so fixed min-width values are appropriate and won't cause layout issues on smaller viewports.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@brunobesson to check the rabbit ;)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

@brunobesson brunobesson merged commit 95c41b9 into master Aug 4, 2025
9 checks passed
@brunobesson brunobesson deleted the bug-ad branch August 4, 2025 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants