-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: Navbar 숨김에 petDetail, timeline 추가 * chore: 반려 식물 상세 전역 Suspense 사용 * refactor: 뒤로가기 헤더 컴포넌트로 추출 * refactor: BackHeader 적용 * design: 색 transition 추가, user-select none 추가 * chore: BackButton width 추가 * feat: BackHeader 추가 * design: 모두의 정원에 기록하기 버튼 BottomSheet에 추가 * feat: 원하면 일정 px 높이에서 투명할 수 있도록 변경 * feat: 헤더에 그림자 추가 * refactor: 의존성 추가 및 button type 추가 * test: 펫 등록 테스트 구현 --------- Co-authored-by: hozzijeong <[email protected]>
- Loading branch information
1 parent
ec911c3
commit af2eff0
Showing
14 changed files
with
199 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
frontend/src/components/@common/BackHeader/BackHeader.style.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const Wrapper = styled.header<{ $transparent: boolean }>` | ||
position: fixed; | ||
z-index: ${(props) => props.theme.zIndex.fixed}; | ||
top: 0; | ||
display: flex; | ||
align-items: center; | ||
width: 100%; | ||
max-width: ${(props) => props.theme.width.pad}; | ||
height: 48px; | ||
padding: 0 16px; | ||
background: ${(props) => | ||
props.$transparent | ||
? `linear-gradient(rgba(0, 0, 0, 0.4), rgba(255, 255, 255, 0))` | ||
: props.theme.color.background}; | ||
box-shadow: 0 2px 2px -2px ${(props) => (props.$transparent ? 'transparent' : props.theme.color.gray)}; | ||
`; | ||
|
||
export const BackButton = styled.button` | ||
position: absolute; | ||
left: 16px; | ||
display: flex; | ||
align-items: center; | ||
width: 22px; | ||
`; | ||
|
||
export const TransparentSensor = styled.div<{ $height: `${string}px` }>` | ||
position: absolute; | ||
top: 0; | ||
height: ${(props) => props.$height}; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { useCallback, type PropsWithChildren } from 'react'; | ||
import { createPortal } from 'react-dom'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { BackButton, TransparentSensor, Wrapper } from './BackHeader.style'; | ||
import useToggle from 'hooks/@common/useToggle'; | ||
import theme from 'style/theme.style'; | ||
import SvgFill from '../SvgIcons/SvgFill'; | ||
|
||
interface BackHeaderProps extends PropsWithChildren { | ||
transparentHeight?: number; | ||
} | ||
|
||
const BackHeader = (props: BackHeaderProps) => { | ||
const { children, transparentHeight } = props; | ||
|
||
const navigate = useNavigate(); | ||
const { isOn: isTop, on, off } = useToggle(false); | ||
|
||
const goBack = () => { | ||
navigate(-1); | ||
}; | ||
|
||
const intersectionRef = useCallback( | ||
<T extends Element>(instance: T | null) => { | ||
const onChangeIntersection = (isIntersecting: boolean) => { | ||
if (!transparentHeight) return; | ||
|
||
if (isIntersecting) { | ||
on(); | ||
} else { | ||
off(); | ||
} | ||
}; | ||
|
||
const observer = new IntersectionObserver((entries) => { | ||
entries.forEach(({ isIntersecting }) => { | ||
onChangeIntersection(isIntersecting); | ||
}); | ||
}); | ||
|
||
if (instance) observer.observe(instance); | ||
}, | ||
[off, on, transparentHeight] | ||
); | ||
|
||
return ( | ||
<> | ||
{createPortal( | ||
<TransparentSensor ref={intersectionRef} $height={`${transparentHeight}px`} />, | ||
document.body | ||
)} | ||
<Wrapper $transparent={isTop}> | ||
<BackButton type="button" onClick={goBack}> | ||
<SvgFill | ||
icon="line-arrow-left" | ||
aria-label="뒤로 가기" | ||
color={isTop ? theme.color.background : theme.color.sub} | ||
/> | ||
</BackButton> | ||
{children} | ||
</Wrapper> | ||
</> | ||
); | ||
}; | ||
|
||
export default BackHeader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
frontend/src/pages/petPlant/PetPlantRegister/Form/Form.style.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.