-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 세부 기록(심박수, 페이스, 칼로리) 작성 구현합니다. #72
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e9ca226
Merge branch 'feat/record-diary' of https://github.com/depromeet/15th…
wokbjso 124abca
Merge branch 'feat/record-equipment' of https://github.com/depromeet/…
wokbjso 0982f40
feat: accordion atom 컴포넌트로 분리
wokbjso 1919bd5
refactor: text-fields들 컴포넌트로 분리
wokbjso 5e38dce
fix: text-field에 값이 반영 안되는 버그 수정
wokbjso 8281079
feat: time-picker 바텀 시트 기본 디자인 구현
wokbjso 36d1d73
design: bottom-sheet들 디자인 수정
wokbjso 1dff4c9
chore: 훅 시작 소문자로 변경
wokbjso de1cd7c
design: time-picker 디자인 수정
wokbjso c66f7ad
design: top 속성 수정
wokbjso a9db130
design: time-picker 디자인 수정
wokbjso 454a694
design: time-picker animation false로 설정
wokbjso cb79627
chore: 불필요하게 변경된 파일 원복
wokbjso c2786f2
chore: 코드 리뷰 반영
wokbjso File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use client'; | ||
|
||
import { motion } from 'framer-motion'; | ||
import { ReactNode } from 'react'; | ||
|
||
interface AccordionProps { | ||
className?: string; | ||
children: ReactNode; | ||
} | ||
|
||
export function Accordion({ className, children }: AccordionProps) { | ||
return ( | ||
<motion.div | ||
layout | ||
animate={{ y: 0, opacity: 1 }} | ||
exit={{ opacity: 0 }} | ||
transition={{ duration: 0.3, ease: [0.43, 0.13, 0.23, 0.96] }} | ||
className={className} | ||
> | ||
{children} | ||
</motion.div> | ||
); | ||
} |
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 @@ | ||
export * from './accordion'; |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './accordion'; | ||
export * from './button'; | ||
export * from './dim'; | ||
export * from './icons'; | ||
|
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
50 changes: 35 additions & 15 deletions
50
features/record/components/organisms/sub-info-section.tsx
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 |
---|---|---|
@@ -1,40 +1,60 @@ | ||
'use client'; | ||
|
||
import { DownArrowIcon } from '@/components/atoms'; | ||
import { AnimatePresence } from 'framer-motion'; | ||
import { useState } from 'react'; | ||
|
||
import { Accordion, DownArrowIcon } from '@/components/atoms'; | ||
import { Divider } from '@/components/atoms/divider'; | ||
import { css } from '@/styled-system/css'; | ||
import { flex } from '@/styled-system/patterns'; | ||
|
||
import { useSubInfoTextFields } from '../../hooks'; | ||
import { FormSectionProps } from '../../types/form-section'; | ||
import { SubInfoTextFields } from './sub-info-text-fields'; | ||
|
||
export function SubInfoSection({ title }: FormSectionProps) { | ||
const { isOpen, handlers } = useSubInfoTextFields(); | ||
const [isTextFieldsOpen, setIsTextFieldsOpen] = useState(false); | ||
|
||
const handleTextFieldsOpenStateClick = () => { | ||
setIsTextFieldsOpen((prev) => !prev); | ||
}; | ||
|
||
return ( | ||
<section> | ||
<> | ||
<div | ||
className={beforeExpandStyles.layout} | ||
onClick={() => handlers.onChangeFieldsOpen()} | ||
className={titleStyles.layout} | ||
onClick={handleTextFieldsOpenStateClick} | ||
> | ||
<h1 className={beforeExpandStyles.title}>{title}</h1> | ||
<h1 className={titleStyles.text}>{title}</h1> | ||
<DownArrowIcon /> | ||
</div> | ||
{!isOpen && <Divider variant="thick" />} | ||
<SubInfoTextFields isOpen={isOpen} /> | ||
</section> | ||
<AnimatePresence> | ||
{!isTextFieldsOpen ? ( | ||
<Accordion> | ||
<Divider variant="thick" /> | ||
</Accordion> | ||
) : ( | ||
<Accordion className={textFieldsStyles}> | ||
<SubInfoTextFields /> | ||
</Accordion> | ||
)} | ||
</AnimatePresence> | ||
</> | ||
); | ||
} | ||
|
||
const beforeExpandStyles = { | ||
layout: css({ | ||
display: 'flex', | ||
const titleStyles = { | ||
layout: flex({ | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
padding: '24px 20px', | ||
padding: '20px 24px', | ||
}), | ||
title: css({ | ||
|
||
text: css({ | ||
textStyle: 'heading4', | ||
fontWeight: '600', | ||
}), | ||
}; | ||
|
||
const textFieldsStyles = css({ | ||
padding: '0 20px 24px 20px', | ||
}); |
36 changes: 23 additions & 13 deletions
36
features/record/components/organisms/sub-info-text-fields.tsx
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 |
---|---|---|
@@ -1,28 +1,38 @@ | ||
'use client'; | ||
|
||
import { useFormContext } from 'react-hook-form'; | ||
|
||
import { TextField } from '@/components/molecules'; | ||
import { css } from '@/styled-system/css'; | ||
|
||
interface SubInfoTextFieldsProps { | ||
isOpen: boolean; | ||
} | ||
import { useSubInfoTextFields } from '../../hooks'; | ||
|
||
export function SubInfoTextFields() { | ||
const { watch } = useFormContext(); | ||
const { handlers } = useSubInfoTextFields(); | ||
|
||
export function SubInfoTextFields({ isOpen }: SubInfoTextFieldsProps) { | ||
return isOpen ? ( | ||
<div className={layoutStyles}> | ||
return ( | ||
<> | ||
<TextField | ||
label="심박수" | ||
unit="BPM" | ||
value={watch('heartRate') ? String(watch('heartRate')) : ''} | ||
wrapperClassName={css({ marginBottom: '23px' })} | ||
onChange={handlers.onChangeHeartRate} | ||
/> | ||
<TextField | ||
label="페이스" | ||
unit="/100m" | ||
value={watch('pace') ? (watch('pace') as string) : ''} | ||
wrapperClassName={css({ marginBottom: '23px' })} | ||
onChange={handlers.onChangePace} | ||
/> | ||
<TextField label="칼로리" unit="Kcal" /> | ||
</div> | ||
) : null; | ||
<TextField | ||
label="칼로리" | ||
unit="Kcal" | ||
value={watch('kcal') ? String(watch('kcal')) : ''} | ||
onChange={handlers.onChangeKcal} | ||
/> | ||
</> | ||
); | ||
} | ||
|
||
const layoutStyles = css({ | ||
padding: '0 20px 24px 20px', | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍👍👍