Skip to content

feat: add static top banner for new ebook edition promotion #405

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

Merged
merged 1 commit into from
Mar 18, 2025

Conversation

dokolyski
Copy link
Contributor

@dokolyski dokolyski commented Mar 18, 2025

Summary by CodeRabbit

  • New Features
    • Added a promotional banner component that displays engaging messages with dynamic styling and an external link.
    • Updated the main layout to integrate the new banner, adjusting positioning and spacing for a seamless visual experience.

@dokolyski dokolyski requested a review from DDonochVA March 18, 2025 11:38
Copy link

coderabbitai bot commented Mar 18, 2025

Walkthrough

The pull request introduces a new Angular component, TopBannerComponent, into the ad-banner UI library. The component, which displays a promotional banner, is exported via the module's index file. In addition, the RootShellComponent in the shell web library has been updated to include the new banner component, leading to template adjustments and layout modifications. These changes affect both the component's public API and the visual structure of the application.

Changes

File(s) Change Summary
libs/blog/ad-banner/ui/.../index.ts
libs/blog/ad-banner/ui/.../top-banner.component.ts
Added export for TopBannerComponent and introduced the new Angular component with a promotional banner template.
libs/blog/shell/feature-shell-web/.../root-shell.component.ts Updated template to include <al-top-banner>, adjusted layout with sticky positioning, and modified margin classes based on the banner's visibility.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant R as RootShellComponent
    participant T as TopBannerComponent

    U->>R: Request page load
    R->>T: Render TopBannerComponent
    T-->>R: Return banner view
    R-->>U: Render complete layout with banner and adjusted margins
Loading

Possibly related PRs

Poem

Hop, hop, hop—what a sight,
A banner bright brings pure delight,
Sticky tops and margins play,
In Angular fields we code away,
A cheerful nibble on each byte,
As I hop through code, morning to night!

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • 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.
  • @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

Deploying angular-love-client with  Cloudflare Pages  Cloudflare Pages

Latest commit: 07632cd
Status: ✅  Deploy successful!
Preview URL: https://7c1732bb.angular-love-client.pages.dev
Branch Preview URL: https://feat-static-top-banner.angular-love-client.pages.dev

View logs

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

🧹 Nitpick comments (2)
libs/blog/ad-banner/ui/src/lib/top-banner.component.ts (1)

3-19: Component structure looks good, but consider accessibility and user experience improvements.

The component is well-structured with appropriate styling for a promotional banner. However, there are a few considerations:

  1. Missing accessibility attributes could make this banner difficult to navigate for screen reader users.
  2. There's no mechanism for users to dismiss the banner after seeing it.
  3. Hardcoded styles may make theming difficult in the future.

Consider these improvements:

@Component({
  selector: 'al-top-banner',
  template: `
    <a
      class="flex w-full flex-wrap justify-center gap-[5px] px-[10px] py-3 text-[18px] font-medium text-white"
      style="background-image: linear-gradient(0.25turn, #fe5758, #8d52fe)"
      href="https://houseofangular.io/the-ultimate-guide-to-angular-evolution/?utm_source=www-al&utm_medium=baner&utm_campaign=angular19-evolution"
+     aria-label="Promotional banner for Angular 19 ebook"
+     role="banner"
    >
      <span>Enhance Your Project with</span>
      <span class="rounded-[4px] bg-white px-[6px] text-[#f9506a]">
        Angular 19
      </span>
      <span class="underline">Download a free ebook!</span>
    </a>
+   <!-- Consider adding a close button here -->
  `,
})
export class TopBannerComponent {}

Also consider adding a method to allow users to dismiss the banner and store this preference:

export class TopBannerComponent {
  visible = true;
  
  dismissBanner(): void {
    this.visible = false;
    localStorage.setItem('bannerDismissed', 'true');
  }
  
  ngOnInit(): void {
    this.visible = localStorage.getItem('bannerDismissed') !== 'true';
  }
}
libs/blog/shell/feature-shell-web/src/lib/root-shell.component.ts (1)

25-25: Unused template reference variable.

