Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add style #6

Merged
merged 3 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
.env
.env
.build
2 changes: 2 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.tailwindcss.com?plugins=forms,typography"></script>
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Expand Down
22 changes: 22 additions & 0 deletions src/Components/CodeActions/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const CodeActions = ({ runEditorCode, refactorCode, isLoading }) => {
return (
<div className="flex md:space-x-2 w-full md:w-1/2 justify-between md:justify-end">
<button
className="border border-gray-200 bg-gray-200 text-gray-700 rounded-md px-4 py-2 md:m-2 mt-2 transition duration-500 ease select-none hover:bg-gray-300 focus:outline-none focus:shadow-outline"
onClick={runEditorCode}
disabled={isLoading}
>
Run Code
</button>
<button
className="border border-gray-200 bg-gray-200 text-gray-700 rounded-md px-4 py-2 md:m-2 mt-2 transition duration-500 ease select-none hover:bg-gray-300 focus:outline-none focus:shadow-outline"
onClick={refactorCode}
disabled={isLoading}
>
Refactor Code
</button>
</div>
);
};

export default CodeActions;
11 changes: 8 additions & 3 deletions src/Components/CustomInput/Header.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
const CustomInputHeader = ({ clearInput }) => {
return (
<div className="flex justify-between items-center">
<label className="mb-2">Custom Input</label>
<input type="button" value="Clear Input" onClick={clearInput} />
<div className="flex justify-between items-center border-grey-700 border-b-2">
<h1 className="uppercase p-0">Custom Input</h1>
<button
className="border border-gray-200 bg-red-200 text-red-700 rounded-md px-4 py-2 m-2 transition duration-500 ease select-none hover:bg-red-300 focus:outline-none focus:shadow-outline"
onClick={clearInput}
>
Clear Input
</button>
</div>
);
};
Expand Down
9 changes: 8 additions & 1 deletion src/Components/CustomInput/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
const CustomInput = ({ input, setInput }) => {
return <textarea value={input} onChange={setInput} className="mt-2" />;
return (
<textarea
value={input}
onChange={setInput}
className="block px-1 w-full text-sm bg-gray-800 text-white border focus:ring-0 border-gray-400 mt-2"
rows={5}
/>
);
};

export default CustomInput;
2 changes: 1 addition & 1 deletion src/Components/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import github from "../Images/github-mark.png";

