Display badges as not inverted

[MAILPOET-2791]
This commit is contained in:
Pavel Dohnal
2020-10-15 13:49:00 +02:00
committed by Veljko V
parent f133e4e664
commit a7c2029c09
3 changed files with 25 additions and 9 deletions

View File

@@ -7,28 +7,31 @@ type BadgeProps = {
tooltip?: string | React.ReactNode, tooltip?: string | React.ReactNode,
tooltipId?: string, tooltipId?: string,
type?: 'average' | 'good' | 'excellent', type?: 'average' | 'good' | 'excellent',
isInverted?: boolean,
} }
function Badge(props: BadgeProps) { function Badge({
const tooltip = props.tooltip || false; name,
// tooltip ID must be unique, defaults to tooltip text tooltip,
const tooltipId = props.tooltipId || tooltip.toString(); tooltipId,
type,
isInverted,
}: BadgeProps) {
return ( return (
<span> <span>
<Tag <Tag
isInverted isInverted={isInverted}
variant={props.type} variant={type}
data-tip data-tip
data-for={tooltipId} data-for={tooltipId}
> >
{props.name} {name}
</Tag> </Tag>
{ tooltip && ( { tooltip && (
<Tooltip <Tooltip
place="top" place="top"
multiline multiline
id={tooltipId} id={tooltipId || tooltip.toString()}
> >
{tooltip} {tooltip}
</Tooltip> </Tooltip>
@@ -37,4 +40,8 @@ function Badge(props: BadgeProps) {
); );
} }
Badge.defaultProps = {
isInverted: true,
};
export default Badge; export default Badge;

View File

@@ -6,6 +6,7 @@ type StatsBadgeProps = {
stat: string, stat: string,
rate: number, rate: number,
tooltipId?: string, tooltipId?: string,
isInverted?: boolean,
} }
const stats = { const stats = {
@@ -116,6 +117,7 @@ export const StatsBadge = (props: StatsBadgeProps) => {
const content = ( const content = (
<Badge <Badge
isInverted={props.isInverted}
type={badgeType} type={badgeType}
name={badge.name} name={badge.name}
tooltip={tooltipText} tooltip={tooltipText}
@@ -125,3 +127,7 @@ export const StatsBadge = (props: StatsBadgeProps) => {
return content; return content;
}; };
StatsBadge.defaultProps = {
isInverted: true,
};

View File

@@ -51,6 +51,7 @@ export const NewsletterGeneralStats = ({
</div> </div>
{displayBadges && ( {displayBadges && (
<StatsBadge <StatsBadge
isInverted={false}
stat="opened" stat="opened"
rate={percentageOpened} rate={percentageOpened}
tooltipId={`opened-${newsletter.id || '0'}`} tooltipId={`opened-${newsletter.id || '0'}`}
@@ -70,6 +71,7 @@ export const NewsletterGeneralStats = ({
</div> </div>
{displayBadges && ( {displayBadges && (
<StatsBadge <StatsBadge
isInverted={false}
stat="unsubscribed" stat="unsubscribed"
rate={percentageUnsubscribed} rate={percentageUnsubscribed}
tooltipId={`unsubscribed-${newsletter.id || '0'}`} tooltipId={`unsubscribed-${newsletter.id || '0'}`}
@@ -90,6 +92,7 @@ export const NewsletterGeneralStats = ({
</div> </div>
{displayBadges && ( {displayBadges && (
<StatsBadge <StatsBadge
isInverted={false}
stat="clicked" stat="clicked"
rate={percentageClicked} rate={percentageClicked}
tooltipId={`clicked-${newsletter.id || '0'}`} tooltipId={`clicked-${newsletter.id || '0'}`}