fix: improve Button component and replace HTML
This commit is contained in:
parent
fd642832c1
commit
4166abeb7d
|
|
@ -1,12 +1,19 @@
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { FC } from "react";
|
import { FC } from "react";
|
||||||
|
|
||||||
|
type Theme = keyof typeof colors;
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
className?: string;
|
className?: string;
|
||||||
theme?: "primary" | "glass";
|
theme?: Theme;
|
||||||
|
size?: "small" | "medium" | "large";
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
href?: string;
|
href?: string;
|
||||||
|
gradient?: {
|
||||||
|
from: string;
|
||||||
|
to: string;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Button: FC<Props> = ({
|
export const Button: FC<Props> = ({
|
||||||
|
|
@ -14,13 +21,18 @@ export const Button: FC<Props> = ({
|
||||||
className = "",
|
className = "",
|
||||||
onClick,
|
onClick,
|
||||||
href,
|
href,
|
||||||
|
size = "medium",
|
||||||
theme = "primary",
|
theme = "primary",
|
||||||
|
gradient,
|
||||||
}) => {
|
}) => {
|
||||||
const Component = (href ? Link : "button") as any;
|
const Component = (href ? Link : "button") as any;
|
||||||
|
|
||||||
|
const buttonColor = gradient ?? colors[theme];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Component
|
<Component
|
||||||
className={`${styles[theme]} cursor-pointer ${className}`}
|
className={`block cursor-pointer text-white rounded-xl font-semibold shadow-2xl transition-all duration-300 hover:scale-105
|
||||||
|
bg-gradient-to-r ${buttonColor?.from} ${buttonColor?.to} cursor-pointer ${sizes[size]} ${className}`}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
{...(href && { href })}
|
{...(href && { href })}
|
||||||
>
|
>
|
||||||
|
|
@ -29,9 +41,39 @@ export const Button: FC<Props> = ({
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const styles = {
|
const sizes = {
|
||||||
primary:
|
small: "px-4 py-2 text-sm",
|
||||||
"block relative bg-gradient-to-r from-purple-600 to-pink-600 hover:from-purple-500 hover:to-pink-500 text-white px-8 py-4 rounded-xl font-semibold text-lg shadow-2xl transition-all duration-300 hover:scale-105",
|
medium: "px-8 py-4 text-lg",
|
||||||
glass:
|
large: "px-12 py-6 text-xl",
|
||||||
"p-3 rounded-xl bg-gradient-to-br from-white/15 via-white/8 to-white/12 border border-white/20 transition-all duration-300 hover:bg-gradient-to-br hover:from-white/25 hover:to-white/15 hover:scale-105 shadow-lg shadow-black/20",
|
};
|
||||||
|
|
||||||
|
const colors = {
|
||||||
|
primary: {
|
||||||
|
from: "from-purple-600 to-pink-600 hover:from-purple-500 hover:to-pink-500",
|
||||||
|
to: "to-emerald-600 hover:to-emerald-500",
|
||||||
|
},
|
||||||
|
glass: {
|
||||||
|
from: "from-white/15 via-white/8 to-white/12",
|
||||||
|
to: "to-white/15 hover:to-white/10",
|
||||||
|
},
|
||||||
|
rose: {
|
||||||
|
from: "from-rose-600/90 hover:from-rose-500/90",
|
||||||
|
to: "to-pink-600/90 hover:to-pink-500/90",
|
||||||
|
},
|
||||||
|
emerald: {
|
||||||
|
from: "from-emerald-600/90 hover:from-emerald-500/90",
|
||||||
|
to: "to-teal-600/90 hover:to-teal-500/90",
|
||||||
|
},
|
||||||
|
purple: {
|
||||||
|
from: "from-purple-600/90 hover:from-purple-500/90",
|
||||||
|
to: "to-pink-600/90 hover:to-pink-500/90",
|
||||||
|
},
|
||||||
|
pink: {
|
||||||
|
from: "from-pink-600/90 hover:from-pink-500/90",
|
||||||
|
to: "to-emerald-600/90 hover:to-emerald-500/90",
|
||||||
|
},
|
||||||
|
teal: {
|
||||||
|
from: "from-teal-600/90 hover:from-teal-500/90",
|
||||||
|
to: "to-emerald-600/90 hover:to-emerald-500/90",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
"use client";
|
"use client";
|
||||||
import { FC, useState } from "react";
|
import { FC, useState } from "react";
|
||||||
import Link from "next/link";
|
|
||||||
import { MdFavorite } from "react-icons/md";
|
import { MdFavorite } from "react-icons/md";
|
||||||
import { RxEyeOpen } from "react-icons/rx";
|
import { RxEyeOpen } from "react-icons/rx";
|
||||||
import { FaFire, FaTrash, FaInfoCircle } from "react-icons/fa";
|
import { FaFire, FaTrash, FaInfoCircle } from "react-icons/fa";
|
||||||
import { RiCalendarCheckLine, RiCalendarScheduleLine } from "react-icons/ri";
|
import { RiCalendarCheckLine, RiCalendarScheduleLine } from "react-icons/ri";
|
||||||
import { Movie } from "@/types/global";
|
import { Movie } from "@/types/global";
|
||||||
|
import { Button } from "../../Button";
|
||||||
|
|
||||||
interface AuroraLayoutProps extends Movie {
|
interface AuroraLayoutProps extends Movie {
|
||||||
showDayCounter?: boolean;
|
showDayCounter?: boolean;
|
||||||
|
|
@ -153,13 +153,13 @@ export const AuroraLayout: FC<AuroraLayoutProps> = ({
|
||||||
{/* Magical action overlay */}
|
{/* Magical action overlay */}
|
||||||
{!alreadyInStore && (
|
{!alreadyInStore && (
|
||||||
<div className="absolute inset-0 bg-gradient-to-t from-black/80 via-purple-900/40 to-transparent opacity-0 group-hover:opacity-100 transition-all duration-500 flex items-center justify-center">
|
<div className="absolute inset-0 bg-gradient-to-t from-black/80 via-purple-900/40 to-transparent opacity-0 group-hover:opacity-100 transition-all duration-500 flex items-center justify-center">
|
||||||
<button
|
<Button
|
||||||
|
theme="primary"
|
||||||
onClick={handleAdd}
|
onClick={handleAdd}
|
||||||
className="relative overflow-hidden bg-gradient-to-r from-purple-600 to-pink-600 hover:from-purple-500 hover:to-pink-500 text-white px-8 py-4 rounded-2xl font-semibold text-lg shadow-2xl transform hover:scale-105 transition-all duration-300 group/btn"
|
className="relative overflow-hidden"
|
||||||
>
|
>
|
||||||
<span className="relative z-10">Dodaj do listy</span>
|
<span className="relative z-10">Dodaj do listy</span>
|
||||||
<div className="absolute inset-0 bg-gradient-to-r from-white/20 to-transparent opacity-0 group-hover/btn:opacity-100 transition-opacity duration-300"></div>
|
</Button>
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</figure>
|
</figure>
|
||||||
|
|
@ -225,15 +225,15 @@ export const AuroraLayout: FC<AuroraLayoutProps> = ({
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Zobacz więcej button */}
|
{/* Zobacz więcej button */}
|
||||||
<Link
|
<Button
|
||||||
|
theme="teal"
|
||||||
|
size="small"
|
||||||
href={`/film/${id}`}
|
href={`/film/${id}`}
|
||||||
className="transform hover:scale-105 transition-all duration-300 mt-4 flex justify-center"
|
className="transform hover:scale-105 transition-all duration-300 mt-4 flex justify-center items-center gap-2"
|
||||||
>
|
>
|
||||||
<div className="inline-flex items-center gap-2 bg-gradient-to-r from-purple-600/90 to-pink-600/90 hover:from-purple-500 hover:to-pink-500 px-3 py-2 rounded-lg text-white text-sm font-medium shadow-lg border border-white/10 transition-all duration-300">
|
<FaInfoCircle size={14} />
|
||||||
<FaInfoCircle size={14} />
|
<span>Zobacz więcej</span>
|
||||||
<span>Zobacz więcej</span>
|
</Button>
|
||||||
</div>
|
|
||||||
</Link>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Decorative border glow */}
|
{/* Decorative border glow */}
|
||||||
|
|
|
||||||
|
|
@ -201,22 +201,27 @@ export const HeroMovie: FC<Props> = ({ movieDetails }) => {
|
||||||
{/* Action buttons */}
|
{/* Action buttons */}
|
||||||
<div className="flex gap-4 flex-wrap">
|
<div className="flex gap-4 flex-wrap">
|
||||||
<Button
|
<Button
|
||||||
className={`flex items-center gap-3 ${
|
gradient={
|
||||||
isInStore
|
isInStore
|
||||||
? "bg-gradient-to-r from-emerald-600 to-teal-600 hover:from-emerald-500 hover:to-teal-500"
|
? {
|
||||||
: ""
|
from: "from-purple-600 hover:from-purple-500",
|
||||||
}`}
|
to: "to-emerald-600 hover:to-emerald-500",
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
from: "from-purple-600 hover:from-purple-500",
|
||||||
|
to: "to-pink-600 hover:to-pink-500",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
className={`flex items-center gap-3`}
|
||||||
onClick={handleAddToList}
|
onClick={handleAddToList}
|
||||||
>
|
>
|
||||||
<FaBookmark />
|
<FaBookmark />
|
||||||
{isInStore ? "Usuń z listy" : "Dodaj do listy"}
|
{isInStore ? "Usuń z listy" : "Dodaj do listy"}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
theme="glass"
|
theme={isFavorite ? "rose" : "glass"}
|
||||||
className={`flex items-center gap-3 ${
|
className={`flex items-center gap-3 ${
|
||||||
isFavorite
|
isFavorite ? "bg-gradient-to-r border-rose-400/30" : ""
|
||||||
? "bg-gradient-to-r from-rose-600/90 to-pink-600/90 hover:from-rose-500/90 hover:to-pink-500/90 border-rose-400/30"
|
|
||||||
: ""
|
|
||||||
}`}
|
}`}
|
||||||
onClick={handleToggleFavorite}
|
onClick={handleToggleFavorite}
|
||||||
>
|
>
|
||||||
|
|
@ -224,11 +229,9 @@ export const HeroMovie: FC<Props> = ({ movieDetails }) => {
|
||||||
{isFavorite ? "Usuń z ulubionych" : "Dodaj do ulubionych"}
|
{isFavorite ? "Usuń z ulubionych" : "Dodaj do ulubionych"}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
theme="glass"
|
theme={isSeen ? "emerald" : "glass"}
|
||||||
className={`flex items-center gap-3 ${
|
className={`flex items-center gap-3 ${
|
||||||
isSeen
|
isSeen ? "bg-gradient-to-r border-emerald-400/30" : ""
|
||||||
? "bg-gradient-to-r from-emerald-600/90 to-teal-600/90 hover:from-emerald-500/90 hover:to-teal-500/90 border-emerald-400/30"
|
|
||||||
: ""
|
|
||||||
}`}
|
}`}
|
||||||
onClick={handleToggleSeen}
|
onClick={handleToggleSeen}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ export const RecommendedMovies: FC<Props> = ({ movies }) => {
|
||||||
<FaStar className="text-white" size={20} />
|
<FaStar className="text-white" size={20} />
|
||||||
</div>
|
</div>
|
||||||
<h2 className="text-3xl font-bold bg-gradient-to-r from-yellow-400 to-orange-400 bg-clip-text text-transparent">
|
<h2 className="text-3xl font-bold bg-gradient-to-r from-yellow-400 to-orange-400 bg-clip-text text-transparent">
|
||||||
Podobne filmy
|
Rekomendowane filmy
|
||||||
</h2>
|
</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ export const Search = () => {
|
||||||
<>
|
<>
|
||||||
<Button
|
<Button
|
||||||
theme="glass"
|
theme="glass"
|
||||||
|
size="small"
|
||||||
className="group relative"
|
className="group relative"
|
||||||
onClick={() => setIsSearchOpen(!isSearchOpen)}
|
onClick={() => setIsSearchOpen(!isSearchOpen)}
|
||||||
>
|
>
|
||||||
|
|
@ -71,6 +72,7 @@ export const Search = () => {
|
||||||
{/* Close button */}
|
{/* Close button */}
|
||||||
<Button
|
<Button
|
||||||
theme="glass"
|
theme="glass"
|
||||||
|
size="small"
|
||||||
className="absolute top-6 right-6 z-10 group hover:!bg-red-500/50"
|
className="absolute top-6 right-6 z-10 group hover:!bg-red-500/50"
|
||||||
onClick={handleClose}
|
onClick={handleClose}
|
||||||
>
|
>
|
||||||
|
|
@ -144,9 +146,8 @@ export const Search = () => {
|
||||||
{/* Show More Button */}
|
{/* Show More Button */}
|
||||||
{total_results > 4 && (
|
{total_results > 4 && (
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<div className="relative inline-block">
|
<div className="inline-block">
|
||||||
<div className="absolute inset-0 bg-gradient-to-r from-purple-500 to-cyan-500 rounded-xl blur-lg opacity-50"></div>
|
<Button href={`/search?s=${query}`}>
|
||||||
<Button href={`/search?s=${query}`} onClick={handleClose}>
|
|
||||||
<span className="flex items-center gap-2">
|
<span className="flex items-center gap-2">
|
||||||
Zobacz wszystkie ({total_results})
|
Zobacz wszystkie ({total_results})
|
||||||
</span>
|
</span>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue