fix(app): centralize workspace diff stat rendering
The source-control button rendered diff stats inline with no formatting while the sidebar used toLocaleString, so identical numbers looked different. Route both through DiffStat and switch to compact notation (e.g. 87,700 -> 87.7k) so large counts stay readable.
This commit is contained in:
@@ -6,11 +6,20 @@ interface DiffStatProps {
|
|||||||
deletions: number;
|
deletions: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const compactFormatter = new Intl.NumberFormat("en-US", {
|
||||||
|
notation: "compact",
|
||||||
|
maximumFractionDigits: 1,
|
||||||
|
});
|
||||||
|
|
||||||
|
export function formatDiffCount(value: number): string {
|
||||||
|
return compactFormatter.format(value).toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
export function DiffStat({ additions, deletions }: DiffStatProps) {
|
export function DiffStat({ additions, deletions }: DiffStatProps) {
|
||||||
return (
|
return (
|
||||||
<View style={styles.row}>
|
<View style={styles.row}>
|
||||||
<Text style={styles.additions}>+{additions.toLocaleString()}</Text>
|
<Text style={styles.additions}>+{formatDiffCount(additions)}</Text>
|
||||||
<Text style={styles.deletions}>-{deletions.toLocaleString()}</Text>
|
<Text style={styles.deletions}>-{formatDiffCount(deletions)}</Text>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -25,11 +34,11 @@ const styles = StyleSheet.create((theme) => ({
|
|||||||
additions: {
|
additions: {
|
||||||
fontSize: theme.fontSize.xs,
|
fontSize: theme.fontSize.xs,
|
||||||
fontWeight: theme.fontWeight.normal,
|
fontWeight: theme.fontWeight.normal,
|
||||||
color: theme.colors.palette.green[400],
|
color: theme.colors.diffAddition,
|
||||||
},
|
},
|
||||||
deletions: {
|
deletions: {
|
||||||
fontSize: theme.fontSize.xs,
|
fontSize: theme.fontSize.xs,
|
||||||
fontWeight: theme.fontWeight.normal,
|
fontWeight: theme.fontWeight.normal,
|
||||||
color: theme.colors.palette.red[500],
|
color: theme.colors.diffDeletion,
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -2494,22 +2494,6 @@ const styles = StyleSheet.create((theme) => ({
|
|||||||
fontSize: theme.fontSize.xs,
|
fontSize: theme.fontSize.xs,
|
||||||
flexShrink: 0,
|
flexShrink: 0,
|
||||||
},
|
},
|
||||||
diffStatRow: {
|
|
||||||
flexDirection: "row",
|
|
||||||
alignItems: "center",
|
|
||||||
gap: 6,
|
|
||||||
flexShrink: 0,
|
|
||||||
},
|
|
||||||
diffStatAdditions: {
|
|
||||||
fontSize: theme.fontSize.xs,
|
|
||||||
fontWeight: theme.fontWeight.normal,
|
|
||||||
color: theme.colors.diffAddition,
|
|
||||||
},
|
|
||||||
diffStatDeletions: {
|
|
||||||
fontSize: theme.fontSize.xs,
|
|
||||||
fontWeight: theme.fontWeight.normal,
|
|
||||||
color: theme.colors.diffDeletion,
|
|
||||||
},
|
|
||||||
kebabButton: {
|
kebabButton: {
|
||||||
padding: 2,
|
padding: 2,
|
||||||
borderRadius: 4,
|
borderRadius: 4,
|
||||||
|
|||||||
@@ -2192,14 +2192,10 @@ function WorkspaceScreenContent({ serverId, workspaceId }: WorkspaceScreenProps)
|
|||||||
color={iconColor}
|
color={iconColor}
|
||||||
/>
|
/>
|
||||||
{workspaceDescriptor?.diffStat ? (
|
{workspaceDescriptor?.diffStat ? (
|
||||||
<View style={styles.diffStatRow}>
|
<DiffStat
|
||||||
<Text style={styles.diffStatAdditions}>
|
additions={workspaceDescriptor.diffStat.additions}
|
||||||
+{workspaceDescriptor.diffStat.additions}
|
deletions={workspaceDescriptor.diffStat.deletions}
|
||||||
</Text>
|
/>
|
||||||
<Text style={styles.diffStatDeletions}>
|
|
||||||
-{workspaceDescriptor.diffStat.deletions}
|
|
||||||
</Text>
|
|
||||||
</View>
|
|
||||||
) : null}
|
) : null}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
@@ -2493,22 +2489,6 @@ const styles = StyleSheet.create((theme) => ({
|
|||||||
sourceControlButtonHovered: {
|
sourceControlButtonHovered: {
|
||||||
backgroundColor: theme.colors.surface2,
|
backgroundColor: theme.colors.surface2,
|
||||||
},
|
},
|
||||||
diffStatRow: {
|
|
||||||
flexDirection: "row",
|
|
||||||
alignItems: "center",
|
|
||||||
gap: 6,
|
|
||||||
flexShrink: 0,
|
|
||||||
},
|
|
||||||
diffStatAdditions: {
|
|
||||||
fontSize: theme.fontSize.xs,
|
|
||||||
fontWeight: theme.fontWeight.normal,
|
|
||||||
color: theme.colors.diffAddition,
|
|
||||||
},
|
|
||||||
diffStatDeletions: {
|
|
||||||
fontSize: theme.fontSize.xs,
|
|
||||||
fontWeight: theme.fontWeight.normal,
|
|
||||||
color: theme.colors.diffDeletion,
|
|
||||||
},
|
|
||||||
newTabActions: {
|
newTabActions: {
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
|
|||||||
Reference in New Issue
Block a user