-
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
15 changed files
with
347 additions
and
79 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
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 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,37 +1,109 @@ | ||
"use client"; | ||
|
||
import CaretRightIcon from "@/icons/caretRightIcon"; | ||
import { motion } from "framer-motion"; | ||
import { Loader2 } from "lucide-react"; | ||
import { useState } from "react"; | ||
|
||
interface Props { | ||
text: string; | ||
action: () => void; | ||
disabled?: boolean; | ||
className?: string; | ||
textStyle?: string; | ||
isLoading?: boolean; | ||
} | ||
|
||
export default function ButtonPrimary1({ text, action, disabled = false, className, textStyle }: Props) { | ||
export default function ButtonPrimary1({ | ||
text, | ||
action, | ||
disabled = false, | ||
className, | ||
textStyle, | ||
isLoading = false, | ||
}: Props) { | ||
const [isHovered, setIsHovered] = useState<boolean>(false); | ||
const [isPressed, setIsPressed] = useState<boolean>(false); | ||
|
||
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => { | ||
event.stopPropagation(); // Prevent event from bubbling up | ||
action(); | ||
}; | ||
|
||
const iconVariants = { | ||
chevron: { x: 0 }, | ||
arrow: { x: 1 }, | ||
}; | ||
|
||
const lineVariants = { | ||
hidden: { scaleX: 0, originX: 1 }, | ||
visible: { scaleX: 1, originX: 1 }, | ||
}; | ||
|
||
return ( | ||
<button | ||
className={`flex p-4 justify-center items-center gap-1 rounded-md w-full ${className} ${ | ||
disabled ? "bg-other-background" : "bg-red-600" | ||
}`} | ||
onClick={handleClick} | ||
className={`flex p-4 justify-center items-center gap-2 rounded-md w-full transition-all duration-300 ${ | ||
disabled ? "bg-other-background" : isPressed ? "bg-red-500" : "bg-red-600" | ||
} ${isLoading ? "cursor-default" : ""} ${className}`} | ||
onClick={(event) => { | ||
if (!isLoading) handleClick(event); | ||
}} | ||
disabled={disabled} | ||
onMouseEnter={() => setIsHovered(true)} | ||
onMouseLeave={() => setIsHovered(false)} | ||
onMouseDown={() => { | ||
if (!isLoading) setIsPressed(true); | ||
}} | ||
onMouseUp={() => { | ||
if (!isLoading) setIsPressed(false); | ||
}} | ||
> | ||
<p | ||
className={`text-center ${disabled ? "text-neutral-400" : "text-neutral-white"} ${ | ||
textStyle ? textStyle : "s2" | ||
}`} | ||
> | ||
{text} | ||
</p> | ||
{!disabled ? <CaretRightIcon className="h-[20px] w-[20px] shrink-0 fill-neutral-white" /> : null} | ||
{isLoading ? ( | ||
<div className="animate-spin"> | ||
<Loader2 className="stroke-neutral-white" /> | ||
</div> | ||
) : ( | ||
<> | ||
<p | ||
className={`text-center ${disabled ? "text-neutral-400" : "text-neutral-white"} ${ | ||
textStyle ? textStyle : "s2" | ||
}`} | ||
> | ||
{text} | ||
</p> | ||
{!disabled && ( | ||
<motion.svg | ||
width="24" | ||
height="24" | ||
viewBox="0 0 24 24" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
animate={isHovered ? "arrow" : "chevron"} | ||
> | ||
<motion.path | ||
d="M9 18L15 12L9 6" | ||
stroke="white" | ||
strokeWidth="2" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
variants={iconVariants} | ||
/> | ||
<motion.line | ||
x1="3" | ||
y1="12" | ||
x2="14" | ||
y2="12" | ||
stroke="white" | ||
strokeWidth="2" | ||
strokeLinecap="round" | ||
variants={lineVariants} | ||
initial="hidden" | ||
animate={isHovered ? "visible" : "hidden"} | ||
transition={{ duration: 0.2 }} | ||
/> | ||
</motion.svg> | ||
)} | ||
</> | ||
)} | ||
</button> | ||
); | ||
} |
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,22 +1,52 @@ | ||
"use client"; | ||
|
||
import { Loader2 } from "lucide-react"; | ||
|
||
interface Props { | ||
text: string; | ||
action: () => void; | ||
disabled?: boolean; | ||
className?: string; | ||
textStyle?: string; | ||
isLoading?: boolean; | ||
} | ||
|
||
export default function ButtonPrimary2({ text, action, disabled = false, className, textStyle }: Props) { | ||
export default function ButtonPrimary2({ | ||
text, | ||
action, | ||
disabled = false, | ||
className, | ||
textStyle, | ||
isLoading = false, | ||
}: Props) { | ||
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => { | ||
event.stopPropagation(); // Prevent event from bubbling up | ||
action(); | ||
}; | ||
|
||
return ( | ||
<button className={`p-4 bg-red-600 rounded-md w-full ${className}`} onClick={handleClick} disabled={disabled}> | ||
<p className={`text-neutral-white text-center ${textStyle ? textStyle : "s2"}`}>{text}</p> | ||
<button | ||
className={`flex p-4 justify-center items-center rounded-md w-full transition-all duration-300 ${ | ||
disabled ? "bg-other-background" : "bg-red-600" | ||
} ${!disabled && !isLoading ? "hover:bg-red-500" : "cursor-default"} ${className}`} | ||
onClick={(event) => { | ||
if (!isLoading) handleClick(event); | ||
}} | ||
disabled={disabled} | ||
> | ||
{isLoading ? ( | ||
<div className="animate-spin"> | ||
<Loader2 className="stroke-neutral-white" /> | ||
</div> | ||
) : ( | ||
<p | ||
className={`text-center ${disabled ? "text-neutral-400" : "text-neutral-white"} ${ | ||
textStyle ? textStyle : "s2" | ||
}`} | ||
> | ||
{text} | ||
</p> | ||
)} | ||
</button> | ||
); | ||
} |
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,26 +1,61 @@ | ||
"use client"; | ||
|
||
import { Loader2 } from "lucide-react"; | ||
import { useState } from "react"; | ||
|
||
interface Props { | ||
text: string; | ||
action: () => void; | ||
disabled?: boolean; | ||
className?: string; | ||
textStyle?: string; | ||
isLoading?: boolean; | ||
} | ||
|
||
export default function ButtonPrimary3({ text, action, disabled = false, className, textStyle }: Props) { | ||
export default function ButtonPrimary3({ | ||
text, | ||
action, | ||
disabled = false, | ||
className, | ||
textStyle, | ||
isLoading = false, | ||
}: Props) { | ||
const [isPressed, setIsPressed] = useState<boolean>(false); | ||
|
||
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => { | ||
event.stopPropagation(); // Prevent event from bubbling up | ||
action(); | ||
}; | ||
|
||
return ( | ||
<button | ||
className={`p-4 bg-other-background rounded-md w-full ${className}`} | ||
onClick={handleClick} | ||
className={`flex p-4 justify-center items-center rounded-md w-full transition-all duration-300 ${ | ||
!disabled && !isLoading ? "hover:opacity-80" : "cursor-default" | ||
} ${isPressed ? "bg-neutral-100" : "bg-other-background"} ${className}`} | ||
onClick={(event) => { | ||
if (!isLoading) handleClick(event); | ||
}} | ||
disabled={disabled} | ||
onMouseDown={() => { | ||
if (!isLoading) setIsPressed(true); | ||
}} | ||
onMouseUp={() => { | ||
if (!isLoading) setIsPressed(false); | ||
}} | ||
> | ||
<p className={`text-neutral-700 text-center ${textStyle ? textStyle : "s2"}`}>{text}</p> | ||
{isLoading ? ( | ||
<div className="animate-spin"> | ||
<Loader2 className="stroke-neutral-700" /> | ||
</div> | ||
) : ( | ||
<p | ||
className={`text-center ${ | ||
disabled ? "text-neutral-400" : isPressed ? "text-neutral-500" : "text-neutral-700" | ||
} ${textStyle ? textStyle : "s2"}`} | ||
> | ||
{text} | ||
</p> | ||
)} | ||
</button> | ||
); | ||
} |
Oops, something went wrong.