PageSourceSearch

https://www.checklist.design/assets/HomepagePinsPage-Dauz_cDq.js

js checklist.design collected 2026-10-02 17:41:27 UTC 5,765 bytes, 1 lines download raw bytes

1import{j as e}from"./index-v5JK2qZg.js";import{c as h}from"./react-vendor-fTGEjNcT.js";import{u as $,a as P,D as M,d as T,S as H,r as O,s as K,K as R,P as F,b as G,c as U,C as W}from"./sortable.esm-B9l_3mnu.js";import{a as z,h as B}from"./api-BcXTeLMZ.js";import{g as b}from"./categoryConfig-OksRL5Xb.js";import{s as V,H as q}from"./homepagePanels-B0VuxFNr.js";import"./supabase-CbCDwtWw.js";const J=q.flat();function Q({url:i}){return e.jsx("span",{className:"w-4 h-4 shrink-0",children:i?e.jsx("img",{src:i,alt:"",className:"w-full h-full"}):e.jsx("span",{className:"block w-full h-full rounded bg-dark/10"})})}function X({id:i,children:d}){const{attributes:o,listeners:c,setNodeRef:m,transform:u,transition:x,isDragging:f}=U({id:i}),j={transform:W.Transform.toString(u),transition:x};return e.jsx("div",{ref:m,style:j,...o,...c,className:`flex items-center gap-2 pl-3 pr-2 py-2 rounded-xl bg-white/70 text-dark text-sm font-medium cursor-grab active:cursor-grabbing select-none ${f?"opacity-50 shadow-md":""}`,children:d})}function Y({available:i,onPick:d}){return e.jsxs("select",{value:"",disabled:i.length===0,onChange:o=>{const c=i.find(m=>String(m.id)===o.target.value);c&&d(c)},className:"px-2 py-1.5 border border-dark/15 rounded-md text-[0.8125rem] font-sans text-dark bg-white/70 h-8 focus:outline-none focus:border-primary disabled:opacity-50",children:[e.jsx("option",{value:"",children:i.length?"+ Pin a checklist…":"All pinned"}),i.map(o=>e.jsxs("option",{value:o.id,children:[o.name,o.status!=="published"?" (draft)":""]},o.id))]})}function ae(){const[i,d]=h.useState([]),[o,c]=h.useState(!0),[m,u]=h.useState(""),[x,f]=h.useState(""),j=$(P(F,{activationConstraint:{distance:4}}),P(R,{coordinateGetter:K})),k=h.useCallback(async()=>{try{const t=await z();d(t.checklists||[])}catch(t){v(`Error: ${t.message}`)}finally{c(!1)}},[]);h.useEffect(()=>{k()},[k]);function v(t){f(t),setTimeout(()=>f(""),3e3)}const w={};for(const t of i){const n=t.website_categories?.slug;if(!n)continue;const s=b(n).slug;(w[s]||=[]).push(t)}function y(t){const n=b(t).slug;return V((w[n]||[]).filter(s=>s.homepage_pinned))}function E(t){const n=b(t).slug;return(w[n]||[]).filter(s=>!s.homepage_pinned).sort((s,a)=>(s.sort_order??0)-(a.sort_order??0))}async function N(t){u("Saving…");try{await Promise.all(t.map(n=>{const s=i.find(a=>a.id===n.id)||{};return B(n.id,{...s,...n})})),u("Saved"),setTimeout(()=>u(""),1500)}catch(n){v(`Error: ${n.message}`),u(""),k()}}function D(t,n){const{active:s,over:a}=n;if(!a||s.id===a.id)return;const r=y(t),g=r.findIndex(l=>l.id===s.id),S=r.findIndex(l=>l.id===a.id);if(g===-1||S===-1)return;const C=G(r,g,S);d(l=>l.map(p=>{const _=C.findIndex(L=>L.id===p.id);return _===-1?p:{...p,pin_order:_}})),N(C.map((l,p)=>({id:l.id,pin_order:p})))}function A(t){d(n=>n.map(s=>s.id===t.id?{...s,homepage_pinned:!1}:s)),N([{id:t.id,homepage_pinned:!1}])}function I(t,n){const s=y(t).length;d(a=>a.map(r=>r.id===n.id?{...r,homepage_pinned:!0,pin_order:s}:r)),N([{id:n.id,homepage_pinned:!0,pin_order:s}])}return o?e.jsx("div",{className:"flex items-center justify-center min-h-screen text-text-muted font-sans text-sm",children:"Loading…"}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5 gap-4 flex-wrap",children:[e.jsx("h1",{className:"text-lg font-semibold text-text-main tracking-tight",children:"Homepage"}),e.jsxs("div",{className:"flex items-center gap-3",children:[m&&e.jsx("span",{className:"text-[0.75rem] text-text-muted font-medium",children:m}),e.jsx("a",{href:"/",target:"_blank",rel:"noreferrer",className:"text-[0.8125rem] text-primary hover:underline",children:"View homepage ↗"})]})]}),e.jsx("p",{className:"text-[0.8125rem] text-text-muted m-0 mb-5 max-w-[640px]",children:"Pinned checklists appear as chips in their category panel on the homepage, in the order shown here — drag to reorder. A category with no pins falls back to its first 6 by sort order. Only published checklists show publicly."}),e.jsx("div",{className:"flex flex-col gap-3 max-w-[760px]",children:J.map(t=>{const n=b(t.slug),s=y(t.slug),a=E(t.slug);return e.jsxs("div",{className:`rounded-2xl p-5 ${n.bgClass}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h2",{className:"text-base font-semibold text-dark m-0",children:t.title}),e.jsx("span",{className:"text-[0.75rem] text-dark/50 tabular-nums",children:s.length?`${s.length} pinned`:"Using fallback"})]}),s.length===0?e.jsx("p",{className:"text-[0.8125rem] text-dark/50 m-0 mb-3",children:"No pins — the homepage shows the first 6 by sort order."}):e.jsx(M,{sensors:j,collisionDetection:T,onDragEnd:r=>D(t.slug,r),children:e.jsx(H,{items:s.map(r=>r.id),strategy:O,children:e.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:s.map(r=>e.jsxs(X,{id:r.id,children:[e.jsx(Q,{url:r.icon_url}),e.jsx("span",{className:"whitespace-nowrap",children:r.name}),r.status!=="published"&&e.jsx("span",{className:"text-[0.625rem] uppercase tracking-wide font-semibold text-dark/40",children:"draft"}),e.jsx("button",{type:"button",onPointerDown:g=>g.stopPropagation(),onClick:()=>A(r),"aria-label":`Unpin ${r.name}`,className:"ml-0.5 w-5 h-5 flex items-center justify-center rounded-md text-dark/40 hover:text-dark hover:bg-dark/10 transition-colors cursor-pointer",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]},r.id))})})}),e.jsx(Y,{available:a,onPick:r=>I(t.slug,r)})]},t.slug)})}),x&&e.jsx("div",{className:"fixed bottom-4 right-4 bg-text-main text-white px-3.5 py-2 rounded-md text-xs font-sans z-[2000] shadow-lg",children:x})]})}export{ae 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.