@stanfordspezi/spezi-web-design-system
Version:
Stanford Biodesign Digital Health Spezi Web Design System
7 lines (6 loc) • 3.96 kB
JavaScript
"use strict";const e=require("react/jsx-runtime"),l=require("./index-DwV9MiDB.js"),h=require("./Button-DEDWKDkp.js"),g=require("./useOpenState-CgJdmjB3.js"),m=require("./createLucideIcon-BnAj0RnC.js"),c=require("react"),p=require("./SpeziProvider-BboZeZq0.js"),f=require("./Tooltip-79kZaPuP.js"),b=require("./Avatar-CtGMgyI-.js");/**
* @license lucide-react v0.511.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const j=[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]],v=m.createLucideIcon("menu",j),o=c.createContext({shrinkable:!0}),N=({title:t,actions:s,children:n,aside:a,mobile:d,shrinkable:i=!0})=>{const r=g.useOpenState();return e.jsx(o.Provider,{value:{shrinkable:i},children:e.jsxs("div",{className:l.cn("text-foreground [--headerHeight:72px] **:[box-sizing:border-box] lg:[--headerHeight:86px]",i?"[--asideWidth:86px] xl:[--asideWidth:240px]":"[--asideWidth:240px]"),children:[e.jsxs("header",{className:l.cn("border-b-border-layout flex h-(--headerHeight) items-center gap-4 border-x-0 border-t-0 border-b border-solid px-4 py-1 lg:ml-(--asideWidth) xl:px-8",!t&&!s&&"lg:hidden"),children:[t,e.jsxs("div",{className:"ml-auto gap-4",children:[s,e.jsx(h.Button,{onClick:r.toggle,"aria-label":`${r.isOpen?"Close":"Open"} menu`,className:"ml-4 lg:hidden",children:e.jsx(v,{})})]})]}),e.jsx("aside",{className:l.cn("border-r-border-layout bg-surface fixed top-0 left-0 hidden h-screen w-(--asideWidth) flex-col items-center border-y-0 border-r border-l-0 border-solid py-4 lg:flex",i?"xl:px-3":"lg:px-3"),children:a}),e.jsxs("nav",{className:l.cn("bg-surface fixed top-[calc(var(--headerHeight)+1px)] right-0 left-0 flex h-[calc(100vh-var(--headerHeight)-1px)] w-screen flex-col overflow-y-auto transition duration-300 lg:hidden",r.isOpen?"z-10 translate-x-0":"pointer-events-none -translate-x-24 opacity-0"),hidden:!r.isOpen,"data-testid":"mobileMenu",children:[s&&e.jsx("div",{className:"p-4",children:s}),d]}),e.jsx("div",{className:"flex min-h-[calc(100vh-var(--headerHeight))] flex-col px-4 pt-6 pb-12 md:px-12 md:pt-10 md:pb-16 lg:ml-(--asideWidth)",children:n})]})})},y=({href:t,icon:s,isActive:n,label:a,isHighlighted:d,children:i})=>{const{shrinkable:r}=c.useContext(o),{router:{Link:u}}=p.useSpeziContext(),x=e.jsx(e.Fragment,{children:e.jsxs(u,{href:t,className:l.cn("focus-ring relative flex items-center gap-3 rounded-lg p-2 font-medium no-underline transition",n?"bg-accent/50 text-primary hover:opacity-60":"text-foreground/60 hover:bg-accent hover:text-foreground",r?"xl:w-full xl:self-start":"lg:w-full lg:self-start"),children:[s,e.jsx("span",{className:l.cn("grow",r&&"lg:hidden xl:block"),children:a}),i,d&&e.jsx("i",{"aria-hidden":!0,className:l.cn("bg-destructive size-2.5 rounded-full",r&&"lg:absolute lg:top-1 lg:right-1 lg:size-1.5 xl:static xl:size-2.5")})]})});return r?e.jsx(f.Tooltip,{tooltip:a,sideOffset:8,side:"right",className:"hidden lg:block xl:hidden",children:x},t):x},k=({title:t,subTitle:s,icon:n})=>e.jsxs("div",{className:"flex items-center gap-2 lg:gap-4",children:[n&&e.jsx("div",{className:"flex-center bg-muted rounded-lg p-2 [&_svg]:size-5 lg:[&_svg]:size-6","aria-hidden":!0,children:n}),e.jsxs("div",{className:"flex flex-col",children:[t&&e.jsx("h1",{className:"font-medium lg:text-xl",children:t}),s&&e.jsx("h2",{className:"text-xs lg:text-sm",children:s})]})]}),z=({name:t,img:s,...n})=>{const{shrinkable:a}=c.useContext(o);return e.jsxs(h.Button,{variant:"ghost",className:l.cn("mt-auto mb-2 p-2! transition",a?"xl:mb-0 xl:w-full xl:justify-start xl:self-start":"lg:mb-0 lg:w-full lg:justify-start lg:self-start"),...n,children:[e.jsx(b.Avatar,{size:"sm",name:t,src:s}),e.jsx("span",{className:l.cn("truncate text-sm",a&&"lg:hidden xl:block"),children:t})]})};exports.DashboardLayout=N;exports.MenuItem=y;exports.PageTitle=k;exports.UserMenuItem=z;