- Create a form component
- Render the form component
-
Add the following CSS style to to set the width of the form.
form { min-width: 300px; }
-
Create the file
src\projects\ProjectForm.js
. -
Implement a
ProjectForm
class component that meets the following specifications:-
Paste the HTML below into the render method of the
ProjectForm
and use your editor and the link below to identify the changes needed to theHTML
to make itJSX
.We will pass the
project
object as aprop
in a later lab so you just need to render theHTML
from the previous step asJSX
.<form class="input-group vertical"> <label for="name">Project Name</label> <input type="text" name="name" placeholder="enter name" /> <label for="description">Project Description</label> <textarea name="description" placeholder="enter description"></textarea> <label for="budget">Project Budget</label> <input type="number" name="budget" placeholder="enter budget" /> <label for="isActive">Active?</label> <input type="checkbox" name="isActive" /> <div class="input-group"> <button class="primary bordered medium">Save</button> <span></span> <button type="button" class="bordered medium">cancel</button> </div> </form>
import React from 'react'; function ProjectForm() { return ( <form className="input-group vertical"> <label htmlFor="name">Project Name</label> <input type="text" name="name" placeholder="enter name" /> <label htmlFor="description">Project Description</label> <textarea name="description" placeholder="enter description" /> <label htmlFor="budget">Project Budget</label> <input type="number" name="budget" placeholder="enter budget" /> <label htmlFor="isActive">Active?</label> <input type="checkbox" name="isActive" /> <div className="input-group"> <button className="primary bordered medium">Save</button> <span /> <button type="button" className="bordered medium"> cancel </button> </div> </form> ); } export default ProjectForm;
-
-
Open the file
src\projects\ProjectList.js
. -
Render the
ProjectForm
component below theProjectCard
.... + import ProjectForm from './ProjectForm'; ... function ProjectList ({ projects }) { const items = projects.map(project => ( <div key={project.id} className="cols-sm"> <ProjectCard project={project}></ProjectCard> + <ProjectForm /> </div> )); return <div className="row">{items}</div>; } ...
-
Verify a form renders under each card in the application. Note, you may need to reload the application a few times to see the changes on this step.