Skip to content

Commit

Permalink
fix: welcome text, button visibility in light/dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
JeevaRamanathan committed Oct 7, 2024
1 parent 7f23426 commit 2011149
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 64 deletions.
24 changes: 19 additions & 5 deletions src/components/GoogleSignIn.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from "react";
import "../components/css/GoogleSignIn.css";
import { Button } from "@mui/material";
import { useAuth } from "../context/AuthContext.js";

const GoogleSignIn = () => {
Expand All @@ -22,16 +22,30 @@ const GoogleSignIn = () => {
};

return loading ? null : (
<button onClick={handleSignIn} className="sign-in-button">
<Button
variant="outlined"
onClick={handleSignIn}
sx={[
(theme) => ({
marginLeft: "5px",
bgcolor: theme.palette.text.primary,
color: theme.palette.background.default,
border: "1px solid #E2E8F0",
fontSize: "0.8em",
cursor: "pointer",
boxShadow: "0 4px 6px rgba(0, 0, 0, 0.1)",
}),
]}
>
<img
className="google-logo"
style={{ height: "25px", width: "25px", paddingRight: "6px" }}
src="https://www.svgrepo.com/show/475656/google-color.svg"
loading="lazy"
alt="google logo"
/>
<span>Login with Google</span>
</button>

<span> Login with Google</span>
</Button>
);
};

Expand Down
40 changes: 0 additions & 40 deletions src/components/css/GoogleSignIn.css

This file was deleted.

50 changes: 31 additions & 19 deletions src/pages/EditorComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ const OutputLayout = styled("div")(({ theme }) => ({
borderRadius: "1rem",
}));

const WelcomeText = styled("span")(({ theme }) => ({
color: theme.palette.text.primary,
fontWeight: "bold",
}));

function EditorComponent() {
const [code, setCode] = useState(null);
const [output, setOutput] = useState([]);
Expand Down Expand Up @@ -200,18 +205,16 @@ function EditorComponent() {
function handleLanguageChange(_, value) {
setCurrentLanguage(value.DEFAULT_LANGUAGE);
setOutput("");
setCode(
code ? code : value.HELLO_WORLD
);
setCode(code ? code : value.HELLO_WORLD);
}

const handleSignOut = async () => {
try {
await logOut();
} catch (error) {
console.log(error);
}
};
try {
await logOut();
} catch (error) {
console.log(error);
}
};

const renderAuthenticatedContent = () => (
<>
Expand Down Expand Up @@ -278,13 +281,15 @@ function EditorComponent() {
);

const renderUnauthenticatedContent = () => (
<div style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
height: "50vh",
flexDirection: "column"
}}>
<div
style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
height: "50vh",
flexDirection: "column",
}}
>
<h2>Please sign in to use the Code Editor</h2>
<GoogleSignIn />
</div>
Expand Down Expand Up @@ -330,11 +335,16 @@ function EditorComponent() {
<div className="flex items-center space-x-2">
{currentUser ? (
<>
<span className="welcome-text">Welcome, {currentUser.displayName}</span>
<WelcomeText>Welcome, {currentUser.displayName}</WelcomeText>
<Avatar
src={currentUser.photoURL}
alt={currentUser.displayName}
sx={{ width: 32, height: 32, marginLeft: "0.5rem", marginRight: "0.5rem" }}
sx={{
width: 32,
height: 32,
marginLeft: "0.5rem",
marginRight: "0.5rem",
}}
/>
<div className="signout-container">
<button onClick={handleSignOut} className="signout-button">
Expand All @@ -351,7 +361,9 @@ function EditorComponent() {
</div>
</div>
</Box>
{currentUser ? renderAuthenticatedContent() : renderUnauthenticatedContent()}
{currentUser
? renderAuthenticatedContent()
: renderUnauthenticatedContent()}
</div>
);
}
Expand Down

0 comments on commit 2011149

Please sign in to comment.