Origin UI Utils
Description
UI general utils library for building Origin marketplace user interface.
Origin UI Assets is a component of Energy Web Origin's SDK.
Installation
This package is available through the npm registry.
npm install @energyweb/origin-ui-utils
yarn add @energyweb/origin-ui-utils
Usage
-
isArrayEqual
- Checks if two arrays are equal usinglodash
modular methods.
isArrayEqual(arrayOne: T[], arrayTwo: T[]): boolean
-
COUNTRY_OPTIONS_ISO
- An array of country options with ISO country code asvalue
and country name aslabel
COUNTRY_OPTIONS_ISO: { value: string, label: string }[]
-
DateFormatEnum
- Enum containing Date-Time formats used in Origin
enum DateFormatEnum {
DATE_FORMAT_MDY = 'MMM D, YYYY',
DATE_FORMAT_DMY = 'DD/MM/YYYY',
DATE_FORMAT_MONTH_AND_YEAR = 'MMM, YYYY',
DATE_FORMAT_FULL_YEAR = 'YYYY',
DATE_FORMAT_INCLUDING_TIME = `MMM D, YYYY hh:mm a`,
}
-
formatDate
- function formatting dates/timestamps/dayjs-objects to the most used date format 'MMM D, YYYY' in displaying dates in user interface
formatDate(date: Dayjs | number | string): 'MMM D, YYYY'
const includeTime = true;
formatDate(date, includeTime): `MMM D, YYYY hh:mm a`
const timezone = 'Asia/Bangkok'
// by default uses dayjs.tz.guess()
formatDate(date, false, timezone): 'MMM D, YYYY'
-
EnergyFormatter
- function for formatting energy values from MWh to Wh and from Wh to MWh.
const amountInWh = 100000;
const mWhAmount = 365;
EnergyFormatter.getValueInDisplayUnit(amountInWh): 100
EnergyFormatter.getBaseValueFromValueInDisplayUnit(mWhAmount): BigNumber.from(365000)
EnergyFormatter.format(amountInWh): "100"
EnergyFormatter.format(amountInWh, true): "100 MWh"
-
PowerFormatter
- function for formatting power values from MW to W and from W to MW.
const amountInW = 987000;
const mWAmount = 123;
PowerFormatter.getBaseValueFromValueInDisplayUnit(mWAmount): "123000"
PowerFormatter.format(amountInW): "987"
PowerFormatter.format(amountInW, true): "987 MW"
-
Currency formatters
formatCurrency(value)
- formats the number or string usingIntl.NumberFormat
to USD currency style without '$' sign.formatCurrencyComplete(value, currency = 'usd')
- formats the number or string to currency format usingIntl.NumberFormat
with 2 digits displaying the currency sign. -
useQueryParams
- hook for retrieving query params. -
useQueryString
- hook for receiving parsed query string viaquery-string
package. -
EnergyTypeEnum
- enum containing all energy types used in Origin user interface. This is mainly used for icons displaying.
WIND = 'wind',
SOLAR = 'solar',
HYDRO = 'hydro-electric',
MARINE_TIDAL = 'marine tidal',
MARINE_WAVE = 'marine wave',
MARINE_CURRENT = 'marine current',
MARINE_VERTICAL = 'marine vertical pressure',
RENEWABLE_HEAT = 'renewable heat',
BIOMASS_SOLID = 'biomass solid',
BIOMASS_LIQUID = 'biomass liquid',
BIOGAS = 'biogas',
CO_FIRED_WITH_FOSSIL = 'co-fired with fossil',
Contributing Guidelines
See contributing.md
Energy Web Decentralized Operating System
EW-Origin is a component of the Energy Web Decentralized Operating System (EW-DOS).
The purpose of EW-DOS is to develop and deploy an open and decentralized digital operating system for the energy sector in support of a low-carbon, customer-centric energy future.
We develop blockchain technology, full-stack applications and middleware packages that facilitate participation of Distributed Energy Resources on the grid and create open market places for transparent and efficient renewable energy trading.
- To learn about more about the EW-DOS tech stack, see our documentation
For a deep-dive into the motivation and methodology behind our technical solutions, read our White Papers:
Connect with Energy Web
License
This project is licensed under the MIT License - see the LICENSE file for details