From fbea66eba930eb8e8e8cf8894f677a0fc63fc1d4 Mon Sep 17 00:00:00 2001 From: Giancarlo Buomprisco Date: Fri, 29 Nov 2024 09:07:26 +0100 Subject: [PATCH] Added a "Coming Soon" marketing component (#85) --- .../ui/src/makerkit/marketing/coming-soon.tsx | 112 ++++++++++++++++++ packages/ui/src/makerkit/marketing/index.tsx | 1 + 2 files changed, 113 insertions(+) create mode 100644 packages/ui/src/makerkit/marketing/coming-soon.tsx diff --git a/packages/ui/src/makerkit/marketing/coming-soon.tsx b/packages/ui/src/makerkit/marketing/coming-soon.tsx new file mode 100644 index 000000000..9b8b5a105 --- /dev/null +++ b/packages/ui/src/makerkit/marketing/coming-soon.tsx @@ -0,0 +1,112 @@ +import React, { forwardRef } from 'react'; + +import { Button } from '@kit/ui/button'; +import { cn } from '@kit/ui/utils'; + +import { CtaButton } from './cta-button'; +import { GradientSecondaryText } from './gradient-secondary-text'; +import { HeroTitle } from './hero-title'; + +const ComingSoonHeading = React.forwardRef< + HTMLHeadingElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( + +)); +ComingSoonHeading.displayName = 'ComingSoonHeading'; + +const ComingSoonText = React.forwardRef< + HTMLParagraphElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( + +)); +ComingSoonText.displayName = 'ComingSoonText'; + +const ComingSoonButton = React.forwardRef< + HTMLButtonElement, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)); +ComingSoonButton.displayName = 'ComingSoonButton'; + +const ComingSoon = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ children, className, ...props }, ref) => { + const childrenArray = React.Children.toArray(children); + + const logo = childrenArray.find( + (child) => React.isValidElement(child) && child.type === ComingSoonLogo, + ); + + const heading = childrenArray.find( + (child) => React.isValidElement(child) && child.type === ComingSoonHeading, + ); + + const text = childrenArray.find( + (child) => React.isValidElement(child) && child.type === ComingSoonText, + ); + + const button = childrenArray.find( + (child) => React.isValidElement(child) && child.type === ComingSoonButton, + ); + + const cmps = [ + ComingSoonHeading, + ComingSoonText, + ComingSoonButton, + ComingSoonLogo, + ]; + + const otherChildren = childrenArray.filter( + (child) => + React.isValidElement(child) && + !cmps.includes(child.type as (typeof cmps)[number]), + ); + + return ( +
+ {logo} + +
+ {heading} + +
{text}
+ + {button} + + {otherChildren} +
+
+ ); +}); +ComingSoon.displayName = 'ComingSoon'; + +const ComingSoonLogo = forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)); +ComingSoonLogo.displayName = 'ComingSoonLogo'; + +export { + ComingSoon, + ComingSoonHeading, + ComingSoonText, + ComingSoonButton, + ComingSoonLogo, +}; diff --git a/packages/ui/src/makerkit/marketing/index.tsx b/packages/ui/src/makerkit/marketing/index.tsx index c6cacbb3a..331382261 100644 --- a/packages/ui/src/makerkit/marketing/index.tsx +++ b/packages/ui/src/makerkit/marketing/index.tsx @@ -12,3 +12,4 @@ export * from './feature-grid'; export * from './feature-card'; export * from './newsletter-signup'; export * from './newsletter-signup-container'; +export * from './coming-soon'; \ No newline at end of file