Skip to content

Commit

Permalink
[FE] Refactor/#513 지도 생성 및 핀 생성 페이지 지도 위치 조정 (#514)
Browse files Browse the repository at this point in the history
* design: 모든페이지에서 지도 상, 사이드바 하 고정

* refactor: 지도 생성 및 핀 생성 페이지에서 기존 잔류 핀 초기화

* design: 모아보기 페이지 반응형시 중앙 정렬
  • Loading branch information
semnil5202 authored Sep 27, 2023
1 parent 551217f commit 0c5bf0d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 7 deletions.
1 change: 0 additions & 1 deletion frontend/src/components/Layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ const MediaWrapper = styled.section<{
overflow: hidden;
@media (max-width: 1076px) {
flex-direction: ${({ $isAddPage, $layoutWidth }) => {
if ($isAddPage) return 'column';
if ($layoutWidth === '372px') return 'column-reverse';
}};
}
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/pages/NewPin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ const NewPin = () => {
const [topic, setTopic] = useState<any>(null);
const [selectedTopic, setSelectedTopic] = useState<any>(null);
const [showedImages, setShowedImages] = useState<string[]>([]);
const { clickedMarker } = useContext(MarkerContext);
const { clickedMarker, markers, removeMarkers, removeInfowindows } =
useContext(MarkerContext);
const { clickedCoordinate, setClickedCoordinate } =
useContext(CoordinatesContext);
const { formValues, errorMessages, onChangeInput } =
Expand Down Expand Up @@ -228,6 +229,11 @@ const NewPin = () => {
}
};

if (!topicId && markers && markers.length > 0) {
removeMarkers();
removeInfowindows();
}

getTopicId();
}, []);

Expand Down Expand Up @@ -307,7 +313,6 @@ const NewPin = () => {
onChangeInput={onChangeInput}
tabIndex={1}
errorMessage={errorMessages.name}
autoFocus
maxLength={50}
/>

Expand Down Expand Up @@ -364,6 +369,7 @@ const NewPin = () => {
추가하기
</Button>
</Flex>
<Space size={7} />
</Wrapper>
</form>

Expand Down
30 changes: 27 additions & 3 deletions frontend/src/pages/NewTopic.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContext, useState } from 'react';
import { useContext, useEffect, useState } from 'react';
import Text from '../components/common/Text';
import Flex from '../components/common/Flex';
import Space from '../components/common/Space';
Expand All @@ -18,6 +18,7 @@ import usePost from '../apiHooks/usePost';
import AuthorityRadioContainer from '../components/AuthorityRadioContainer';
import styled from 'styled-components';
import useCompressImage from '../hooks/useCompressImage';
import { MarkerContext } from '../context/MarkerContext';

type NewTopicFormValuesType = Omit<NewTopicFormProps, 'topics'>;

Expand All @@ -36,6 +37,8 @@ const NewTopic = () => {
image: '',
});
const { compressImage } = useCompressImage();
const { markers, removeMarkers, removeInfowindows } =
useContext(MarkerContext);

const [isPrivate, setIsPrivate] = useState(false); // 혼자 볼 지도 : 같이 볼 지도
const [isAllPermissioned, setIsAllPermissioned] = useState(true); // 모두 : 지정 인원
Expand Down Expand Up @@ -137,10 +140,17 @@ const NewTopic = () => {
setShowImage(URL.createObjectURL(file));
};

useEffect(() => {
if (!pulledPinIds && markers && markers.length > 0) {
removeMarkers();
removeInfowindows();
}
}, []);

return (
<form onSubmit={onSubmit}>
<Space size={4} />
<Flex
<Wrapper
width={`calc(${width} - ${LAYOUT_PADDING})`}
$flexDirection="column"
>
Expand Down Expand Up @@ -237,11 +247,25 @@ const NewTopic = () => {
생성하기
</Button>
</Flex>
</Flex>
<Space size={7} />
</Wrapper>
</form>
);
};

const Wrapper = styled(Flex)`
margin: 0 auto;
@media (max-width: 1076px) {
width: calc(50vw - 40px);
}
@media (max-width: 744px) {
width: ${({ width }) => width};
margin: 0 auto;
}
`;

const ImageInputLabel = styled.label`
height: 40px;
padding: 10px 10px;
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/pages/SeeTogetherTopics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ const Wrapper = styled.section<{ width: '372px' | '100vw' }>`
height: 100%;
display: flex;
flex-direction: column;
margin: 0 auto;
`;

const WrapperWhenEmpty = styled.section<{ width: '372px' | '100vw' }>`
Expand All @@ -139,11 +141,13 @@ const WrapperWhenEmpty = styled.section<{ width: '372px' | '100vw' }>`
flex-direction: column;
justify-content: center;
align-items: center;
margin: 0 auto;
`;

const ButtonsWrapper = styled.div`
display: flex;
justify-content: center;
justify-content: end;
align-items: center;
`;

Expand Down

0 comments on commit 0c5bf0d

Please sign in to comment.