@levo-so/blocks 0.1.81 → 0.1.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,93 @@
1
+ import type { ILevoBlockBaseProps } from "@levo-so/studio";
2
+ import {
3
+ Box,
4
+ Button,
5
+ Container,
6
+ Heading,
7
+ Icon,
8
+ Image,
9
+ Section,
10
+ Typography,
11
+ useContentEngine,
12
+ } from "@levo-so/studio";
13
+ import dayjs from "dayjs";
14
+
15
+ import { ClientOnly } from "../event/ClientOnly";
16
+ import type { ICards21Content } from "./cards-21.schema";
17
+
18
+ const Cards21: React.FC<ILevoBlockBaseProps<ICards21Content>> = () => {
19
+ const { data, query, setQuery, meta } = useContentEngine("events");
20
+
21
+ const handleNext = () => setQuery({ page: (query?.page || 1) + 1 });
22
+ const handlePrevious = () => setQuery({ page: Math.max(1, (query?.page || 1) - 1) });
23
+
24
+ return (
25
+ <Section elementKey="layout">
26
+ <Container elementKey="container">
27
+ <Box elementKey="header-container">
28
+ <Heading elementKey="title" />
29
+ <Button elementKey="cta-button" />
30
+ </Box>
31
+
32
+ <Box elementKey="events_levoGroup" data-levo_group>
33
+ {(data || [])?.map((item: any, index: number) => (
34
+ <Box
35
+ key={`events-listing-element-${index}`}
36
+ data-levo_group_item
37
+ elementKey={`events.${index}.eventWrapper`}
38
+ >
39
+ <Image elementKey={`events.${index}.image`} alt="event poster" />
40
+ <Box elementKey={`events.${index}.text-wrapper`}>
41
+ <Box elementKey={`events.${index}.text-container`}>
42
+ <Box elementKey={`events.${index}.date-wrapper`}>
43
+ <Icon elementKey={`events.${index}.date-icon`} />
44
+ <Typography elementKey={`events.${index}.publishedAt-header`}>
45
+ <ClientOnly>
46
+ {dayjs(item?.["publishedAt-header"]).format("MMM D, YYYY")}
47
+ </ClientOnly>
48
+ </Typography>
49
+ </Box>
50
+
51
+ <Box elementKey={`events.${index}.author-wrapper`}>
52
+ <Icon elementKey={`events.${index}.author-image`} />
53
+ <Typography elementKey={`events.${index}.author-name`} />
54
+ </Box>
55
+ </Box>
56
+
57
+ <Box elementKey={`events.${index}.content-container`}>
58
+ <Typography elementKey={`events.${index}.title`} />
59
+ <Typography elementKey={`events.${index}.description`} />
60
+ <Typography elementKey={`events.${index}.publishedAt`}>
61
+ <ClientOnly>{dayjs(item?.publishedAt).format("MMM D, YYYY")}</ClientOnly>
62
+ </Typography>
63
+
64
+ <Button elementKey={`events.${index}.cta`} />
65
+ </Box>
66
+ </Box>
67
+ </Box>
68
+ ))}
69
+ </Box>
70
+ {(meta?.pages || 0) > 1 && (
71
+ <Box elementKey="paginationWrapper">
72
+ <Button
73
+ elementKey="paginationLeftButton"
74
+ disabled={query?.page === 1}
75
+ onClick={handlePrevious}
76
+ />
77
+
78
+ <Typography elementKey="paginationText">
79
+ {`${query?.page || 1}/${meta?.pages || 0}`}
80
+ </Typography>
81
+ <Button
82
+ elementKey="paginationRightButton"
83
+ onClick={handleNext}
84
+ disabled={query?.page === meta?.pages}
85
+ />
86
+ </Box>
87
+ )}
88
+ </Container>
89
+ </Section>
90
+ );
91
+ };
92
+
93
+ export default Cards21;