-
Notifications
You must be signed in to change notification settings - Fork 157
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
1 parent
c7e04bc
commit 753c28a
Showing
3 changed files
with
59 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from "react"; | ||
import { IconCheck, IconCopy } from '@tabler/icons-react'; | ||
|
||
interface Props { | ||
storeName: string; | ||
storeLink: string; | ||
storeImage: string; | ||
code: string; | ||
percentOff: number; | ||
} | ||
|
||
const CreatorCode: React.FC<Props> = ({storeName, storeLink, storeImage, code, percentOff}) => { | ||
const [copied, setCopied] = React.useState(false) | ||
|
||
function copyCode() { | ||
setCopied(true) | ||
navigator.clipboard.writeText(code).then() | ||
setTimeout(() => setCopied(false), 1500) | ||
} | ||
|
||
|
||
return <div className="flex flex-col border border-neutral-200 dark:border-neutral-700 rounded-lg shadow-md"> | ||
<a href={storeLink} target='_blank' className="h-[150px] flex items-center justify-center bg-neutral-800 dark:hover:bg-neutral-800 hover:bg-neutral-700 dark:bg-neutral-900 rounded-none rounded-tl-lg rounded-tr-lg"> | ||
<img className="self-center" width="150" src={storeImage} alt={storeName}/> | ||
</a> | ||
<div className='p-2 flex items-center justify-center flex-col gap-2'> | ||
<p className="font-bold text-lg line-clamp-1">{storeName}</p> | ||
<p className="text-sm">Code: <code className="font-bold">{code}</code> {!copied ? <button onClick={copyCode}><IconCopy size={16}/></button> : <button><IconCheck size={16}/></button>}</p> | ||
<p className="text-sm self-end text-red-400 font-bold mt-4">{percentOff}% off</p> | ||
</div> | ||
</div> | ||
} | ||
|
||
export default CreatorCode |
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,8 @@ | ||
const CreatorCodes: React.FC<{children: React.ReactNode}> = ({children}) => { | ||
|
||
return <div className="grid md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 grid-cols-1 mt-4 gap-4"> | ||
{children} | ||
</div> | ||
} | ||
|
||
export default CreatorCodes |
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