Skip to content

Commit

Permalink
[Upd #71] Added new custom legend component
Browse files Browse the repository at this point in the history
  • Loading branch information
LaChope committed Oct 4, 2022
1 parent 2356ebe commit 0259c5e
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 27 deletions.
12 changes: 0 additions & 12 deletions src/assets/PlanningTool.css
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,6 @@
margin-right: 1.3rem;
}

.explanatory-notes .note .color.scheduled-wo {
background-color: #aa0000;
}

.explanatory-notes .note .color.task-card {
background-color: #00aa00;
}

.explanatory-notes .note .color.maintenance-wo {
background-color: #0000aa;
}

.static-item:after {
content: '';
display: block;
Expand Down
24 changes: 24 additions & 0 deletions src/components/Legend.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from "react";

const Legend = ({ title, legendItems }) => {
return (
<div className="explanatory-notes">
<h3>{title}</h3>
<React.Fragment>
{legendItems.map((item, index) => {
return (
<div key={index} className="note">
<span
className="color"
style={{ backgroundColor: `${item.color}` }}
></span>
{item.name}
</div>
);
})}
</React.Fragment>
</div>
);
};

export default Legend;
35 changes: 20 additions & 15 deletions src/components/PlanningTool.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Popup from './Popup'
import Modal from './Modal'
import EditItemModal from './EditItemModal'
import Constants from '../constants/Constants'
import Legend from "./Legend";

const keys = {
groupIdKey: "id",
Expand Down Expand Up @@ -1627,21 +1628,7 @@ class PlanningTool extends Component {
}
</Timeline>
<div className="explanatory-notes-container">
<div className="explanatory-notes">
<h3>Task types</h3>
<div className="note">
<span className="color scheduled-wo"/>
Scheduled_wo
</div>
<div className="note">
<span className="color task-card"/>
Task_card
</div>
<div className="note">
<span className="color maintenance-wo"/>
Maintenance_wo
</div>
</div>
<Legend legendItems={this.props.legendItems} title="Legend" />
{this.renderPopup(popup)}
{/*undo redo*/}
<div className="action-buttons">
Expand Down Expand Up @@ -1710,6 +1697,10 @@ PlanningTool
date: PropTypes.instanceOf(moment).isRequired,
label: PropTypes.string,
color: PropTypes.string,
})),
legendItems: PropTypes.arrayOf(PropTypes.shape({
name: PropTypes.string,
color: PropTypes.string
}))
}

Expand All @@ -1734,5 +1725,19 @@ PlanningTool
],
groups: [],
popup: Popup,
legendItems: [
{
name: "scheduled_wo",
color: "red"
},
{
name: "maintenance_wo",
color: "green"
},
{
name: "task group",
color: "blue"
}
]
}
export default PlanningTool

0 comments on commit 0259c5e

Please sign in to comment.