-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from JupGo/map/8
[ 🗺 Map ] UI 완성 후 타이머기능까지 연결하기
- Loading branch information
Showing
22 changed files
with
329 additions
and
35 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 +1,5 @@ | ||
export { ReactComponent as IcFloggingStart } from './IcFlogging.svg'; | ||
export { ReactComponent as IcLogo } from './IcLogo.svg'; | ||
export { ReactComponent as IcTemporaryPause } from './IcPause.svg'; | ||
export { ReactComponent as IcRunning } from './IcRunning.svg'; | ||
export { ReactComponent as IcStop } from './IcStop.svg'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
import { IcFloggingStart, IcStop, IcTemporaryPause } from '../../asset/icon'; | ||
|
||
interface JupgoButtonProps { | ||
btnType: string; | ||
handleBtnClick: React.MouseEventHandler; | ||
} | ||
|
||
const JupgoButton = (props: JupgoButtonProps) => { | ||
const { btnType, handleBtnClick } = props; | ||
|
||
return ( | ||
<JupgoBtn onClick={handleBtnClick} btnType={btnType}> | ||
{btnType === 'floggingPause' ? ( | ||
<IcTemporaryPause /> | ||
) : btnType === 'floggingStart' ? ( | ||
<IcFloggingStart /> | ||
) : ( | ||
<IcStop /> | ||
)} | ||
</JupgoBtn> | ||
); | ||
}; | ||
|
||
export default JupgoButton; | ||
|
||
const JupgoBtn = styled.button<{ btnType: string }>` | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: 45%; | ||
height: 100%; | ||
background-color: ${({ theme, btnType }) => | ||
btnType === 'floggingPause' | ||
? theme.colors.gray_01 | ||
: btnType === 'floggingStart' | ||
? theme.colors.green_dark | ||
: theme.colors.pink}; | ||
border: none; | ||
border-radius: 2rem; | ||
`; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import { useState } from 'react'; | ||
import { useRecoilState } from 'recoil'; | ||
import styled from 'styled-components'; | ||
|
||
import { IcRunning } from '../../asset/icon'; | ||
import useCouter from '../../lib/hooks/useCouter'; | ||
import { floggingInfoState } from '../../recoil/atom'; | ||
import { getDateParse } from '../../utils/dateParse'; | ||
import JupgoButton from './JupgoButton'; | ||
|
||
const RunningControl = () => { | ||
const [isFloggingPause, setIsFloggintPause] = useState(false); | ||
const [floggingInfo, setFloggingInfo] = useRecoilState(floggingInfoState); | ||
const { count, start, stop } = useCouter(0, 1000); | ||
const { distance, duration } = floggingInfo; | ||
|
||
const handleFloggingStart = () => { | ||
start(); | ||
setIsFloggintPause(!isFloggingPause); | ||
}; | ||
const handleFloggingPause = () => { | ||
stop(); | ||
setIsFloggintPause(!isFloggingPause); | ||
}; | ||
const handleFloggingStop = () => { | ||
stop(); | ||
setFloggingInfo({ ...floggingInfo }); | ||
}; | ||
|
||
return ( | ||
<RunningControlWrapper> | ||
<HeaderWrapper> | ||
<header> | ||
<h1>{distance}</h1> | ||
<h1>km</h1> | ||
<IcRunning /> | ||
</header> | ||
<p>{getDateParse(count).map((data, idx) => (idx !== 2 ? data + ' : ' : data))}</p> | ||
</HeaderWrapper> | ||
|
||
<article> | ||
{isFloggingPause ? ( | ||
<JupgoButton btnType={'floggingPause'} handleBtnClick={handleFloggingPause} /> | ||
) : ( | ||
<JupgoButton btnType={'floggingStart'} handleBtnClick={handleFloggingStart} /> | ||
)} | ||
|
||
<JupgoButton btnType={'floggingStop'} handleBtnClick={handleFloggingStop} /> | ||
</article> | ||
</RunningControlWrapper> | ||
); | ||
}; | ||
|
||
export default RunningControl; | ||
|
||
const RunningControlWrapper = styled.section` | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
width: 94%; | ||
height: 14%; | ||
padding: 4% 8%; | ||
background-color: rgba(250, 250, 250, 0.9); | ||
border-radius: 1rem; | ||
article { | ||
display: flex; | ||
justify-content: space-between; | ||
width: 100%; | ||
height: 40%; | ||
} | ||
`; | ||
const HeaderWrapper = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
width: 100%; | ||
header { | ||
display: flex; | ||
justify-content: flex-start; | ||
align-items: center; | ||
gap: 0.5rem; | ||
& > h1 { | ||
vertical-align: bottom; | ||
${({ theme }) => theme.fonts.Jupgo_Bold_32} | ||
:nth-child(2) { | ||
font-size: 2rem; | ||
} | ||
} | ||
} | ||
p { | ||
margin-right: 12%; | ||
${({ theme }) => theme.fonts.Jupgo_Bold_20} | ||
color:${({ theme }) => theme.colors.gray_01}; | ||
} | ||
`; |
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 +1,2 @@ | ||
export { default as KakaoMap } from './KakaoMap'; | ||
export { default as RunningControl } from './RunningControl'; |
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 @@ | ||
import { useCallback, useRef, useState } from 'react'; | ||
|
||
const useCouter = (initMinutes: number, ms: number) => { | ||
const [count, setCount] = useState(initMinutes); | ||
const intervalRef = useRef<NodeJS.Timeout | null>(null); | ||
|
||
const start = useCallback(() => { | ||
if (intervalRef.current) return; | ||
intervalRef.current = setInterval(() => { | ||
setCount((prev) => prev + 1); | ||
}, ms); | ||
}, []); | ||
|
||
const stop = useCallback(() => { | ||
if (!intervalRef.current) return; | ||
clearInterval(intervalRef.current); | ||
intervalRef.current = null; | ||
}, []); | ||
|
||
return { count, start, stop }; | ||
}; | ||
|
||
export default useCouter; |
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,9 +1,42 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
import { KakaoMap } from '../components/map'; | ||
import { IcLogo } from '../asset/icon'; | ||
import { KakaoMap, RunningControl } from '../components/map'; | ||
|
||
const Map = () => { | ||
return <KakaoMap />; | ||
return ( | ||
<StMapWrapper> | ||
<KakaoMap /> | ||
<IcLogo /> | ||
<RunningControl /> | ||
</StMapWrapper> | ||
); | ||
}; | ||
|
||
export default Map; | ||
|
||
const StMapWrapper = styled.div` | ||
width: 100%; | ||
height: 100%; | ||
& > svg { | ||
position: absolute; | ||
top: 2rem; | ||
left: 50%; | ||
height: 3.064rem; | ||
transform: translate(-50%, 0%); | ||
z-index: 3; | ||
} | ||
& > section { | ||
position: absolute; | ||
bottom: 12%; | ||
left: 50%; | ||
transform: translate(-50%, 0%); | ||
z-index: 3; | ||
} | ||
`; |
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,18 @@ | ||
import { atom } from 'recoil'; | ||
import { recoilPersist } from 'recoil-persist'; | ||
|
||
import { FloggingData } from '../types/flogging'; | ||
|
||
const { persistAtom } = recoilPersist(); | ||
|
||
export const floggingInfoState = atom<FloggingData>({ | ||
key: 'floggingInfo', | ||
default: { | ||
date: '2023.01.12', | ||
location: '인천', | ||
distance: 0, | ||
duration: '00:00:00', | ||
photo: new FormData(), | ||
}, | ||
effects_UNSTABLE: [persistAtom], | ||
}); |
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.