mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-23 17:52:49 +00:00
Treat the appearance setting as the rendered base size so the type ramp scales predictably. Native starts one pixel larger while web and desktop preserve the authored 14px base, with legacy values migrated on load.
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import { View, Text } from "react-native";
|
|
import { StyleSheet } from "react-native-unistyles";
|
|
|
|
interface DiffStatProps {
|
|
additions: number;
|
|
deletions: number;
|
|
testID?: string;
|
|
}
|
|
|
|
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, testID }: DiffStatProps) {
|
|
return (
|
|
<View style={styles.row} testID={testID}>
|
|
<Text style={styles.additions}>+{formatDiffCount(additions)}</Text>
|
|
<Text style={styles.deletions}>-{formatDiffCount(deletions)}</Text>
|
|
</View>
|
|
);
|
|
}
|
|
|
|
const styles = StyleSheet.create((theme) => ({
|
|
row: {
|
|
flexDirection: "row",
|
|
alignItems: "center",
|
|
height: 20,
|
|
gap: 4,
|
|
flexShrink: 0,
|
|
},
|
|
additions: {
|
|
fontSize: theme.fontSize.sm,
|
|
fontWeight: theme.fontWeight.normal,
|
|
color: theme.colors.statusSuccess,
|
|
},
|
|
deletions: {
|
|
fontSize: theme.fontSize.sm,
|
|
fontWeight: theme.fontWeight.normal,
|
|
color: theme.colors.statusDanger,
|
|
},
|
|
}));
|