Githubgemini / assets /AiCommitGenerator-C6eo_GuV.js
admin08077's picture
Upload 204 files
d4e36ef verified
import{r,j as e}from"./react-DKy9e2uO.js";import{b,G as y,L as u,A as N,j as w}from"./index-Ck8YGBbR.js";import"./bottleneck-Cpj98o6Y.js";import"./react-dom-CpxHE_eW.js";import"./scheduler-DYLXRpC5.js";import"./idb-Dob3nYDb.js";import"./@google-D80DdW2m.js";import"./marked-CesSW9Du.js";import"./jszip-s56H2EZ-.js";const v=`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;
}
`,L=({diff:a})=>{const[x,d]=r.useState(a||v),[s,f]=r.useState(""),[t,p]=r.useState(!1),[c,i]=r.useState(""),m=r.useCallback(async n=>{if(!n.trim()){i("Please paste a diff to generate a message.");return}p(!0),i(""),f("");try{const o=b(n);let l="";for await(const j of o)l+=j,f(l)}catch(o){const l=o instanceof Error?o.message:"An unknown error occurred.";i(`Failed to generate message: ${l}`)}finally{p(!1)}},[]);r.useEffect(()=>{a&&(d(a),m(a))},[a,m]);const h=()=>{navigator.clipboard.writeText(s)},g=()=>{w(s,"commit_message.txt","text/plain")};return e.jsxs("div",{className:"h-full flex flex-col p-4 sm:p-6 lg:p-8 text-text-primary",children:[e.jsxs("header",{className:"mb-6",children:[e.jsxs("h1",{className:"text-3xl font-bold flex items-center",children:[e.jsx(y,{}),e.jsx("span",{className:"ml-3",children:"AI Commit Message Generator"})]}),e.jsx("p",{className:"text-text-secondary mt-1",children:"Paste your diff and let Gemini craft the perfect commit message."})]}),e.jsxs("div",{className:"flex-grow flex flex-col gap-4 min-h-0",children:[e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[e.jsx("label",{htmlFor:"diff-input",className:"text-sm font-medium text-text-secondary mb-2",children:"Git Diff"}),e.jsx("textarea",{id:"diff-input",value:x,onChange:n=>d(n.target.value),placeholder:"Paste your git diff here...",className:"flex-grow p-4 bg-surface border border-border rounded-md resize-none font-mono text-sm text-text-primary focus:ring-2 focus:ring-primary focus:outline-none"})]}),e.jsx("div",{className:"flex-shrink-0",children:e.jsx("button",{onClick:()=>m(x),disabled:t,className:"btn-primary w-full max-w-xs mx-auto flex items-center justify-center px-6 py-3",children:t?e.jsx(u,{}):"Generate Commit Message"})}),e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("label",{className:"text-sm font-medium text-text-secondary",children:"Generated Message"}),s&&!t&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:h,className:"px-3 py-1 bg-gray-100 text-xs rounded-md hover:bg-gray-200",children:"Copy"}),e.jsxs("button",{onClick:g,className:"flex items-center gap-1 px-3 py-1 bg-gray-100 text-xs rounded-md hover:bg-gray-200",children:[e.jsx(N,{className:"w-4 h-4"})," Download"]})]})]}),e.jsxs("div",{className:"relative flex-grow p-4 bg-surface border border-border rounded-md overflow-y-auto",children:[t&&e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(u,{})}),c&&e.jsx("p",{className:"text-red-500",children:c}),s&&!t&&e.jsx("pre",{className:"whitespace-pre-wrap font-sans text-text-primary",children:s}),!t&&!s&&!c&&e.jsx("div",{className:"text-text-secondary h-full flex items-center justify-center",children:"The commit message will appear here."})]})]})]})]})};export{L as AiCommitGenerator};
//# sourceMappingURL=AiCommitGenerator-C6eo_GuV.js.map