Skip to content

Commit bf63905

Browse files
authored
Merge pull request CEOS-Developers#7 from Team-MailedIt/corinthionia
Vote, Result 페이지 기본 컴포넌트 추가
2 parents 754321a + dc2daf6 commit bf63905

File tree

15 files changed

+11165
-10195
lines changed

15 files changed

+11165
-10195
lines changed

package-lock.json

Lines changed: 334 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"styled-components": "^5.3.3",
2121
"styled-normalize": "^8.0.7",
2222
"typescript": "^4.1.2",
23-
"web-vitals": "^1.0.1"
23+
"web-vitals": "^1.0.1",
24+
"yarn": "^1.22.17"
2425
},
2526
"scripts": {
2627
"start": "react-scripts start",

src/assets/styles/global-styles.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { normalize } from 'styled-normalize';
2-
import { createGlobalStyle } from 'styled-components';
1+
import { normalize } from "styled-normalize";
2+
import { createGlobalStyle } from "styled-components";
33

44
const GlobalStyle = createGlobalStyle`
55
${normalize}
@@ -8,6 +8,7 @@ const GlobalStyle = createGlobalStyle`
88
body {
99
height: 100vh;
1010
width: 100vw;
11+
1112
margin: 0;
1213
padding: 0;
1314
}

src/components/header/HeaderContainer.tsx

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/components/header/HeaderPresenter.tsx

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import {
2+
Wrapper,
3+
Title,
4+
ResultsWrapper,
5+
ResultWrapper,
6+
} from "./ResultPresenter";
7+
import axios from "axios";
8+
import { useEffect, useState } from "react";
9+
10+
const ResultContainer = () => {
11+
const [resultList, setResultList] = useState([]);
12+
13+
useEffect(() => {
14+
const fetchResult = async () => {
15+
const response = await axios.get(
16+
"https://9a63efda-a674-4015-be3c-824740a2aa52.mock.pstmn.io/vote"
17+
);
18+
setResultList(response.data);
19+
};
20+
fetchResult();
21+
}, []);
22+
23+
resultList.sort((a, b: any) => {
24+
return b["voteCount"] - a["voteCount"];
25+
});
26+
27+
console.log(resultList);
28+
29+
return (
30+
<Wrapper>
31+
<Title>Result</Title>
32+
<ResultsWrapper>
33+
{resultList.map((result: any) => (
34+
<ResultWrapper key={result.name}>{result.name}</ResultWrapper>
35+
))}
36+
</ResultsWrapper>
37+
</Wrapper>
38+
);
39+
};
40+
41+
export default ResultContainer;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import styled from "styled-components";
2+
3+
export const Wrapper = styled.section`
4+
width: 80%;
5+
padding: 2.5%;
6+
`;
7+
8+
export const Title = styled.span`
9+
font-size: 50px;
10+
font-weight: 400;
11+
12+
margin: 0;
13+
`;
14+
15+
export const ResultsWrapper = styled.section`
16+
width: 80%;
17+
height: 80%;
18+
19+
display: flex;
20+
align-items: center;
21+
justify-content: center;
22+
23+
flex-wrap: wrap;
24+
25+
border: 1px solid black;
26+
`;
27+
28+
export const ResultWrapper = styled.section`
29+
width: 500px;
30+
height: 50px;
31+
32+
margin: 0 25px;
33+
34+
display: flex;
35+
align-items: center;
36+
justify-content: center;
37+
38+
border-radius: 10px;
39+
border: 1px solid #d2d2d2;
40+
`;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import {
2+
Sidebar,
3+
ItemsWrapper,
4+
StyledNavLink,
5+
Logo,
6+
Text,
7+
} from "./SidebarPresenter";
8+
import logo from "../../assets/images/logo.png";
9+
10+
// 수정 중
11+
const SidebarContainer = () => {
12+
return (
13+
<Sidebar>
14+
<ItemsWrapper>
15+
<StyledNavLink to={"/"}>
16+
<Logo src={logo} alt="" />
17+
</StyledNavLink>
18+
<StyledNavLink to={"/vote/:part"}>
19+
<Text>Vote</Text>
20+
</StyledNavLink>
21+
<StyledNavLink to={"/result"}>
22+
<Text>Result</Text>
23+
</StyledNavLink>
24+
</ItemsWrapper>
25+
<StyledNavLink to={"/"}>
26+
<Text>Profile</Text>
27+
</StyledNavLink>
28+
</Sidebar>
29+
);
30+
};
31+
32+
export default SidebarContainer;
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { NavLink } from "react-router-dom";
2+
import styled from "styled-components";
3+
4+
export const Sidebar = styled.section`
5+
width: 20%;
6+
height: 100vh;
7+
8+
display: flex;
9+
flex-direction: column;
10+
justify-content: space-between;
11+
12+
border-right: 1px solid #e2e2e2;
13+
`;
14+
15+
export const ItemsWrapper = styled.section`
16+
height: 45%;
17+
width: 100%;
18+
19+
margin-top: 10%;
20+
`;
21+
22+
export const StyledNavLink = styled(NavLink)`
23+
height: 25%;
24+
width: 100%;
25+
26+
display: flex;
27+
align-items: center;
28+
justify-content: center;
29+
30+
text-decoration: none;
31+
color: black;
32+
33+
.active {
34+
color: pink;
35+
}
36+
`;
37+
38+
export const Logo = styled.img`
39+
width: 150px;
40+
height: 30px;
41+
42+
object-fit: contain;
43+
`;
44+
45+
export const Text = styled.h3`
46+
display: flex;
47+
`;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import {
2+
Wrapper,
3+
Title,
4+
CandidatesWrapper,
5+
CandidateWrapper,
6+
SubmitButton,
7+
} from "./VotePresenter";
8+
9+
import axios from "axios";
10+
import { useEffect, useState } from "react";
11+
12+
const VoteContainer = () => {
13+
const [candidates, setCandidates] = useState([]);
14+
15+
useEffect(() => {
16+
const fetchCandidates = async () => {
17+
const response = await axios.get(
18+
"https://9a63efda-a674-4015-be3c-824740a2aa52.mock.pstmn.io/vote"
19+
);
20+
setCandidates(response.data);
21+
};
22+
fetchCandidates();
23+
}, []);
24+
25+
return (
26+
<Wrapper>
27+
<Title>Front-end</Title>
28+
<CandidatesWrapper>
29+
{candidates.map((candidate: any) => (
30+
<CandidateWrapper>{candidate.name}</CandidateWrapper>
31+
))}
32+
</CandidatesWrapper>
33+
<SubmitButton>Vote!</SubmitButton>
34+
</Wrapper>
35+
);
36+
};
37+
38+
export default VoteContainer;

0 commit comments

Comments
 (0)