Mixins
Description
Mixins provides small reusable helper modules for file-type inspection and number formatting across Enso UI packages.
Installation
Install the package:
yarn add @enso-ui/mixins
The helpers can be consumed from any Vue application or Enso UI package.
Features
- exports
EnsoFile,numberFormat, andshortNumberfrom the package root - maps file extensions to Font Awesome icons and viewability helpers
- formats decimal values with the current Enso locale preferences
- compacts large numbers into SI-style suffixes such as
k,M, andG
Usage
import { EnsoFile, numberFormat, shortNumber } from '@enso-ui/mixins';
const file = new EnsoFile({ extension: 'pdf' });
file.icon();
numberFormat(1234.567, 2);
shortNumber(128000);
API
Root exports
Import: @enso-ui/mixins
EnsoFile
Helper class for file extension inspection.
Constructor:
new EnsoFile({ extension })
Methods:
extension()isImage()isPdf()isViewable()icon()
numberFormat(value, decimals = 3)
Formats a decimal number with Intl.NumberFormat using the current Enso UI locale preferences.
shortNumber(number, precision = 2)
Compacts large numbers into SI-style suffixes and returns values such as 1.2k, 4.5M, or 9G.
Depends On
Contributions
are welcome. Pull requests are great, but issues are good too.
Thank you to all the people who already contributed to Enso!