Spaces:
Running
Running
| import{r as s,j as e}from"./react-DKy9e2uO.js";import{b as j,G as b,L as u}from"./index-MnghlAu6.js";import"./bottleneck-Cpj98o6Y.js";import"./react-dom-CpxHE_eW.js";import"./scheduler-DYLXRpC5.js";import"./@google-CZdO-yDN.js";import"./idb-Dob3nYDb.js";import"./marked-CesSW9Du.js";import"./jszip-s56H2EZ-.js";const N=`diff --git a/src/components/Button.tsx b/src/components/Button.tsx | |
| index 1b2c3d4..5e6f7g8 100644 | |
| --- a/src/components/Button.tsx | |
| +++ b/src/components/Button.tsx | |
| @@ -1,7 +1,7 @@ | |
| import React from 'react'; | |
| interface ButtonProps { | |
| - text: string; | |
| + label: string; | |
| onClick: () => void; | |
| } | |
| `,E=({diff:t})=>{const[d,x]=s.useState(t||N),[a,f]=s.useState(""),[r,p]=s.useState(!1),[c,i]=s.useState(""),m=s.useCallback(async l=>{if(!l.trim()){i("Please paste a diff to generate a message.");return}p(!0),i(""),f("");try{const o=j(l);let n="";for await(const h of o)n+=h,f(n)}catch(o){const n=o instanceof Error?o.message:"An unknown error occurred.";i(`Failed to generate message: ${n}`)}finally{p(!1)}},[]);s.useEffect(()=>{t&&(x(t),m(t))},[t,m]);const g=()=>{navigator.clipboard.writeText(a)};return e.jsxs("div",{className:"h-full flex flex-col p-4 sm:p-6 lg:p-8",children:[e.jsxs("header",{className:"mb-6",children:[e.jsxs("h1",{className:"text-3xl flex items-center",children:[e.jsx(b,{}),e.jsx("span",{className:"ml-3",children:"AI Commit Message Generator"})]}),e.jsx("p",{className:"text-slate-400 mt-1",children:"Paste your diff and let Gemini craft the perfect commit message."})]}),e.jsxs("div",{className:"flex-grow grid grid-cols-1 lg:grid-cols-2 gap-6 h-full overflow-hidden",children:[e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("label",{htmlFor:"diff-input",className:"text-sm font-medium text-slate-400 mb-2",children:"Git Diff"}),e.jsx("textarea",{id:"diff-input",value:d,onChange:l=>x(l.target.value),placeholder:"Paste your git diff here...",className:"flex-grow p-4 bg-slate-900 border border-slate-700 rounded-md resize-none font-mono text-sm text-slate-300 focus:ring-2 focus:ring-cyan-500 focus:outline-none"}),e.jsx("button",{onClick:()=>m(d),disabled:r,className:"btn-primary mt-4 w-full flex items-center justify-center px-6 py-3",children:r?e.jsx(u,{}):"Generate Commit Message"})]}),e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("label",{className:"text-sm font-medium text-slate-400 mb-2",children:"Generated Message"}),e.jsxs("div",{className:"relative flex-grow p-4 bg-slate-800/50 border border-slate-700/50 rounded-md overflow-y-auto",children:[r&&e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(u,{})}),c&&e.jsx("p",{className:"text-red-400",children:c}),a&&!r&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:g,className:"absolute top-2 right-2 px-2 py-1 bg-slate-700 hover:bg-slate-600 rounded-md text-xs",children:"Copy"}),e.jsx("pre",{className:"whitespace-pre-wrap font-sans text-slate-200",children:a})]}),!r&&!a&&!c&&e.jsx("div",{className:"text-slate-500 h-full flex items-center justify-center",children:"The commit message will appear here."})]})]})]})]})};export{E as AiCommitGenerator}; | |
| //# sourceMappingURL=AiCommitGenerator-ChzesS-C.js.map | |