PageSourceSearch

https://patternweaver.ai/assets/Collections-BuGTGNO5.js

js patternweaver.ai collected 2026-10-05 13:58:24 UTC 12,629 bytes, 1 lines download raw bytes

1import{o as H,r as d,s as q,j as e,B as o,T as y,a3 as V,d as g,L as W,m as U,a as M,U as R,V as Z,Y as $,Z as J,$ as X,a0 as ee,a1 as se,a2 as te,x as p,t as b,v as re}from"./index-Bk4l7YwH.js";import{u as w,T as ae}from"./trash-2-Dlt-kS_o.js";import{I as C}from"./input-B9Hlyres.js";import{L as c}from"./index-LJe8URE6.js";import{T as le}from"./textarea-B3-obedv.js";import{T as oe}from"./TipCard-BFre2tbq.js";import{D as ne,a as ie,c as de,b as ce,C as me}from"./ColorPaletteEditor-BdVrZTnA.js";import{S as ue,a as xe,b as he,c as ge,d as u}from"./select-Bmu9jqN0.js";import{P as E}from"./plus-BmGmoHnD.js";import{P as pe}from"./pen-B56RKtfG.js";import"./index-DV6iGrPF.js";import"./lock-wIwAZ4DR.js";import"./save-DKweEcnX.js";import"./shuffle-Cx6rKFxW.js";import"./palette-DAfFsiWz.js";import"./heart-DAxyLrH8.js";import"./loader-circle--Xrf5k44.js";import"./index-BGAo0zij.js";import"./index-BJcIP3DM.js";import"./index-g9pJL1eD.js";import"./chevron-down-atnpyh2D.js";import"./check-XfJkeQee.js";function Qe(){const f=H(),[be,fe]=d.useState(null),[L,x]=d.useState(!1),[h,j]=d.useState(null),[m,k]=d.useState(null),[n,v]=d.useState(null),[t,l]=d.useState({name:"",description:"",season:"all-season",year:new Date().getFullYear(),mood:"",color_palette:[]}),{data:D=[],isLoading:K}=q({queryKey:["collections"],queryFn:()=>p.list("-created_date")}),{data:Y=[]}=q({queryKey:["patterns"],queryFn:()=>re.list("-created_date",2e3)}),z=w({mutationFn:s=>p.create(s),onSuccess:()=>{f.invalidateQueries({queryKey:["collections"]}),b.success("Your collection is ready"),_()}}),S=w({mutationFn:({id:s,data:r})=>p.update(s,r),onSuccess:()=>{f.invalidateQueries({queryKey:["collections"]}),b.success("Changes saved"),_()}}),O=w({mutationFn:s=>p.delete(s),onSuccess:()=>{f.invalidateQueries({queryKey:["collections"]}),b.success("Collection removed")}}),P=()=>{j(null),l({name:"",description:"",season:"all-season",year:new Date().getFullYear(),mood:"",color_palette:[]}),x(!0)},Q=s=>{j(s),l({name:s.name||"",description:s.description||"",season:s.season||"all-season",year:s.year||new Date().getFullYear(),mood:s.mood||"",color_palette:s.color_palette||[]}),x(!0)},_=()=>{x(!1),j(null)},B=()=>{if(!t.name){b.error("Give your collection a name to get started");return}h?S.mutate({id:h.id,data:t}):z.mutate(t)},I=s=>{v(s)},G=()=>{n&&(O.mutate(n.id),v(null))},T=s=>Y.filter(r=>r.collection===s);return K?e.jsx("div",{className:"min-h-screen bg-transparent flex items-center justify-center",children:e.jsx("div",{className:"w-8 h-8 border-2 border-white/30 border-t-transparent rounded-full animate-spin"})}):e.jsxs("div",{className:"h-screen bg-transparent text-foreground overflow-hidden flex flex-col",children:[e.jsx("header",{className:"bg-gradient-to-r from-white/[0.08] via-white/[0.05] to-white/[0.08] backdrop-blur-2xl backdrop-saturate-[1.8] shrink-0",children:e.jsx("div",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-bold tracking-tight font-display",children:"Collections"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Organize your patterns by theme, project, or client"})]}),e.jsxs(o,{onClick:P,className:"h-9 bg-white text-zinc-900 hover:bg-zinc-100",children:[e.jsx(E,{className:"w-4 h-4 mr-2"}),"Create Collection"]})]})})}),e.jsxs("main",{className:"max-w-screen-2xl mx-auto px-6 py-8 overflow-y-auto flex-1",children:[e.jsx(oe,{id:"collections",icon:y,children:"Group your patterns into collections by theme, project, or client. Create a collection, then add patterns from your library."}),m?(()=>{const s=T(m.name);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx(o,{variant:"ghost",onClick:()=>k(null),className:"text-muted-foreground hover:text-foreground h-9 w-9 p-0 shrink-0",children:e.jsx(V,{className:"w-5 h-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-base font-semibold truncate",children:m.name}),m.description&&e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:m.description})]}),e.jsxs("span",{className:"ml-auto text-sm text-muted-foreground shrink-0",children:[s.length," ",s.length===1?"pattern":"patterns"]})]}),s.length===0?e.jsxs("div",{className:"text-center py-20",children:[e.jsx(g,{className:"w-12 h-12 text-muted-foreground mx-auto mb-4"}),e.jsx("h3",{className:"text-sm text-muted-foreground mb-2",children:"No patterns in this collection"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Assign patterns from your library"}),e.jsx(W,{to:"/app/library/",children:e.jsx(o,{className:"bg-white text-zinc-900 hover:bg-zinc-100",size:"sm",children:"Go to Library"})})]}):e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 ga
1p-4",children:s.map(r=>e.jsxs("div",{children:[e.jsx("div",{className:"aspect-square rounded-xl overflow-hidden border border-glass-border hover:border-glass-border-strong transition-colors",children:r.image_url?e.jsx("img",{src:r.image_url,alt:r.name,className:"w-full h-full object-cover",loading:"lazy"}):e.jsx("div",{className:"w-full h-full bg-surface-1 flex items-center justify-center",children:e.jsx(g,{className:"w-8 h-8 text-muted-foreground"})})}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground truncate",children:r.name})]},r.id))})]})})():D.length===0?e.jsxs("div",{className:"text-center py-20",children:[e.jsx("div",{className:"w-20 h-20 mx-auto mb-6 rounded-xl bg-surface-1 border border-glass-border flex items-center justify-center",children:e.jsx(y,{className:"w-10 h-10 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-semibold text-muted-foreground mb-2",children:"No collections yet"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Create your first collection to organize patterns"}),e.jsxs(o,{onClick:P,className:"bg-white text-zinc-900 hover:bg-zinc-100",children:[e.jsx(E,{className:"w-4 h-4 mr-2"}),"Create Collection"]})]}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:D.map(s=>{var A,F;const r=T(s.name),i=r.slice(0,4);return e.jsxs(U.div,{layout:!0,initial:{opacity:0,y:20},animate:{opacity:1,y:0},onClick:()=>k(s),className:"group relative bg-gradient-to-br from-white/[0.06] to-white/[0.02] border border-glass-border rounded-xl overflow-hidden hover:border-glass-border-strong hover:shadow-card-hover transition-all duration-300 cursor-pointer",children:[e.jsxs("div",{className:"aspect-square bg-zinc-900/50 relative overflow-hidden",children:[i.length>0?e.jsx("div",{className:M("w-full h-full grid gap-0.5",i.length===1&&"grid-cols-1",i.length===2&&"grid-cols-2",i.length>=3&&"grid-cols-2 grid-rows-2"),children:i.map((a,N)=>e.jsx("div",{className:M("overflow-hidden bg-zinc-800",i.length===3&&N===0&&"row-span-2"),children:a.image_url?e.jsx("img",{src:a.image_url,alt:"",className:"w-full h-full object-cover",loading:"lazy"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(g,{className:"w-6 h-6 text-zinc-700"})})},a.id))}):e.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center gap-3",children:[e.jsx("div",{className:"w-14 h-14 rounded-xl bg-surface-1 border border-glass-border flex items-center justify-center",children:e.jsx(y,{className:"w-7 h-7 text-muted-foreground"})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Empty collection"})]}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-zinc-950/90 via-transparent to-transparent pointer-events-none"}),e.jsx("div",{className:"absolute top-3 right-3 px-2.5 py-1 rounded-full bg-black/60 backdrop-blur-md border border-glass-border-strong",children:e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground font-medium",children:[e.jsx(g,{className:"w-3 h-3"}),r.length]})}),e.jsxs("div",{className:"absolute top-3 left-3 flex gap-2 opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:[e.jsx(o,{size:"icon",variant:"ghost",onClick:a=>{a.stopPropagation(),Q(s)},className:"h-8 w-8 bg-black/60 backdrop-blur-md border border-glass-border-strong hover:bg-surface-active",children:e.jsx(pe,{className:"w-3.5 h-3.5 text-white"})}),e.jsx(o,{size:"icon",variant:"ghost",onClick:a=>{a.stopPropagation(),I(s)},className:"h-8 w-8 bg-black/60 backdrop-blur-md border border-glass-border-strong hover:bg-red-500/80",children:e.jsx(ae,{className:"w-3.5 h-3.5 text-white"})})]}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-4",children:[e.jsx("h3",{className:"text-base font-semibold text-white truncate",children:s.name}),s.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:s.description})]})]}),e.jsxs("div",{className:"px-4 py-3 flex items-center gap-2 flex-wrap",children:[((A=s.color_palette)==null?void 0:A.length)>0&&e.jsx("div",{className:"flex gap-0.5 mr-auto",children:s.color_palette.slice(0,6).map((a,N)=>e.jsx("div",{className:"w-4 h-4 rounded-full ring-1 ring-glass-border",style:{backgroundColor:a}},N))}),s.season&&s.season!=="all-season"&&e.jsx("span",{className:"text-[11px] text-muted-foreground px-2 py-0.5 rounded-full bg-surface-2 capitalize",children:s.season}),s.mood&&e.jsx("span",{className:"text-[11px] text-muted-foreground px-2 py-0.5 rounded-full bg-surface-2",children:s.mood}),!((F=s.color_palette)!=null&&F.length)&&!s.mood&&!(s.season&&s.season!=="all-season")&&e.jsxs("span",{className:"text-[11px] text-muted-foreground",children:[r.length," ",r.length===1?"pattern":"patterns"]})]})]},s.id)})})]}),e.jsx(ne,{open:L,onOpenChange:x,children:e.jsxs(ie,{className:"bg-card border-glass-border text-foreground max-w-lg",children:[e.jsx(de,{children:e.jsx(ce,{children:h?"Edit Collection":"Create New Collection"})}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-muted-foreground",children:"Collection Name"}),e.jsx(C,{value:t.name,onChange:s=>l({...t,name:s.target.value}
1),placeholder:"e.g., Website Backgrounds",className:"mt-1.5 bg-surface-1 border-glass-border text-foreground"})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-muted-foreground",children:"Description"}),e.jsx(le,{value:t.description,onChange:s=>l({...t,description:s.target.value}),placeholder:"What's this collection about?",className:"mt-1.5 bg-surface-1 border-glass-border text-white h-20 resize-none"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-muted-foreground",children:"Category"}),e.jsxs(ue,{value:t.season,onValueChange:s=>l({...t,season:s}),children:[e.jsx(xe,{className:"mt-1.5 bg-surface-1 border-glass-border text-foreground",children:e.jsx(he,{})}),e.jsxs(ge,{className:"bg-zinc-950 border-glass-border",children:[e.jsx(u,{value:"all-season",children:"All"}),e.jsx(u,{value:"personal",children:"Personal"}),e.jsx(u,{value:"client",children:"Client Work"}),e.jsx(u,{value:"commercial",children:"Commercial"}),e.jsx(u,{value:"experimental",children:"Experimental"})]})]})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-muted-foreground",children:"Year"}),e.jsx(C,{type:"number",value:t.year,onChange:s=>l({...t,year:parseInt(s.target.value)}),className:"mt-1.5 bg-surface-1 border-glass-border text-foreground"})]})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-muted-foreground",children:"Tags"}),e.jsx(C,{value:t.mood,onChange:s=>l({...t,mood:s.target.value}),placeholder:"e.g., Minimalist, Bold, Organic",className:"mt-1.5 bg-surface-1 border-glass-border text-foreground"})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-muted-foreground",children:"Color Palette"}),e.jsx("div",{className:"mt-2",children:e.jsx(me,{colors:t.color_palette,onChange:s=>l({...t,color_palette:s}),maxColors:6,showHarmony:!1,showPresets:!1})})]}),e.jsx(o,{onClick:B,disabled:!t.name||z.isPending||S.isPending,className:"w-full bg-white text-zinc-900 hover:bg-zinc-100",children:h?"Update Collection":"Create Collection"})]})]})}),e.jsx(R,{open:!!n,onOpenChange:s=>!s&&v(null),children:e.jsxs(Z,{children:[e.jsxs($,{children:[e.jsx(J,{children:"Delete this collection?"}),e.jsxs(X,{children:['"',n==null?void 0:n.name,'" will be permanently removed. The patterns inside it will stay in your library — only the collection grouping is deleted.']})]}),e.jsxs(ee,{children:[e.jsx(se,{children:"Keep collection"}),e.jsx(te,{onClick:G,className:"bg-red-500 hover:bg-red-600 text-white",children:"Delete collection"})]})]})})]})}export{Qe as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.