Giter VIP home page Giter VIP logo

csfs1010-lab-1's Introduction

Installation:

git clone https://github.com/markcrispo/CSFS1010-Lab-1
cd CSFS1010-Lab-1
npm i
npm run dev

CFS1010 Lab 1

You've been hired to code a To Do list app! We'll build it step-by-step.

Step 1

Create a component called ToDoItem that renders a checkbox and a text field. The component should track its state with the useState hook. This is an example of a common pattern - a controlled component!

The goal is to drive the inputs with state variables.

const [title, setTitle] = useState('');
const [isChecked, setIsChecked] = useState(false);

Hints:

  • You can use <input type="checkbox" /> and <input type="text" /> for the checkbox and textfield
  • Use the onChange prop to capture change events and call setTitle and setIsChecked

Step 2 - Save/Edit

Add a "Save" button beside the text field.

When the user clicks Save...

  • replace the text field with regular non-editable text
  • replace the Save button with an Edit button

When the user clicks Edit...

  • the Save button should reappear
  • the text should be editable again.
  • the Save button should be disabled when the text field is empty

Step 3 - Hover Effects!

A designer has taken a look at your progress so far, and they have some feedback:

When the text has been saved, the "Edit" button should only show up when the user is hovering over the task.

Hints:

Step 4 - Multiple To-Do list items

Underneath the To-Do list, add an "Add" button and a "Remove" button to add and remove tasks from the bottom of the To-do list.

Hints:

  • Add a useState to track the number of todos. Add and Remove should increment/decrement the count respectively.

Step 5 - Removing individual tasks

Next, we'll want to be able to remove specific tasks from the To-Do list. To accomplish this, we'll want to lift state

In ToDoItem:

  • Add a "Remove" button, and a handleRemove prop
  • convert the useState hooks for the checkbox and text field to props

In App.jsx:

  • Add const [todos, setTodos] = useState([{ title: 'Get groceries', isChecked: false }])
  • Map the todos state to the <ToDoItem /> component
  • Implement functions setIsChecked and setTitle for a to-do item at a particular index

Once we're done with that refactor, we can implement the remove button:

In ToDoItem:

  • Add a "Remove" button, and a handleRemove prop

In App.jsx:

  • Implement handleRemove for a to-do item at a particular index

csfs1010-lab-1's People

Contributors

markcrispo avatar mccooll avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.