mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-04 03:21:04 +08:00
refactor: extract repeated star formatting logic
- Extract formattedStars calculation to avoid duplication - Keep tabular-nums span for consistent number width during animation - Address code review feedback from @xqliu Co-Authored-By: tinkle-community <tinklefund@gmail.com>
This commit is contained in:
@@ -22,6 +22,9 @@ export default function HeroSection({ language }: HeroSectionProps) {
|
||||
duration: 2000,
|
||||
})
|
||||
|
||||
// 格式化 stars 显示
|
||||
const formattedStars = (animatedStars / 1000).toFixed(1)
|
||||
|
||||
const fadeInUp = {
|
||||
initial: { opacity: 0, y: 60 },
|
||||
animate: { opacity: 1, y: 0 },
|
||||
@@ -48,12 +51,12 @@ export default function HeroSection({ language }: HeroSectionProps) {
|
||||
) : language === 'zh' ? (
|
||||
<>
|
||||
{daysOld} 天内{' '}
|
||||
<span className='inline-block tabular-nums'>{(animatedStars / 1000).toFixed(1)}</span>
|
||||
<span className='inline-block tabular-nums'>{formattedStars}</span>
|
||||
K+ GitHub Stars
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<span className='inline-block tabular-nums'>{(animatedStars / 1000).toFixed(1)}</span>
|
||||
<span className='inline-block tabular-nums'>{formattedStars}</span>
|
||||
K+ GitHub Stars in {daysOld} days
|
||||
</>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user