From 42d5ccef9a4a1176396d98eb7780e6e1a4617cb6 Mon Sep 17 00:00:00 2001 From: Dan Manchester Date: Fri, 12 May 2023 07:09:13 -0700 Subject: [PATCH] Adds countColor prop to Cardinal --- src/components/Cardinal.stories.tsx | 5 +++++ src/components/Cardinal.tsx | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/components/Cardinal.stories.tsx b/src/components/Cardinal.stories.tsx index a7fd60fb..9250be4d 100644 --- a/src/components/Cardinal.stories.tsx +++ b/src/components/Cardinal.stories.tsx @@ -72,6 +72,7 @@ export const AllCardinals = () => ( + ); @@ -193,3 +194,7 @@ Thousands.storyName = 'thousands'; export const Decimals = () => ; Decimals.storyName = 'decimals'; + +export const WithCountColor = () => ; + +WithCountColor.storyName = 'with CountColor'; diff --git a/src/components/Cardinal.tsx b/src/components/Cardinal.tsx index 1f8a730a..05e51ce1 100644 --- a/src/components/Cardinal.tsx +++ b/src/components/Cardinal.tsx @@ -9,9 +9,11 @@ import { inlineGlow } from './shared/animation'; type Status = 'default' | 'positive' | 'negative' | 'warning' | 'neutral' | 'link' | 'inverse'; type Size = 'small' | 'large'; type Alignment = 'left' | 'center' | 'right'; +type Color = keyof typeof color; interface CountProps { status: Status; + countColor: Color; } const Count = styled.div` @@ -55,6 +57,12 @@ const Count = styled.div` css` color: rgba(255, 255, 255, 0.7); `}; + ${(props) => + props.status === 'default' && + props.countColor && + css` + color: ${color[props.countColor]}; + `}; span { display: inline-block; @@ -169,6 +177,7 @@ export interface CardinalProps { countLink?: string; text: string; status?: Status; + countColor?: Color; noPlural?: boolean; CountWrapper?: React.ElementType; TextWrapper?: React.ElementType; @@ -187,6 +196,7 @@ export const Cardinal: FunctionComponent = ({ text, noPlural, status, + countColor, CountWrapper, TextWrapper, alignment, @@ -220,7 +230,7 @@ export const Cardinal: FunctionComponent = ({ {...events} {...props} > - + {countValue} @@ -242,6 +252,7 @@ Cardinal.defaultProps = { active: false, size: 'large' as Size, status: 'default' as Status, + countColor: null, count: '000', countLink: null, noPlural: false,