-
Notifications
You must be signed in to change notification settings - Fork 0
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/map #10
Feat/map #10
Changes from all commits
755dbde
3fc23dc
2c56c25
48dcc02
fc5a691
267b3f2
46db46e
a110654
817abe3
e25651f
eb0a16d
956f0c5
d9320b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from "react"; | ||
import {HeaderBar} from "components/HeaderBar"; | ||
import {SearchBar} from "components/SearchBar"; | ||
import {Stack} from "components/Stack"; | ||
|
||
type LayoutMapProps = { | ||
children: React.ReactNode; | ||
}; | ||
|
||
const LayoutMap = ({children}: LayoutMapProps) => { | ||
return ( | ||
<div | ||
css={{ | ||
display: "flex", | ||
flexDirection: "column", | ||
width: "100%", | ||
height: "100vh", | ||
}} | ||
> | ||
<HeaderBar /> | ||
<SearchBar /> | ||
hotbreakb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<div css={{flex: 1, height: 10}}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
<Stack | ||
spacing="29px" | ||
divider={<hr css={{width: "88%", color: "#DDDDDD"}} />} | ||
> | ||
<div css={{height: 200}}>item2</div> | ||
<div css={{height: 200}}>item2</div> | ||
<div css={{height: 200}}>item2</div> | ||
<div css={{height: 200}}>item2</div> | ||
<div css={{height: 200}}>item2</div> | ||
</Stack> | ||
|
||
{/* naver map */} | ||
<div css={{width: "100%"}}>{children}</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default LayoutMap; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./LayoutMap" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from "react"; | ||
import {Select} from "components/Select"; | ||
|
||
export const SearchBar = () => { | ||
const hrColor = "#DDDDDD"; | ||
|
||
return ( | ||
<section | ||
hotbreakb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
css={{ | ||
height: 68, | ||
padding: 12, | ||
display: "flex", | ||
alignItems: "center", | ||
}} | ||
> | ||
<input | ||
type="text" | ||
placeholder="검색어를 입력해 주세요" | ||
css={{marginRight: 24}} | ||
/> | ||
<hr css={{height: 24, color: hrColor, marginRight: 16, marginLeft: 24}} /> | ||
<Select id="distance" name="거리순"></Select> | ||
<Select id="distance" name="동물 선택"></Select> | ||
<Select id="distance" name="혈액형 선택"></Select> | ||
</section> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./SearchBar" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {ComponentMeta, ComponentStory} from "@storybook/react"; | ||
import {Select} from "./Select"; | ||
|
||
export default { | ||
title: "atoms/Select", | ||
component: Select, | ||
argTypes: {}, | ||
args: { | ||
id: "id", | ||
name: "name", | ||
}, | ||
} as ComponentMeta<typeof Select>; | ||
|
||
const Template: ComponentStory<typeof Select> = (args) => <Select {...args} />; | ||
|
||
export const Default = Template.bind({}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import {ChangeEventHandler, ReactNode, useCallback} from "react"; | ||
import {Css, CssObject} from "styles/theme"; | ||
|
||
export type SelectProps = { | ||
children?: ReactNode; | ||
id: string; | ||
name: string; | ||
onChange?: ChangeEventHandler<HTMLSelectElement>; | ||
}; | ||
|
||
export const Select = ({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 색상 값이 사실 컬러시스템에서 가져오지 않고 hex 값을 사용하는 등 |
||
children, | ||
id, | ||
name, | ||
onChange, | ||
...rest | ||
}: SelectProps) => { | ||
return ( | ||
<div | ||
css={{ | ||
borderWidth: 1, | ||
borderStyle: "solid", | ||
borderRadius: "22px", | ||
borderColor: "#E6E7E9", | ||
paddingTop: 12, | ||
paddingRight: 11, | ||
paddingBottom: 13, | ||
paddingLeft: 12, | ||
marginLeft: 8, | ||
marginRight: 8, | ||
}} | ||
> | ||
<select | ||
id={id} | ||
onChange={onChange} | ||
{...rest} | ||
css={{border: 0, color: "#393939", fontSize: 13, paddingRight: 4}} | ||
> | ||
{children} | ||
<option value="">{name}</option> | ||
</select> | ||
</div> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./Select" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React, {ReactNode} from "react"; | ||
|
||
// ref: https://stackoverflow.com/questions/62432985/typescript-saying-a-string-is-invalid-even-though-its-in-the-union | ||
type FlexDirection = | ||
| "column" | ||
| "inherit" | ||
| "-moz-initial" | ||
| "initial" | ||
| "revert" | ||
| "unset" | ||
| "column-reverse" | ||
| "row" | ||
| "row-reverse" | ||
| undefined; | ||
|
||
export type StackProps = { | ||
children: ReactNode; | ||
direction?: FlexDirection; | ||
divider?: ReactNode; | ||
spacing: number | string; | ||
}; | ||
|
||
// ref: https://stackoverflow.com/questions/49496906/react-mapping-children-of-a-parent-component | ||
export const Stack = ({ | ||
children, | ||
direction = "column", | ||
divider, | ||
spacing, | ||
}: StackProps) => { | ||
return ( | ||
<> | ||
{children && ( | ||
<div | ||
css={{ | ||
display: "flex", | ||
flexDirection: direction, | ||
width: 400, | ||
padding: 24, | ||
overflowY: "scroll", | ||
}} | ||
> | ||
{React.Children.map(children, (child) => { | ||
return ( | ||
<div | ||
css={{ | ||
display: "flex", | ||
flexDirection: "column", | ||
}} | ||
> | ||
{child} | ||
{divider} | ||
</div> | ||
); | ||
})} | ||
</div> | ||
)} | ||
</> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./Stack" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
"@storybook/react": "^6.4.22", | ||
"@storybook/testing-library": "^0.0.9", | ||
"@svgr/webpack": "5.5.0", | ||
"@types/navermaps": "^3.0.13", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
"@types/node": "17.0.23", | ||
"@types/react": "18.0.1", | ||
"@types/react-dom": "18.0.0", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import type {NextPage} from "next"; | ||
import Script from "next/script"; | ||
import {useEffect, useState} from "react"; | ||
import LayoutMap from "components/LayoutMap/LayoutMap"; | ||
|
||
type Location = { | ||
latitude: number; | ||
longitude: number; | ||
}; | ||
|
||
const Request: NextPage = () => { | ||
// 초기 위치: 건국대학교 동물병원 | ||
const [userLocation, setUserLocation] = useState<Location>({ | ||
latitude: 37.5390908, | ||
longitude: 127.0747238, | ||
}); | ||
|
||
useEffect(() => { | ||
// 현재 위치 반영 | ||
if (navigator.geolocation) { | ||
navigator.geolocation.getCurrentPosition((position) => { | ||
setUserLocation({ | ||
latitude: position.coords.latitude, | ||
longitude: position.coords.longitude, | ||
}); | ||
}); | ||
} | ||
}, []); | ||
|
||
useEffect(() => { | ||
// userLocation으로 이동 | ||
const map = new naver.maps.Map("map", { | ||
center: new naver.maps.LatLng( | ||
userLocation.latitude, | ||
userLocation.longitude | ||
), | ||
zoom: 14, | ||
zoomControl: true, | ||
zoomControlOptions: { | ||
style: naver.maps.ZoomControlStyle.SMALL, | ||
position: naver.maps.Position.BOTTOM_RIGHT, | ||
}, | ||
}); | ||
|
||
const locationBtn = "현재 위치 추적하는 아이콘, 추가 예정"; | ||
|
||
const getUserLocation = new naver.maps.CustomControl(locationBtn, { | ||
position: naver.maps.Position.BOTTOM_RIGHT, | ||
}); | ||
|
||
// 마커로 위치 표시 | ||
const marker = new naver.maps.Marker({ | ||
position: new naver.maps.LatLng( | ||
userLocation.latitude, | ||
userLocation.longitude | ||
), | ||
map, | ||
// icon: { | ||
// url: ZoopiMarker, | ||
// size: new naver.maps.Size(25, 34), | ||
// scaledSize: new naver.maps.Size(25, 34), | ||
// origin: new naver.maps.Point(0, 0), | ||
// anchor: new naver.maps.Point(12, 34), | ||
// }, | ||
}); | ||
|
||
naver.maps.Event.once(map, "init", function () { | ||
getUserLocation.setMap(map); | ||
}); | ||
}, [userLocation]); | ||
|
||
const mapStyle = { | ||
width: "100%", | ||
height: "100%", | ||
}; | ||
|
||
return ( | ||
<> | ||
<LayoutMap> | ||
<div id="map" style={mapStyle}></div> | ||
</LayoutMap> | ||
<Script | ||
src="https://openapi.map.naver.com/openapi/v3/maps.js?ncpClientId=w4dthat1j6" | ||
strategy="beforeInteractive" | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
// ref: https://nextjs.org/docs/basic-features/script | ||
|
||
export default Request; |
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.
홍빈님 말씀대로 이 부분의 영향이 있었어요. 확인해보니,
SearchBar
안에 들어있는 컴포넌트의margin, padding
을 설정해주지 않아서 마음대로 움직이고 있는 거였어요.