File tree Expand file tree Collapse file tree 2 files changed +37
-17
lines changed Expand file tree Collapse file tree 2 files changed +37
-17
lines changed Original file line number Diff line number Diff line change 1
1
import Image from 'next/image' ;
2
- import Link from 'next/link ' ;
2
+ import Button from '../UI/Button.component ' ;
3
3
4
4
/**
5
5
* Renders Hero section for Index page
@@ -25,12 +25,12 @@ const Hero = () => (
25
25
< h1 className = "text-3xl md:text-4xl lg:text-5xl font-light text-white mb-6" >
26
26
Stripete Zig Zag Pute Sett
27
27
</ h1 >
28
- < Link
28
+ < Button
29
29
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
31
31
>
32
32
Se Utvalget
33
- </ Link >
33
+ </ Button >
34
34
</ div >
35
35
</ div >
36
36
</ section >
Original file line number Diff line number Diff line change 1
1
import { ReactNode } from 'react' ;
2
+ import Link from 'next/link' ;
2
3
3
4
type TButtonColors = 'red' | 'blue' ;
4
5
@@ -8,6 +9,8 @@ interface IButtonProps {
8
9
color ?: TButtonColors ;
9
10
children : ReactNode ;
10
11
fullWidth ?: boolean ;
12
+ isHero ?: boolean ;
13
+ href ?: string ;
11
14
}
12
15
13
16
/**
@@ -26,21 +29,38 @@ const Button = ({
26
29
color = 'blue' ,
27
30
children,
28
31
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
- ${
32
+ isHero = false ,
33
+ href ,
34
+ } : IButtonProps ) => {
35
+ const buttonClasses = isHero
36
+ ? 'inline-block px-8 py-4 text-sm tracking-wider uppercase bg-white text-gray-900 hover:bg-gray-400 hover:text-white'
37
+ : `px-2 lg:px-4 py-2 font-bold border border-gray-400 border-solid rounded text-white ${
35
38
color === 'blue'
36
39
? 'bg-blue-500 hover:bg-blue-600'
37
40
: 'bg-red-500 hover:bg-red-600'
38
- }
39
- ${ fullWidth ? 'w-full md:w-auto' : '' }
40
- ` }
41
- >
42
- { children }
43
- </ button >
44
- ) ;
41
+ } `;
42
+
43
+ const classes = `${ buttonClasses } ease-in-out transition-all duration-300 disabled:opacity-50 ${
44
+ fullWidth ? 'w-full md:w-auto' : ''
45
+ } `;
46
+
47
+ if ( href && isHero ) {
48
+ return (
49
+ < Link href = { href } className = { classes } >
50
+ { children }
51
+ </ Link >
52
+ ) ;
53
+ }
54
+
55
+ return (
56
+ < button
57
+ onClick = { handleButtonClick }
58
+ disabled = { buttonDisabled }
59
+ className = { classes }
60
+ >
61
+ { children }
62
+ </ button >
63
+ ) ;
64
+ } ;
45
65
46
66
export default Button ;
You can’t perform that action at this time.
0 commit comments