Axborot texnologiyalari va kommunikatsiyalarini rivojlantirish vazirligi muhammad al-xorazmiy nomidagi toshkent axborot texnologiyalari universiteti “Individual loyiha” ishi



Download 1,09 Mb.
bet10/12
Sana24.12.2022
Hajmi1,09 Mb.
#895767
1   ...   4   5   6   7   8   9   10   11   12
Bog'liq
Individual loyiha

{day.date.getDate()}



{selected ?
setTask({})}>+
: null}

)
}

export default Day;

Header.js dagi kodlar.
import React, { useContext } from "react";
import { CalendarContext } from "../context/CalendarContext";

function Header() {


const { date, setDate } = useContext(CalendarContext);
const monthNames = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
];

const addMonth = value => {


const tmp = new Date(date.setMonth(date.getMonth() + value));
setDate(tmp);
};

return (




{monthNames[date.getMonth()]} {date.getFullYear()}









);
}

export default Header;


Task.js dagi kodlar.


import React, { useContext } from 'react'
import { CalendarContext } from '../context/CalendarContext';

function Task({task, style}) {


const {setTask} = useContext(CalendarContext);


return (
{setTask(task)}}>{task.name}


)
}

export default Task


TaskForm.js dagi fayllar.


import React, { useContext, useEffect, useState } from "react";
import Modal from "react-modal";
import { CalendarContext } from "../context/CalendarContext";
import { CirclePicker } from "react-color";

const customStyles = {


content: {
top: "50%",
left: "50%",
right: "auto",
bottom: "auto",
marginRight: "-50%",
transform: "translate(-50%, -50%)"
}
};

function TaskForm() {


const { date, task, setTask, saveTask, setDate, deleteTask } = useContext(
CalendarContext
);

const [name, setName] = useState("");


const [color, setColor] = useState("#f44336");
const [error, setError] = useState(false);

useEffect(


() => {
if (task) {
setName(task.name || "");
setColor(task.color || "#f44336");
}
},
[task]
);

const closeModal = () => {


setTask(null);
setError(false);
};

const _saveTask = () => {


if (name.trim().length < 1) {
setError(true);
return;
}
setError(false);

saveTask({


...task,
date: date,
name: name,
color: color
});
setDate(date);
closeModal();
};

const _deleteTask = () => {


deleteTask(task.id);
setDate(date);
closeModal();
setError(false);
};

return (

isOpen={task != null}
onRequestClose={closeModal}
style={customStyles}
ariaHideApp={false}
contentLabel="Task Form"
>



name="name"
value={name}
onChange={e => setName(e.target.value)}
type="text"
placeholder="Task Name"
/>




color={color}
onChange={color => {
setColor(color.hex);
}}
/>





{task && task.id
?
: null}


{error
?
The name of the task is required
: null}


);
}

export default TaskForm;



Utils.js dagi filelar.
export function computeColor(color, f) {
const compute = (c, f) => Math.floor(Math.min(parseInt(c, 16) * f, 255)).toString(16).padStart(2, '0');
const b = compute(color.substring(color.length - 2, color.length - 0), f);
const g = compute(color.substring(color.length - 4, color.length - 2), f);
const r = compute(color.substring(color.length - 6, color.length - 4), f);
return `${(color.charAt(0) === '#') ? '#' : ''}${r}${g}${b}`;
}

export function contrast(color, threshold=0.5) {


const b = parseInt(color.substring(color.length - 2, color.length - 0), 16);


const g = parseInt(color.substring(color.length - 4, color.length - 2), 16);
const r = parseInt(color.substring(color.length - 6, color.length - 4), 16);

let luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;


let d = luminance > threshold ? '000000' : 'ffffff';
return `${(color.charAt(0) === '#') ? '#' : ''}${d}`;
}

Download 1,09 Mb.

Do'stlaringiz bilan baham:
1   ...   4   5   6   7   8   9   10   11   12




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish