Me learning react like an absolute chungus
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

57 satır
1.4KB

  1. import Task from "../types/Task";
  2. type KBColumnProps = {
  3. color?: string;
  4. title?: string;
  5. tasks: Task[];
  6. id: number;
  7. onDelete?: (id: number) => void;
  8. };
  9. const defaultProps: KBColumnProps = {
  10. color: "#404552",
  11. title: "waah",
  12. tasks: [],
  13. id: -1,
  14. onDelete: (id: number) => {},
  15. };
  16. let bgc = "#666";
  17. const KBColumn = (props: KBColumnProps) => {
  18. const { color, title, tasks, onDelete, id } = { ...defaultProps, ...props };
  19. let colTasks = tasks.map((task) => {
  20. if (task.priority === "urgent") {
  21. bgc = "red";
  22. } else if (task.priority === "important") {
  23. bgc = "yellow";
  24. } else if (task.priority === "normal") {
  25. bgc = "blue";
  26. }
  27. return (
  28. <div style={{borderColor: "#ccc", borderWidth: "1px", borderStyle: "solid", margin: "10px"}} className="taskWrapper">
  29. <div style={{width: "20px", height: "100%", backgroundColor: bgc, display: "inline"}} className="prioBlock"></div>
  30. <div className="taskText">
  31. <p> {task.title} </p>
  32. <p> {task.description} </p>
  33. </div>
  34. </div>
  35. );
  36. });
  37. return (
  38. <div className="KBColumn" style={{ backgroundColor: color }}>
  39. <h3>{title}</h3>
  40. {colTasks}
  41. <button
  42. onClick={() => {
  43. onDelete && onDelete(id);
  44. }}
  45. >
  46. Deleete
  47. </button>
  48. </div>
  49. );
  50. };
  51. export default KBColumn;