diff --git a/packages/frontend/src/components/project-details-related-project-banner.tsx b/packages/frontend/src/components/project-details-related-project-banner.tsx index e0f1a1e93c7..e33fbe7bf25 100644 --- a/packages/frontend/src/components/project-details-related-project-banner.tsx +++ b/packages/frontend/src/components/project-details-related-project-banner.tsx @@ -1,29 +1,37 @@ import Image from 'next/image' import Link from 'next/link' +import { cn } from '~/utils/cn' export type ProjectDetailsRelatedProjectBannerProps = { text: string project: { name: string - type: 'scaling' | 'bridges' + type: 'scaling' | 'bridges' | 'data-availability' slug: string } + className?: string } export function ProjectDetailsRelatedProjectBanner({ text, project, + className, }: ProjectDetailsRelatedProjectBannerProps) { const href = `/${project.type}/projects/${project.slug}` as const return ( -
+
{text}{' '} {`${project.name}{' '} )} + {item.relatedProjectBanner && ( + + )}
))} diff --git a/packages/frontend/src/utils/project/technology/get-technology-section.ts b/packages/frontend/src/utils/project/technology/get-technology-section.ts index 3007482655e..e1123a794d7 100644 --- a/packages/frontend/src/utils/project/technology/get-technology-section.ts +++ b/packages/frontend/src/utils/project/technology/get-technology-section.ts @@ -1,9 +1,17 @@ +import { daLayers } from '@l2beat/config' import { type Bridge, type Layer2, type Layer3 } from '@l2beat/config' import { compact } from 'lodash' +import { env } from '~/env' import { getTechnologySectionProps } from './get-technology-section-props' import { makeTechnologyChoice } from './make-technology-section' export function getScalingTechnologySection(project: Layer2 | Layer3) { + const relatedDaProjects = daLayers.filter( + (layer) => + layer.usedIn.some((usedIn) => usedIn.id === project.id) && + layer.bridges.length > 0, + ) + const items = compact([ project.technology.stateCorrectness && makeTechnologyChoice( @@ -19,6 +27,21 @@ export function getScalingTechnologySection(project: Layer2 | Layer3) { makeTechnologyChoice( 'data-availability', project.technology.dataAvailability, + { + relatedProjectBanner: + env.NEXT_PUBLIC_FEATURE_FLAG_DA_BEAT && + relatedDaProjects.length < 2 && + relatedDaProjects[0] + ? { + text: 'Learn more about the DA layer here:', + project: { + name: relatedDaProjects[0].display.name, + slug: `${relatedDaProjects[0].display.slug}/${relatedDaProjects[0].bridges[0]?.display.slug}`, + type: 'data-availability', + }, + } + : undefined, + }, ), ]) diff --git a/packages/frontend/src/utils/project/technology/make-technology-section.ts b/packages/frontend/src/utils/project/technology/make-technology-section.ts index e31946e4803..9647e47bc02 100644 --- a/packages/frontend/src/utils/project/technology/make-technology-section.ts +++ b/packages/frontend/src/utils/project/technology/make-technology-section.ts @@ -1,9 +1,13 @@ import { type ScalingProjectTechnologyChoice } from '@l2beat/config' +import { type ProjectDetailsRelatedProjectBannerProps } from '~/components/project-details-related-project-banner' import { type TechnologyChoice } from '../../../components/projects/sections/technology-section' export function makeTechnologyChoice( id: string, item: ScalingProjectTechnologyChoice, + options: { + relatedProjectBanner?: ProjectDetailsRelatedProjectBannerProps + } = {}, ): TechnologyChoice { const risks = item.risks.map((risk) => ({ text: `${risk.category} ${risk.text}`, @@ -18,5 +22,6 @@ export function makeTechnologyChoice( isUnderReview: !!item.isUnderReview, references: item.references, risks, + ...options, } }