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
3 changes: 3 additions & 0 deletions src/containers/App/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
* {
// FIXME: this is an overkill, potentially could break external components, needs refactoring
box-sizing: border-box;

// Make all digits in the app monospace
font-variant-numeric: tabular-nums;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deleted font for TopShards table. It's different from font throughout the app. Instead I set monospace numbers everywhere in the app

}

.yc-select-popup__tick-icon {
Expand Down
14 changes: 7 additions & 7 deletions src/utils/bytesParsers/__test__/formatBytes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ describe('formatBytes', () => {
expect(formatBytes({value: 100_000_000_000_000})).toBe('100 TB');
});
it('should convert to size', () => {
expect(formatBytes({value: 100_000, size: 'b'})).toBe('100,000 B');
expect(formatBytes({value: 100_000_000_000_000, size: 'gb'})).toBe('100,000 GB');
expect(formatBytes({value: 100_000, size: 'b'})).toBe('100 000 B');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed broken tests

expect(formatBytes({value: 100_000_000_000_000, size: 'gb'})).toBe('100 000 GB');
});
it('should convert without labels', () => {
expect(formatBytes({value: 100_000, size: 'b', withSizeLabel: false})).toBe('100,000');
expect(formatBytes({value: 100_000, size: 'b', withSizeLabel: false})).toBe('100 000');
expect(formatBytes({value: 100_000_000_000_000, size: 'gb', withSizeLabel: false})).toBe(
'100,000',
'100 000',
);
});
it('should convert to speed', () => {
expect(formatBytes({value: 100_000, withSpeedLabel: true})).toBe('100 KB/s');
expect(formatBytes({value: 100_000, size: 'b', withSpeedLabel: true})).toBe('100,000 B/s');
expect(formatBytes({value: 100_000, size: 'b', withSpeedLabel: true})).toBe('100 000 B/s');
});
it('should return fixed amount of significant digits', () => {
expect(formatBytes({value: 99_000, significantDigits: 2})).toEqual('99,000 B');
expect(formatBytes({value: 99_000, significantDigits: 2})).toEqual('99 000 B');
expect(formatBytes({value: 100_000, significantDigits: 2})).toEqual('100 KB');
expect(formatBytes({value: 99_000_000_000_000, significantDigits: 2})).toEqual('99,000 GB');
expect(formatBytes({value: 99_000_000_000_000, significantDigits: 2})).toEqual('99 000 GB');
expect(formatBytes({value: 100_000_000_000_000, significantDigits: 2})).toEqual('100 TB');
});
it('should return empty string on invalid data', () => {
Expand Down
1 change: 1 addition & 0 deletions src/utils/dataFormatters/dataFormatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export const formatNumber = (number?: unknown) => {
return '';
}

// "," in format is delimiter sign, not delimiter itself
return configuredNumeral(number).format('0,0.[00000]');
};

Expand Down
9 changes: 8 additions & 1 deletion src/utils/numeral.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import numeral from 'numeral';
import 'numeral/locales'; // Without this numeral will throw an error when using not 'en' locale

import {i18n} from './i18n';
import {Lang, i18n} from './i18n';

// Set space delimiter for all locales possible in project
Object.values(Lang).forEach((value) => {
if (numeral.locales[value]) {
numeral.locales[value].delimiters.thousands = ' ';
}
});

numeral.locale(i18n.lang);

Expand Down