diff --git a/src/incentive-card.tsx b/src/incentive-card.tsx new file mode 100644 index 0000000..e1d386a --- /dev/null +++ b/src/incentive-card.tsx @@ -0,0 +1,130 @@ +import clsx from 'clsx'; +import { FC, PropsWithChildren } from 'react'; +import { Card } from './card'; +import { ExclamationPoint, ExternalLink, UpRightArrow } from './icons'; + +const Chip: FC> = ({ + isWarning, + children, +}) => ( +
+ {isWarning ? : null} + {children} +
+); + +/** Rendered as a button, with a border. Narrow layout only. */ +const BorderedLinkButton: FC> = ({ + href, + children, +}) => ( + + {children} + +); + +/** Rendered as a pseudo-link, without a border. Med and wide layouts only */ +const BorderlessLinkButton: FC> = ({ + href, + children, +}) => ( + + {children} + +); + +export const IncentiveCard: FC<{ + typeChip: string; + headline: string; + subHeadline: string; + body: string; + warningChip: string | null; + buttonUrl: string; + buttonText: string; +}> = ({ + typeChip, + headline, + subHeadline, + body, + warningChip, + buttonUrl, + buttonText, +}) => ( + +
+
+ {headline} +
+ {/* Only appears on medium and wide layout */} + + {buttonText} + +
+
+ {subHeadline} +
+
{body}
+
+ {typeChip} + {warningChip && {warningChip}} +
+ {/* Only appears on narrow layout */} + + {buttonText} + +
+); diff --git a/src/state-incentive-details.tsx b/src/state-incentive-details.tsx index d151acb..7f212db 100644 --- a/src/state-incentive-details.tsx +++ b/src/state-incentive-details.tsx @@ -1,5 +1,4 @@ -import clsx from 'clsx'; -import { FC, PropsWithChildren, forwardRef, useState } from 'react'; +import { FC, forwardRef, useState } from 'react'; import scrollIntoView from 'scroll-into-view-if-needed'; import { APIResponse, @@ -15,7 +14,7 @@ import { TextInput } from './components/text-input'; import { wasEmailSubmitted } from './email-signup'; import { str } from './i18n/str'; import { MsgFn, useTranslated } from './i18n/use-translated'; -import { ExclamationPoint, ExternalLink, UpRightArrow } from './icons'; +import { IncentiveCard } from './incentive-card'; import { IRARebate, getRebatesFor } from './ira-rebates'; import { itemName } from './item-name'; import { PartnerLogos } from './partner-logos'; @@ -108,132 +107,6 @@ const getStartYearIfInFuture = (incentive: Incentive) => ? getYear(incentive.start_date) : null; -const Chip: FC> = ({ - isWarning, - children, -}) => ( -
- {isWarning ? : null} - {children} -
-); - -/** Rendered as a button, with a border. */ -const BorderedLinkButton: FC> = ({ - href, - children, -}) => ( - - {children} - -); - -/** Rendered as a pseudo-link, without a border */ -const BorderlessLinkButton: FC> = ({ - href, - children, -}) => ( - - {children} - -); - -const IncentiveCard: FC<{ - typeChip: string; - headline: string; - subHeadline: string; - body: string; - warningChip: string | null; - buttonUrl: string; - buttonText: string; -}> = ({ - typeChip, - headline, - subHeadline, - body, - warningChip, - buttonUrl, - buttonText, -}) => ( - -
-
- {headline} -
- {/* Only appears on medium and wide layout */} - - {buttonText} - -
-
- {subHeadline} -
-
{body}
-
- {typeChip} - {warningChip && {warningChip}} -
- {/* Only appears on narrow layout */} - - {buttonText} - -
-); - function scrollToForm(event: React.MouseEvent) { const calculator = ( event.currentTarget.getRootNode() as ShadowRoot