PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.8
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.8
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 2.3.5 2.3.6 2.4.0 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.16 2.4.17 2.4.18 2.4.19 2.4.2 2.4.20 2.4.21 All 88 releases
post-carousel / src / blocks / news-ticker / template.js

template.js in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.8, at src/blocks/news-ticker/template.js

70 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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