xonecas.io
366
Hc

hirenimble-challenge / commit 47c5c01

Fix issue with modal showing wrong details. Add aesthetics

xonecas2020-09-01 47c5c012ad35b0ac75288e0c1b55f12e74764885 parent f297689

7 files changed

src/App.js+36−1
@@ -1,9 +1,44 @@
11 import React from "react";
2+import styled from "styled-components";
3+
24 import data from "data/candidates.json";
5+
36 import CandidatesList from "components/candidatesList";
7+import Header from "components/header";
8+
9+const MainPane = styled.div`
10+ display: grid;
11+
12+ grid-template-areas: "nav content";
13+ grid-template-columns: 200px 1fr;
14+ grid-template-rows: auto 1fr;
15+ grid-gap: 1em;
16+
17+ height: 100vh;
18+`;
19+
20+const Sidebar = styled.div`
21+ grid-area: nav;
22+`;
23+
24+const Content = styled.div`
25+ grid-area: content;
26+ background-color: rgba(0, 0, 0, 0.05);
27+ border-left: 1px solid #eee;
28+`;
429
530 function App() {
6- return <CandidatesList candidates={data} />;
31+ return (
32+ <React.Fragment>
33+ <Header />
34+ <MainPane>
35+ <Sidebar />
36+ <Content>
37+ <CandidatesList candidates={data} />
38+ </Content>
39+ </MainPane>
40+ </React.Fragment>
41+ );
742 }
843
944 export default App;
src/components/applicationDetais.js+8−9
@@ -1,19 +1,18 @@
1-import React from "react";
1+import React, { useState } from "react";
2+
23 import { Modal, Title, Body } from "../ui-kit/Modal";
34 import { roleStatuses } from "../utils/enums";
45
56 function ApplicationDetails(props) {
6- const {
7- candidate,
8- application,
9- visibility,
10- modalIsOpen,
11- toggleModal,
12- } = props;
13-
7+ const { candidate, application, visibility } = props;
148 const roleStatus = roleStatuses().filter((status) => {
159 return status.key === application.role.status;
1610 })[0].label;
11+ const [modalIsOpen, setModalIsOpen] = useState(false);
12+
13+ let toggleModal = (ev) => {
14+ setModalIsOpen(!modalIsOpen);
15+ };
1716
1817 return (
1918 <React.Fragment key={application.id}>
src/components/candidateListItem.js+49−31
@@ -1,52 +1,70 @@
11 import React, { useState } from "react";
22 import moment from "moment";
3+import styled from "styled-components";
4+
5+import { colorMapping } from "utils/enums";
36 import ApplicationDetail from "./applicationDetais";
47
8+import NimbleScore from "ui-kit/icons/svg/nimble_score.svg";
9+import Scorecard from "ui-kit/icons/svg/scorecard.svg";
10+import Notes from "ui-kit/icons/svg/note.svg";
11+
512 function CandidateListItem(props) {
613 const candidate = props.candidate;
714 const [visibility, setVisibility] = useState(false);
8- const [modalIsOpen, setModalIsOpen] = useState(false);
915
1016 let toggleApplicationDetail = (ev) => {
1117 setVisibility(!visibility);
1218 };
1319
14- let toggleModal = (ev) => {
15- setModalIsOpen(!modalIsOpen);
16- };
20+ const TableCell = styled.td`
21+ padding: 1em 0;
22+ border-bottom: 1px solid #ccc;
23+ `;
1724
1825 return (
1926 <React.Fragment key={candidate.id}>
2027 <tr onClick={toggleApplicationDetail}>
21- <td>{candidate.name}</td>
22- <td>
23- {candidate.applications[0].new_status.color}
28+ <TableCell>{candidate.name}</TableCell>
29+ <TableCell>
30+ <span
31+ className={
32+ "dot " + colorMapping[candidate.applications[0].new_status.color]
33+ }
34+ ></span>
2435 {candidate.applications[0].new_status.label}
25- </td>
26- <td>{candidate.applications.lengtd}</td>
27- <td>{moment(candidate.profile.updated).fromNow()}</td>
28- <td>{candidate.scorecard_count}</td>
29- <td>{candidate.profile.nimble_score}</td>
30- <td>{candidate.note_count}</td>
36+ </TableCell>
37+ <TableCell className="t-center">
38+ {candidate.applications.length}
39+ </TableCell>
40+ <TableCell>{moment(candidate.profile.updated).fromNow()}</TableCell>
41+ <TableCell className="t-right">
42+ <img src={Scorecard} alt="scorecard icon" />
43+ {candidate.scorecard_count}
44+ </TableCell>
45+ <TableCell className="t-center">
46+ <img src={NimbleScore} alt="nimble score icon" />
47+ {candidate.profile.nimble_score}
48+ </TableCell>
49+ <TableCell>
50+ <img src={Notes} alt="Notes icon" />
51+ {candidate.note_count}
52+ </TableCell>
3153 </tr>
32- <tr>
33- {candidate.applications.map((application) => {
34- return (
35- <td
36- key={application.id}
37- className={visibility ? "d-table-row" : "d-none"}
38- onClick={toggleModal}
39- >
40- <ApplicationDetail
41- candidate={candidate}
42- application={application}
43- visibility={visibility}
44- modalIsOpen={modalIsOpen}
45- toggleModal={toggleModal}
46- ></ApplicationDetail>
47- </td>
48- );
49- })}
54+ <tr className={visibility ? "d-table-row" : "d-none"}>
55+ <TableCell colSpan="7">
56+ {candidate.applications.map((application) => {
57+ return (
58+ <div key={application.id}>
59+ <ApplicationDetail
60+ candidate={candidate}
61+ application={application}
62+ visibility={visibility}
63+ ></ApplicationDetail>
64+ </div>
65+ );
66+ })}
67+ </TableCell>
5068 </tr>
5169 </React.Fragment>
5270 );
src/components/candidatesList.js+30−10
@@ -1,21 +1,41 @@
11 import React from "react";
2+import styled from "styled-components";
3+
24 import CandidateListItem from "./candidateListItem";
35
46 function CandidatesList(props) {
57 const candidates = props.candidates.results;
68
9+ const Table = styled.table`
10+ padding: 2em;
11+ border-spacing: 0;
12+ width: 100%;
13+ `;
14+
15+ const TableHeader = styled.th`
16+ border-bottom: 1px solid #ccc;
17+ color: #999;
18+ font-size: 0.6em;
19+ font-weight: 500;
20+ max-width: 20em;
21+ overflow: hidden;
22+ padding-bottom: 0.5em;
23+ text-align: left;
24+ text-overflow: ellipsis;
25+ text-transform: uppercase;
26+ `;
27+
728 return (
8- <table className="table">
29+ <Table cellspacing="0" cellpadding="0">
930 <thead>
1031 <tr>
11- <th>Candidate name</th>
12- <th>Canditate status</th>
13- <th># Applications</th>
14- <th>Last action</th>
15- <th>Scorecard</th>
16- <th>Nimble score</th>
17- <th>notes</th>
18- <th>actions</th>
32+ <TableHeader>Candidate name</TableHeader>
33+ <TableHeader>Canditate status</TableHeader>
34+ <TableHeader># Applications</TableHeader>
35+ <TableHeader>Last action</TableHeader>
36+ <TableHeader></TableHeader>
37+ <TableHeader></TableHeader>
38+ <TableHeader></TableHeader>
1939 </tr>
2040 </thead>
2141 <tbody>
@@ -23,7 +43,7 @@ function CandidatesList(props) {
2343 return <CandidateListItem key={candidate.id} candidate={candidate} />;
2444 })}
2545 </tbody>
26- </table>
46+ </Table>
2747 );
2848 }
2949
src/components/header.js+19−0
@@ -0,0 +1,19 @@
1+import React from "react";
2+import styled from "styled-components";
3+
4+import Logo from "ui-kit/icons/svg/nimble_navbar_logo.svg";
5+
6+const Navbar = styled.div`
7+ border-bottom: 1px solid #eee;
8+ padding: 1em;
9+`;
10+
11+function Header(props) {
12+ return (
13+ <Navbar>
14+ <img src={Logo} alt="brand icon" />
15+ </Navbar>
16+ );
17+}
18+
19+export default Header;
src/index.css+48−0
@@ -11,3 +11,51 @@ code {
1111 font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
1212 monospace;
1313 }
14+
15+.d-table-row {
16+ display: table-row !important;
17+}
18+
19+.d-none {
20+ display: none !important;
21+}
22+
23+.t-center {
24+ text-align: center;
25+}
26+
27+.t-right {
28+ text-align: right;
29+}
30+
31+tr > td {
32+ border-bottom: 1px solid #888;
33+}
34+td > img {
35+ margin-right: 0.4em;
36+}
37+
38+.dot {
39+ height: 1em;
40+ width: 1em;
41+ background-color: #bbb;
42+ border-radius: 50%;
43+ display: inline-block;
44+ margin-right: 1em;
45+}
46+
47+.dot.red {
48+ background-color: red;
49+}
50+
51+.dot.green {
52+ background-color: green;
53+}
54+
55+.dot.blue {
56+ background-color: blue;
57+}
58+
59+.dot.yellow {
60+ background-color: yellow;
61+}
src/index.js+0−1
@@ -1,6 +1,5 @@
11 import React from "react";
22 import ReactDOM from "react-dom";
3-import "bootstrap/dist/css/bootstrap.css";
43 import "./index.css";
54 import App from "./App";
65 import * as serviceWorker from "./serviceWorker";