generated from IqbalLx/chrome-extension-boilerplate-react-vite
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
92 changed files
with
781 additions
and
2,129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1 @@ | ||
import 'webextension-polyfill'; | ||
import { exampleThemeStorage } from '@extension/storage'; | ||
|
||
exampleThemeStorage.get().then(theme => { | ||
console.log('theme', theme); | ||
}); | ||
|
||
console.log('background loaded'); | ||
console.log("Edit 'chrome-extension/src/background/index.ts' and save to reload."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"$schema": "https://ui.shadcn.com/schema.json", | ||
"style": "new-york", | ||
"rsc": false, | ||
"tsx": true, | ||
"tailwind": { | ||
"config": "tailwind.config.js", | ||
"css": "src/index.css", | ||
"baseColor": "zinc", | ||
"cssVariables": true, | ||
"prefix": "" | ||
}, | ||
"aliases": { | ||
"components": "@/lib/components", | ||
"utils": "@/lib/utils", | ||
"ui": "@/lib/components/ui", | ||
"lib": "@/lib" | ||
}, | ||
"iconLibrary": "lucide" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { useState } from 'react'; | ||
import { Button } from './ui/button'; | ||
import { Card, CardContent, CardFooter } from './ui/card'; | ||
import { Clipboard, CheckCircle } from 'lucide-react'; | ||
|
||
import FeedbackButton from './FeedbackButton'; | ||
|
||
interface Coupon { | ||
id: string; | ||
code: string; | ||
description: string; | ||
} | ||
|
||
interface CouponListProps { | ||
coupons: Coupon[]; | ||
} | ||
|
||
export default function CouponList({ coupons }: CouponListProps) { | ||
const [copiedCoupon, setCopiedCoupon] = useState<string | null>(null); | ||
|
||
const handleCopy = (code: string) => { | ||
navigator.clipboard.writeText(code); | ||
setCopiedCoupon(code); | ||
setTimeout(() => setCopiedCoupon(null), 2000); // Reset after 2 seconds | ||
}; | ||
|
||
return ( | ||
<div className="space-y-4"> | ||
{coupons.map(coupon => ( | ||
<Card key={coupon.id}> | ||
<CardContent className="pt-4"> | ||
<h2 className="text-lg font-semibold">{coupon.code}</h2> | ||
<p className="text-sm text-gray-500">{coupon.description}</p> | ||
</CardContent> | ||
<CardFooter className="flex justify-between"> | ||
<Button variant="outline" size="icon" onClick={() => handleCopy(coupon.code)} className="w-10 h-10"> | ||
{copiedCoupon === coupon.code ? ( | ||
<CheckCircle className="h-4 w-4 text-green-500" /> | ||
) : ( | ||
<Clipboard className="h-4 w-4" /> | ||
)} | ||
</Button> | ||
<FeedbackButton couponId={coupon.id} /> | ||
</CardFooter> | ||
</Card> | ||
))} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { FileX } from 'lucide-react'; | ||
|
||
export default function EmptyState() { | ||
return ( | ||
<div className="flex flex-col items-center justify-center h-full text-center p-4"> | ||
<FileX className="w-16 h-16 text-gray-400 mb-4" /> | ||
<h2 className="text-xl font-semibold mb-2">No Coupons Available</h2> | ||
<p className="text-gray-500"> | ||
There are currently no coupons available for this site. Check back later or add a new coupon if you know one! | ||
</p> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { useState } from 'react'; | ||
import { Button } from './ui/button'; | ||
import { ThumbsUp, ThumbsDown } from 'lucide-react'; | ||
|
||
import { cn } from '../utils'; | ||
|
||
interface FeedbackButtonProps { | ||
couponId: string; | ||
} | ||
|
||
export default function FeedbackButton({ couponId }: FeedbackButtonProps) { | ||
const [feedback, setFeedback] = useState<'positive' | 'negative' | null>(null); | ||
|
||
const handleFeedback = (type: 'positive' | 'negative') => { | ||
setFeedback(type); | ||
// In a real app, you would send this feedback to your backend | ||
console.log(`Feedback for coupon ${couponId}: ${type}`); | ||
}; | ||
|
||
return ( | ||
<div className="flex space-x-2"> | ||
<Button | ||
variant="outline" | ||
size="icon" | ||
onClick={() => handleFeedback('positive')} | ||
disabled={feedback !== null} | ||
className={cn( | ||
'transition-colors', | ||
feedback === 'positive' && 'bg-green-500 text-white border-green-500 hover:bg-green-500 hover:text-white', | ||
)}> | ||
<ThumbsUp className="h-4 w-4" /> | ||
</Button> | ||
<Button | ||
variant="outline" | ||
size="icon" | ||
onClick={() => handleFeedback('negative')} | ||
disabled={feedback !== null} | ||
className={cn( | ||
'transition-colors', | ||
feedback === 'negative' && 'bg-red-500 text-white border-red-500 hover:bg-red-500 hover:text-white', | ||
)}> | ||
<ThumbsDown className="h-4 w-4" /> | ||
</Button> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React, { useState } from 'react'; | ||
import { Button } from './ui/button'; | ||
import { Input } from './ui/input'; | ||
import { Textarea } from './ui/textarea'; | ||
|
||
interface NewCouponFormProps { | ||
onSubmit: (coupon: { code: string; description: string }) => void; | ||
onCancel: () => void; | ||
} | ||
|
||
export default function NewCouponForm({ onSubmit, onCancel }: NewCouponFormProps) { | ||
const [code, setCode] = useState(''); | ||
const [description, setDescription] = useState(''); | ||
|
||
const handleSubmit = (e: React.FormEvent) => { | ||
e.preventDefault(); | ||
onSubmit({ code, description }); | ||
}; | ||
|
||
return ( | ||
<form onSubmit={handleSubmit} className="space-y-4"> | ||
<Input placeholder="Coupon Code" value={code} onChange={e => setCode(e.target.value)} required /> | ||
<Textarea placeholder="Description" value={description} onChange={e => setDescription(e.target.value)} required /> | ||
<div className="flex justify-between"> | ||
<Button type="submit">Submit</Button> | ||
<Button variant="outline" onClick={onCancel}> | ||
Cancel | ||
</Button> | ||
</div> | ||
</form> | ||
); | ||
} |
Oops, something went wrong.