-
Notifications
You must be signed in to change notification settings - Fork 0
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 #13 from NewWays-TechForImpactKAIST/feat/map-selector
Feat/map selector
- Loading branch information
Showing
11 changed files
with
2,136 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { MapSVG, type MetroID, MetroInfo } from "@/../static/MapSVGData"; | ||
import { type ReactNode } from "react"; | ||
|
||
interface Props { | ||
selected: MetroID; | ||
onClick?: (local: string) => void; | ||
} | ||
|
||
const LocalSelector = ({ selected, onClick = () => {} }: Props) => ( | ||
<svg | ||
version="1.1" | ||
id="Layer_1" | ||
xmlns="http://www.w3.org/2000/svg" | ||
xmlnsXlink="http://www.w3.org/1999/xlink" | ||
x="0px" | ||
y="0px" | ||
viewBox={MetroInfo[selected]?.viewBox || "0 0 509 716.1"} | ||
xmlSpace="preserve" | ||
> | ||
<style type="text/css"> | ||
{` | ||
.local{ | ||
fill: ${MetroInfo[selected]?.color || "#1c3f64"}; | ||
stroke: #1c3f64; | ||
stroke-width: 0.5px; | ||
-webkit-transition: | ||
fill 0.2s, | ||
stroke 0.2s | ||
} | ||
.local:hover{ | ||
fill: #1c3f64; | ||
} | ||
`} | ||
</style> | ||
{MapSVG.map<ReactNode>(group => | ||
group.groupId === selected ? ( | ||
<g key={group.groupId}> | ||
{group.component.map(shape => { | ||
if (shape.type === `path`) { | ||
return ( | ||
<path | ||
key={shape.id} | ||
className="local" | ||
id={shape.id} | ||
d={shape.data} | ||
onClick={() => onClick(shape.id)} | ||
/> | ||
); | ||
} | ||
if (shape.type === `polygon`) { | ||
return ( | ||
<polygon | ||
key={shape.id} | ||
className="local" | ||
id={shape.id} | ||
points={shape.data} | ||
onClick={() => onClick(shape.id)} | ||
/> | ||
); | ||
} | ||
throw new Error(`${shape.id} is not path or polygon`); | ||
})} | ||
</g> | ||
) : ( | ||
<g key={group.groupId} /> | ||
), | ||
)} | ||
</svg> | ||
); | ||
export default LocalSelector; |
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,72 @@ | ||
import { MapSVG, MetroInfo } from "@/../static/MapSVGData"; | ||
import { type ReactNode, useState } from "react"; | ||
|
||
interface Props { | ||
onClick?: (local: string) => void; | ||
} | ||
|
||
const MetroSelector = ({ onClick = () => {} }: Props) => { | ||
const [hover, setHover] = useState<string>(""); | ||
return ( | ||
<svg | ||
version="1.1" | ||
id="Layer_1" | ||
xmlns="http://www.w3.org/2000/svg" | ||
xmlnsXlink="http://www.w3.org/1999/xlink" | ||
x="0px" | ||
y="0px" | ||
viewBox="0 0 509 716.1" | ||
xmlSpace="preserve" | ||
> | ||
<style type="text/css"> | ||
{` | ||
.metro{ | ||
-webkit-transition: | ||
fill 0.2s, | ||
stroke 0.2s | ||
} | ||
`} | ||
</style> | ||
{MapSVG.map<ReactNode>(group => ( | ||
<g | ||
key={group.groupId} | ||
id={group.groupId} | ||
className="metro" | ||
style={{ | ||
fill: | ||
hover !== group.groupId | ||
? MetroInfo[group.groupId].color | ||
: "#1c3f64", | ||
stroke: | ||
hover !== group.groupId | ||
? MetroInfo[group.groupId].color | ||
: "#1c3f64", | ||
}} | ||
onMouseEnter={() => { | ||
setHover(group.groupId); | ||
}} | ||
onMouseLeave={() => { | ||
setHover(""); | ||
}} | ||
onClick={() => { | ||
onClick(group.groupId); | ||
}} | ||
> | ||
{group.component.map(shape => { | ||
if (shape.type === `path`) { | ||
return <path key={shape.id} id={shape.id} d={shape.data} />; | ||
} | ||
if (shape.type === `polygon`) { | ||
return ( | ||
<polygon key={shape.id} id={shape.id} points={shape.data} /> | ||
); | ||
} | ||
throw new Error(`${shape.id} is not path or polygon`); | ||
})} | ||
</g> | ||
))} | ||
</svg> | ||
); | ||
}; | ||
|
||
export default MetroSelector; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from "react"; | ||
import { Flex } from "antd"; | ||
import { css } from "@emotion/react"; | ||
|
||
import { Layout } from "@/components/templates"; | ||
import { LocalSelector, MetroSelector } from "@/components/organisms"; | ||
|
||
const LocalCouncil: React.FC = () => ( | ||
<Layout> | ||
<Flex | ||
vertical | ||
gap={40} | ||
css={css` | ||
margin: 40px 0 40px 0; | ||
`} | ||
> | ||
<LocalSelector | ||
selected="서울특별시" | ||
onClick={id => { | ||
alert(id); | ||
}} | ||
/> | ||
<MetroSelector | ||
onClick={id => { | ||
alert(id); | ||
}} | ||
/> | ||
</Flex> | ||
</Layout> | ||
); | ||
|
||
export default LocalCouncil; |
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,30 +1,47 @@ | ||
import React from "react"; | ||
import { Flex } from "antd"; | ||
import { Flex, Typography } from "antd"; | ||
import { css } from "@emotion/react"; | ||
import { useParams } from "react-router-dom"; | ||
|
||
import { Layout } from "@/components/templates"; | ||
import { Histogram, PieChart } from "@/components/organisms"; | ||
|
||
import { | ||
sampleAgeHistogramData, | ||
samplePartyPieData, | ||
sampleSexPieData, | ||
} from "@/utils"; | ||
|
||
const Test: React.FC = () => ( | ||
<Layout> | ||
<Flex | ||
vertical | ||
gap={40} | ||
css={css` | ||
margin: 40px 0 40px 0; | ||
`} | ||
> | ||
<Histogram data={sampleAgeHistogramData} /> | ||
<PieChart data={samplePartyPieData} /> | ||
<PieChart data={sampleSexPieData} /> | ||
</Flex> | ||
</Layout> | ||
); | ||
const { Title } = Typography; | ||
|
||
const LocalCouncilReport: React.FC = () => { | ||
const { metroId, localId } = useParams(); | ||
return ( | ||
<Layout> | ||
<Flex | ||
vertical | ||
gap={40} | ||
css={css` | ||
margin: 40px 0 40px 0; | ||
`} | ||
> | ||
<Title | ||
level={1} | ||
>{`MetroId(${metroId}) LocalId(${localId})의 지역의회 다양성 리포트`}</Title> | ||
<Title level={2}>연령 다양성</Title> | ||
<Histogram data={sampleAgeHistogramData} /> | ||
<Title level={2}>정당 다양성</Title> | ||
<PieChart | ||
data={samplePartyPieData.data} | ||
colors={samplePartyPieData.colors} | ||
/> | ||
<Title level={2}>성별 다양성</Title> | ||
<PieChart | ||
data={sampleSexPieData.data} | ||
colors={sampleSexPieData.colors} | ||
/> | ||
</Flex> | ||
</Layout> | ||
); | ||
}; | ||
|
||
export default Test; | ||
export default LocalCouncilReport; |
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,2 +1,3 @@ | ||
// page 컴포넌트를 모아놓은 파일 | ||
export { default as LocalCouncil } from "./LocalCouncil"; | ||
export { default as LocalCouncilReport } from "./LocalCouncilReport"; |
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
Oops, something went wrong.