Skip to content

Commit

Permalink
Merge branch 'main' into 14-router-consumer
Browse files Browse the repository at this point in the history
  • Loading branch information
happycastle114 authored Nov 22, 2023
2 parents b09b9be + f74fe5d commit 4d54ff7
Show file tree
Hide file tree
Showing 14 changed files with 435 additions and 243 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_API_BASE_URL=https://diversity-api.tech4impact.kr
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
},
"dependencies": {
"@ant-design/charts": "^1.4.2",
"@ant-design/icons": "^5.2.6",
"@ant-design/plots": "^1.2.5",
"@emotion/react": "^11.11.1",
"antd": "^5.11.1",
"axios": "^1.6.2",
"immer": "^10.0.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
260 changes: 162 additions & 98 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions src/components/organisms/Histogram.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Histogram, type HistogramConfig } from "@ant-design/plots";
import { css } from "@emotion/react";

interface HistogramData {
export interface HistogramData {
value: number;
}

interface Props {
data: HistogramData[];
}

const AgeHistogram = ({ data }: Props) => {
export const AgeHistogram = ({ data }: Props) => {
const config: HistogramConfig = {
data,
binField: "value",
Expand Down Expand Up @@ -37,5 +37,3 @@ const AgeHistogram = ({ data }: Props) => {
/>
);
};

export default AgeHistogram;
155 changes: 98 additions & 57 deletions src/components/organisms/LocalSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,70 +1,111 @@
import { MapSVG, type MetroID, MetroInfo } from "@/../static/MapSVGData";
import { type ReactNode } from "react";
import { Dropdown, Flex } from "antd";
import { DownOutlined } from "@ant-design/icons";
import { css } from "@emotion/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;
<Flex vertical align="center">
<Dropdown
menu={{
items: [
{ key: "1", label: "One" },
{ key: "2", label: "Two" },
{ type: "divider" },
{ key: "3", label: "Three" },
{ key: "4", label: "Four" },
],
}}
>
<Flex
justify="center"
align="center"
gap="small"
css={css`
@media (max-width: 768px) {
width: 80%;
}
width: 30%;
height: 20pt;
border-radius: 5pt;
background-color: white;
`}
</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>
>
기초 자치 단체 선택하기
<DownOutlined />
</Flex>
</Dropdown>
<div
css={css`
height: 15pt;
`}
/>
<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"
css={css`
@media (max-width: 768px) {
width: 80%;
}
width: 30%;
.local {
fill: ${MetroInfo[selected]?.color || "#4CC9F0"};
stroke: #080808;
stroke-width: 1px;
-webkit-transition:
fill 0.2s,
stroke 0.2s;
}
.local:hover {
fill: #080808;
}
`}
>
{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>
</Flex>
);
export default LocalSelector;
151 changes: 95 additions & 56 deletions src/components/organisms/MetroSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { MapSVG, MetroInfo } from "@/../static/MapSVGData";
import { type ReactNode, useState } from "react";
import { Dropdown, Flex } from "antd";
import { css } from "@emotion/react";
import { DownOutlined } from "@ant-design/icons";

interface Props {
onClick?: (local: string) => void;
Expand All @@ -8,64 +11,100 @@ interface Props {
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
<Flex vertical align="center">
<Dropdown
menu={{
items: [
{ key: "1", label: "One" },
{ key: "2", label: "Two" },
{ type: "divider" },
{ key: "3", label: "Three" },
{ key: "4", label: "Four" },
],
}}
>
<Flex
justify="center"
align="center"
gap="small"
css={css`
@media (max-width: 768px) {
width: 80%;
}
width: 30%;
height: 20pt;
border-radius: 5pt;
background-color: white;
`}
>
광역 자치 단체 선택하기
<DownOutlined />
</Flex>
</Dropdown>
<div
css={css`
height: 15pt;
`}
/>
<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"
css={css`
@media (max-width: 768px) {
width: 80%;
}
width: 30%;
.metro {
-webkit-transition:
fill 0.2s,
stroke 0.2s;
}
`}
>
{MapSVG.map<ReactNode>(group => (
<g
key={group.groupId}
id={group.groupId}
className="metro"
css={css`
fill: ${hover !== group.groupId
? MetroInfo[group.groupId].color
: "#1c3f64",
stroke:
hover !== group.groupId
: "#060606"};
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>
: "#060606"};
`}
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>
</Flex>
);
};

Expand Down
4 changes: 1 addition & 3 deletions src/components/organisms/PieChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface Props {
colors: string[];
}

const PieChart = ({ data, colors }: Props) => {
export const PieChart = ({ data, colors }: Props) => {
const config: PieConfig = {
appendPadding: 10,
data,
Expand Down Expand Up @@ -42,5 +42,3 @@ const PieChart = ({ data, colors }: Props) => {
/>
);
};

export default PieChart;
4 changes: 2 additions & 2 deletions src/components/organisms/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// organism 단계의 컴포넌트들을 한번에 export 하기 위한 index.ts 파일
export { default as Header } from "./Header";
export { default as Footer } from "./Footer";
export { default as Histogram } from "./Histogram";
export { default as PieChart } from "./PieChart";
export * from "./Histogram";
export * from "./PieChart";
export { default as TestChart } from "./TestChart";
export { default as MetroSelector } from "./MetroSelector";
export { default as LocalSelector } from "./LocalSelector";
Loading

0 comments on commit 4d54ff7

Please sign in to comment.