Files
ThreadNet-Web/modules/banner/element-web/src/Banner.tsx
T

68 lines
1.9 KiB
TypeScript
Raw Normal View History

2025-05-08 12:06:05 +01:00
/*
Copyright 2025 New Vector Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
import { type FC } from "react";
import styled, { ThemeProvider } from "styled-components";
import { type Api } from "@element-hq/element-web-module-api";
2025-05-15 17:03:02 +01:00
import { Heading } from "@vector-im/compound-web";
2025-05-08 12:06:05 +01:00
import { type ModuleConfig } from "./config";
import UniventionMenu from "./Univention/Menu";
import Menu from "./Menu";
import Logo from "./Logo.tsx";
2025-05-15 17:03:02 +01:00
import { theme } from "./theme.ts";
2025-05-08 12:06:05 +01:00
const Root = styled.nav`
2025-05-15 17:03:02 +01:00
height: ${({ theme }): string => theme.bannerHeight};
background-color: ${({ theme }): string => theme.bannerBackgroundColor};
border-bottom: "1px solid var(--cpd-color-bg-subtle-primary)";
display: flex;
gap: var(--cpd-space-3x);
2025-05-08 12:06:05 +01:00
`;
2025-05-15 17:03:02 +01:00
const LogoContainer = styled.div`
2025-05-08 12:06:05 +01:00
display: flex;
2025-05-15 17:03:02 +01:00
padding: var(--cpd-space-3x) 0;
2025-05-08 12:06:05 +01:00
`;
interface Props {
api: Api;
logoUrl: string;
href: string;
menu: ModuleConfig["menu"];
}
const Banner: FC<Props> = ({ api, logoUrl, href, menu }) => {
let menuJsx;
switch (menu.type) {
case "static": {
menuJsx = <Menu api={api} config={menu} fallbackLogoUrl={logoUrl} />;
break;
}
case "univention": {
menuJsx = <UniventionMenu api={api} config={menu} fallbackLogoUrl={logoUrl} />;
break;
}
}
return (
<ThemeProvider theme={theme}>
<Root>
{menuJsx}
2025-05-15 17:03:02 +01:00
<LogoContainer>
<Logo api={api} src={logoUrl} href={href} height="100%" />
</LogoContainer>
<Heading size="sm" weight="medium" as="h1">
{api.config.get("brand")}
</Heading>
2025-05-08 12:06:05 +01:00
</Root>
</ThemeProvider>
);
};
export default Banner;