2021-06-27 06:17:59 -04:00
|
|
|
import { Cog } from "@styled-icons/boxicons-solid";
|
2021-07-05 06:23:23 -04:00
|
|
|
import { Link } from "react-router-dom";
|
2021-06-21 16:35:21 -04:00
|
|
|
import { Server } from "revolt.js/dist/api/objects";
|
|
|
|
import { ServerPermission } from "revolt.js/dist/api/permissions";
|
2021-07-05 06:23:23 -04:00
|
|
|
import styled from "styled-components";
|
|
|
|
|
2021-06-21 16:35:21 -04:00
|
|
|
import { HookContext, useServerPermission } from "../../context/revoltjs/hooks";
|
|
|
|
|
2021-07-05 06:23:23 -04:00
|
|
|
import Header from "../ui/Header";
|
|
|
|
import IconButton from "../ui/IconButton";
|
|
|
|
|
2021-06-21 16:35:21 -04:00
|
|
|
interface Props {
|
2021-07-05 06:23:23 -04:00
|
|
|
server: Server;
|
|
|
|
ctx: HookContext;
|
2021-06-21 16:35:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
const ServerName = styled.div`
|
2021-07-05 06:23:23 -04:00
|
|
|
flex-grow: 1;
|
2021-06-21 16:35:21 -04:00
|
|
|
`;
|
|
|
|
|
|
|
|
export default function ServerHeader({ server, ctx }: Props) {
|
2021-07-05 06:23:23 -04:00
|
|
|
const permissions = useServerPermission(server._id, ctx);
|
|
|
|
const bannerURL = ctx.client.servers.getBannerURL(
|
|
|
|
server._id,
|
|
|
|
{ width: 480 },
|
|
|
|
true,
|
|
|
|
);
|
2021-06-21 16:35:21 -04:00
|
|
|
|
2021-07-05 06:23:23 -04:00
|
|
|
return (
|
|
|
|
<Header
|
|
|
|
borders
|
|
|
|
placement="secondary"
|
|
|
|
background={typeof bannerURL !== "undefined"}
|
|
|
|
style={{
|
|
|
|
background: bannerURL ? `url('${bannerURL}')` : undefined,
|
|
|
|
}}>
|
|
|
|
<ServerName>{server.name}</ServerName>
|
|
|
|
{(permissions & ServerPermission.ManageServer) > 0 && (
|
|
|
|
<div className="actions">
|
|
|
|
<Link to={`/server/${server._id}/settings`}>
|
|
|
|
<IconButton>
|
|
|
|
<Cog size={24} />
|
|
|
|
</IconButton>
|
|
|
|
</Link>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</Header>
|
|
|
|
);
|
2021-06-21 16:35:21 -04:00
|
|
|
}
|