|
| 1 | +import { useTranslation } from "next-i18next" |
| 2 | + |
| 3 | +import type { ChildOnlyProp } from "@/lib/types" |
| 4 | +import type { MdPageContent, UseCasesFrontmatter } from "@/lib/interfaces" |
| 5 | + |
| 6 | +// import BannerNotification from "@/components/Banners/BannerNotification" |
| 7 | +import { List as ButtonDropdownList } from "@/components/ButtonDropdown" |
| 8 | +import { List, ListItem } from "@/components/ui/list" |
| 9 | + |
| 10 | +import { getSummaryPoints } from "@/lib/utils/getSummaryPoints" |
| 11 | + |
| 12 | +import { ContentLayout } from "../ContentLayout" |
| 13 | + |
| 14 | +// UseCases layout components |
| 15 | +export const useCasesComponents = { |
| 16 | + // Export empty object if none needed |
| 17 | +} |
| 18 | + |
| 19 | +type UseCasesLayoutProps = ChildOnlyProp & |
| 20 | + Pick<MdPageContent, "slug" | "tocItems" | "contentNotTranslated"> & { |
| 21 | + frontmatter: UseCasesFrontmatter |
| 22 | + } |
| 23 | +export const UseCasesLayout = ({ |
| 24 | + children, |
| 25 | + frontmatter, |
| 26 | + slug, |
| 27 | + tocItems, |
| 28 | + contentNotTranslated, |
| 29 | +}: UseCasesLayoutProps) => { |
| 30 | + // const { asPath: relativePath } = useRouter() |
| 31 | + const { t } = useTranslation("template-usecase") |
| 32 | + |
| 33 | + const summaryPoints = getSummaryPoints(frontmatter) |
| 34 | + |
| 35 | + // const absoluteEditPath = getEditPath(relativePath) |
| 36 | + |
| 37 | + const dropdownLinks: ButtonDropdownList = { |
| 38 | + text: t("template-usecase:template-usecase-dropdown"), |
| 39 | + ariaLabel: t("template-usecase:template-usecase-dropdown-aria"), |
| 40 | + items: [ |
| 41 | + { |
| 42 | + text: t("template-usecase:template-usecase-dropdown-defi"), |
| 43 | + href: "/defi/", |
| 44 | + matomo: { |
| 45 | + eventCategory: "use cases menu", |
| 46 | + eventAction: "click", |
| 47 | + eventName: "defi", |
| 48 | + }, |
| 49 | + }, |
| 50 | + { |
| 51 | + text: t("template-usecase:template-usecase-dropdown-nft"), |
| 52 | + href: "/nft/", |
| 53 | + matomo: { |
| 54 | + eventCategory: "use cases menu", |
| 55 | + eventAction: "click", |
| 56 | + eventName: "nft", |
| 57 | + }, |
| 58 | + }, |
| 59 | + { |
| 60 | + text: t("template-usecase:template-usecase-dropdown-dao"), |
| 61 | + href: "/dao/", |
| 62 | + matomo: { |
| 63 | + eventCategory: "use cases menu", |
| 64 | + eventAction: "click", |
| 65 | + eventName: "dao", |
| 66 | + }, |
| 67 | + }, |
| 68 | + { |
| 69 | + text: t("template-usecase:template-usecase-dropdown-social-networks"), |
| 70 | + href: "/social-networks/", |
| 71 | + matomo: { |
| 72 | + eventCategory: "use cases menu", |
| 73 | + eventAction: "click", |
| 74 | + eventName: "social-networks", |
| 75 | + }, |
| 76 | + }, |
| 77 | + { |
| 78 | + text: t("template-usecase:template-usecase-dropdown-identity"), |
| 79 | + href: "/decentralized-identity/", |
| 80 | + matomo: { |
| 81 | + eventCategory: "use cases menu", |
| 82 | + eventAction: "click", |
| 83 | + eventName: "decentralized-identity", |
| 84 | + }, |
| 85 | + }, |
| 86 | + { |
| 87 | + text: t("template-usecase:template-usecase-dropdown-desci"), |
| 88 | + href: "/desci/", |
| 89 | + matomo: { |
| 90 | + eventCategory: "use cases menu", |
| 91 | + eventAction: "click", |
| 92 | + eventName: "desci", |
| 93 | + }, |
| 94 | + }, |
| 95 | + { |
| 96 | + text: t("template-usecase:template-usecase-dropdown-refi"), |
| 97 | + href: "/refi/", |
| 98 | + matomo: { |
| 99 | + eventCategory: "use cases menu", |
| 100 | + eventAction: "click", |
| 101 | + eventName: "refi", |
| 102 | + }, |
| 103 | + }, |
| 104 | + ], |
| 105 | + } |
| 106 | + |
| 107 | + return ( |
| 108 | + <ContentLayout |
| 109 | + dir={contentNotTranslated ? "ltr" : "unset"} |
| 110 | + tocItems={tocItems} |
| 111 | + dropdownLinks={dropdownLinks} |
| 112 | + maxDepth={frontmatter.sidebarDepth} |
| 113 | + heroProps={{ |
| 114 | + ...frontmatter, |
| 115 | + breadcrumbs: { slug, startDepth: 1 }, |
| 116 | + heroImg: frontmatter.image, |
| 117 | + description: ( |
| 118 | + <div> |
| 119 | + <List> |
| 120 | + {summaryPoints.map((point, idx) => ( |
| 121 | + <ListItem key={idx}>{point}</ListItem> |
| 122 | + ))} |
| 123 | + </List> |
| 124 | + </div> |
| 125 | + ), |
| 126 | + }} |
| 127 | + > |
| 128 | + {/* TODO: Add back in when we figure out how to handle this case inside the ContentLayout */} |
| 129 | + {/* <BannerNotification shouldShow className="z-sticky max-lg:hidden"> |
| 130 | + <Emoji text=":pencil:" className="me-4 shrink-0 text-2xl" /> |
| 131 | + <Text m={0}> |
| 132 | + {t("template-usecase:template-usecase-banner")}{" "} |
| 133 | + <InlineLink href={absoluteEditPath}> |
| 134 | + {t("template-usecase-edit-link")} |
| 135 | + </InlineLink> |
| 136 | + </Text> |
| 137 | + </BannerNotification> */} |
| 138 | + {children} |
| 139 | + </ContentLayout> |
| 140 | + ) |
| 141 | +} |
0 commit comments