Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

3.5 KB
Raw Blame
import { buttonVariants } from "@rallly/ui";
import {
  Sidebar,
  SidebarContent,
  SidebarFooter,
  SidebarGroup,
  SidebarGroupContent,
  SidebarGroupLabel,
  SidebarHeader,
  SidebarInset,
  SidebarMenu,
  SidebarMenuItem,
  SidebarProvider,
  SidebarSeparator,
  SidebarTrigger,
} from "@rallly/ui/sidebar";
import { ArrowLeftIcon, SettingsIcon } from "lucide-react";
import type React from "react";
import { HoverPrefetchLink } from "@/components/hover-prefetch-link";
import { PastDueAlert } from "@/features/billing/components/past-due-alert";
import { NavUser } from "@/features/user/components/nav-user";
import { Trans } from "@/i18n/client";
import { isFeatureEnabled } from "@/lib/feature-flags/server";
import {
  AccountSidebarMenu,
  DeveloperSidebarMenu,
  SpaceSidebarMenu,
} from "./components/sidebar";

export default function Layout({ children }: { children?: React.ReactNode }) {
  return (
    <SidebarProvider>
      <Sidebar>
        <SidebarHeader>
          <SidebarGroup>
            <SidebarGroupContent>
              <SidebarMenu>
                <SidebarMenuItem className="flex items-center gap-3">
                  <HoverPrefetchLink
                    href="/"
                    className={buttonVariants({
                      variant: "ghost",
                      size: "icon",
                    })}
                  >
                    <ArrowLeftIcon className="text-muted-foreground" />
                    <span className="sr-only">
                      <Trans i18nKey="back" defaults="Back" />
                    </span>
                  </HoverPrefetchLink>
                  <span className="font-medium text-sm">
                    <Trans i18nKey="settings" defaults="Settings" />
                  </span>
                </SidebarMenuItem>
              </SidebarMenu>
            </SidebarGroupContent>
          </SidebarGroup>
        </SidebarHeader>
        <SidebarSeparator />
        <SidebarContent>
          <SidebarGroup>
            <SidebarGroupLabel>
              <Trans i18nKey="account" defaults="Account" />
            </SidebarGroupLabel>
            <SidebarGroupContent>
              <AccountSidebarMenu
                showConferencing={isFeatureEnabled("conferencing")}
              />
            </SidebarGroupContent>
          </SidebarGroup>
          <SidebarGroup>
            <SidebarGroupLabel>
              <Trans i18nKey="space" defaults="Space" />
            </SidebarGroupLabel>
            <SidebarGroupContent>
              <SpaceSidebarMenu />
            </SidebarGroupContent>
          </SidebarGroup>
          <DeveloperSidebarMenu />
        </SidebarContent>
        <SidebarFooter>
          <NavUser />
        </SidebarFooter>
      </Sidebar>
      <SidebarInset id="main-content" tabIndex={-1}>
        <PastDueAlert />
        <div className="flex flex-1 flex-col">
          <header className="sticky top-0 z-10 border-b bg-sidebar/90 p-3 backdrop-blur-xs md:hidden">
            <div className="flex items-center gap-4">
              <SidebarTrigger />
              <div className="flex items-center gap-2">
                <SettingsIcon className="size-4 shrink-0 text-muted-foreground" />
                <span className="font-medium text-sm">
                  <Trans i18nKey="settings" defaults="Settings" />
                </span>
              </div>
            </div>
          </header>
          <div className="flex-1 p-4 lg:py-12">{children}</div>
        </div>
      </SidebarInset>
    </SidebarProvider>
  );
}