Skip to content

Commit

Permalink
feat: problem status
Browse files Browse the repository at this point in the history
  • Loading branch information
amrsalama committed Feb 9, 2020
1 parent abd6728 commit e01272e
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 16 deletions.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.4.0",
"@testing-library/user-event": "^7.2.1",
"classnames": "^2.2.6",
"prop-types": "^15.7.2",
"react": "^16.12.0",
"react-dom": "^16.12.0",
Expand Down
19 changes: 17 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,29 @@ const App = () => {
{ id: 'B', name: 'Find Length' },
{ id: 'C', name: "Let's use Getline" },
{ id: 'D', name: 'Compare' },
{ id: 'E', name: 'Strings' }
{ id: 'E', name: 'Strings Strings Strings' }
]
}
];

const submissions = {
'ahmed.7oskaa': {
// '219158-A': {
// verdict: 'AC',
// list: [{ id: '' }]
// },
// '219158-B': {
// verdict: 'WA',
// list: [
// // { id: }
// ]
// }
}
};

return (
<div className="App">
<Board sheets={sheets} trainees={trainees} />
<Board sheets={sheets} trainees={trainees} submissions={submissions} />
</div>
);
};
Expand Down
47 changes: 34 additions & 13 deletions src/Components/Board/Board.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React from 'react';
import PropTypes from 'prop-types';
import cn from 'classnames';
import { blockSize, paddingBetweenRows } from '../common';
import { TraineeList } from '../TraineeList';
import Sheet from '../Sheet';
import styles from './styles';

class Board extends React.Component {
render() {
const { sheets, trainees } = this.props;
const { sheets, trainees, submissions } = this.props;

return (
<>
Expand All @@ -30,7 +31,7 @@ class Board extends React.Component {
paddingBottom: paddingBetweenRows
}}
>
{trainees.map((_, index) => (
{trainees.map(({ handle }, index) => (
<div
key={index}
className="trainee-problems-row"
Expand All @@ -39,16 +40,35 @@ class Board extends React.Component {
paddingBottom: paddingBetweenRows
}}
>
{sheets.map(({ problems }) =>
problems.map(({ id }) => (
<div
key={id}
className="trainee-problems-cell ac"
style={{ width: blockSize, height: blockSize }}
>
AC
</div>
))
{sheets.map(({ id: sheetId, problems }) =>
problems.map(({ id: problemId }) => {
const submission =
(submissions[handle] &&
submissions[handle][`${sheetId}-${problemId}`]) ||
{};

return (
<div
key={`${sheetId}-${problemId}`}
className={cn('trainee-problems-cell', {
ac: submission.verdict === 'AC',
'not-ac': submission.verdict !== 'AC',
'not-solved': submission.verdict === undefined
})}
style={{ width: blockSize, height: blockSize }}
>
{submission.verdict ? (
<>
<div>{submission.verdict}</div>
<div>+10</div>
{/* <div className="list"></div> */}
</>
) : (
<div>?</div>
)}
</div>
);
})
)}
</div>
))}
Expand All @@ -63,7 +83,8 @@ class Board extends React.Component {

Board.propTypes = {
sheets: PropTypes.array.isRequired,
trainees: PropTypes.array.isRequired
trainees: PropTypes.array.isRequired,
submissions: PropTypes.object.isRequired
};

export default Board;
17 changes: 17 additions & 0 deletions src/Components/Board/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default css`
.board .sheets-section .trainee-problems-status .trainee-problems-cell {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
border-top: 1px solid;
Expand All @@ -56,4 +57,20 @@ export default css`
background-color: lightgreen;
border-color: green;
}
.board
.sheets-section
.trainee-problems-status
.trainee-problems-cell.not-ac {
background-color: orangered;
border-color: blue;
}
.board
.sheets-section
.trainee-problems-status
.trainee-problems-cell.not-solved {
background-color: lightgrey;
border-color: grey;
}
`;
2 changes: 1 addition & 1 deletion src/Components/Sheet/Sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Sheet extends React.Component {
className="details"
style={{ top: sheetProblemIdHeight - 5 }}
>
{problem.name}
{`${problem.id}. ${problem.name}`}
</div>
</a>
))}
Expand Down
8 changes: 8 additions & 0 deletions src/Components/Sheet/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ export default css`
visibility: hidden;
}
.sheet .problems .problem:first-child .details {
left: 0;
}
.sheet .problems .problem:last-child .details {
right: 0;
}
.sheet .problems .problem:hover .details {
opacity: 1;
visibility: visible;
Expand Down

0 comments on commit e01272e

Please sign in to comment.