mirror of
https://github.com/bewcloud/bewcloud.git
synced 2026-03-11 08:54:49 +00:00
This implements a huge change, where Fresh is removed as a framework and serving files, allowing more control over importing, bundling, and serving files and components. The biggest challenge was to continue making sure that there weren't too many places to look into for import versions, and `PasswordlessPasskeyLogin.tsx` became a prototype in migrating a component to fully SSR, no need for frontend parsing (via Babel) or bundling (via a custom-script, downloading frontend dependencies from esm.sh). Still, there are too many components to migrate like that, and it's all working, so I likely won't even attempt it unless there's some bug, new feature, or security vulnerability to address that warrants a rewrite of those. This also updates all dependencies (except `@libs/xml` because that still causes some breaking in DAV endpoints), including Deno! All other advantages can be seen in the related issues, and the breaking change this (v4.0.0) introduces is related simply to `config.email.tlsMode` (which had a deprecation warning throughout v3), and because, while I tested many things exhaustively, it's not impossible something broke that I didn't see. Closes #141 Closes #132
118 lines
No EOL
3.9 KiB
JavaScript
118 lines
No EOL
3.9 KiB
JavaScript
import { capitalizeWord } from '/public/ts/utils/misc.ts';
|
|
export default function Header({
|
|
route,
|
|
user,
|
|
enabledApps
|
|
}) {
|
|
const activeClass = 'bg-slate-800 text-white rounded-md px-3 py-2 text-sm font-medium';
|
|
const defaultClass = 'text-slate-300 hover:bg-slate-700 hover:text-white rounded-md px-3 py-2 text-sm font-medium';
|
|
const mobileActiveClass = 'bg-slate-800 text-white block rounded-md px-3 py-2 text-base font-medium';
|
|
const mobileDefaultClass = 'text-slate-300 hover:bg-slate-700 hover:text-white block rounded-md px-3 py-2 text-base font-medium';
|
|
const iconWidthAndHeightInPixels = 20;
|
|
const potentialMenuItems = enabledApps.map(app => ({
|
|
url: `/${app}`,
|
|
label: capitalizeWord(app)
|
|
}));
|
|
const menuItems = potentialMenuItems.filter(Boolean);
|
|
if (user && !route.startsWith('/file-share')) {
|
|
const activeMenu = menuItems.find(menu => route.startsWith(menu.url));
|
|
let pageLabel = activeMenu?.label || '404 - Page not found';
|
|
if (route.startsWith('/news/feeds')) {
|
|
pageLabel = 'News feeds';
|
|
}
|
|
if (route.startsWith('/settings')) {
|
|
pageLabel = 'Settings';
|
|
}
|
|
if (route.startsWith('/expenses')) {
|
|
pageLabel = 'Budgets & Expenses';
|
|
}
|
|
if (route.startsWith('/contacts')) {
|
|
pageLabel = 'Contacts';
|
|
}
|
|
if (route.startsWith('/calendar')) {
|
|
pageLabel = 'Calendar';
|
|
}
|
|
return h(Fragment, null, h("nav", {
|
|
class: "bg-slate-950"
|
|
}, h("div", {
|
|
class: "mx-auto max-w-7xl px-4 sm:px-6 lg:px-8"
|
|
}, h("div", {
|
|
class: "flex h-16 items-center justify-between"
|
|
}, h("div", {
|
|
class: "flex items-center"
|
|
}, h("div", {
|
|
class: "shrink-0"
|
|
}, h("a", {
|
|
href: "/"
|
|
}, h("img", {
|
|
class: "h-12 w-12 drop-shadow-md",
|
|
src: "/public/images/logomark.svg",
|
|
alt: "a stylized blue cloud"
|
|
}))), h("div", {
|
|
class: "hidden md:block"
|
|
}, h("div", {
|
|
class: "ml-10 flex items-center space-x-4"
|
|
}, menuItems.map(menu => h("a", {
|
|
href: menu.url,
|
|
class: route.startsWith(menu.url) ? activeClass : defaultClass
|
|
}, h("img", {
|
|
src: `/public/images${menu.url}${'.svg'}`,
|
|
alt: menu.label,
|
|
title: menu.label,
|
|
width: iconWidthAndHeightInPixels,
|
|
height: iconWidthAndHeightInPixels,
|
|
class: "white"
|
|
})))))), h("div", {
|
|
class: "ml-4 flex items-center md:ml-6"
|
|
}, h("div", {
|
|
class: "ml-10 flex items-center space-x-4"
|
|
}, h("span", {
|
|
class: "mx-2 text-white text-sm"
|
|
}, user.email), h("a", {
|
|
href: "/settings",
|
|
class: route.startsWith('/settings') ? activeClass : defaultClass
|
|
}, h("img", {
|
|
src: "/public/images/settings.svg",
|
|
alt: "Settings",
|
|
title: "Settings",
|
|
width: iconWidthAndHeightInPixels,
|
|
height: iconWidthAndHeightInPixels,
|
|
class: "white"
|
|
})), h("a", {
|
|
href: "/logout",
|
|
class: defaultClass
|
|
}, h("img", {
|
|
src: "/public/images/logout.svg",
|
|
alt: "Logout",
|
|
title: "Logout",
|
|
width: iconWidthAndHeightInPixels,
|
|
height: iconWidthAndHeightInPixels,
|
|
class: "white"
|
|
})))))), h("div", {
|
|
class: "md:hidden",
|
|
id: "mobile-menu"
|
|
}, h("div", {
|
|
class: "space-y-1 px-2 pb-3 pt-2 sm:px-3"
|
|
}, menuItems.map(menu => h("a", {
|
|
href: menu.url,
|
|
class: route.startsWith(menu.url) ? mobileActiveClass : mobileDefaultClass
|
|
}, menu.label))))), h("header", {
|
|
class: "bg-gray-900 shadow-md"
|
|
}, h("div", {
|
|
class: "mx-auto max-w-7xl px-4 py-6 sm:px-6 lg:px-8"
|
|
}, h("h1", {
|
|
class: "text-3xl font-bold tracking-tight text-white"
|
|
}, pageLabel))));
|
|
}
|
|
return h("header", {
|
|
class: "px-4 pt-8 pb-2 max-w-3xl mx-auto flex flex-col items-center justify-center"
|
|
}, h("a", {
|
|
href: "/"
|
|
}, h("img", {
|
|
class: "mt-6 mb-2 drop-shadow-md",
|
|
src: "/public/images/logo-white.svg",
|
|
width: "250",
|
|
height: "50",
|
|
alt: "the bewCloud logo: a stylized logo"
|
|
})));
|
|
} |