diff --git a/src/layouts/EditHomepage/HomepagePreview.tsx b/src/layouts/EditHomepage/HomepagePreview.tsx index aaf4017455..bb86e43de8 100644 --- a/src/layouts/EditHomepage/HomepagePreview.tsx +++ b/src/layouts/EditHomepage/HomepagePreview.tsx @@ -5,6 +5,7 @@ import { useParams } from "react-router-dom" import editorStyles from "styles/isomer-cms/pages/Editor.module.scss" +import { TemplateAnnouncementsSection } from "templates/homepage/AnnouncementsSection" import TemplateHeroSection from "templates/homepage/HeroSection" import TemplateInfobarSection from "templates/homepage/InfobarSection" import TemplateInfopicLeftSection from "templates/homepage/InfopicLeftSection" @@ -166,6 +167,19 @@ export const HomepagePreview = ({ )} )} + {/* Announcements section */} + {EditorHomepageFrontmatterSection.isAnnouncements(section) && ( + <> + } + /> + + )} ))} diff --git a/src/templates/homepage/AnnouncementsSection.tsx b/src/templates/homepage/AnnouncementsSection.tsx new file mode 100644 index 0000000000..bf1e562535 --- /dev/null +++ b/src/templates/homepage/AnnouncementsSection.tsx @@ -0,0 +1,170 @@ +import { forwardRef } from "react" + +import editorStyles from "styles/isomer-cms/pages/Editor.module.scss" + +import { getClassNames } from "templates/utils/stylingUtils" + +import { AnnouncementsSection } from "types/homepage" + +type TemplateAnnouncementsSectionProps = Omit< + AnnouncementsSection, + "announcement_items" +> & { + announcementItems: AnnouncementsSection["announcement_items"] + sectionIndex: number +} + +export const TemplateAnnouncementsSection = forwardRef< + HTMLDivElement, + TemplateAnnouncementsSectionProps +>( + ( + { + title, + subtitle, + announcementItems, + sectionIndex, + }: TemplateAnnouncementsSectionProps, + ref + ) => { + return ( +
+
+
+
+
+ <> + {subtitle && ( +

+ {subtitle} +

+ )} + {title && ( +

+ {title} +

+ )} + +
+ + {announcementItems && + announcementItems.map((announcement, index) => { + return ( + <> +
+
+

+ {announcement.title} +

+

+ {announcement.date} +

+
+
+

{announcement.announcement}

+ {announcement.link_text && announcement.link_url && ( +
+
+ {announcement.link_text} +
+
+ )} +
+
+ {announcementItems && + announcementItems.length === index + 1 ? ( +
+ ) : ( +
+ )} + + ) + })} + +
+
+
+
+
+ ) + } +)