Skip to content

Commit

Permalink
Media: Show Storage Count to 2 Decimal Places When <1% (#86124)
Browse files Browse the repository at this point in the history
* Media: Show Storage Count to 2 Decimal Places

* Only apply to <1%
  • Loading branch information
Aurorum authored Sep 27, 2024
1 parent 06d100a commit e300d53
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions client/blocks/plan-storage/bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,10 @@ export class PlanStorageBar extends Component {
return null;
}

const percent = Math.min(
Math.round(
( ( mediaStorage.storageUsedBytes / mediaStorage.maxStorageBytes ) * 1000 ) / 10
),
100
);
let percent = ( mediaStorage.storageUsedBytes / mediaStorage.maxStorageBytes ) * 100;

// Round percentage to 2dp for values under 1%, and whole numbers otherwise.
percent = percent < 1 ? percent.toFixed( 2 ) : Math.round( percent );

const classes = clsx( className, 'plan-storage__bar', {
'is-alert': percent > ALERT_PERCENT,
Expand Down

0 comments on commit e300d53

Please sign in to comment.