Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import React from "react";
import { IGatsbyImageData } from "gatsby-plugin-image";
import { Link } from "gatsby";
import FeatureComponent from "./feature/FeatureComponent";
interface Props {
title?: string;
content?: string;
image?: string | IGatsbyImageData;
idMap?: number;
layout?: 'left' | 'right';
backgroundImage?: string;
action?: {
label: string;
to: string;
};
custom?: JSX.Element;
}
const oClassName = {
'left' : {
'container': 'flex-col lg:flex-row',
'content': 'pt-10 lg:pl-10'
},
'right' : {
'container': 'flex-col-reverse lg:flex-row-reverse',
'content': 'pt-10 pb-10 lg:pr-10 lg:pb-0'
}
}
const Feature = (props: Props) => {
const {
layout='left',
title='',
content='',
image,
idMap,
backgroundImage,
action,
custom
} = props;
const className = oClassName[layout];
const bTextOnly = ( ! (idMap || image || custom));
const classNameContent = (bTextOnly) ? 'grow' : `lg:w-1/2 ${className['content']}`;
const classNameBackground = (backgroundImage) ? "bg-[url('" + backgroundImage + "')] bg-cover bg-no-repeat bg-center " : '';
return (
<div className={`flex ${className['container']} ${classNameBackground}`}>
{
! bTextOnly && (
<div className="h-[480px] lg:w-1/2">
<FeatureComponent
idMap={idMap}
image={image}
custom={custom}
/>
</div>
)
}
<div className={classNameContent}>
<h2 className="font-extrabold sm:text-4xl">{title}</h2>
<p className="text-xl text-gray-500 leading-8 pt-10 text-justify">{content}</p>
{
action && (
<Link
to={action.to}
className="btn btn-active mt-10"
>
{action.label}
</Link>
)
}
</div>
</div>
);
};
export default Feature;