The #topBanner template reference variable is defined but not used elsewhere in the template or component logic.

Remove the unused reference variable unless you plan to use it:

-<al-top-banner #topBanner />
+<al-top-banner />
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b68d82c and 07632cd.

📒 Files selected for processing (3)
  • libs/blog/ad-banner/ui/src/index.ts (1 hunks)
  • libs/blog/ad-banner/ui/src/lib/top-banner.component.ts (1 hunks)
  • libs/blog/shell/feature-shell-web/src/lib/root-shell.component.ts (3 hunks)
🧰 Additional context used
🧬 Code Definitions (2)
libs/blog/ad-banner/ui/src/lib/top-banner.component.ts (1)
libs/blog/shell/feature-shell-web/src/lib/root-shell.component.ts (1) (1)
  • Component (22:106)
libs/blog/shell/feature-shell-web/src/lib/root-shell.component.ts (2)
libs/blog/ad-banner/ui/src/lib/top-banner.component.ts (1) (1)
  • Component (3:19)
libs/blog/ad-banner/ui/src/lib/banner-carousel/al-banner-carousel.component.ts (1) (1)
  • Component (7:36)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (3)
libs/blog/ad-banner/ui/src/index.ts (1)

4-4: LGTM: Export of the new TopBannerComponent.

The export follows the existing pattern and correctly exposes the new component through the module's public API.

libs/blog/shell/feature-shell-web/src/lib/root-shell.component.ts (2)

19-19: Import and component registration look good.

The TopBannerComponent is correctly imported and added to the component imports array.

Also applies to: 55-55


97-103:

❓ Verification inconclusive

Review viewport offset calculations.

The effect adjusts viewport offset based on adBannerVisible(), but since this computed value is hardcoded to return false, it will always use the [0, 80] offset. If the banner visibility should affect scrolling behavior, ensure this logic is consistent with the banner's actual visibility.


🏁 Script executed:

#!/bin/bash
# Check for other usages of adBannerVisible that might be affected
rg "adBannerVisible" --type ts

Length of output: 1037


Viewport Offset Logic Verification

We confirmed that in libs/blog/shell/feature-shell-web/src/lib/root-shell.component.ts the computed property for adBannerVisible is hardcoded to return false. This forces the offset to always be set to [0, 80], meaning the [0, 160] branch is never executed. The similar usage seen in the table of contents directive reinforces that the banner state is currently static. If the banner is intended to eventually display dynamically (and thus affect scrolling behavior), the computed value should be updated to reflect its actual visibility state.

  • Location: libs/blog/shell/feature-shell-web/src/lib/root-shell.component.ts (lines 97-103)
  • Observation: protected readonly adBannerVisible = computed(() => false); ensures the offset is always [0, 80].
  • Recommendation: Update the computed logic if dynamic banner visibility is expected, or remove the condition if the banner state remains static.

@@ -30,7 +32,7 @@ import {
<al-search />
</al-header>
</div>
<al-layout class="mt-20" [ngClass]="{ 'mt-40': adBannerVisible() }">
<al-layout class="mt-0" [ngClass]="{ 'mt-20': adBannerVisible() }">
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Banner visibility logic needs attention.

The adBannerVisible() computed value is hardcoded to return false, which means the conditional margin class mt-20 will never be applied. If the top banner should affect the layout, this needs to be updated.

Update the adBannerVisible computed property to reflect the actual visibility of the banner:

// todo: temporary solution to keep in mind how banner influence the layout
-protected readonly adBannerVisible = computed(() => false);
+protected readonly adBannerVisible = computed(() => true); // or implement actual logic

Alternatively, if the banner should always be visible, consider removing the conditional and directly applying the desired margin:

-<al-layout class="mt-0" [ngClass]="{ 'mt-20': adBannerVisible() }">
+<al-layout class="mt-20">

Also applies to: 76-77

@dokolyski dokolyski merged commit 59d723e into main Mar 18, 2025
2 checks passed
@dokolyski dokolyski deleted the feat/static-top-banner branch March 18, 2025 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants