diff --git a/src/blocks/Showcase/Component.tsx b/src/blocks/Showcase/Component.tsx
index 8e7fc71..4ce1076 100644
--- a/src/blocks/Showcase/Component.tsx
+++ b/src/blocks/Showcase/Component.tsx
@@ -1,15 +1,17 @@
'use client'
-import React from 'react'
+import React, { useState } from 'react'
import Image from 'next/image'
import { Container } from '@/components/ui/Container'
import type { Media as MediaType } from '@/payload-types'
+// Updated type to include category for the 15-project Lab structure
type ShowcaseItem = {
image?: MediaType | null
imageUrl?: string
title: string
description?: string
+ category: 'engineering' | 'design'
tags?: { tag: string }[]
links?: { label: string; url: string; newTab?: boolean }[]
}
@@ -20,125 +22,119 @@ type ShowcaseBlockProps = {
items?: ShowcaseItem[]
}
-function ShowcaseImage(props: { item: ShowcaseItem }): React.ReactElement {
- const item = props.item
+function ShowcaseImage({ item }: { item: ShowcaseItem }): React.ReactElement {
const image = item.image
const imageUrl = image != null && typeof image === 'object' && 'url' in image ? image.url : null
const imageAlt =
image != null && typeof image === 'object' && 'alt' in image ? image.alt : item.title
- if (imageUrl != null) {
- const imgEl = (
-
+ const imgContent = (
+
+ {imageUrl ? (
- {item.imageUrl && (
+ ) : (
+
+
+ Coming soon
+
+ )}
+ {imageUrl && (
+ <>
- )}
- {item.imageUrl && (
-
+
- )}
-
- )
-
- if (item.imageUrl) {
- return (
-
- {imgEl}
-
- )
- }
- return imgEl
- }
-
- return (
-
-
- Coming soon
+ >
+ )}
)
+
+ return item.imageUrl ? (
+
+ {imgContent}
+
+ ) : (
+ imgContent
+ )
}
export function ShowcaseBlock(props: ShowcaseBlockProps): React.ReactElement | null {
const { heading, subheading, items } = props
+ const [filter, setFilter] = useState<'all' | 'engineering' | 'design'>('all')
if (!Array.isArray(items) || items.length === 0) return null
+ const filteredItems = filter === 'all' ? items : items.filter((item) => item.category === filter)
+
return (
- // Replaced hardcoded max-w-5xl and section with the unified Container
- {(heading || subheading) && (
-
+
+
{heading &&
{heading}
}
{subheading &&
{subheading}
}
- )}
-
- {items.map(function (item, i) {
- const isFeatured = i === 0 && items.length > 1
- return (
-
+ {(['all', 'engineering', 'design'] as const).map((f) => (
+
+ ))}
+
+
+
+
+ {filteredItems.map((item, i) => (
+
+
+
+
{item.title}
+ {item.description && (
+
{item.description}
+ )}
+ {item.tags && item.tags.length > 0 && (
+
+ {item.tags.map((t, j) => (
+
+ {t.tag}
+
+ ))}
+
+ )}
+ {item.links && item.links.length > 0 && (
+
+ )}
- )
- })}
+
+ ))}
)