Skip to content

Commit

Permalink
chore: Add IconColor for the LinkButton and add rightIcon on all Pric…
Browse files Browse the repository at this point in the history
…ing Cards CTA
  • Loading branch information
aralovelace authored and jamiehenson committed Dec 20, 2024
1 parent 3117564 commit 0aa9428
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
14 changes: 10 additions & 4 deletions src/core/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { PropsWithChildren } from "react";
import { IconName } from "./Icon/types";
import Icon from "./Icon";
import cn from "./utils/cn";
import { ColorClass, ColorThemeSet } from "./styles/colors/types";

export type ButtonType = "priority" | "primary" | "secondary";

Expand All @@ -28,6 +29,10 @@ export type ButtonPropsBase = {
* Optional classes to add to the button element.
*/
className?: string;
/**
* Optional color to apply to the icon on either left and/or right side of the button.
*/
iconColor?: ColorClass | ColorThemeSet;
};

type ButtonProps = ButtonPropsBase &
Expand Down Expand Up @@ -81,12 +86,12 @@ export const commonButtonProps = (props: ButtonPropsBase) => {
export const commonButtonInterior = (
props: PropsWithChildren<ButtonPropsBase>,
) => {
const { leftIcon, rightIcon, children } = props;
const { leftIcon, rightIcon, iconColor, children } = props;
return (
<>
{leftIcon ? <Icon name={leftIcon} /> : null}
{leftIcon ? <Icon name={leftIcon} additionalCSS={iconColor} /> : null}
{children}
{rightIcon ? <Icon name={rightIcon} /> : null}
{rightIcon ? <Icon name={rightIcon} additionalCSS={iconColor} /> : null}
</>
);
};
Expand All @@ -98,14 +103,15 @@ const Button: React.FC<PropsWithChildren<ButtonProps>> = ({
rightIcon,
children,
className,
iconColor,
...rest
}) => {
return (
<button
{...commonButtonProps({ variant, size, leftIcon, rightIcon, className })}
{...(rest as React.ButtonHTMLAttributes<HTMLButtonElement>)}
>
{commonButtonInterior({ leftIcon, rightIcon, children })}
{commonButtonInterior({ leftIcon, rightIcon, iconColor, children })}
</button>
);
};
Expand Down
5 changes: 4 additions & 1 deletion src/core/LinkButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import {
commonButtonProps,
} from "./Button";
import cn from "./utils/cn";
import { ColorClass, ColorThemeSet } from "./styles/colors/types";

export type LinkButtonProps = ButtonPropsBase & {
disabled?: boolean;
onClick?: (event: React.MouseEvent<HTMLAnchorElement>) => void;
iconColor?: ColorClass | ColorThemeSet;
} & React.AnchorHTMLAttributes<HTMLAnchorElement>;

const LinkButton: React.FC<LinkButtonProps> = ({
Expand All @@ -20,6 +22,7 @@ const LinkButton: React.FC<LinkButtonProps> = ({
className,
disabled,
onClick,
iconColor,
...rest
}) => {
const handleClick = (e: React.MouseEvent<HTMLAnchorElement>) => {
Expand All @@ -46,7 +49,7 @@ const LinkButton: React.FC<LinkButtonProps> = ({
onClick={handleClick}
{...(rest as React.AnchorHTMLAttributes<HTMLAnchorElement>)}
>
{commonButtonInterior({ leftIcon, rightIcon, children })}
{commonButtonInterior({ leftIcon, rightIcon, iconColor, children })}
</a>
);
};
Expand Down
2 changes: 2 additions & 0 deletions src/core/Pricing/PricingCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ const PricingCards = ({ data, delimiter }: PricingCardsProps) => {
href={cta.url}
onClick={cta.onClick}
disabled={cta.disabled}
rightIcon="icon-gui-arrow-right"
iconColor={cta.iconColor}
>
{cta.text}
</LinkButton>
Expand Down
13 changes: 11 additions & 2 deletions src/core/Pricing/data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ export const planData: PricingDataFeature[] = [
color: "text-neutral-800 dark:text-neutral-500",
},
price: { amount: "$0" },
cta: { text: "Start for free", url: "/sign-up" },
cta: {
text: "Start for free",
url: "/sign-up",
iconColor: "text-neutral-700 dark:text-neutral-600",
},
sections: [
{
title: "Limits",
Expand Down Expand Up @@ -69,6 +73,7 @@ export const planData: PricingDataFeature[] = [
cta: {
text: "Get started",
url: "/users/paid_sign_up?package=standard",
iconColor: "text-blue-600 dark:text-blue-400",
},
sections: [
{
Expand Down Expand Up @@ -120,7 +125,11 @@ export const planData: PricingDataFeature[] = [
</>
),
},
cta: { text: "Get started", url: "/users/paid_sign_up?package=pro" },
cta: {
text: "Get started",
url: "/users/paid_sign_up?package=pro",
iconColor: "text-blue-600 dark:text-blue-400",
},
sections: [
{
title: "Limits",
Expand Down
1 change: 1 addition & 0 deletions src/core/Pricing/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type PricingDataFeatureCta = {
className?: string;
disabled?: boolean;
onClick?: () => void;
iconColor?: ColorClass | ColorThemeSet;
};

export type PricingDataFeatureSection = {
Expand Down

0 comments on commit 0aa9428

Please sign in to comment.