Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/components/Charts/components/ChartTooltipComparison.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function ChartTooltipComparison({rows, change}: ChartTooltipComparisonProps) {
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const icons = useMemoizedLazyExpensifyIcons(['ArrowUpLong', 'ArrowDownLong']);
const changeColor = StyleUtils.getSpendChangeColor(!!change?.isIncrease);
const isIncrease = !!change?.isIncrease;

return (
<>
Expand All @@ -40,12 +40,12 @@ function ChartTooltipComparison({rows, change}: ChartTooltipComparisonProps) {
{!!change && (
<View style={[styles.flexRow, styles.alignItemsCenter, styles.gap1]}>
<Icon
src={change.isIncrease ? icons.ArrowUpLong : icons.ArrowDownLong}
fill={changeColor}
src={isIncrease ? icons.ArrowUpLong : icons.ArrowDownLong}
fill={StyleUtils.getSpendChangeIconColor(isIncrease)}
width={variables.iconSizeXXSmall}
height={variables.iconSizeXXSmall}
/>
<Text style={[styles.chartTooltipText, StyleUtils.getColorStyle(changeColor)]}>{formatTooltipValue(change)}</Text>
<Text style={[styles.chartTooltipText, StyleUtils.getColorStyle(StyleUtils.getSpendChangeTextColor(isIncrease))]}>{formatTooltipValue(change)}</Text>
</View>
)}
</>
Expand Down
5 changes: 2 additions & 3 deletions src/pages/Insights/charts/InsightsDataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ function InsightsDataTable({rows, formatValue, isLoading, skeletonRowCount = SKE
const changePercentage = hasChange ? formatChangePercentage(primaryValue, comparedValue, preferredLocale) : undefined;
const isIncrease = hasChange && primaryValue > comparedValue;
const isNewSpend = comparedValue === 0;
const changeColor = StyleUtils.getSpendChangeColor(isIncrease);
const isLevelTag = item.groupedBy === CONST.SEARCH.GROUP_BY.TAG && item.tagLevel !== undefined;
const parentLabel = isLevelTag ? formatTagParentPath(item.parentTagPath) : '';

Expand Down Expand Up @@ -144,11 +143,11 @@ function InsightsDataTable({rows, formatValue, isLoading, skeletonRowCount = SKE
>
<Icon
src={isIncrease ? icons.ArrowUpLong : icons.ArrowDownLong}
fill={changeColor}
fill={StyleUtils.getSpendChangeIconColor(isIncrease)}
width={variables.iconSizeXXSmall}
height={variables.iconSizeXXSmall}
/>
<Text style={[styles.textLabel, StyleUtils.getColorStyle(changeColor)]}>{changePercentage}</Text>
<Text style={[styles.textLabel, StyleUtils.getColorStyle(StyleUtils.getSpendChangeTextColor(isIncrease))]}>{changePercentage}</Text>
</View>
)}
</View>
Expand Down
5 changes: 2 additions & 3 deletions src/pages/Insights/details/InsightsSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ function SummaryAverageComparison({comparison, graphKey, periodGroupBy, currency
}

const isIncrease = comparison.difference > 0;
const changeColor = StyleUtils.getSpendChangeColor(isIncrease);
const percentage = formatPercentOfTotal(comparison.percentage, comparison.difference, preferredLocale);
const amount = convertToDisplayString(Math.abs(comparison.difference), currency);

Expand All @@ -169,13 +168,13 @@ function SummaryAverageComparison({comparison, graphKey, periodGroupBy, currency
<View style={[styles.flexRow, styles.alignItemsCenter, styles.gapHalf]}>
<Icon
src={isIncrease ? icons.ArrowUpLong : icons.ArrowDownLong}
fill={changeColor}
fill={StyleUtils.getSpendChangeIconColor(isIncrease)}
width={variables.iconSizeExtraSmall}
height={variables.iconSizeExtraSmall}
/>
<Text
variant="label"
style={StyleUtils.getColorStyle(changeColor)}
style={StyleUtils.getColorStyle(StyleUtils.getSpendChangeTextColor(isIncrease))}
>
{getVersusAverageLabel(amount)}
</Text>
Expand Down
7 changes: 5 additions & 2 deletions src/styles/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2138,8 +2138,11 @@ const createStyleUtils = (theme: ThemeColors, styles: ThemeStyles) => ({
*/
getMentionTextColor: (isOurMention: boolean): string => (isOurMention ? theme.ourMentionText : theme.mentionText),

/** Returns the color of a change in spend, red when it went up and green when it went down */
getSpendChangeColor: (isIncrease: boolean): string => (isIncrease ? theme.danger : theme.successHover),
/** Returns the arrow color of a change in spend, red when it went up and green when it went down */
getSpendChangeIconColor: (isIncrease: boolean): string => (isIncrease ? theme.danger : theme.success),

/** Returns the text color of a change in spend, red when it went up and green when it went down */
getSpendChangeTextColor: (isIncrease: boolean): string => (isIncrease ? theme.textError : theme.textSuccess),

/**
* Generate the wrapper styles for the mini ReportActionContextMenu.
Expand Down
Loading