From 4197f205f4eee2003182ac6db33befff1109e3e4 Mon Sep 17 00:00:00 2001 From: Mackie Date: Wed, 3 Jun 2026 13:26:38 +0800 Subject: [PATCH] about --- src/blocks/AboutProfile/Component.tsx | 100 ++++++++++++++++++++++++++ src/blocks/AboutProfile/config.ts | 41 +++++++++++ src/blocks/RenderBlocks.tsx | 2 + src/collections/Pages/index.ts | 2 + src/payload-types.ts | 43 +++++++++++ 5 files changed, 188 insertions(+) create mode 100644 src/blocks/AboutProfile/Component.tsx create mode 100644 src/blocks/AboutProfile/config.ts diff --git a/src/blocks/AboutProfile/Component.tsx b/src/blocks/AboutProfile/Component.tsx new file mode 100644 index 0000000..04244e6 --- /dev/null +++ b/src/blocks/AboutProfile/Component.tsx @@ -0,0 +1,100 @@ +import React from 'react' +import { ImageMedia } from '../ImageMedia' // Adjust this path to wherever your ImageMedia file lives +import type { Media as MediaType } from '@/payload-types' + +type ButtonGroup = { + label?: string + url?: string + newTab?: boolean +} + +type AboutProfileBlockProps = { + imagePosition?: 'left' | 'right' + image?: MediaType | null + heading?: string + subheading?: string + body?: string + primaryButton?: ButtonGroup + secondaryButton?: ButtonGroup +} + +export function AboutProfileBlock({ + imagePosition = 'left', + image, + heading, + subheading, + body, + primaryButton, + secondaryButton, +}: AboutProfileBlockProps) { + const isRight = imagePosition === 'right' + + // Using your unified ImageMedia component handles S3 URLs, fallback widths, heights, and alt texts seamlessly + const imageEl = image ? ( +
+ +
+ ) : null + + const hasPrimary = primaryButton?.label && primaryButton?.url + const hasSecondary = secondaryButton?.label && secondaryButton?.url + + return ( +
+ {(heading || subheading) && ( +
+ {heading && ( +

+ {heading} +

+ )} + {subheading && ( +

{subheading}

+ )} +
+ )} + +
+ {imageEl} + +
+ {body && ( +

{body}

+ )} + + {(hasPrimary || hasSecondary) && ( +
+ {hasPrimary && ( + +