Skip to content

Commit

Permalink
Add Status component
Browse files Browse the repository at this point in the history
  • Loading branch information
brunojuca committed Aug 14, 2021
1 parent 9b0566f commit e13d551
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 17 deletions.
33 changes: 33 additions & 0 deletions src/components/Status.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { makeStyles } from "@material-ui/core";
import React from "react";

const useStyle = makeStyles((theme) => ({
status: {
width: "max-content",
padding: "3px 10px 0px 10px",
borderRadius: "20px",
},
done: {
backgroundColor: "green",
},
waiting: {
backgroundColor: "yellow",
color: "black",
},
failed: {
backgroundColor: "red",
},
center: {
margin: "auto",
}
}));

function Status({ children, color, center }) {
const classes = useStyle();

return (
<div className={`${classes.status} ${classes[color]} ${center ? classes.center : null}`}>{children}</div>
);
}

export default Status;
22 changes: 5 additions & 17 deletions src/pages/Jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
import React, { useState, useEffect } from "react";
import { Link, useHistory } from "react-router-dom";
import API from "../api/API";
import Status from "../components/Status";
import { useJobsContext } from "../contexts/JobsContext";

const useStyle = makeStyles((theme) => ({
Expand Down Expand Up @@ -44,21 +45,8 @@ const useStyle = makeStyles((theme) => ({
color: "white",
},
status: {
width: "max-content",
padding: "3px 10px 0px 10px",
margin: "auto",
borderRadius: "20px",
},
done: {
backgroundColor: "green",
},
waiting: {
backgroundColor: "yellow",
color: "black",
},
failed: {
backgroundColor: "red",
},
margin: "auto"
}
}));

function descendingComparator(a, b, orderBy) {
Expand Down Expand Up @@ -158,9 +146,9 @@ function Jobs() {
{job.version}
</TableCell>
<TableCell className={classes.cell} align="center">
<div className={`${classes.status} ${classes[job.status]}`}>
<Status color={job.status} center>
{job.status.toUpperCase()}
</div>
</Status>
</TableCell>
</TableRow>
))}
Expand Down

0 comments on commit e13d551

Please sign in to comment.