@stanfordspezi/spezi-web-design-system
Version:
Stanford Biodesign Digital Health Spezi Web Design System
7 lines (6 loc) • 4.01 kB
JavaScript
"use strict";const e=require("react/jsx-runtime"),l=require("./index-DwV9MiDB.js"),u=require("./Button-CTJ3Li3o.js"),g=require("./useOpenState-CgJdmjB3.js"),m=require("./createLucideIcon-DpotSgUx.js"),o=require("react"),p=require("./SpeziProvider-BW6pacsq.js"),b=require("./Tooltip-CY2BbJro.js"),f=require("./Avatar-CtGMgyI-.js");/**
* @license lucide-react v0.488.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const v=[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]],j=m.createLucideIcon("menu",v),c=o.createContext({shrinkable:!0}),y=({title:t,actions:s,children:n,aside:i,mobile:d,shrinkable:a=!0})=>{const r=g.useOpenState();return e.jsx(c.Provider,{value:{shrinkable:a},children:e.jsxs("div",{className:l.cn("text-foreground [--headerHeight:72px] **:[box-sizing:border-box] lg:[--headerHeight:86px]",a?"[--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(u.Button,{onClick:r.toggle,"aria-label":`${r.isOpen?"Close":"Open"} menu`,className:"ml-4 lg:hidden",children:e.jsx(j,{})})]})]}),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",a?"xl:px-3":"lg:px-3"),children:i}),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})]})})},N=({href:t,icon:s,isActive:n,label:i,isHighlighted:d,children:a})=>{const{shrinkable:r}=o.useContext(c),{router:{Link:h}}=p.useSpeziContext(),x=e.jsx(e.Fragment,{children:e.jsxs(h,{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:i}),a,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(b.Tooltip,{tooltip:i,sideOffset:8,side:"right",className:"hidden lg:block xl:hidden",children:x},t):x},z=({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})]})]}),k=({name:t,img:s,...n})=>{const{shrinkable:i}=o.useContext(c);return e.jsxs(u.Button,{variant:"ghost",className:l.cn("mt-auto mb-2 p-2! transition",i?"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(f.Avatar,{size:"sm",name:t,src:s}),e.jsx("span",{className:l.cn("truncate text-sm",i&&"lg:hidden xl:block"),children:t})]})};exports.DashboardLayout=y;exports.MenuItem=N;exports.PageTitle=z;exports.UserMenuItem=k;