From 67286f14bba16b941060e0e9e51233c2696d637d Mon Sep 17 00:00:00 2001 From: Sasan Salehzadeh Date: Thu, 15 Jun 2023 16:08:13 +0430 Subject: [PATCH] Create board js --- components/BoardsList.tsx | 50 +++-- components/CreateBoard.tsx | 90 +++++--- components/MobileBoards.tsx | 2 +- components/TaskColumn.tsx | 77 ++----- components/ToggleTheme.tsx | 22 +- components/UI/Modal.tsx | 28 ++- components/UI/Select.tsx | 29 ++- components/UI/TextInput.tsx | 32 ++- data/data.json | 430 ++++++++++++++++++++++++++++++++++++ icons/LogoDark.tsx | 16 -- layout/Sidebar.tsx | 15 +- layout/Tasks.tsx | 14 +- model/Board.tsx | 7 + model/BoardListProps.tsx | 7 + model/Subtask.tsx | 5 + model/Task.tsx | 9 + next.config.js | 2 +- package-lock.json | 33 ++- pages/index.tsx | 45 +++- styles/globals.css | 4 +- 20 files changed, 745 insertions(+), 172 deletions(-) create mode 100644 data/data.json delete mode 100644 icons/LogoDark.tsx create mode 100644 model/Board.tsx create mode 100644 model/BoardListProps.tsx create mode 100644 model/Subtask.tsx create mode 100644 model/Task.tsx diff --git a/components/BoardsList.tsx b/components/BoardsList.tsx index 91f1a89..ebb7f2b 100644 --- a/components/BoardsList.tsx +++ b/components/BoardsList.tsx @@ -1,29 +1,37 @@ import React from "react"; import BoardIcon from "@/icons/icon-board.svg"; -const BoardsList = () => { +import BoardListProps from "@/model/BoardListProps"; +const BoardsList: React.FC = ({ + boards, + activeBoard = 0, + onChangedaActiveBoard, + onAddNewBoard, +}) => { return (
-

all boards (3)

+

+ all boards ({boards.length}) +

    -
  • - - - -

    Platform Launch

    -
  • -
  • - - - -

    Marketing Plan

    -
  • -
  • - - - -

    Roadmap

    -
  • -
  • + {boards.map((board, i) => ( +
  • onChangedaActiveBoard(i)} + > + + + +

    {board.name}

    +
  • + ))} + +
  • diff --git a/components/CreateBoard.tsx b/components/CreateBoard.tsx index b8a9bc7..8244388 100644 --- a/components/CreateBoard.tsx +++ b/components/CreateBoard.tsx @@ -1,53 +1,77 @@ +import { useState } from "react"; import TextInput from "./UI/TextInput"; import CrossIcon from "@/icons/icon-cross.svg"; import Button from "./UI/Button"; -import Select from "./UI/Select"; + const CreateBoard = () => { + const [columns, setColumns] = useState(["", ""]); + const [name, setName] = useState(""); + + const handleDeleteColumn = (e: MouseEvent, index: number) => { + e.stopPropagation(); + const updatedColumns = [...columns]; + updatedColumns.splice(index, 1); + setColumns(updatedColumns); + }; + + const onChangedName = (e: React.FormEvent) => { + setName((e.target as HTMLInputElement).value); + }; + + const handleChangedColumn = ( + e: React.FormEvent, + index: number + ) => { + const updatedColumns = [...columns]; + updatedColumns[index] = (e.target as HTMLInputElement).value; + setColumns(updatedColumns); + }; + + const onCreateNewBoard = () => {}; return (
    -

    Add New Board

    - - -
    +

    Add New Board

    + +
    -
    - {}} - /> -
    - -
    -
    +
      + {columns.map((col, index) => ( +
    • + ) => + handleChangedColumn(e, index) + } + value={columns[index]} + /> +
      + handleDeleteColumn(e, index)} + /> +
      +
    • + ))} +
    +