Create a React component for src/components/TaskItem.tsx. Here are the instructions:
Task: Create TaskItem.tsx React Component
Description
We need to create a new React component called TaskItem.tsx that will be responsible for displaying individual task items in our project tasks page. This component will be written in TypeScript using ES6 syntax, such as arrow functions, and will utilize Tailwind CSS for styling.
Requirements
Create a new file named TaskItem.tsx inside the src/components directory.
Import the necessary dependencies at the top of the file:
import React from 'react';
import { ProjectTask } from '~/types';
Define a Props interface for this component, which should include a task prop of type ProjectTask:
interface Props {
task: ProjectTask;
}
Create a functional component named TaskItem that accepts the Props interface as its props:
Inside the component, render the following elements:
A div container with the Tailwind CSS classes bg-white p-4 rounded-lg shadow-md to style the task item.
An h3 element with the Tailwind CSS classes text-lg font-semibold mb-2 to display the task name. Use the task.taskName prop for the content.
A p element with the Tailwind CSS classes text-gray-600 to display the task description. Use the task.taskDescription prop for the content.
A div container with the Tailwind CSS classes mt-4 flex items-center to hold the status indicator and the "Approved" label.
A status indicator that shows whether the task is approved or not. Use a span element with the Tailwind CSS classes w-4 h-4 mr-2 rounded-full and apply the class bg-green-500 if the task is approved (task.approved === true) or bg-red-500 if not approved.
A span element with the Tailwind CSS classes text-gray-600 to display the text "Approved" if the task is approved or "Not Approved" if not approved.
Export the TaskItem component as the default export:
export default TaskItem;
Example Usage
Here's an example of how the TaskItem component will be used in the parent component:
Ensure that the component renders correctly with the provided props.
Verify that the task name and description are displayed correctly.
Check that the status indicator and the "Approved" label are displayed with the correct colors and text based on the task.approved prop.
Please submit a pull request with your changes once you have completed the task. If you have any questions or need further clarification, feel free to ask.
Create a React component for src/components/TaskItem.tsx. Here are the instructions:
Task: Create TaskItem.tsx React Component
Description
We need to create a new React component called
TaskItem.tsx
that will be responsible for displaying individual task items in our project tasks page. This component will be written in TypeScript using ES6 syntax, such as arrow functions, and will utilize Tailwind CSS for styling.Requirements
Create a new file named
TaskItem.tsx
inside thesrc/components
directory.Import the necessary dependencies at the top of the file:
Props
interface for this component, which should include atask
prop of typeProjectTask
:TaskItem
that accepts theProps
interface as its props:Inside the component, render the following elements:
div
container with the Tailwind CSS classesbg-white p-4 rounded-lg shadow-md
to style the task item.h3
element with the Tailwind CSS classestext-lg font-semibold mb-2
to display the task name. Use thetask.taskName
prop for the content.p
element with the Tailwind CSS classestext-gray-600
to display the task description. Use thetask.taskDescription
prop for the content.div
container with the Tailwind CSS classesmt-4 flex items-center
to hold the status indicator and the "Approved" label.span
element with the Tailwind CSS classesw-4 h-4 mr-2 rounded-full
and apply the classbg-green-500
if the task is approved (task.approved === true
) orbg-red-500
if not approved.span
element with the Tailwind CSS classestext-gray-600
to display the text "Approved" if the task is approved or "Not Approved" if not approved.Export the
TaskItem
component as the default export:Example Usage
Here's an example of how the
TaskItem
component will be used in the parent component:Testing
task.approved
prop.Please submit a pull request with your changes once you have completed the task. If you have any questions or need further clarification, feel free to ask.