| 1 |
import classNames from "classnames"; |
| 2 |
import { humanReadableTimeAgo } from "../../controls/controls"; |
| 3 |
import { formatDate, Icon, stringTrim } from "../shared/helpFn"; |
| 4 |
|
| 5 |
const TemplateOne = ({ |
| 6 |
data, |
| 7 |
tickerListStyle, |
| 8 |
tickerListStyleColor, |
| 9 |
tickerDate, |
| 10 |
tickerDateType, |
| 11 |
metaDateFormat, |
| 12 |
tickerImg, |
| 13 |
tickerImagePosition, |
| 14 |
tickerTitleListStyleEnble, |
| 15 |
titleLength, |
| 16 |
tickerImgShape, |
| 17 |
tickerTitleGlobalTypography, |
| 18 |
tickerDateGlobalTypography, |
| 19 |
}) => { |
| 20 |
const rawDate = data?.date; |
| 21 |
const postDateDefault = data?.post_date?.default; |
| 22 |
|
| 23 |
// Determine formatted date |
| 24 |
const date = |
| 25 |
// eslint-disable-next-line no-nested-ternary |
| 26 |
tickerDateType === "date" |
| 27 |
? metaDateFormat === "time_ago" |
| 28 |
? humanReadableTimeAgo(new Date(rawDate)) |
| 29 |
: postDateDefault // both 'default' and 'custom' fallback here |
| 30 |
: formatDate(rawDate, tickerDateType); |
| 31 |
|
| 32 |
return ( |
| 33 |
<div |
| 34 |
className={classNames( |
| 35 |
"sp-smart-post-ticker-title", |
| 36 |
tickerTitleGlobalTypography?.class ? tickerTitleGlobalTypography?.class : "" |
| 37 |
)} |
| 38 |
> |
| 39 |
{tickerTitleListStyleEnble && <Icon iconSourse={tickerListStyle} color={tickerListStyleColor} />} |
| 40 |
<div |
| 41 |
className={`sp-smart-post-ticker-title-img-wrapper sp-d-flex${ |
| 42 |
tickerImg ? " sp-img-" + tickerImagePosition : "" |
| 43 |
}`} |
| 44 |
> |
| 45 |
{tickerImg && ( |
| 46 |
<img |
| 47 |
src={data?.post_thumbnail_url || ""} |
| 48 |
alt={data?.post_thumbnail_url || data?.title} |
| 49 |
className={`sp-ticker-img sp-img-${tickerImgShape}`} |
| 50 |
/> |
| 51 |
)} |
| 52 |
<span> {data.title} </span> |
| 53 |
</div> |
| 54 |
|
| 55 |
{tickerDate && ( |
| 56 |
<span |
| 57 |
className={classNames( |
| 58 |
"ticker-date", |
| 59 |
tickerDateGlobalTypography?.class ? tickerDateGlobalTypography?.class : "" |
| 60 |
)} |
| 61 |
> |
| 62 |
{date} |
| 63 |
</span> |
| 64 |
)} |
| 65 |
</div> |
| 66 |
); |
| 67 |
}; |
| 68 |
|
| 69 |
export default TemplateOne; |
| 70 |
|