Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cart #1397

Merged
merged 4 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Header/Cart.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const Cart = ({ stickyNav }: ICartProps) => {

{productCount && (
<span
className={`w-6 h-6 pb-2 -mt-5 !ml-auto text-center rounded-full
className={`w-6 h-6 pb-2 -mt-5 !-ml-2 text-center rounded-full
${stickyNav ? 'text-black bg-white' : 'text-white bg-black'}`}
>
{productCount}
Expand Down
8 changes: 4 additions & 4 deletions src/components/Index/Hero.component.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Image from 'next/image';
import Link from 'next/link';
import Button from '../UI/Button.component';

/**
* Renders Hero section for Index page
Expand All @@ -25,12 +25,12 @@ const Hero = () => (
<h1 className="text-3xl md:text-4xl lg:text-5xl font-light text-white mb-6">
Stripete Zig Zag Pute Sett
</h1>
<Link
<Button
href="/produkter"
className="inline-block px-8 py-4 text-sm tracking-wider uppercase bg-white text-gray-900 hover:bg-gray-100 transition-colors duration-200"
isHero
>
Se Utvalget
</Link>
</Button>
</div>
</div>
</section>
Expand Down
55 changes: 39 additions & 16 deletions src/components/UI/Button.component.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ReactNode } from 'react';
import Link from 'next/link';

type TButtonColors = 'red' | 'blue';

Expand All @@ -8,6 +9,8 @@ interface IButtonProps {
color?: TButtonColors;
children: ReactNode;
fullWidth?: boolean;
isHero?: boolean;
href?: string;
}

/**
Expand All @@ -26,21 +29,41 @@ const Button = ({
color = 'blue',
children,
fullWidth = false,
}: IButtonProps) => (
<button
onClick={handleButtonClick}
disabled={buttonDisabled}
className={`px-2 lg:px-4 py-2 font-bold bg-blue-500 border border-gray-400 border-solid rounded text-white ease-in-out transition-all duration-300 disabled:opacity-50
${
color === 'blue'
? 'bg-blue-500 hover:bg-blue-600'
: 'bg-red-500 hover:bg-red-600'
}
${fullWidth ? 'w-full md:w-auto' : ''}
`}
>
{children}
</button>
);
isHero = false,
href,
}: IButtonProps) => {
const getColorClasses = (buttonColor: TButtonColors) => {
if (buttonColor === 'blue') {
return 'bg-blue-500 hover:bg-blue-600';
}
return 'bg-red-500 hover:bg-red-600';
};

const buttonClasses = isHero
? 'inline-block px-8 py-4 text-sm tracking-wider uppercase bg-white bg-opacity-90 text-gray-900 hover:bg-gray-400 hover:bg-opacity-95 hover:text-white hover:shadow-md'
: `px-2 lg:px-4 py-2 font-bold border border-gray-400 border-solid rounded text-white ${getColorClasses(color)}`;

const classes = `${buttonClasses} ease-in-out transition-all duration-300 disabled:opacity-50 ${
fullWidth ? 'w-full md:w-auto' : ''
}`;

if (href && isHero) {
return (
<Link href={href} className={classes}>
{children}
</Link>
);
}

return (
<button
onClick={handleButtonClick}
disabled={buttonDisabled}
className={classes}
>
{children}
</button>
);
};

export default Button;
Loading