File tree Expand file tree Collapse file tree 15 files changed +11165
-10195
lines changed
Expand file tree Collapse file tree 15 files changed +11165
-10195
lines changed Original file line number Diff line number Diff line change 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" ,
Original file line number Diff line number Diff line change 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
44const 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 }
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 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 ;
Original file line number Diff line number Diff line change 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+ ` ;
Original file line number Diff line number Diff line change 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 ;
Original file line number Diff line number Diff line change 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+ ` ;
Original file line number Diff line number Diff line change 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 ;
You can’t perform that action at this time.
0 commit comments