Skip to content

Commit

Permalink
feat(SaleHeaderBanner): L3-4648 add countdown to sale header banner f…
Browse files Browse the repository at this point in the history
…or timed auctions
  • Loading branch information
Aaron Hill authored and Aaron Hill committed Nov 25, 2024
1 parent 97fb256 commit 5112f2d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/patterns/SaleHeaderBanner/SaleHeaderBanner.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,17 @@ export const Closed = (props: SaleHeaderBannerProps) => (
<SaleHeaderBrowseAuctions />
</SaleHeaderBanner>
);

export const TimedAuction = (props: SaleHeaderBannerProps) => (
<SaleHeaderBanner
{...props}
auctionTitle="Modern & Contemporary Art: Online Auction, New York"
imageSrcUrl="https://assets.phillips.com/image/upload/t_Website_AuctionPageHero/v1726172550/auctions/NY090324/NY090324.jpg"
occurrenceInformation={[{ date: '10:00am EDT, 4 Sep 2024', occurrenceLabel: 'Lots Begin to Close' }]}
auctionEndTime={addMinutes(new Date(), 24 * 60).toString()}
location="New York"
auctionState={AuctionStatus.live}
>
<SaleHeaderBrowseAuctions />
</SaleHeaderBanner>
);
10 changes: 10 additions & 0 deletions src/patterns/SaleHeaderBanner/SaleHeaderBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { AuctionStatus } from '../../types/commonTypes';
import { Text, TextVariants } from '../../components/Text';
import { PageContentWrapper as PageMargin } from '../../components/PageContentWrapper';
import Button from '../../components/Button/Button';
import { Countdown } from '../../components/Countdown';

// You'll need to change the ComponentProps<"htmlelementname"> to match the top-level element of your component
export interface SaleHeaderBannerProps extends ComponentProps<'div'> {
Expand Down Expand Up @@ -37,6 +38,10 @@ export interface SaleHeaderBannerProps extends ComponentProps<'div'> {
* What is the current state of the auction?
*/
auctionState: AuctionStatus;
/**
* Used to display a countdown timer to show when the Lots begin to close
*/
auctionEndTime?: string;
/**
* What text should the CTA button display?
*/
Expand All @@ -59,6 +64,7 @@ export interface SaleHeaderBannerProps extends ComponentProps<'div'> {
const SaleHeaderBanner = forwardRef<HTMLDivElement, SaleHeaderBannerProps>(
(
{
auctionEndTime,
auctionTitle,
imageSrcUrl,
location,
Expand All @@ -75,6 +81,7 @@ const SaleHeaderBanner = forwardRef<HTMLDivElement, SaleHeaderBannerProps>(
const { className: baseClassName, ...commonProps } = getCommonProps(props, 'SaleHeaderBanner');
const isOpenForBidding = auctionState === AuctionStatus.live;
const isClosed = auctionState === AuctionStatus.past;
const showCountdown = isOpenForBidding && auctionEndTime;
return (
<div {...commonProps} className={classnames(baseClassName, className)} {...props} ref={ref}>
<SeldonImage
Expand All @@ -85,6 +92,9 @@ const SaleHeaderBanner = forwardRef<HTMLDivElement, SaleHeaderBannerProps>(
className={`${baseClassName}__image`}
/>
<PageMargin className={`${baseClassName}__stack-wrapper`} {...commonProps} {...props} ref={ref}>
{showCountdown && (
<Countdown endDateTime={new Date(auctionEndTime)} className={`${baseClassName}__countdown`} />
)}
<div className={`${baseClassName}__stack`}>
{isOpenForBidding && children}
<Text variant={TextVariants.title1}>{auctionTitle}</Text>
Expand Down
9 changes: 8 additions & 1 deletion src/patterns/SaleHeaderBanner/_saleHeaderBanner.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
align-items: start;
display: flex;
flex-direction: column;
height: 100%;
justify-content: center;
padding: $spacing-md 0;
}
Expand Down Expand Up @@ -56,4 +55,12 @@
&__cta {
margin: $spacing-sm 0;
}

&__countdown {
margin-top: $spacing-md;

@include media($size-md, $type: 'min') {
margin-top: 109px;
}
}
}

0 comments on commit 5112f2d

Please sign in to comment.