Skip to content

Commit

Permalink
Merge pull request #41 from ehdrhelr/fe/feature/map
Browse files Browse the repository at this point in the history
[Fe] 카카오 Map
  • Loading branch information
hayoung123 authored Jun 1, 2021
2 parents 48bbe29 + 4b3c285 commit a1f13f9
Show file tree
Hide file tree
Showing 32 changed files with 779 additions and 24 deletions.
1 change: 1 addition & 0 deletions FE/airbnb/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REACT_APP_MAP_APPKEY=9f0ba239664a570240d7a243e65f8e6a
1 change: 1 addition & 0 deletions FE/airbnb/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REACT_APP_MAP_APPKEY=9f0ba239664a570240d7a243e65f8e6a
117 changes: 117 additions & 0 deletions FE/airbnb/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions FE/airbnb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
"@types/node": "^12.0.0",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@types/react-router-dom": "^5.1.7",
"@types/styled-components": "^5.1.9",
"react": "^17.0.2",
"react-cool-kyle-carousel": "0.0.6",
"react-dom": "^17.0.2",
"react-icons": "^4.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"recoil": "^0.3.1",
"styled-components": "^5.3.0",
Expand Down
4 changes: 4 additions & 0 deletions FE/airbnb/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Web site created using create-react-app" />
<script
type="text/javascript"
src="//dapi.kakao.com/v2/maps/sdk.js?appkey=%REACT_APP_MAP_APPKEY%"
></script>
<title>Airbnb</title>
</head>
<body>
Expand Down
21 changes: 20 additions & 1 deletion FE/airbnb/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,31 @@ import './App.css';
import theme from './theme';
import styled, { ThemeProvider } from 'styled-components';
import MainPage from './pages/MainPage';
import ReservePage from './pages/ReservePage';
import { Suspense } from 'react';
import { BrowserRouter as Router, Route, Link } from 'react-router-dom';

declare global {
interface Window {
kakao: any;
}
}

function App() {
console.log('app');
return (
<ThemeProvider theme={theme}>
<StyledApp>
<MainPage />
<Router>
<Route exact={true} path='/'>
<MainPage />
</Route>
<Route path='/reserve'>
<Suspense fallback='loading'>
<ReservePage />
</Suspense>
</Route>
</Router>
</StyledApp>
</ThemeProvider>
);
Expand Down
File renamed without changes
2 changes: 1 addition & 1 deletion FE/airbnb/src/assets/svg/Property 1=star.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions FE/airbnb/src/components/header/Background.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';
import styled from 'styled-components';

interface Props {
src: string;
}

const Background = ({ src }: Props) => {
return (
<StyledBackground>
<img src={src} alt='' />{' '}
</StyledBackground>
);
};

export default React.memo(Background);

const StyledBackground = styled.div`
position: absolute;
top: 0;
z-index: -1;
width: 100%;
height: 70vh;
img {
width: 100%;
height: 100%;
}
background-repeat: no-repeat;
background-size: contain;
`;
14 changes: 12 additions & 2 deletions FE/airbnb/src/components/header/form/FormColumn.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
import { FormEvent, RefObject } from 'react';
import styled from 'styled-components';

interface Props {
title: string;
description: string;
isInput?: boolean;
inputRef?: RefObject<HTMLInputElement>;
handleInput?: (e: FormEvent<HTMLInputElement>) => void;
}

const FormColumn = ({ title, description, isInput }: Props) => {
const FormColumn = ({ title, description, isInput, inputRef, handleInput }: Props) => {
return (
<StyledFormColumn>
<div className='title'>{title}</div>
{isInput ? (
<input type='text' name='locationInput' placeholder={description} />
<input
type='text'
name='locationInput'
placeholder={description}
ref={inputRef}
onChange={handleInput}
autoComplete='off'
/>
) : (
<div className='description'>{description}</div>
)}
Expand Down
34 changes: 27 additions & 7 deletions FE/airbnb/src/components/header/form/FormLocation.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useRef, useEffect } from 'react';
import { useSetRecoilState } from 'recoil';
import { useRef, useEffect, FormEvent } from 'react';
import { useRecoilState, useResetRecoilState, useSetRecoilState } from 'recoil';
import styled from 'styled-components';
import useToggle from '../../../hooks/useToggle';
import { isFormOpenedState } from '../../../recoil/headerAtom';
import { isFormOpenedState, locationState } from '../../../recoil/headerAtom';
import HoverBlock from '../HoverBlock';
import FormColumn from './FormColumn';
import FormLocationToggle from './FormLocationToggle';
Expand All @@ -13,20 +13,40 @@ const FormLocation = () => {
const toggleRef = useRef<HTMLDivElement>(null);
const { open } = useToggle({ clickRef, toggleRef });
const setIsFormOpened = useSetRecoilState(isFormOpenedState);
const inputRef = useRef<HTMLInputElement>(null);
const [location, setLocation] = useRecoilState(locationState);
const clearLocation = useResetRecoilState(locationState);

const isShowDeleteBtn = open;

useEffect(() => {
if (open) setIsFormOpened(true);
else setIsFormOpened(false);
if (open) {
setIsFormOpened(true);
if (inputRef.current) inputRef.current.focus();
} else setIsFormOpened(false);
}, [open]);

const handleInput = (e: FormEvent<HTMLInputElement>) => {
setLocation(e.currentTarget.value);
};

const handleDeleteBtn = () => {
clearLocation();
if (inputRef.current) inputRef.current.value = '';
};

return (
<StyledLocationWrapper>
<StyledFormLocation ref={clickRef} data-type='location'>
<HoverBlock color='gray4' className='hover__location' dataKey='location' isModal={open}>
<FormColumn title='위치' description='어디로 여행가세요' isInput={true} />
{isShowDeleteBtn && <DeleteBtn />}
<FormColumn
title='위치'
description='어디로 여행가세요'
isInput={true}
inputRef={inputRef}
handleInput={handleInput}
/>
{isShowDeleteBtn && <DeleteBtn onClick={handleDeleteBtn} />}
</HoverBlock>
</StyledFormLocation>
{open && <FormLocationToggle toggleRef={toggleRef} />}
Expand Down
4 changes: 3 additions & 1 deletion FE/airbnb/src/components/header/form/FormPrice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ const FormPrice = () => {

export default FormPrice;

const StyledFormPriceWrapper = styled.div``;
const StyledFormPriceWrapper = styled.div`
position: relative;
`;

const StyledFormPrice = styled.div`
height: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ interface StyleType {
}

const StyledFormCalendar = styled.div<StyleType>`
z-index: 10;
overflow: hidden;
position: absolute;
top: 100px;
Expand Down
10 changes: 10 additions & 0 deletions FE/airbnb/src/components/header/form/calendar/calendarDateFn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,13 @@ export const getDateByTime = (time: number | null): date | void => {
const date = new Date(time);
return { year: date.getFullYear(), month: date.getMonth() + 1, day: date.getDate() };
};

export const dateToString = (date: date | void): string => {
if (!date) return '';
let { year, month, day } = date;
let newMonth = month + '';
let newDay = day + '';
if (month < 10) newMonth = '0' + month;
if (day < 10) newDay = '0' + day;
return `${year}-${newMonth}-${newDay}`;
};
Loading

0 comments on commit a1f13f9

Please sign in to comment.