Skip to content

Commit e703df8

Browse files
committed
fix: 코드 리뷰 피드백 반영 (UltraQA)
- Layout: useRef DOM mutation → useState로 전환 (라우트 변경 시 stale style 방지) - scroll-behavior: prefers-reduced-motion 미디어 쿼리로 접근성 개선 - HeroSection: fixed header 오프셋 보정 (pt 복원) - TermDetailPage: 예시 박스 스타일 상수 추출, 복사 버튼 44px 터치 타겟 - Container maxWidth: !important 제거, 미디어 쿼리 방식으로 변경
1 parent 2d4f136 commit e703df8

5 files changed

Lines changed: 34 additions & 38 deletions

File tree

src/components/HeroSection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function HeroSection({ totalTerms, totalMeanings, query, onQueryChange }:
1515
sx={{
1616
background: 'linear-gradient(135deg, #ee4c2c 0%, #2D2D2D 100%)',
1717
color: 'white',
18-
pt: { xs: 8, md: 9 },
18+
pt: { xs: 10, md: 11 },
1919
pb: { xs: 3, md: 4 },
2020
mb: 0,
2121
}}

src/components/Layout.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useRef, useEffect } from 'react'
1+
import React, { useState, useEffect, useCallback } from 'react'
22
import { AppBar, Toolbar, Typography, Container, Box, IconButton, Link, Button } from '@mui/material'
33
import GitHubIcon from '@mui/icons-material/GitHub'
44
import SearchIcon from '@mui/icons-material/Search'
@@ -12,39 +12,41 @@ export function Layout({ children }: LayoutProps): React.ReactNode {
1212
const navigate = useNavigate()
1313
const location = useLocation()
1414
const isHomePage = location.pathname === '/' || location.pathname === ''
15-
const appBarRef = useRef<HTMLDivElement>(null)
15+
const [scrolled, setScrolled] = useState(false)
1616

1717
useEffect(() => {
1818
if (!isHomePage) return
1919

2020
const handleScroll = () => {
21-
if (!appBarRef.current) return
22-
const scrolled = window.scrollY > 60
23-
appBarRef.current.style.backgroundColor = scrolled ? '#262626' : 'transparent'
24-
appBarRef.current.style.boxShadow = scrolled ? '0 2px 8px rgba(0,0,0,0.15)' : 'none'
21+
setScrolled(window.scrollY > 60)
2522
}
2623

2724
window.addEventListener('scroll', handleScroll, { passive: true })
2825
handleScroll()
29-
return () => window.removeEventListener('scroll', handleScroll)
26+
return () => {
27+
window.removeEventListener('scroll', handleScroll)
28+
setScrolled(false)
29+
}
3030
}, [isHomePage])
3131

32-
const handleSearchClick = () => {
32+
const handleSearchClick = useCallback(() => {
3333
if (isHomePage) {
3434
window.scrollTo({ top: 0, behavior: 'smooth' })
3535
} else {
3636
navigate('/')
3737
}
38-
}
38+
}, [isHomePage, navigate])
39+
40+
const showSolidHeader = !isHomePage || scrolled
3941

4042
return (
4143
<Box sx={{ display: 'flex', flexDirection: 'column', minHeight: '100vh' }}>
4244
<AppBar
43-
ref={appBarRef}
4445
position="fixed"
4546
elevation={0}
4647
sx={{
47-
backgroundColor: isHomePage ? 'transparent' : '#262626',
48+
backgroundColor: showSolidHeader ? '#262626' : 'transparent',
49+
boxShadow: showSolidHeader ? '0 2px 8px rgba(0,0,0,0.15)' : 'none',
4850
transition: 'background-color 0.3s ease, box-shadow 0.3s ease',
4951
zIndex: 20,
5052
}}
@@ -86,7 +88,7 @@ export function Layout({ children }: LayoutProps): React.ReactNode {
8688
</Toolbar>
8789
</AppBar>
8890

89-
<Box component="main" sx={{ flex: 1, pt: 'var(--header-height)' }}>
91+
<Box component="main" sx={{ flex: 1, pt: isHomePage ? 0 : 'var(--header-height)' }}>
9092
{isHomePage ? (
9193
children
9294
) : (

src/index.css

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
}
99
}
1010

11-
html {
12-
scroll-behavior: smooth;
11+
@media (prefers-reduced-motion: no-preference) {
12+
html {
13+
scroll-behavior: smooth;
14+
}
1315
}
1416

1517
body {

src/pages/TermDetailPage.tsx

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ function isTermExample(example: string | TermExample): example is TermExample {
3131
return typeof example === 'object' && 'en' in example && 'ko' in example
3232
}
3333

34+
const exampleBoxSx = {
35+
borderLeft: '4px solid',
36+
borderLeftColor: 'rgba(238, 76, 44, 0.2)',
37+
backgroundColor: '#F7F7F8',
38+
px: 2,
39+
py: 1.5,
40+
borderRadius: 1,
41+
} as const
42+
3443
function MeaningContent({ meaning }: { meaning: TermMeaning }) {
3544
return (
3645
<Box>
@@ -46,17 +55,7 @@ function MeaningContent({ meaning }: { meaning: TermMeaning }) {
4655
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 1.5 }}>
4756
{meaning.examples.map((example, exIndex) =>
4857
isTermExample(example) ? (
49-
<Box
50-
key={exIndex}
51-
sx={{
52-
borderLeft: '4px solid',
53-
borderLeftColor: 'rgba(238, 76, 44, 0.2)',
54-
backgroundColor: '#F7F7F8',
55-
px: 2,
56-
py: 1.5,
57-
borderRadius: 1,
58-
}}
59-
>
58+
<Box key={exIndex} sx={exampleBoxSx}>
6059
<Typography variant="body2" sx={{ color: 'text.secondary', fontStyle: 'italic' }}>
6160
{example.en}
6261
</Typography>
@@ -76,17 +75,7 @@ function MeaningContent({ meaning }: { meaning: TermMeaning }) {
7675
)}
7776
</Box>
7877
) : (
79-
<Box
80-
key={exIndex}
81-
sx={{
82-
borderLeft: '4px solid',
83-
borderLeftColor: 'rgba(238, 76, 44, 0.2)',
84-
backgroundColor: '#F7F7F8',
85-
px: 2,
86-
py: 1.5,
87-
borderRadius: 1,
88-
}}
89-
>
78+
<Box key={exIndex} sx={exampleBoxSx}>
9079
<Typography variant="body2">{example}</Typography>
9180
</Box>
9281
)
@@ -253,6 +242,7 @@ export function TermDetailPage(): React.ReactNode {
253242
size="small"
254243
onClick={() => handleCopyKorean(term.meanings[0].korean)}
255244
aria-label={`${term.meanings[0].korean} 복사`}
245+
sx={{ minHeight: 44, minWidth: 44 }}
256246
>
257247
<ContentCopyIcon fontSize="small" />
258248
</IconButton>

src/theme.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ export const theme = createTheme({
102102
MuiContainer: {
103103
styleOverrides: {
104104
maxWidthLg: {
105-
maxWidth: '1300px !important',
105+
'@media (min-width: 1200px)': {
106+
maxWidth: 1300,
107+
},
106108
},
107109
},
108110
},

0 commit comments

Comments
 (0)