From 6d48cd1c973c30388fe0fc75751ac0bd0ce0f760 Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Tue, 2 Feb 2021 20:25:36 +1100 Subject: [PATCH] Minor UI tweaks (#1099) * Show one decimal point for sizes GB and over * Don't open 0.4 version section by default --- ui/v2.5/src/components/Changelog/Changelog.tsx | 1 - ui/v2.5/src/components/Stats.tsx | 14 ++++++++++++-- ui/v2.5/src/utils/text.ts | 11 +++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/ui/v2.5/src/components/Changelog/Changelog.tsx b/ui/v2.5/src/components/Changelog/Changelog.tsx index 250ba2534..1d8d321e8 100644 --- a/ui/v2.5/src/components/Changelog/Changelog.tsx +++ b/ui/v2.5/src/components/Changelog/Changelog.tsx @@ -50,7 +50,6 @@ const Changelog: React.FC = () => { date="2020-11-24" openState={openState} setOpenState={setVersionOpenState} - defaultOpen > diff --git a/ui/v2.5/src/components/Stats.tsx b/ui/v2.5/src/components/Stats.tsx index dae25ddb9..dbbff140a 100644 --- a/ui/v2.5/src/components/Stats.tsx +++ b/ui/v2.5/src/components/Stats.tsx @@ -19,7 +19,12 @@ export const Stats: React.FC = () => {

- + {` ${TextUtils.formatFileSizeUnit(scenesSize.unit)}`}

@@ -36,7 +41,12 @@ export const Stats: React.FC = () => {

- + {` ${TextUtils.formatFileSizeUnit(imagesSize.unit)}`}

diff --git a/ui/v2.5/src/utils/text.ts b/ui/v2.5/src/utils/text.ts index 4d2182c8e..3a919b6be 100644 --- a/ui/v2.5/src/utils/text.ts +++ b/ui/v2.5/src/utils/text.ts @@ -40,6 +40,16 @@ const formatFileSizeUnit = (u: Unit) => { return shortUnits[i]; }; +// returns the number of fractional digits to use when displaying file sizes +// returns 0 for MB and under, 1 for GB and over. +const fileSizeFractionalDigits = (unit: Unit) => { + if (Units.indexOf(unit) >= 3) { + return 1; + } + + return 0; +}; + const secondsToTimestamp = (seconds: number) => { let ret = new Date(seconds * 1000).toISOString().substr(11, 8); @@ -163,6 +173,7 @@ const formatDate = (intl: IntlShape, date?: string) => { const TextUtils = { fileSize, formatFileSizeUnit, + fileSizeFractionalDigits, secondsToTimestamp, fileNameFromPath, age: getAge,