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

View File

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

View File

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