Working on an Angular 7 project, I have a <td>
element where I display different colors to indicate the status of a task:
- Red - Indicates 'Delayed'
- Orange - Indicates 'In progress'
- Grey - Indicates 'Rejected'
Currently, I am able to display these status colors successfully. Now, I want to enhance the user experience by adding text that appears when the user hovers over each status, explaining the meaning behind the color.
Here's the code snippet:
<td data-label="Status" class="cell status-cell">
<span [style.backgroundColor]="getStatus(working_period)"></span>
<p>Text on hover here</p>
</td>
I've written the TypeScript logic as well:
public getStatus(period: WorkingPeriod): string {
if (+period.status !== 2) {
return 'grey';
}
const time: number = +new Date() - +period.endDate;
if (time > 2 * 24 * 60 * 60 * 1000) {
return `red`;
}
return 'orange';
}
The issue I'm facing is aligning the text with the respective colors displayed. For example, I want 'In progress' below orange and 'Delayed' below red.
You can view my current layout in the screenshot below:
(I appreciate your patience as I continue to learn Angular)
Thanks in advance!