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

feat: account menu #1021

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 6 additions & 1 deletion apps/antalmanac/src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import LoadSaveScheduleFunctionality from './LoadSaveFunctionality';
import { Logo } from './Logo';
import AppDrawer from './SettingsMenu';

import { AccountMenu } from '$components/Header/account/AccountMenu';

const styles = {
appBar: {
marginBottom: '4px',
Expand Down Expand Up @@ -40,9 +42,12 @@ const Header = ({ classes }: CustomAppBarProps) => {
<Toolbar variant="dense" style={{ padding: '5px', display: 'flex', justifyContent: 'space-between' }}>
<Logo />

<div style={{ display: 'flex', flexDirection: 'row' }}>
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
<LoadSaveScheduleFunctionality />
<Import key="studylist" />

<AccountMenu />

<AppDrawer key="settings" />
</div>
</Toolbar>
Expand Down
92 changes: 92 additions & 0 deletions apps/antalmanac/src/components/Header/account/AccountMenu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { Box, Button, Popover, Typography } from '@mui/material';
import { useState } from 'react';

import { ChangeVisibility } from '$components/Header/account/ChangeVisibility';

export function AccountMenu() {
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);

const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
setAnchorEl(event.currentTarget);
};

const handleClose = () => {
setAnchorEl(null);
};

return (
<div>
<Button
onClick={handleClick}
sx={{
backgroundColor: 'green',
borderRadius: '100%',
width: 24,
height: 24,
minWidth: 24,
paddingX: 1,
}}
/>

<Popover
open={Boolean(anchorEl)}
anchorEl={anchorEl}
onClose={handleClose}
anchorOrigin={{
vertical: 'bottom',
horizontal: 'right',
}}
transformOrigin={{
vertical: 'top',
horizontal: 'right',
}}
>
<Box
sx={{
display: 'flex',
flexDirection: 'column',
gap: 2,
padding: 2,
backgroundColor: 'background.paper',
}}
>
<Box
sx={{
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
gap: 1,
minWidth: 300,
}}
>
<Box
sx={{
backgroundColor: 'green',
borderRadius: '100%',
width: 32,
height: 32,
}}
/>
<Box sx={{ display: 'flex', flexDirection: 'column' }}>
<Typography sx={{ fontWeight: 600 }}>Peter Anteater</Typography>
<Typography sx={{ opacity: '50%' }}>[email protected]</Typography>
</Box>
</Box>
<Box sx={{ display: 'flex', justifyContent: 'space-between', gap: 1 }}>
<Button sx={{ width: '50%' }} variant="contained">
Manage Friends
</Button>

<ChangeVisibility />
</Box>

<Box sx={{ marginLeft: 'auto' }}>
<Button variant="text">
<Typography>Log Out</Typography>
</Button>
</Box>
</Box>
</Popover>
</div>
);
}
59 changes: 59 additions & 0 deletions apps/antalmanac/src/components/Header/account/ChangeVisibility.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import {
Box,
Alert,
Button,
Dialog,
DialogActions,
DialogContent,
DialogTitle,
FormControl,
FormControlLabel,
FormLabel,
Radio,
RadioGroup,
Typography,
} from '@mui/material';
import { useState } from 'react';

export function ChangeVisibility() {
const [open, setOpen] = useState(false);

const handleOpen = () => {
setOpen(true);
};

const handleClose = () => {
setOpen(false);
};

return (
<Box sx={{ width: '50%' }}>
<Button sx={{ width: '100%' }} variant="contained" onClick={handleOpen}>
Change Visibility
</Button>

<Dialog open={open} onClose={handleClose} maxWidth={'lg'}>
<DialogTitle>Change Account Visibility</DialogTitle>

<DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
<Alert severity="warning">
<Typography>Changing account visibility allows other users to view your schedules.</Typography>
</Alert>

<FormControl>
<FormLabel>Visibility</FormLabel>
<RadioGroup row defaultValue={'private'}>
<FormControlLabel value="private" control={<Radio />} label="Private" />
<FormControlLabel value="shared" control={<Radio />} label="Shared" />
<FormControlLabel value="public" control={<Radio />} label="Public" />
</RadioGroup>
</FormControl>
</DialogContent>

<DialogActions>
<Button onClick={handleClose}>Close</Button>
</DialogActions>
</Dialog>
</Box>
);
}
Loading