mirror of
https://github.com/bubblecup-12/VogelSocialMedia.git
synced 2025-07-08 22:28:46 +00:00
change button functions
This commit is contained in:
parent
d0d879336e
commit
8136e95c6a
7 changed files with 88 additions and 33 deletions
|
@ -1,6 +1,7 @@
|
||||||
import "./App.css";
|
import "./App.css";
|
||||||
import "./styles/colors.css";
|
import "./styles/colors.css";
|
||||||
import "./styles/fonts.css";
|
import "./styles/fonts.css";
|
||||||
|
import "./styles/sizes.css";
|
||||||
import LoginAndSignUpPage from "./pages/LoginAndSignUpPage";
|
import LoginAndSignUpPage from "./pages/LoginAndSignUpPage";
|
||||||
import Footer from "./components/Footer";
|
import Footer from "./components/Footer";
|
||||||
import Header from "./components/header";
|
import Header from "./components/header";
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { Button } from "@mui/material";
|
|
||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import TextField from "@mui/material/TextField";
|
import TextField from "@mui/material/TextField";
|
||||||
import StyledEngineProvider from "@mui/styled-engine/StyledEngineProvider";
|
import StyledEngineProvider from "@mui/styled-engine/StyledEngineProvider";
|
||||||
|
@ -9,11 +8,20 @@ import IconButton from "@mui/material/IconButton";
|
||||||
import EditSquareIcon from "@mui/icons-material/EditSquare";
|
import EditSquareIcon from "@mui/icons-material/EditSquare";
|
||||||
import ButtonPrimary from "./ButtonRotkehlchen";
|
import ButtonPrimary from "./ButtonRotkehlchen";
|
||||||
|
|
||||||
export default function MultilineTextFields() {
|
export default function BioTextField({ ownAccount }: { ownAccount: boolean }) {
|
||||||
|
const [bio, setBio] = useState<string>("");
|
||||||
|
const [oldBio, setOldbio] = useState<string>("");
|
||||||
|
const [editMode, setEditable] = useState(false);
|
||||||
|
|
||||||
const toggleEditMode = () => {
|
const toggleEditMode = () => {
|
||||||
isEditable(!editMode);
|
!editMode && setOldbio(bio);
|
||||||
|
ownAccount && setEditable(!editMode);
|
||||||
|
};
|
||||||
|
|
||||||
|
const cancleBio = () => {
|
||||||
|
setBio(oldBio);
|
||||||
|
setEditable(false);
|
||||||
};
|
};
|
||||||
const [editMode, isEditable] = useState(false);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledEngineProvider injectFirst>
|
<StyledEngineProvider injectFirst>
|
||||||
|
@ -31,16 +39,35 @@ export default function MultilineTextFields() {
|
||||||
multiline
|
multiline
|
||||||
maxRows={4}
|
maxRows={4}
|
||||||
disabled={!editMode}
|
disabled={!editMode}
|
||||||
|
value={bio}
|
||||||
|
onChange={(e) => setBio(e.target.value)}
|
||||||
/>
|
/>
|
||||||
<IconButton aria-label="edit-bio">
|
{ownAccount && (
|
||||||
<EditSquareIcon
|
<IconButton aria-label="edit-bio">
|
||||||
className="edit-icon"
|
<EditSquareIcon
|
||||||
onClick={toggleEditMode}
|
className="edit-icon"
|
||||||
style={{ display: editMode ? "none" : "block" }}
|
onClick={toggleEditMode}
|
||||||
/>
|
style={{ display: editMode ? "none" : "block" }}
|
||||||
</IconButton>
|
/>
|
||||||
|
</IconButton>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
{editMode && <ButtonPrimary style="primary" label={"Ok"} onClick={toggleEditMode} />}
|
{ownAccount && editMode && (
|
||||||
|
<div>
|
||||||
|
<ButtonPrimary
|
||||||
|
style="primary"
|
||||||
|
label={"Save"}
|
||||||
|
type="submit"
|
||||||
|
onClick={toggleEditMode}
|
||||||
|
/>
|
||||||
|
<ButtonPrimary
|
||||||
|
style="secondary"
|
||||||
|
label={"Cancel"}
|
||||||
|
type="reset"
|
||||||
|
onClick={cancleBio}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
</StyledEngineProvider>
|
</StyledEngineProvider>
|
||||||
);
|
);
|
||||||
|
|
|
@ -3,15 +3,16 @@ import "./buttonRotkehlchen.css";
|
||||||
interface ButtonPrimaryProps {
|
interface ButtonPrimaryProps {
|
||||||
style: "primary" | "secondary";
|
style: "primary" | "secondary";
|
||||||
label: string;
|
label: string;
|
||||||
|
type: "button" | "submit" | "reset";
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ButtonPrimary({ style, label, onClick }: ButtonPrimaryProps) {
|
export default function ButtonPrimary({ style, label, type, onClick }: ButtonPrimaryProps) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{style === "primary" && (
|
{style === "primary" && (
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type={type}
|
||||||
className="button-primary body-m"
|
className="button-primary body-m"
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
>
|
>
|
||||||
|
|
|
@ -28,7 +28,13 @@ const BootstrapDialog = styled(Dialog)(({ theme }) => ({
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export default function CustomizedDialogs() {
|
export default function AvatarDialog({
|
||||||
|
ownAccount,
|
||||||
|
username,
|
||||||
|
}: {
|
||||||
|
ownAccount: boolean;
|
||||||
|
username: string;
|
||||||
|
}) {
|
||||||
const { openFilePicker, filesContent, loading } = useFilePicker({
|
const { openFilePicker, filesContent, loading } = useFilePicker({
|
||||||
accept: ".png, .jpg, .jpeg",
|
accept: ".png, .jpg, .jpeg",
|
||||||
multiple: false,
|
multiple: false,
|
||||||
|
@ -83,8 +89,10 @@ export default function CustomizedDialogs() {
|
||||||
className="small-title orange-text"
|
className="small-title orange-text"
|
||||||
sx={{ m: 1.5, p: 2 }}
|
sx={{ m: 1.5, p: 2 }}
|
||||||
id="change-profile-picture-dialog"
|
id="change-profile-picture-dialog"
|
||||||
>
|
> { ownAccount ?
|
||||||
Change Profile Picture
|
"Change Profile Picture" :
|
||||||
|
username
|
||||||
|
}
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
<IconButton
|
<IconButton
|
||||||
aria-label="close"
|
aria-label="close"
|
||||||
|
@ -125,20 +133,36 @@ export default function CustomizedDialogs() {
|
||||||
></img>
|
></img>
|
||||||
))}
|
))}
|
||||||
</Box>
|
</Box>
|
||||||
<div className="change-avatar-button">
|
{ownAccount && (
|
||||||
<IconButton
|
<div className="change-avatar-button">
|
||||||
aria-label="upload picture"
|
<IconButton
|
||||||
onClick={() => openFilePicker()}
|
aria-label="upload picture"
|
||||||
>
|
onClick={() => openFilePicker()}
|
||||||
<EditSquareIcon className="edit-icon" />
|
>
|
||||||
</IconButton>
|
<EditSquareIcon className="edit-icon" />
|
||||||
</div>
|
</IconButton>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<Divider variant="middle" className="divider" />
|
{ownAccount && (
|
||||||
<DialogActions>
|
<div>
|
||||||
<ButtonRotkehlchen style="primary" label="Save Changes" onClick={handleSaveChanges} />
|
<Divider variant="middle" className="divider" />
|
||||||
<ButtonRotkehlchen style="secondary" label="Cancel" onClick={handleClose} />
|
<DialogActions>
|
||||||
</DialogActions>
|
<ButtonRotkehlchen
|
||||||
|
style="primary"
|
||||||
|
label="Save Changes"
|
||||||
|
type="submit"
|
||||||
|
onClick={handleSaveChanges}
|
||||||
|
/>
|
||||||
|
<ButtonRotkehlchen
|
||||||
|
style="secondary"
|
||||||
|
label="Cancel"
|
||||||
|
type="reset"
|
||||||
|
onClick={handleClose}
|
||||||
|
/>
|
||||||
|
</DialogActions>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</BootstrapDialog>
|
</BootstrapDialog>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
width: 5rem;
|
width: 5rem;
|
||||||
height: 5rem;
|
height: 5rem;
|
||||||
margin: -0.1rem;
|
margin: -0.1rem;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media only screen and (min-width: 768px) {
|
@media only screen and (min-width: 768px) {
|
||||||
|
|
|
@ -135,7 +135,7 @@ function LoginAndSignUpPage({ signupProp }: { signupProp: boolean }) {
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<ButtonRotkehlchen style="primary" label={signup ? "Sign Up" : "Login"} />
|
<ButtonRotkehlchen style="primary" label={signup ? "Sign Up" : "Login"} type="submit"/>
|
||||||
<div className="login-signup body-m" onClick={toggleLogin}>
|
<div className="login-signup body-m" onClick={toggleLogin}>
|
||||||
{signup
|
{signup
|
||||||
? "Already have an account? "
|
? "Already have an account? "
|
||||||
|
|
|
@ -30,13 +30,14 @@ function Profile() {
|
||||||
const id = isPopoverOpen ? "simple-popover" : undefined;
|
const id = isPopoverOpen ? "simple-popover" : undefined;
|
||||||
|
|
||||||
const username = "Username12345678"; /* Get username from database */
|
const username = "Username12345678"; /* Get username from database */
|
||||||
|
const ownAccount = false;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledEngineProvider injectFirst>
|
<StyledEngineProvider injectFirst>
|
||||||
<div className="profile-display">
|
<div className="profile-display">
|
||||||
<div className="user-info">
|
<div className="user-info">
|
||||||
<div className="user">
|
<div className="user">
|
||||||
<ChangeAvatarDialog />
|
<ChangeAvatarDialog ownAccount={ownAccount} username={username} />
|
||||||
<Popover
|
<Popover
|
||||||
className="profile-popover"
|
className="profile-popover"
|
||||||
onClose={closePopover}
|
onClose={closePopover}
|
||||||
|
@ -58,7 +59,7 @@ function Profile() {
|
||||||
{username}
|
{username}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<Bio/>
|
<Bio ownAccount={ownAccount}/>
|
||||||
<Divider variant="middle" className="divider" />
|
<Divider variant="middle" className="divider" />
|
||||||
{/* TODO: Change data to data from Database */}
|
{/* TODO: Change data to data from Database */}
|
||||||
<div className="numeral-data">
|
<div className="numeral-data">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue