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 11import 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 >
Original file line number Diff line number Diff line change 11import { ReactNode } from 'react' ;
2+ import Link from 'next/link' ;
23
34type 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,38 @@ 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- ${
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 ${
3538 color === 'blue'
3639 ? 'bg-blue-500 hover:bg-blue-600'
3740 : '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+ } ;
4565
4666export default Button ;
You can’t perform that action at this time.
0 commit comments