Skip to content

Commit

Permalink
Merge pull request #119 from AimeTPGM/party-member-vote
Browse files Browse the repository at this point in the history
Party member vote result panel
  • Loading branch information
AimeTPGM authored Mar 23, 2019
2 parents b58d3b9 + be65d6b commit 3a201df
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 21 deletions.
105 changes: 105 additions & 0 deletions src/components/PerPartyMemberVoteResult.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import React from "react"
import { DESKTOP_MIN_WIDTH, media, DISPLAY_FONT } from "../styles"
import _ from "lodash"

const mockData = [
{
name: "นายประมูล อึ้งไปเลยสิย้ง",
zone: "ราชบุรี, เขต 3",
vote: "1234567",
percentage: "20",
},
{
name: "นายย้ง อึ้งไปเลยสิประมูล",
zone: "ราชบุรี, เขต 3",
vote: "672367",
percentage: "20",
},
{
name: "นายอึ้ง ย้ง",
zone: "ราชบุรี, เขต 3",
vote: "345",
percentage: "20",
},
{
name: "นายย้ง อึ้ง",
zone: "ราชบุรี, เขต 3",
vote: "22344",
percentage: "20",
},
]

// @todo #1 Party View - binding data to ZonePartyMemberVoteResult
export default function ZonePartyMemberVoteResult({ data = mockData }) {
const active = { background: "#000", color: "#FFF" }
const tabHeaderStyle = {
padding: "15px",
width: "100%",
cursor: "pointer",
border: 0,
borderBottom: "1px solid #000",
["&:hover"]: {
active,
},
}
return (
<div
css={{
[media(DESKTOP_MIN_WIDTH)]: {
display: "block",
order: 3,
margin: "0",
padding: "16px",
width: "320px",
textAlign: "center",
},
}}
>
<h2 css={{ fontFamily: DISPLAY_FONT }}>ประมาณจำนวน สส. ที่ได้</h2>
<div>
{/* tab */}
{
// @todo #1 Party View - implement interactive tab
}
<div>
<ul
css={{
display: "flex",
listStyle: "none",
padding: 0,
margin: 0,
width: "100%",
}}
>
<li css={{ ...tabHeaderStyle, ...active }}>แบ่งเขต(31)</li>
<li css={{ ...tabHeaderStyle }}>บัญชีรายชื่อ (13)</li>
</ul>
</div>

{/* list */}
<div css={{ textAlign: "left", padding: "5px" }}>
{data.map(item => (
<div
css={{ display: "flex", position: "relative", marginTop: "15px" }}
>
<img
src={require(`../styles/images/pmcan/1-s.png`)}
css={{ width: "30px", height: "30px", borderRadius: "50%" }}
/>
<div css={{ marginLeft: "5px", fontFamily: DISPLAY_FONT }}>
<div css={{ fontWeight: "bold" }}>{item.name}</div>
<div css={{ fontSize: "0.8em" }}>{item.zone}</div>
</div>
<div css={{ float: "right", position: "absolute", right: 0 }}>
<span css={{ fontWeight: "bold" }}>
{item.vote.replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,")}
</span>{" "}
- {item.percentage}%
</div>
</div>
))}
</div>
</div>
</div>
)
}
23 changes: 2 additions & 21 deletions src/components/PerPartyView.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import ErrorBoundary from "./ErrorBoundary"
import ElectionMapContainer from "./ElectionMapContainer"
import { Link } from "gatsby"
import PerPartyMemberVoteResult from "./PerPartyMemberVoteResult"

export default function PerPartyView() {
return (
Expand All @@ -26,7 +27,7 @@ export default function PerPartyView() {
>
<ZoneSearchParty />
<ZoneMapView />
<ZonePartyVoteResult />
<PerPartyMemberVoteResult />
</div>
</div>
)
Expand Down Expand Up @@ -122,23 +123,3 @@ function ZoneMapView() {
</div>
)
}

// @todo #1 show each party vote result
function ZonePartyVoteResult() {
return (
<div
css={{
[media(DESKTOP_MIN_WIDTH)]: {
display: "block",
order: 3,
margin: "0",
padding: "16px",
width: "320px",
},
}}
>
{/* right zone */}
<div>ประมาณจำนวน สส. ที่ได้</div>
</div>
)
}

3 comments on commit 3a201df

@0pdd
Copy link

@0pdd 0pdd commented on 3a201df Mar 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1-edaaced4 disappeared from src/components/ZonePartyView.js, that's why I closed #117. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link

@0pdd 0pdd commented on 3a201df Mar 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1-50f0f6bf discovered in src/components/PerPartyMemberVoteResult.js and submitted as #120. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link

@0pdd 0pdd commented on 3a201df Mar 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1-c71f393e discovered in src/components/PerPartyMemberVoteResult.js and submitted as #122. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.