Skip to content

Commit c0c845b

Browse files
authored
Merge pull request #1397 from w3bdesign/develop
Fix cart and Hero button
2 parents 0ee6160 + 88db27a commit c0c845b

File tree

3 files changed

+44
-21
lines changed

3 files changed

+44
-21
lines changed

src/components/Header/Cart.component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const Cart = ({ stickyNav }: ICartProps) => {
5050

5151
{productCount && (
5252
<span
53-
className={`w-6 h-6 pb-2 -mt-5 !ml-auto text-center rounded-full
53+
className={`w-6 h-6 pb-2 -mt-5 !-ml-2 text-center rounded-full
5454
${stickyNav ? 'text-black bg-white' : 'text-white bg-black'}`}
5555
>
5656
{productCount}

src/components/Index/Hero.component.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Image from 'next/image';
2-
import Link from 'next/link';
2+
import Button from '../UI/Button.component';
33

44
/**
55
* Renders Hero section for Index page
@@ -25,12 +25,12 @@ const Hero = () => (
2525
<h1 className="text-3xl md:text-4xl lg:text-5xl font-light text-white mb-6">
2626
Stripete Zig Zag Pute Sett
2727
</h1>
28-
<Link
28+
<Button
2929
href="/produkter"
30-
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"
30+
isHero
3131
>
3232
Se Utvalget
33-
</Link>
33+
</Button>
3434
</div>
3535
</div>
3636
</section>
Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ReactNode } from 'react';
2+
import Link from 'next/link';
23

34
type TButtonColors = 'red' | 'blue';
45

@@ -8,6 +9,8 @@ interface IButtonProps {
89
color?: TButtonColors;
910
children: ReactNode;
1011
fullWidth?: boolean;
12+
isHero?: boolean;
13+
href?: string;
1114
}
1215

1316
/**
@@ -26,21 +29,41 @@ const Button = ({
2629
color = 'blue',
2730
children,
2831
fullWidth = false,
29-
}: IButtonProps) => (
30-
<button
31-
onClick={handleButtonClick}
32-
disabled={buttonDisabled}
33-
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
34-
${
35-
color === 'blue'
36-
? 'bg-blue-500 hover:bg-blue-600'
37-
: 'bg-red-500 hover:bg-red-600'
38-
}
39-
${fullWidth ? 'w-full md:w-auto' : ''}
40-
`}
41-
>
42-
{children}
43-
</button>
44-
);
32+
isHero = false,
33+
href,
34+
}: IButtonProps) => {
35+
const getColorClasses = (buttonColor: TButtonColors) => {
36+
if (buttonColor === 'blue') {
37+
return 'bg-blue-500 hover:bg-blue-600';
38+
}
39+
return 'bg-red-500 hover:bg-red-600';
40+
};
41+
42+
const buttonClasses = isHero
43+
? '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'
44+
: `px-2 lg:px-4 py-2 font-bold border border-gray-400 border-solid rounded text-white ${getColorClasses(color)}`;
45+
46+
const classes = `${buttonClasses} ease-in-out transition-all duration-300 disabled:opacity-50 ${
47+
fullWidth ? 'w-full md:w-auto' : ''
48+
}`;
49+
50+
if (href && isHero) {
51+
return (
52+
<Link href={href} className={classes}>
53+
{children}
54+
</Link>
55+
);
56+
}
57+
58+
return (
59+
<button
60+
onClick={handleButtonClick}
61+
disabled={buttonDisabled}
62+
className={classes}
63+
>
64+
{children}
65+
</button>
66+
);
67+
};
4568

4669
export default Button;

0 commit comments

Comments
 (0)