2 lines
5.4 KiB
JavaScript
2 lines
5.4 KiB
JavaScript
import{u as v,j as e,L as n,an as _,r as o,aj as y,ao as D,p as E,ap as P}from"./vendor-BKmmeuxg.js";import{I as B}from"./index-CupQom6K.js";import{M as O}from"./main-_V386djS.js";import{A as F}from"./app-logo-CmnEIwal.js";import{B as l}from"./button-BpNwv2aE.js";import{D as L,a as k,b as z,d as R,c as T}from"./dropdown-menu-DO-po5c1.js";import{S as G}from"./scroll-area-C8HGru-R.js";import{u as A}from"./use-auth-NG-DQJrC.js";import{u as M}from"./use-screen-DU5n3V8C.js";import{c as C}from"./utils-DxSsnXxD.js";import{A as X}from"./appearance-D2z3xcjR.js";import{L as Y}from"./language-BFZ7KItL.js";import{N as q}from"./notification-CYMPYbAP.js";import{P as H}from"./profile-toggle-CvHrFE0q.js";const J=()=>{const{cartCount:a}=v().props;return e.jsx(n,{href:route("course-cart.index"),children:e.jsxs("div",{className:"relative",children:[a&&a>0?e.jsx("span",{className:"absolute -top-1 -right-1 flex h-4 w-4 items-center justify-center rounded-full bg-red-500 text-[10px] font-medium text-white",children:a}):null,e.jsx(l,{variant:"secondary",size:"icon",className:"relative h-9 w-9 rounded-full p-0",children:e.jsx(_,{className:"!h-5 !w-5"})})]})})},K=({language:a})=>{const{props:c}=v(),{navbar:i,translate:t,system:f}=c,{isLoggedIn:d}=A(),{screen:h}=M(),[m,j]=o.useState(!1),p=i.navbar_items.sort((r,g)=>r.sort-g.sort),u=()=>p.map(r=>r.slug==="theme"?e.jsx(X,{},r.id):f.fields.language_selector&&a&&r.slug==="language"?e.jsx(Y,{},r.id):d&&r.slug==="notification"?e.jsx(q,{},r.id):d&&r.slug==="cart"?e.jsx(J,{},r.id):null);return e.jsxs("div",{className:"flex items-center gap-2",children:[h>768?e.jsx("div",{className:"flex items-center gap-2",children:u()}):e.jsxs(L,{open:m,onOpenChange:j,children:[e.jsx(k,{asChild:!0,children:e.jsx(l,{size:"icon",variant:"secondary",className:"md:hidden",children:m?e.jsx(y,{className:"h-6 w-6"}):e.jsx(D,{className:"h-6 w-6"})})}),e.jsx(z,{className:"w-12 min-w-10",children:e.jsx(R,{value:"bottom",children:e.jsx("div",{className:"flex flex-col items-center gap-2",children:u()})})})]}),d?p.map(r=>r.slug==="profile"?e.jsx(H,{},r.id):null):e.jsxs("div",{className:"hidden space-x-2 sm:block",children:[e.jsx(l,{asChild:!0,variant:"outline",className:"",children:e.jsx(n,{href:route("register"),children:t.button.sign_up})}),e.jsx(l,{asChild:!0,className:"",children:e.jsx(n,{href:route("login"),children:t.button.log_in})})]})]})},Q=({language:a=!1,heightCover:c=!0,customizable:i=!0})=>{const{props:t}=v(),{ziggy:f,navbar:d,translate:h}=t,{isAdmin:m,isLoggedIn:j}=A(),[p,u]=o.useState(!1),[r,g]=o.useState(!1),{screen:S}=M();o.useEffect(()=>{const s=()=>{window.scrollY>100?u(!0):u(!1)};return window.addEventListener("scroll",s),()=>{window.removeEventListener("scroll",s)}},[]);const N=s=>{if(s.active)switch(s.type){case"url":return e.jsx(n,{href:s.value||"",className:"text-sm font-normal",children:s.title},s.id);case"dropdown":return e.jsxs(L,{children:[e.jsxs(k,{className:"flex cursor-pointer items-center gap-1 text-sm",children:[s.title,e.jsx(P,{className:"ml-1 h-4 w-4"})]}),e.jsx(z,{align:"start",className:"min-w-20",children:s.items&&Array.isArray(s.items)&&s.items.map((x,I)=>e.jsx(T,{asChild:!0,className:"cursor-pointer px-5",children:e.jsx(n,{href:x.url||"",children:x.title})},I))})]},s.id);default:return null}},w=d.navbar_items.sort((s,x)=>s.sort-x.sort),b=t.customize?f.location:"?customize=true";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:C("fixed top-0 z-30 w-full",r&&"bg-background"),children:[e.jsxs("div",{className:C("container mt-0 flex h-[72px] items-center justify-between gap-1 !px-4 transition-all duration-200 md:gap-6",p&&"bg-background shadow-card mx-auto mt-4 h-16 w-full rounded-2xl md:!max-w-6xl",S<768&&"mt-0 h-[72px] rounded-none"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l,{size:"icon",variant:"secondary",className:"md:hidden",onClick:()=>g(!r),children:r?e.jsx(y,{className:"h-6 w-6"}):e.jsx(E,{className:"h-6 w-6"})}),e.jsx(n,{href:"/",children:e.jsx(F,{})})]}),e.jsx("div",{className:"hidden gap-4 md:flex md:items-center",children:w.map(s=>e.jsx(o.Fragment,{children:N(s)},s.id))}),e.jsxs("div",{className:"flex items-center gap-2",children:[i&&m&&e.jsx(l,{asChild:!0,variant:"outline",className:"hidden text-sm font-normal sm:block",children:e.jsx(n,{href:b,children:t.customize?"Back":"Customize"})}),e.jsx(K,{language:a})]})]}),r&&e.jsx(G,{className:"bg-background h-[calc(100vh-72px)] border-t md:hidden",children:e.jsxs("div",{className:"flex flex-col space-y-4 px-6 py-4",children:[w.map(s=>e.jsx(o.Fragment,{children:N(s)},s.id)),i&&m&&e.jsx(l,{asChild:!0,variant:"outline",className:"text-sm font-normal",children:e.jsx(n,{href:b,children:t.customize?"Back":"Customize"})}),!j&&e.jsxs("div",{className:"block space-y-2 sm:hidden",children:[e.jsx(l,{asChild:!0,variant:"outline",className:"w-full rounded-sm shadow-none sm:px-5 md:h-10",children:e.jsx(n,{href:route("register"),children:h.button.sign_up})}),e.jsx(l,{asChild:!0,className:"w-full rounded-sm shadow-none sm:px-5 md:h-10",children:e.jsx(n,{href:route("login"),children:h.button.log_in})})]})]})})]}),c&&e.jsx("div",{className:"relative z-20 h-[72px] bg-transparent"})]})},ce=({children:a,language:c=!1,navbarHeight:i=!0,customizable:t})=>e.jsx(O,{children:e.jsxs("div",{className:"flex min-h-screen flex-col justify-between overflow-x-hidden",children:[e.jsxs("main",{children:[e.jsx(Q,{heightCover:i,customizable:t,language:c}),a]}),e.jsx(B,{})]})});export{ce as L};
|