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