Skip to content

refactor(home): redesign hackathon top bar with aurora gradient style#72

Open
dethan3 wants to merge 1 commit intomainfrom
labor-hackathon-2026
Open

refactor(home): redesign hackathon top bar with aurora gradient style#72
dethan3 wants to merge 1 commit intomainfrom
labor-hackathon-2026

Conversation

@dethan3
Copy link
Copy Markdown
Member

@dethan3 dethan3 commented Apr 30, 2026

PR-72 PR-72 PR-72 Powered by Pull Request Badge

Checklist(清单):

  • Labels
  • Assignees
  • Reviewers
  1. 增加首页活动横幅
  2. pnpm-lock.yaml 有变动导致 eslint.config.ts:29@next/next 插件类型不匹配

Summary by CodeRabbit

发布说明

  • 新功能
    • 在首页添加黑客马拉松宣传顶部栏
    • 支持关闭按钮隐藏顶部栏
    • 顶部栏包含本地化文本内容和活动链接
    • 自动调整与导航栏的间距对齐

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2026

📝 Walkthrough

总体概述

主页添加了黑客马拉松推广顶栏,由 React 状态控制其显隐。组件使用 useEffect 计算相邻导航栏高度并动态更新 CSS 自定义属性调整栏的间距;支持窗口尺寸变化监听,暂未持久化关闭状态。

变更清单

群组 / 文件(s) 变更摘要
主页推广栏
pages/index.tsx
新增黑客马拉松推广顶栏组件,使用状态管理控制显隐;集成 ResizeObserver 动态计算导航栏高度并更新 CSS 自定义属性;注意 UI 文本需统一使用 t() 实现国际化;localStorage 持久化逻辑已注释,需确认产品需求。

代码审查要点

审查建议:

  1. 国际化完整性 — 验证推广栏的所有文本(标题、描述、按钮)是否通过 t() 函数完整国际化,避免硬编码字符串

  2. 性能优化useEffect 中的 ResizeObserver 是否在组件卸载时正确清理?建议检查内存泄漏风险

  3. 样式方案 — 确认 CSS 自定义属性的更新方案是否与现有设计系统对齐;是否考虑使用 React Bootstrap 的栅格/间距工具

  4. 状态持久化 — localStorage 逻辑已注释,需确认是否为临时方案还是产品需求变更

  5. TypeScript 类型 — 验证新增状态变量和 ref 是否具有明确的类型注解

  6. 无障碍访问 — 推广栏是否包含适当的 ARIA 属性和关闭按钮的键盘导航支持

审查工作量评估

🎯 2 (简单) | ⏱️ ~8 分钟

庆祝诗句

🎉 顶栏闪闪新上线,
React 状态巧控制,
ResizeObserver 显身手,
响应式设计妙如斯! 🚀

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 标题准确概括了主要变化:重新设计首页的 hackathon 顶部横幅组件,添加了新的 aurora 梯度样式。标题简洁清晰,与提供的摘要相符。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch labor-hackathon-2026
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch labor-hackathon-2026

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
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

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

