mirror of
https://github.com/coder/coder.git
synced 2026-11-07 12:34:23 +08:00
#37 implemented the Sign-_in_ flow, but there wasn't a Sign-_out_ flow as part of that PR (aside from letting the cookie expire... or manually deleting the cookie...), which is obviously not ideal. This PR implements a basic sign-out flow, along with a very simple user dropdown:  Bringing in a few pruned down components for the `<UserDropdown />` to integrate into the `<NavBar />`. In addition, this also implements a simple back-end API for `/logout` which just clears the session token.
32 lines
876 B
TypeScript
32 lines
876 B
TypeScript
import Popover, { PopoverProps } from "@material-ui/core/Popover"
|
|
import { fade, makeStyles } from "@material-ui/core/styles"
|
|
import React from "react"
|
|
|
|
type BorderedMenuVariant = "manage-dropdown" | "user-dropdown"
|
|
|
|
type BorderedMenuProps = Omit<PopoverProps, "variant"> & {
|
|
variant?: BorderedMenuVariant
|
|
}
|
|
|
|
export const BorderedMenu: React.FC<BorderedMenuProps> = ({ children, variant, ...rest }) => {
|
|
const styles = useStyles()
|
|
|
|
return (
|
|
<Popover classes={{ root: styles.root, paper: styles.paperRoot }} data-variant={variant} {...rest}>
|
|
{children}
|
|
</Popover>
|
|
)
|
|
}
|
|
|
|
const useStyles = makeStyles((theme) => ({
|
|
root: {
|
|
paddingBottom: theme.spacing(1),
|
|
},
|
|
paperRoot: {
|
|
width: "292px",
|
|
border: `2px solid ${theme.palette.primary.main}`,
|
|
borderRadius: 7,
|
|
boxShadow: `4px 4px 0px ${fade(theme.palette.primary.main, 0.2)}`,
|
|
},
|
|
}))
|