Git Product home page Git Product logo

task-traker's Introduction

Task Traker

πŸ‘‰ Click here to see on browser

tasktraker


What's used in this app ? How use third party libraries Author
useEfect() Hook Take a look at my portfolio
useState() Hook Visit me on Linkedin
LocalStorage
react-events
React-Conditional rendering
React-icons npm i / yarn add react-icons
props-drilling
Semantic-Commits
Deploy with Netlify

How To Run This Project πŸš€


πŸ’» Install React πŸ‘‡

yarn create react-app .  or npx create-react-app .

πŸ’» Install Sass πŸ‘‡

yarn add sass  or npm i sass

πŸ”΄ Delete these files and delete the importsπŸ‘‡

- App.test.js
- reportWebVitals.js
- setupTests.js
- favicon.ico
- logo192.png
- logo512.png
- manifest.json
- robots.txt

πŸ’» Start the project πŸ‘‡

yarn start or npm start

OR

  • Clone the Repo

    git clone
  • Install NPM packages

    npm install or yarn
  • Run the project

    npm start or yarn start
  • Open the project on your browser

    http://localhost:3000/
  • Enjoy! πŸŽ‰


Project Skeleton

 Task Traker (folder)
|
|----public (folder)
β”‚     └── index.html
|----src (folder)
|    |--- components (folder)
β”‚    β”‚       β”œβ”€β”€ AddTaskForm.jsx
β”‚    β”‚       β”œβ”€β”€ Header.jsx
β”‚    β”‚       β”œβ”€β”€ ShowTasks.jsx
β”‚    β”‚
|    |--- helpers (folder)
|    |       |── StartData.jsx
β”‚    β”‚
β”‚    |--- pages (folder)
|    |      β”œβ”€β”€ Home.jsx
|    |
β”‚    β”œ--- App.js
β”‚    β”‚--- App.css
β”‚    |--- index.js
β”‚
β”‚
|-- .gitignore
|── package-lock.json
β”œβ”€β”€ package.json
|── README.md
|── yarn.lock



At the end of the project, the following topics are to be covered;

  • useEffect() & useState() & LocalStorage & Conditional rendering
    import React from "react";
       import Header from "../components/Header";
       import ShowTasks from "../components/ShowTasks";
       import { useState, useEffect } from "react";
       // import data from '../helper/starterData';

       const Home = () => {
           const [tasks, setTasks] = useState(
               JSON.parse(localStorage.getItem("tasks")) || []
           );

           useEffect(() => {
               localStorage.setItem("tasks", JSON.stringify(tasks));
           }, [tasks]);

           // console.log(tasks);
           return (
               <div className="container">
                   <Header tasks={tasks} setTasks={setTasks} />
                   {tasks.length > 0 ? (
                       <ShowTasks tasks={tasks} setTasks={setTasks} />
                   ) : (
                       <p className="text-center">NO TASK TO SHOW</p>
                   )}
               </div>
               
           );
       };

       export default Home;
  • conditional rendering & toggle

        import AddTaskForm from "./AddTaskForm";
        import { useState } from "react";
    
        const Header = ({ tasks, setTasks }) => {
            const [show, setShow] = useState(false);
            const [btnStyle, setBtnStyle] = useState({
                name: "SHOW ADD TASK BAR",
                bgColor: "purple",
            });
    
            //! React, default olarak state'leri hemen degistirmeyebilir.
            //! Ekstra render'lari azaltmak icin state'leri toplu (batch) bir sekilde gunceller.
            //! Bir event handler icerisindeki ardasik state'ler event bitiminde toplu bir
            //! sekilde guncellenmis olur.State'lerin guncelenmesi gelis sirasina gorere yapilir.
            //! Ayni event icerisinde birbirine bagli state'leri kullanirken buna dikkat etmek gerkir.
    
            //? https://stackoverflow.com/questions/48563650/does-react-keep-the-order-for-state-updates
    
            const handleShow = () => {
                if (show) {
                    setBtnStyle({
                        name: "SHOW ADD TASK BAR",
                        bgColor: "purple",
                    });
                } else {
                    setBtnStyle({
                        name: "CLOSE ADD TASK BAR",
                        bgColor: "red",
                    });
                }
                setShow(!show);
            };
            // console.log(show);
    
            return (
                <header className="header">
                    <h1>TASK TRACKER</h1>
                    <button
                        onClick={handleShow}
                        className="btn"
                        style={{ backgroundColor: btnStyle.bgColor }}
                    >
                        {btnStyle.name}
                    </button>
                    {show && <AddTaskForm tasks={tasks} setTasks={setTasks} />}
                </header>
            );
        };
    
        export default Header;
  • with filter deleting

            import { FaTimesCircle } from "react-icons/fa";
    
            const ShowTasks = ({ tasks, setTasks }) => {
                console.log(tasks);
                const toggleDone = (id) => {
                    setTasks(
                        tasks.map((task) =>
                            task.id === id ? { ...task, isDone: !task.isDone } : task
                        )
                    );
                };
    
                const deleteTask = (id) => {
                    setTasks(tasks.filter((task) => task.id !== id));
                };
                return (
                    <div>
                        {tasks.map((task) => {
                            const { id, task: text, day, isDone } = task;
                            return (
                                <div
                                    key={id}
                                    className={`task ${isDone ? "done" : ""}`}
                                    onDoubleClick={() => toggleDone(id)}
                                >
                                    <h3>
                                        {text}
                                        <FaTimesCircle
                                            style={{ color: "red" }}
                                            onClick={() => deleteTask(id)}
                                        />
                                    </h3>
                                    <h6>{day}</h6>
                                </div>
                            );
                        })}
                    </div>
                );
            };
    
            export default ShowTasks;
  • Semantic Commit Messages See how a minor change to your commit message style can make you a better programmer.

    Format: ():

    is optional

    • Example
                feat: add hat wobble
        ^--^  ^------------^
        |     |
        |     +-> Summary in present tense.
        |
        +-------> Type: chore, docs, feat, fix, refactor, style, or test.
    
  • More Examples:

    • feat: (new feature for the user, not a new feature for build script)
    • fix: (bug fix for the user, not a fix to a build script)
    • docs: (changes to the documentation)
    • style: (formatting, missing semi colons, etc; no production code change)
    • refactor: (refactoring production code, eg. renaming a variable)
    • test: (adding missing tests, refactoring tests; no production code change)
    • chore: (updating grunt tasks etc; no production code change)

Feedback and Collaboration

I value your feedback and suggestions. If you have any comments, questions, or ideas for improvement regarding this project or any of my other projects, please don't hesitate to reach out. I'm always open to collaboration and welcome the opportunity to work on exciting projects together. Thank you for visiting my project. I hope you have a wonderful experience exploring it, and I look forward to connecting with you soon!

βŒ› Happy Coding ✍

task-traker's People

Contributors

kaplanh avatar

Stargazers

 avatar

Watchers

 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.