Skip to content

Conversation

@BensOmnitrix
Copy link

@BensOmnitrix BensOmnitrix commented Nov 12, 2025

Description

    1. Added the utils/windowSize.ts file which is exporting the size of the window after it resizes
    1. In the components/buttons/GithubButton.tsx file just imported the the size and put the check on it so that if the width greater than 1144px it remains the same when window size becomes less than 1144px it changes to IconGithub
    1. Also encapsulated the IconButton in the Link so that after clicking it one could be redirected to the asyncapi github repo.

Final look after the fix

Screenshot 2025-11-12 134832

Related issue(s)

Summary by CodeRabbit

  • New Features
    • GitHub button now displays responsively based on screen size—showing the full button on wider viewports and an icon-only link on mobile devices for improved space utilization.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@netlify
Copy link

netlify bot commented Nov 12, 2025

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 3915248
🔍 Latest deploy log https://app.netlify.com/projects/asyncapi-website/deploys/69144774589ce50008b0a5ce
😎 Deploy Preview https://deploy-preview-4576--asyncapi-website.netlify.app
📱 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 project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 12, 2025

Walkthrough

This PR introduces responsive behavior to the GithubButton component by adding a new useWindowSize hook that tracks browser viewport dimensions. The button conditionally renders either a full button with icon (wide viewports >1144px) or a simple external link containing the icon (narrow viewports).

Changes

Cohort / File(s) Change Summary
Window Size Tracking
utils/windowSize.ts
Introduces new WindowSize interface and useWindowSize hook to track viewport dimensions; hook initializes with width/height of 0, sets up resize event listener on mount, guards against SSR, and cleans up listener on unmount
Responsive GithubButton
components/buttons/GithubButton.tsx
Adds responsive rendering logic: displays full Button with Github icon on wide viewports (>1144px) and wraps icon in a Next.js Link to GitHub on narrow viewports; integrates useWindowSize hook; applies minor quoting consistency updates

Sequence Diagram

sequenceDiagram
    participant Component as GithubButton
    participant Hook as useWindowSize
    participant Window as Browser Window
    participant Render as Render Output

    Component->>Hook: Call useWindowSize()
    Hook->>Window: Subscribe to resize events
    Hook->>Hook: Initialize state (width: 0, height: 0)
    Hook->>Window: Get window.innerWidth/innerHeight on mount
    Hook->>Hook: Update state with dimensions

    Window->>Hook: Fire resize event
    Hook->>Hook: Update state with new dimensions
    Hook->>Component: Return current windowSize

    alt width > 1144px
        Component->>Render: Render full Button with icon
    else width ≤ 1144px
        Component->>Render: Render Link with icon only
    end

    Component->>Window: Cleanup resize listener on unmount
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10–15 minutes

  • The useWindowSize hook follows a standard React pattern for tracking window dimensions with proper SSR guards and cleanup
  • GithubButton integration is straightforward conditional rendering based on viewport width
  • No complex state management or intricate logic density

Possibly related PRs

  • asyncapi/website#3294: Adjusts CSS and alignment where GithubButton is rendered, complementing the responsive behavior changes in this PR

Suggested labels

ready-to-merge

Suggested reviewers

  • derberg
  • sambhavgupta0705
  • anshgoyalevil
  • Mayaleeeee

Poem

🐰 A button that bends, now nimble and wise,
Responsive to screens of all shapes and all sizes,
On wide viewports grand, it blooms in full grace,
On narrow ones swift, it finds its own space! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: star-on-github-button-responsiveness' clearly and specifically describes the main change: adding responsive behavior to the GitHub button component.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@asyncapi-bot
Copy link
Contributor

⚡️ Lighthouse report for the changes in this PR:

Category Score
🔴 Performance 41
🟢 Accessibility 98
🟢 Best practices 92
🟢 SEO 100
🔴 PWA 33

Lighthouse ran on https://deploy-preview-4576--asyncapi-website.netlify.app/

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

🧹 Nitpick comments (1)
utils/windowSize.ts (1)

14-27: Optional: Consider consistent function naming.

The function name handleReSize has unusual casing. Standard convention would be handleResize (lowercase 's' in 'size').

-    const handleReSize = () => {
+    const handleResize = () => {
      setWindowSize({
        width: window.innerWidth,
        height: window.innerHeight,
      });
    };

-    handleReSize();
-    window.addEventListener('resize', handleReSize);
-    return () => window.removeEventListener('resize', handleReSize);
+    handleResize();
+    window.addEventListener('resize', handleResize);
+    return () => window.removeEventListener('resize', handleResize);
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4d0d969 and 3915248.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • components/buttons/GithubButton.tsx (2 hunks)
  • utils/windowSize.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
components/buttons/GithubButton.tsx (3)
utils/windowSize.ts (1)
  • useWindowSize (9-30)
components/buttons/Button.tsx (1)
  • Button (53-106)
components/icons/Github.tsx (1)
  • IconGithub (7-13)
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Redirect rules - asyncapi-website
  • GitHub Check: Header rules - asyncapi-website
  • GitHub Check: Pages changed - asyncapi-website
  • GitHub Check: Lighthouse CI

@BensOmnitrix
Copy link
Author

/ready-to-merge

@BensOmnitrix BensOmnitrix deleted the fix/star-on-github-button branch November 12, 2025 12:42
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.

2 participants