@dethan3 dethan3 requested a review from TechQuery April 30, 2026 09:26
@dethan3 dethan3 added the feature New feature or request label Apr 30, 2026
Copy link
Copy Markdown

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pages/index.tsx`:
- Line 69: Replace the hardcoded event name inside the span (className
styles.hackathonTopBarEventName) with a call to the i18n t() function and add a
corresponding translation key (e.g. "hackathon.eventName") to your locale files;
update pages/index.tsx to use t('hackathon.eventName') (or the chosen key) so
the visible text is localized and ensure the new key exists in all supported
locales.
- Around line 57-84: The top-banner uses raw HTML elements and a hard-coded
event name; replace the <aside>/<div>/<a>/<button>/<span> usage with React
Bootstrap components (e.g., Alert, Card, Button/CloseButton) while preserving
behavior tied to isHackathonTopBarVisible, hackathonTopBarStyle,
HackathonTopBarLink and the closeHackathonTopBar handler, and move the literal
"Labor AI Hackathon 2026" into i18n as home_hackathon_top_bar_event_name,
rendering it via t('home_hackathon_top_bar_event_name') alongside the existing
t('home_hackathon_top_bar_title'), t('home_hackathon_top_bar_description') and
t('home_hackathon_top_bar_action'); ensure aria-label/title still use
t('home_hackathon_top_bar_aria_label') and t('home_hackathon_top_bar_close').
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: afcd89f5-d1e7-40d2-bfc2-16789a915968

📥 Commits

Reviewing files that changed from the base of the PR and between b160b03 and 3b66c69.

⛔ Files ignored due to path filters (6)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !pnpm-lock.yaml and included by none
  • styles/Home.module.less is excluded by none and included by none
  • styles/globals.css is excluded by none and included by none
  • translation/en-US.ts is excluded by none and included by none
  • translation/zh-CN.ts is excluded by none and included by none
  • translation/zh-TW.ts is excluded by none and included by none
📒 Files selected for processing (1)
  • pages/index.tsx

Comment thread pages/index.tsx
Comment on lines +57 to +84
{isHackathonTopBarVisible && (
<aside
className={styles.hackathonTopBar}
aria-label={t('home_hackathon_top_bar_aria_label')}
style={hackathonTopBarStyle}
>
<div className={styles.hackathonTopBarInner}>
<a className={styles.hackathonTopBarContent} href={HackathonTopBarLink}>
<span className={styles.hackathonTopBarText}>
<strong>{t('home_hackathon_top_bar_title')}</strong>
<span>{t('home_hackathon_top_bar_description')}</span>
</span>
<span className={styles.hackathonTopBarEventName}>Labor AI Hackathon 2026</span>
<span className={styles.hackathonTopBarAction}>
{t('home_hackathon_top_bar_action')}
</span>
</a>
<button
className={styles.hackathonTopBarClose}
type="button"
aria-label={t('home_hackathon_top_bar_close')}
title={t('home_hackathon_top_bar_close')}
onClick={closeHackathonTopBar}
>
×
</button>
</div>
</aside>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# 只做只读检索:查找 pages/components 中已有的 React Bootstrap 横幅/通知条模式。
rg -n --type tsx '(<Alert|<Button|<Stack|<Badge|<CloseButton|<Card)' pages components

Repository: Open-Source-Bazaar/Open-Source-Bazaar.github.io

Length of output: 119


🏁 Script executed:

#!/bin/bash
# Search for React Bootstrap component usage with correct approach
rg -n --type ts '<(Alert|Button|Stack|Badge|CloseButton|Card|Container|Row|Col)' pages/ components/

Repository: Open-Source-Bazaar/Open-Source-Bazaar.github.io

Length of output: 13658


🏁 Script executed:

#!/bin/bash
# Also search by file content for Bootstrap imports to understand usage patterns
rg -n "from.*react-bootstrap" pages/ components/

Repository: Open-Source-Bazaar/Open-Source-Bazaar.github.io

Length of output: 4001


🏁 Script executed:

#!/bin/bash
# Examine the full pages/index.tsx file to understand context
wc -l pages/index.tsx

Repository: Open-Source-Bazaar/Open-Source-Bazaar.github.io

Length of output: 111


🏁 Script executed:

#!/bin/bash
# Look at the specific lines mentioned in the review (57-84) plus surrounding context
sed -n '50,90p' pages/index.tsx

Repository: Open-Source-Bazaar/Open-Source-Bazaar.github.io

Length of output: 1618


🏁 Script executed:

#!/bin/bash
# Check if there are any CloseButton or dismissible banner patterns in existing code
rg -n "CloseButton|Alert.*dismissible" pages/ components/ -A 2

Repository: Open-Source-Bazaar/Open-Source-Bazaar.github.io

Length of output: 73


🏁 Script executed:

#!/bin/bash
# Look at how Alert is used in pages/recipe/index.tsx to understand the pattern
sed -n '40,60p' pages/recipe/index.tsx

Repository: Open-Source-Bazaar/Open-Source-Bazaar.github.io

Length of output: 700


将活动横幅改为 React Bootstrap 组件,并将硬编码的事件名提取为 i18n 文本。

根据编码约束 {pages,components}/**/*.tsx,此页面必须统一使用 React Bootstrap 组件(不用原生 HTML 元素),且所有用户文本必须使用 t() 国际化函数。

当前代码的两个问题:

  1. 使用了原生 HTML 元素<aside><div><a><button><span>),应改为 React Bootstrap 的 Alert、Button、CloseButton 等组件。参考项目中已有的 Alert 用法(pages/recipe/index.tsx:45)。

  2. 硬编码事件名称:"Labor AI Hackathon 2026" 是用户可见的文本,应移至 i18n 配置文件并使用 t('home_hackathon_top_bar_event_name') 调用,与其他文本保持一致。

建议用 <Alert><Card> 加上 Bootstrap utility classes 重构此横幅,用 <Button> 替代 <button>,并补充缺失的 i18n 键。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pages/index.tsx` around lines 57 - 84, The top-banner uses raw HTML elements
and a hard-coded event name; replace the <aside>/<div>/<a>/<button>/<span> usage
with React Bootstrap components (e.g., Alert, Card, Button/CloseButton) while
preserving behavior tied to isHackathonTopBarVisible, hackathonTopBarStyle,
HackathonTopBarLink and the closeHackathonTopBar handler, and move the literal
"Labor AI Hackathon 2026" into i18n as home_hackathon_top_bar_event_name,
rendering it via t('home_hackathon_top_bar_event_name') alongside the existing
t('home_hackathon_top_bar_title'), t('home_hackathon_top_bar_description') and
t('home_hackathon_top_bar_action'); ensure aria-label/title still use
t('home_hackathon_top_bar_aria_label') and t('home_hackathon_top_bar_close').

