From 2da9b05f3616959d7877eb0c765d88a31f164289 Mon Sep 17 00:00:00 2001 From: Marvell69 Date: Wed, 27 May 2026 23:51:50 +0100 Subject: [PATCH] added layout guard --- src/components/common/CreatorBio.tsx | 7 +++++++ .../common/CreatorSocialLinksList.tsx | 7 +++++++ .../common/EmptyTransactionTimelineState.tsx | 17 ++++++++++++++--- src/components/common/MarketplaceSection.tsx | 7 +++++++ src/components/common/SectionDivider.tsx | 7 +++++++ src/pages/LandingPage.tsx | 1 + 6 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/components/common/CreatorBio.tsx b/src/components/common/CreatorBio.tsx index 5b8bd973..7408e32f 100644 --- a/src/components/common/CreatorBio.tsx +++ b/src/components/common/CreatorBio.tsx @@ -7,6 +7,8 @@ interface CreatorBioProps { fallback?: string; /** Variant — `card` is muted/italic for list rows, `profile` is slightly more prominent for the detail header. */ variant?: 'card' | 'profile'; + /** If true, returns null instead of a fallback when bio is missing. */ + allowEmpty?: boolean; className?: string; } @@ -33,12 +35,17 @@ const CreatorBio: React.FC = ({ bio, fallback = DEFAULT_FALLBACK, variant = 'card', + allowEmpty = false, className, }) => { const trimmed = bio?.trim(); const styles = variantClasses[variant]; if (!trimmed) { + if (allowEmpty) { + return null; + } + return (

{fallback} diff --git a/src/components/common/CreatorSocialLinksList.tsx b/src/components/common/CreatorSocialLinksList.tsx index 10b71a1f..a4fc1e47 100644 --- a/src/components/common/CreatorSocialLinksList.tsx +++ b/src/components/common/CreatorSocialLinksList.tsx @@ -12,6 +12,8 @@ interface CreatorSocialLinksListProps { handle?: string; /** Override the default empty-state placeholder copy. */ emptyPlaceholder?: string; + /** If true, returns null instead of a placeholder when handle is missing. */ + allowEmpty?: boolean; className?: string; } @@ -27,9 +29,14 @@ interface SocialLinkItem { const CreatorSocialLinksList: React.FC = ({ handle, emptyPlaceholder = DEFAULT_EMPTY_PLACEHOLDER, + allowEmpty = false, className, }) => { if (!handle?.trim()) { + if (allowEmpty) { + return null; + } + return (

`${hash.slice(0, 8)}...${hash.slice(-6)}`; -const EmptyTransactionTimelineState: React.FC = () => { +interface EmptyTransactionTimelineStateProps { + /** Optional transaction data. If provided and empty, the component returns null. */ + data?: TimelineEntry[]; +} + +const EmptyTransactionTimelineState: React.FC = ({ + data = DEFAULT_TIMELINE_ENTRIES, +}) => { const [copyStateById, setCopyStateById] = useState>({}); + if (!data || data.length === 0) { + return null; + } + const copyTxHash = async (entryId: string, txHash: string) => { try { await navigator.clipboard.writeText(txHash); @@ -77,7 +88,7 @@ const EmptyTransactionTimelineState: React.FC = () => {
- {TIMELINE_ENTRIES.map(entry => { + {data.map(entry => { const copyState = copyStateById[entry.id] ?? 'idle'; const isSuccess = copyState === 'success'; const isError = copyState === 'error'; diff --git a/src/components/common/MarketplaceSection.tsx b/src/components/common/MarketplaceSection.tsx index 4bb47dac..36f81c9c 100644 --- a/src/components/common/MarketplaceSection.tsx +++ b/src/components/common/MarketplaceSection.tsx @@ -28,6 +28,8 @@ interface MarketplaceSectionProps React.HTMLAttributes, VariantProps { as?: 'section' | 'div' | 'header' | 'footer'; + /** If true, the section and its spacing/dividers will not be rendered. */ + isEmpty?: boolean; } const MarketplaceSection: React.FC = ({ @@ -35,9 +37,14 @@ const MarketplaceSection: React.FC = ({ spacing, container, className, + isEmpty = false, as: Tag = 'section', ...props }) => { + if (isEmpty) { + return null; + } + return ( = { @@ -18,7 +20,12 @@ function SectionDivider({ title, spacing = 'default', className, + isEmpty = false, }: SectionDividerProps) { + if (isEmpty) { + return null; + } + return (