Skip to content

[refactor] use Time & Time Range components to render all Date Time texts#74

Merged
TechQuery merged 2 commits intomainfrom
TechQuery/issue73
May 1, 2026
Merged

[refactor] use Time & Time Range components to render all Date Time texts#74
TechQuery merged 2 commits intomainfrom
TechQuery/issue73

Conversation

@TechQuery
Copy link
Copy Markdown
Member

@TechQuery TechQuery commented May 1, 2026

PR-74 PR-74 PR-74 Powered by Pull Request Badge

  1. [refactor] use Time & Time Range components to render all Date Time texts (fix 修正飞书版黑客松主页倒计时时区 bug #73)
  2. [migrate] replace built-in Count Down & Zodiac Bar components with Idea-React 2.2

Summary by CodeRabbit

  • 新功能

    • 引入统一的时间显示组件(单点/范围),多处日期时间改为组件化渲染,显示更一致可格式化。
    • 倒计时组件改为延迟加载,优化首屏加载体验。
  • 样式

    • 调整倒计时网格在不同屏幕下的布局和高度,提升响应式呈现。
  • 重构

    • 多处卡片、日程、行动项等支持富内容(非仅字符串)的徽章、标签与事实项,增强展示灵活性。

Copilot AI review requested due to automatic review settings May 1, 2026 16:59
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 1, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

将本地实现的倒计时与生肖条组件迁移至外部库 idea-react,删除本地 MobX 驱动的 CountdownZodiacBar 实现;更新若干使用这些组件的页面与组件的导入、类型与渲染(包括样式选择器、props 类型和动态导入调整)。

Changes

Cohort / File(s) Summary
删除/迁移:本地基础组件
components/Base/Countdown.tsx, components/Base/ZodiacBar.tsx
移除本地 Countdown(含 MobX 逻辑:@observer、computed、reaction、计时器行为)和 ZodiacBar 实现;对外部 idea-react 的等价组件/类型改为依赖。需重点审查 MobX 移除后计时行为与类型兼容性。
Agenda 倒计时与样式
components/Activity/Hackathon/AgendaCountdown.tsx, components/Activity/Hackathon/AgendaCountdown.module.less
改用 Countdown/TimeUnit 来自 idea-react,组件改为默认导出,并通过 itemClassName 传入 styles.item 与居中 flex 工具类;样式选择器从 li 切换为 .item(含移动端规则)。
Hero 与动态导入、类型调整
components/Activity/Hackathon/Hero.tsx
AgendaCountdown 改为 next/dynamic(..., { ssr: false }) 动态客户端导入;TimeUnit 来源切换为 idea-reactbadges/chips 类型由 string[]ReactNode[],渲染 key 改为索引。
页面与时间显示组件迁移
pages/hackathon/[id].tsx, pages/NGO/index.tsx
多处时间渲染从字符串/工具函数迁移为 idea-reactTime、新建的 TimeRange/TimeText 组件;ZodiacBar 的导入改为 idea-react 的实现。
Schedule / ActionHub / 相关 props 宽泛化
components/Activity/Hackathon/Schedule.tsx, components/Activity/Hackathon/ActionHub.tsx, components/Activity/Hackathon/constant.ts
若干接口由 string[] 或字符串字段改为 ReactNode[] 或新增 startedAt/endedAt (TimeData);buildScheduleItems 改为输出包含数值时间端点;list key 使用索引以支持非字符串项。
新增:时间范围/文本组件
components/TimeRange.tsx
新增 TimeTextTimeRange 组件:对可能无效时间进行归一化并使用 idea-reactTime 渲染,支持格式、分隔符与回退。
其他组件:统一使用 idea-react Time
components/ProductCard.tsx, components/Finance/FundCard.tsx, components/Git/Issue/Card.tsx
将若干处原生 <time> 或字符串格式化替换为 idea-reactTime 组件,并简化渲染结构。

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant HackathonHero as Hero (页面)
    participant AgendaCountdown as AgendaCountdown (组件)
    participant IdeaReact as idea-react Countdown
    Client->>Hero: 请求页面(客户端渲染)
    Hero->>AgendaCountdown: 动态导入(ssr: false)
    AgendaCountdown->>IdeaReact: 渲染 Countdown (itemClassName, units)
    IdeaReact-->>AgendaCountdown: 倒计时渲染与更新
    AgendaCountdown-->>Hero: 渲染完成(包含时间 UI)
    Hero-->>Client: 返回已渲染内容
Loading

Estimated code review effort

🎯 3 (中等) | ⏱️ ~20 分钟

Possibly related PRs

Suggested labels

feature

诗一首

组件轻装上阵,外库托管节拍,
MobX 的钟声静下,Time 在前端回响,
动态导入为客,样式小改换名,
时序清晰花开,重构路上微笑行。 🌱

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning 包含超出 issue #73 范围的变更:迁移 Countdown/ZodiacBar 到 idea-react 组件库,改变了导出结构(AgendaCountdown 改为默认导出)。 将组件库迁移工作单独分离为独立 PR,保持本次 PR 专注于时区和日期时间渲染问题的修复。
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了主要变更:使用 Time & TimeRange 组件统一渲染所有日期时间文本,涵盖了跨多个文件的核心重构工作。
Linked Issues check ✅ Passed PR 通过引入 TimeRange/TimeText 组件并更新所有日期时间渲染,解决了时区兼容性问题,符合 issue #73 的需求。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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 TechQuery/issue73

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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors date/time-related UI to rely on idea-react components (notably Countdown and ZodiacBar), while updating dependencies to idea-react@2.2 and related packages.

Changes:

  • Upgraded idea-react to ^2.2.0 (plus small dependency bumps like marked, web-utility, eslint).
  • Replaced local Countdown / ZodiacBar implementations with idea-react equivalents and updated call sites.
  • Switched Hackathon countdown rendering to a client-only dynamic import and adjusted styling hooks.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pnpm-lock.yaml Locks upgraded dependencies (idea-react, eslint, marked, web-utility, etc.).
package.json Bumps runtime/dev dependency versions to align with the refactor and migration.
pages/hackathon/[id].tsx Uses idea-react’s TimeUnit for countdown unit construction.
pages/NGO/index.tsx Migrates ZodiacBar usage to idea-react.
components/Activity/Hackathon/Hero.tsx Loads AgendaCountdown via next/dynamic (SSR disabled) and updates TimeUnit typing source.
components/Activity/Hackathon/AgendaCountdown.tsx Uses idea-react Countdown and exports the component as default for dynamic import.
components/Activity/Hackathon/AgendaCountdown.module.less Moves countdown item styling to a class hook (.item) to match itemClassName.
components/Base/ZodiacBar.tsx Removes in-repo ZodiacBar implementation (replaced by idea-react).
components/Base/Countdown.tsx Removes in-repo Countdown implementation (replaced by idea-react).
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment on lines +11 to +12
const AgendaCountdown = dynamic(() => import('./AgendaCountdown'), { ssr: false });

Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

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

dynamic(() => import('./AgendaCountdown')) loses the component’s prop typing (it becomes ComponentType<any>), which can hide incorrect props being passed from this file. Consider exporting/importing AgendaCountdownProps and providing it as the generic to dynamic<AgendaCountdownProps>(...) (or otherwise typing the dynamic component) to keep type-safety.

Copilot uses AI. Check for mistakes.
Comment on lines +23 to 25
.item {
gap: 0.7rem;
box-shadow:
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

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

The countdown item styling was switched from li to .item, but the mobile override in the @media (max-width: 767px) block still targets li. To avoid relying on the underlying DOM tag (especially after switching to itemClassName), update the media-query selector to target .item as well so the responsive styles keep applying.

Copilot uses AI. Check for mistakes.
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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
components/Activity/Hackathon/AgendaCountdown.module.less (1)

23-31: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

把移动端选择器也同步到 .item

基础样式已经切到 .item 了,但媒体查询里还在写 li,这会让小屏下的最小高度和字号回退跟新结构脱节。建议把这里也改成 .item,保持桌面和移动端一致。

建议修复
 `@media` (max-width: 767px) {
   .grid {
     grid-template-columns: repeat(2, minmax(0, 1fr));
 
-    li {
+    .item {
       min-height: 96px;
 
       strong {
         font-size: 2rem;

Also applies to: 51-63

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

In `@components/Activity/Hackathon/AgendaCountdown.module.less` around lines 23 -
31, Mobile breakpoint selectors still target "li" while base styles moved to
".item", causing small-screen min-height and font-size to fall back; update the
media query rules (the blocks currently selecting "li" around the mobile styles,
referenced in the same file and again at the 51-63 region) to target ".item"
instead so the min-height, font-size and other responsive adjustments apply to
the new ".item" element consistently.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@components/Activity/Hackathon/Hero.tsx`:
- Line 11: Hero 的客户端懒加载 AgendaCountdown 会导致首屏缺少高度、内容被下移;在动态导入(const
AgendaCountdown = dynamic(...)) 时提供一个固定高度的 loading shell 或在 Hero
里渲染占位元素以稳住布局,确保加载完成前 CTA/视觉区块不会位移;定位到 AgendaCountdown 动态导入和 Hero 组件,将 loading
占位返回一个与实际倒计时高度相同的静态占位 DOM(或样式化容器)以保持布局稳定。

---

Outside diff comments:
In `@components/Activity/Hackathon/AgendaCountdown.module.less`:
- Around line 23-31: Mobile breakpoint selectors still target "li" while base
styles moved to ".item", causing small-screen min-height and font-size to fall
back; update the media query rules (the blocks currently selecting "li" around
the mobile styles, referenced in the same file and again at the 51-63 region) to
target ".item" instead so the min-height, font-size and other responsive
adjustments apply to the new ".item" element consistently.
🪄 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: 2e26ec5b-fc56-430c-8d5a-ed073ae6f1ba

📥 Commits

Reviewing files that changed from the base of the PR and between b160b03 and 5924dde.

⛔ Files ignored due to path filters (2)
  • package.json is excluded by none and included by none
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !pnpm-lock.yaml and included by none
📒 Files selected for processing (7)
  • components/Activity/Hackathon/AgendaCountdown.module.less
  • components/Activity/Hackathon/AgendaCountdown.tsx
  • components/Activity/Hackathon/Hero.tsx
  • components/Base/Countdown.tsx
  • components/Base/ZodiacBar.tsx
  • pages/NGO/index.tsx
  • pages/hackathon/[id].tsx
💤 Files with no reviewable changes (2)
  • components/Base/ZodiacBar.tsx
  • components/Base/Countdown.tsx

import { TimeUnit } from '../../Base/Countdown';
import styles from './Hero.module.less';

const AgendaCountdown = dynamic(() => import('./AgendaCountdown'), { ssr: false });
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

给倒计时补一个首屏占位,避免 hydration 后推挤 hero 内容。

这里把 AgendaCountdown 切成了客户端懒加载,首屏会先少掉一块高度,CTA 和视觉区块会在 chunk 到达后下移。建议保留一个固定高度的 loading shell,至少把布局占位先稳住。

建议修复
 const AgendaCountdown = dynamic(() => import('./AgendaCountdown'), {
   ssr: false,
+  loading: () => <div style={{ minHeight: 120 }} />,
 });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@components/Activity/Hackathon/Hero.tsx` at line 11, Hero 的客户端懒加载
AgendaCountdown 会导致首屏缺少高度、内容被下移;在动态导入(const AgendaCountdown = dynamic(...))
时提供一个固定高度的 loading shell 或在 Hero 里渲染占位元素以稳住布局,确保加载完成前 CTA/视觉区块不会位移;定位到
AgendaCountdown 动态导入和 Hero 组件,将 loading 占位返回一个与实际倒计时高度相同的静态占位
DOM(或样式化容器)以保持布局稳定。

…exts

Co-authored-by: Copilot <copilot@github.com>
@TechQuery TechQuery added the enhancement Some improvements label May 1, 2026
@TechQuery TechQuery merged commit ee0cf17 into main May 1, 2026
3 of 4 checks passed
@TechQuery TechQuery deleted the TechQuery/issue73 branch May 1, 2026 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Some improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

修正飞书版黑客松主页倒计时时区 bug

2 participants