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

refactor: adjust footer positioning for better alignment #162

Merged
merged 3 commits into from
Oct 25, 2024
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
10 changes: 5 additions & 5 deletions src/components/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,27 @@ function App() {
<div style={containerStyle}>
<a href="https://github.com/DhanushNehru" target="_blank" rel="noopener noreferrer" style={{ textDecoration: "none" }}>
<IconButton text="DhanushNehru">
<FaGithub size={30} style={iconStyle} />
<FaGithub size={15} style={iconStyle} />
</IconButton>
</a>
<a href="https://www.linkedin.com/in/dhanushnehru/" target="_blank" rel="noopener noreferrer" style={{ textDecoration: "none" }}>
<IconButton text="dhanushnehru" color="#316FF6">
<FaLinkedin size={30} style={iconStyle} />
<FaLinkedin size={15} style={iconStyle} />
</IconButton>
</a>
<a href="https://www.instagram.com/dhanush_nehru/" target="_blank" rel="noopener noreferrer" style={{ textDecoration: "none" }}>
<IconButton text="dhanush_nehru" color="#d62976">
<GrInstagram size={30} style={iconStyle} />
<GrInstagram size={15} style={iconStyle} />
</IconButton>
</a>
<a href="https://x.com/Dhanush_Nehru" target="_blank" rel="noopener noreferrer" style={{ textDecoration: "none" }}>
<IconButton text="Dhanush_Nehru" color="black">
<FaXTwitter size={30} style={iconStyle} />
<FaXTwitter size={15} style={iconStyle} />
</IconButton>
</a>
<a href="https://www.youtube.com/@dhanushnehru" target="_blank" rel="noopener noreferrer" style={{ textDecoration: "none" }}>
<IconButton text="@dhanushnehru" color="#FF0000">
<IoLogoYoutube size={30} style={iconStyle} />
<IoLogoYoutube size={15} style={iconStyle} />
</IconButton>
</a>
</div>
Expand Down
7 changes: 6 additions & 1 deletion src/components/css/EditorComponent.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
width: 100%;
height: 50vh;
}
.flex-container {
.flex-container {
flex-direction: row;
justify-content: space-between;
gap: 0.6em;
Expand Down Expand Up @@ -111,3 +111,8 @@
color: #fff;
}
}

.footer {
margin-bottom: 12px;
margin-top: -8px;
}
103 changes: 60 additions & 43 deletions src/pages/EditorComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const StyledLayout = styled("div")(({ theme }) => ({
const OutputLayout = styled("div")(({ theme }) => ({
backgroundColor: theme.palette.background.paper,
height: "50vh",
margin: "2rem 0",
margin: "1rem 0",
border: `2px solid ${theme.palette.divider}`,
borderRadius: "1rem",
"@media (min-width: 1024px)": {
Expand Down Expand Up @@ -142,20 +142,23 @@ function EditorComponent() {
setLoading(true);
try {
const encodedCode = btoa(codeToSubmit);
const response = await fetch(`${judge0SubmitUrl}?base64_encoded=true&wait=false&fields=*`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-RapidAPI-Key": rapidApiKey,
"X-RapidAPI-Host": rapidApiHost,
},
body: JSON.stringify({
source_code: encodedCode,
language_id: languageDetails.ID,
stdin: "",
expected_output: "",
}),
});
const response = await fetch(
`${judge0SubmitUrl}?base64_encoded=true&wait=false&fields=*`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
"X-RapidAPI-Key": rapidApiKey,
"X-RapidAPI-Host": rapidApiHost,
},
body: JSON.stringify({
source_code: encodedCode,
language_id: languageDetails.ID,
stdin: "",
expected_output: "",
}),
}
);

if (!response.ok) {
enqueueSnackbar(
Expand All @@ -169,13 +172,16 @@ function EditorComponent() {
const submissionId = data["token"];

setTimeout(() => {
fetch(`${judge0SubmitUrl}/${submissionId}?base64_encoded=true&fields=*`, {
method: "GET",
headers: {
"X-RapidAPI-Key": rapidApiKey,
"X-RapidAPI-Host": rapidApiHost,
},
})
fetch(
`${judge0SubmitUrl}/${submissionId}?base64_encoded=true&fields=*`,
{
method: "GET",
headers: {
"X-RapidAPI-Key": rapidApiKey,
"X-RapidAPI-Host": rapidApiHost,
},
}
)
.then((response) => response.json())
.then((data) => {
if (!data.stdout) {
Expand All @@ -199,15 +205,18 @@ function EditorComponent() {
}
}, [enqueueSnackbar, languageDetails]);

const handleEditorDidMount = useCallback((editor, monaco) => {
console.log("Editor mounted"); // Debug log
editorRef.current = editor;
monacoRef.current = monaco;
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter, () => {
console.log("Ctrl+Enter pressed in editor");
submitCode();
});
}, [submitCode]);
const handleEditorDidMount = useCallback(
(editor, monaco) => {
console.log("Editor mounted"); // Debug log
editorRef.current = editor;
monacoRef.current = monaco;
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter, () => {
console.log("Ctrl+Enter pressed in editor");
submitCode();
});
},
[submitCode]
);

useEffect(() => {
const handleKeyDown = (event) => {
Expand Down Expand Up @@ -259,7 +268,10 @@ function EditorComponent() {
language={languageDetails.DEFAULT_LANGUAGE}
options={{ minimap: { enabled: false } }}
/>
<div className="sidebar" style={{ display: "flex", flexDirection: "column" }}>
<div
className="sidebar"
style={{ display: "flex", flexDirection: "column" }}
>
{getLanguageLogoById(languageDetails.ID)}
<div style={{ fontWeight: "bold" }}>
{languageDetails.LANGUAGE_NAME}
Expand Down Expand Up @@ -306,10 +318,7 @@ function EditorComponent() {
</StyledLayout>
<OutputLayout>
{Array.isArray(output) &&
output.map((result, i) => (
<div key={i}>{result}</div>
))}
<Footer />
output.map((result, i) => <div key={i}>{result}</div>)}
</OutputLayout>
</>
);
Expand All @@ -326,8 +335,8 @@ function EditorComponent() {
>
<h2>Please sign in to use the Code Editor</h2>
<GoogleSignIn />
<br/>
<GithubSignIn/>
<br />
<GithubSignIn />
</div>
);

Expand Down Expand Up @@ -364,14 +373,16 @@ function EditorComponent() {
fontSize: "1.5em",
}}
>
Custom Code Editor
Custom Code Editor
</span>
</div>
<div className="flex-container">
<div className="flex items-center space-x-2">
{currentUser ? (
<>
<WelcomeText>Welcome, {currentUser.displayName}</WelcomeText>
<WelcomeText>
Welcome, {currentUser.displayName}
</WelcomeText>
<Avatar
src={currentUser.photoURL}
alt={currentUser.displayName}
Expand All @@ -383,15 +394,18 @@ function EditorComponent() {
}}
/>
<div className="signout-container">
<button onClick={handleSignOut} className="signout-button">
<button
onClick={handleSignOut}
className="signout-button"
>
<span>Logout</span>
</button>
</div>
</>
) : (
<>
<GoogleSignIn />
<GithubSignIn/>
<GithubSignIn />
</>
)}
</div>
Expand All @@ -403,8 +417,11 @@ function EditorComponent() {
{currentUser
? renderAuthenticatedContent()
: renderUnauthenticatedContent()}
<div className="footer">
<Footer />
</div>
</div>
);
}

export default EditorComponent;
export default EditorComponent;