const Header = () => {
return (
<div className="flex justify-between items-center p-4">
<div className="flex justify-between items-center p-4 border-b-2 border-grey-2 h-20">
<img src={codeboost} />
<a href="https://github.com/abhirampai/codeboost" target="_blank" referrerPolicy="no-referrer">
<img src={github} className="w-9 h-9 cursor-pointer"/>
Expand Down
20 changes: 9 additions & 11 deletions src/Components/LanguageSelector/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ import { LANGUAGE_OPTIONS } from "./constants";

const LanguageSelector = ({ selectedLanguage, setSelectedLanguage }) => {
return (
<div className="flex">
<Select
isSearchable
name="language"
placeholder="Select a Language"
className="w-full"
value={selectedLanguage}
options={LANGUAGE_OPTIONS}
onChange={(selectedOption) => setSelectedLanguage(selectedOption)}
/>
</div>
<Select
isSearchable
name="language"
placeholder="Select a Language"
className="w-full"
value={selectedLanguage}
options={LANGUAGE_OPTIONS}
onChange={(selectedOption) => setSelectedLanguage(selectedOption)}
/>
);
};

Expand Down
47 changes: 24 additions & 23 deletions src/Components/Main.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from "react";
import { useEffect, useRef, useState } from "react";

import { assoc } from "ramda";

Expand All @@ -17,8 +17,11 @@ import CustomInputHeader from "./CustomInput/Header";
import OutputTerminalHeader from "./OutputTerminal/Header";
import { useCreateCompletionApi } from "../Hooks/useRefactorApi";
import Header from "./Header";
import CodeActions from "./CodeActions";

const Main = () => {
const outputRef = useRef(null);

const [selectedLanguage, setSelectedLanguage] = useState(LANGUAGE_OPTIONS[0]);
const [value, setValue] = useState(selectedLanguage?.stub);
const [input, setInput] = useState();
Expand All @@ -33,6 +36,12 @@ const Main = () => {
setValue(selectedLanguage?.stub);
}, [selectedLanguage]);

useEffect(() => {
if (output?.data) {
outputRef.current.scrollIntoView({ behavior: "smooth" });
}
}, [output]);

const clearInput = () => {
setInput("");
};
Expand Down Expand Up @@ -93,12 +102,19 @@ const Main = () => {
};

return (
<div className="flex flex-col w-full">
<div className="flex flex-col p-4">
<Header />
<LanguageSelector
selectedLanguage={selectedLanguage}
setSelectedLanguage={setSelectedLanguage}
/>
<div className="md:flex md:w-full mt-4 justify-between items-center">
<LanguageSelector
selectedLanguage={selectedLanguage}
setSelectedLanguage={setSelectedLanguage}
/>
<CodeActions
refactorCode={refactorCode}
runEditorCode={runEditorCode}
isLoading={isLoading}
/>
</div>
<div className="editor-height mt-5">
<CodeEditor
selectedLanguage={selectedLanguage?.title.toLowerCase()}
Expand All @@ -108,33 +124,18 @@ const Main = () => {
runCode={runEditorCode}
/>
</div>
<div className="flex mt-5 justify-end">
<input
value="Run Code"
type="button"
onClick={runEditorCode}
disabled={isLoading}
/>
<input
value="Refactor Code"
type="button"
className="ml-2"
onClick={refactorCode}
disabled={isLoading}
/>
</div>
<div className="flex flex-col mt-5">
<CustomInputHeader clearInput={clearInput} />
<CustomInput input={input} setInput={handleCustomInputChange} />
</div>
{output.data && (
<>
<div className="flex flex-col mt-5">
<div className="flex flex-col py-4">
<OutputTerminalHeader
status={output?.status}
clearOutput={clearOutput}
/>
<OutputTerminal output={output?.data} />
<OutputTerminal output={output?.data} outputRef={outputRef} />
</div>
</>
)}
Expand Down
11 changes: 8 additions & 3 deletions src/Components/OutputTerminal/Header.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
const OutputTerminalHeader = ({ status, clearOutput }) => {
return (
<div className="flex justify-between">
<label className="mb-2">Output ({status})</label>
<input value="Clear Ouput" type="button" onClick={clearOutput} />
<div className="flex justify-between items-center border-grey-700 border-b-2">
<h1 className="uppercase p-0">Output ({status})</h1>
<button
onClick={clearOutput}
className="border border-gray-200 bg-red-200 text-red-700 rounded-md px-4 py-2 m-2 transition duration-500 ease select-none hover:bg-red-300 focus:outline-none focus:shadow-outline"
>
Clear Output
</button>
</div>
);
};
Expand Down
9 changes: 6 additions & 3 deletions src/Components/OutputTerminal/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const OutputTerminal = ({ output }) => {
const OutputTerminal = ({ output, outputRef }) => {
return (
<div className="output-terminal-bg output-terminal-height overflow-auto flex flex-col mt-2">
<pre className="padding-top-left-1 text-white">{output}</pre>
<div
ref={outputRef}
className="block px-1 w-full h-36 text-sm bg-gray-800 text-white border focus:ring-0 border-gray-400 mt-2"
>
{output}
</div>
);
};
Expand Down
60 changes: 0 additions & 60 deletions src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,6 @@
height: calc(80vh - 165px);
}

.flex {
display: flex;
}

.w-full {
width: 100%;
}

.flex-col {
flex-direction: column;
}

.mt-5 {
margin-top: 1.25rem;
}

.justify-end {
justify-content: flex-end;
}

.output-terminal-bg {
background-color: #303841;
}
Expand All @@ -35,46 +15,6 @@
height: 10vh;
}

.overflow-auto {
overflow: auto;
}

.padding-top-left-1 {
padding: 1rem 0rem 0rem 1rem;
}

.text-white {
color: white;
}

.mt-2 {
margin-top: 0.5rem;
}

.justify-between {
justify-content: space-between;
}

.items-center {
align-items: center;
}

.ml-2 {
margin-left: 0.5rem;
}

.w-9 {
width: 2.25rem;
}

.h-9 {
height: 2.25rem;
}

.p-4 {
padding: 1rem;
}

.cursor-pointer {
cursor: pointer;
}