Newer
Older
import React from "react";
import { IGatsbyImageData } from "gatsby-plugin-image";
interface Props {
title?: string;
content?: string;
image?: string | IGatsbyImageData;
idMap?: number;
layout?: 'left' | 'right';
backgroundImage?: string;
action?: {
interface FeatureComponentProps {
image?: string | IGatsbyImageData;
idMap?: number;
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 FeatureComponent = (props: FeatureComponentProps) => {
const {
image,
idMap,
custom
} = props;
if (idMap) {
return (
<>
<Map
idMap={idMap}
/>
</>
)
}
if (image) {
return (
<>
image={image}
/>
</>
)
}
return (
<>
{custom && custom}
</>
);
}
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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>