Comment thread pages/index.tsx
<strong>{t('home_hackathon_top_bar_title')}</strong>
<span>{t('home_hackathon_top_bar_description')}</span>
</span>
<span className={styles.hackathonTopBarEventName}>Labor AI Hackathon 2026</span>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

把活动名称也接入 i18n。

当前横幅里的 Labor AI Hackathon 2026 还是硬编码,和“所有用户可见文案都必须走 t()”的约束不一致。建议补一个翻译 key,再替换成 t(...)

As per coding guidelines: All user-facing text MUST use the i18n t() function (no hardcoded strings).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pages/index.tsx` at line 69, Replace the hardcoded event name inside the span
(className styles.hackathonTopBarEventName) with a call to the i18n t() function
and add a corresponding translation key (e.g. "hackathon.eventName") to your
locale files; update pages/index.tsx to use t('hackathon.eventName') (or the
chosen key) so the visible text is localized and ensure the new key exists in
all supported locales.

Comment thread styles/globals.css
Comment on lines +24 to +27
.navbar .navbar-brand,
.navbar .nav-link {
white-space: nowrap;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
.navbar .navbar-brand,
.navbar .nav-link {
white-space: nowrap;
}

直接在 JSX 中加工具类

Comment thread translation/zh-CN.ts
Comment on lines +34 to +37
home_hackathon_top_bar_aria_label: 'Labor AI Hackathon 2026 活动宣传',
home_hackathon_top_bar_badge: '活动招募中',
home_hackathon_top_bar_title: '打工人の终极反叛',
home_hackathon_top_bar_description: '48 小时,来这里创造未来',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

不要硬编码任何来自数据库的数据。

Comment thread pages/index.tsx
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

某方面专用的功能放到独立组件中实现,再在页面中引用,不要在一个页面里堆砌大量不同功能的代码,样式那边也要跟随组件一同迁移为独立 CSS modules 文件。

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

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants