diff --git a/src/components/sidebarcom.jsx b/src/components/sidebarcom.jsx index b1024d1..419f325 100644 --- a/src/components/sidebarcom.jsx +++ b/src/components/sidebarcom.jsx @@ -1,133 +1,185 @@ -import React, { useState } from "react"; -import { FaBeer,FaPython } from 'react-icons/fa'; -import {DiCode, DiJavascript1,DiRust} from 'react-icons/di'; -import {GiBrokenHeart} from 'react-icons/gi'; -import {AiOutlineFileText,AiFillHeart} from 'react-icons/ai'; -import {SiCsharp} from 'react-icons/si'; -import CodeMirror from '@uiw/react-codemirror'; -import {okaidia} from '@uiw/codemirror-theme-okaidia'; -import {sublime} from '@uiw/codemirror-theme-sublime'; -import FileSaver, { saveAs } from 'file-saver'; +import React, { useEffect, useState } from "react"; +import { FaBeer, FaPython } from "react-icons/fa"; +import { DiCode, DiJavascript1, DiRust } from "react-icons/di"; +import { GiBrokenHeart } from "react-icons/gi"; +import { AiOutlineFileText, AiFillHeart } from "react-icons/ai"; +import { SiCsharp } from "react-icons/si"; +import CodeMirror from "@uiw/react-codemirror"; +import { okaidia } from "@uiw/codemirror-theme-okaidia"; +import { sublime } from "@uiw/codemirror-theme-sublime"; +import FileSaver, { saveAs } from "file-saver"; // const writeFileP = require("write-file-p"); function Sidebar(props) { - const { tabCount } = props; - const {clickblob,changestateblob} = props; - const {textingchan,settextingchan} = props; - let ouputext = ''; - const [textin,setextin] = useState(""); - const texting = document.querySelector('#textinput'); + const { + tabCount, + themestate, + clickblob, + changestateblob, + textingchan, + settextingchan, + } = props; -const [iconstate,seticonstate] = useState(); -const {themestate} = props; -console.log(themestate); -const themefunc = () =>{ - if(themestate === "okaidia"){ - console.log("true"); - return okaidia - } - else if (themestate === "sublime"){ - return sublime + // let ouputext = ""; + const [textin, setextin] = useState(""); + // const texting = document.querySelector("#textinput"); + + const [iconstate, seticonstate] = useState( + + ); + const [theme, setTheme] = useState(() => { + if (themestate === "okaidia") { + return okaidia; + } else if (themestate === "sublime") { + return sublime; } -} + return ""; + }); -let counter = 0; -const [compo, setCompo] = useState( {{setextin(textin + editor)}}} />); -let arrary = [{counter:{key1:iconstate,key2:compo}}] + console.log(themestate); + useEffect(() => { + setTheme(() => { + if (themestate === "okaidia") { + console.log("true"); + return okaidia; + } else if (themestate === "sublime") { + return sublime; + } + return ""; + }); + }, [themestate]); + // const themefunc = () =>{ + // if(themestate === "okaidia"){ + // console.log("true"); + // return okaidia + // } + // else if (themestate === "sublime"){ + // return sublime + // } + // } -if(clickblob == true){ - var blob = new Blob([textin], {type: "text/plain;charset=utf-8"}); + // let counter = 0; + // const [compo, setCompo] = useState( + // { + // { + // setextin(textin + editor); + // } + // }} + // /> + // ); + // let arrary = [{ counter: { key1: iconstate, key2: compo } }]; + + if (clickblob === true) { + var blob = new Blob([textin], { type: "text/plain;charset=utf-8" }); FileSaver.saveAs(blob, "hello world.txt"); changestateblob(false); -} -// const onChange = () => { -// settextingchan(textingchan + textin); -// } -// console.log("Chaning the text...") -// console.log(textingchan); + } + // const onChange = () => { + // settextingchan(textingchan + textin); + // } + // console.log("Chaning the text...") + // console.log(textingchan); + // writeFileP(`output.txt`, textin, (err, data) => { + // console.log(err || data)}); + // const [compo , setCompo] = useState(); -// writeFileP(`output.txt`, textin, (err, data) => { -// console.log(err || data)}); -// const [compo , setCompo] = useState(); + // let varible; -let varible; - -const changingfunc = (e) => { + const changingfunc = (e) => { const value = e.target.value; //console.log(value); let array = value.split("."); console.log(array[1]); - if(array[1] == "txt"){ - seticonstate() - } - else if(array[1] === "py" || array[1] === "python"){ - seticonstate() + if (array[1] === "txt") { + seticonstate( + + ); + } else if (array[1] === "py" || array[1] === "python") { + seticonstate( + + ); + } else if (array[1] === "js" || array[1] === "javascript") { + seticonstate( + + ); + } else if (array[1] === undefined) { + seticonstate( + + ); + } else if (array[1] === "rs" || array[1] === "rust") { + seticonstate( + + ); + } else if (array[1] === "c#") { + seticonstate( + + ); + } else { + seticonstate( + + ); } - else if(array[1] === "js" || array[1] === "javascript"){ - seticonstate() - } - else if (array[1] === undefined ){ - seticonstate() - } - else if (array[1] === "rs" || array[1] === "rust"){ - seticonstate() - } - else if ( array[1] === "c#"){ - seticonstate() - } - else{ - seticonstate() - } - -} - + }; - - return ( - + ); } -export default Sidebar; \ No newline at end of file +export default Sidebar;