🚧 Working on CPU Usage Widgets

This commit is contained in:
Alicia Sykes
2022-01-07 23:25:32 +00:00
parent 9ebdf67a44
commit 4a14b27cf3
6 changed files with 132 additions and 7 deletions

View File

@@ -86,7 +86,8 @@ export const showNumAsThousand = (bigNum) => {
/* Capitalizes the first letter of each word within a string */
export const capitalize = (str) => {
return str.replace(/\w\S*/g, (w) => (w.replace(/^\w/, (c) => c.toUpperCase())));
const words = str.replaceAll('_', ' ').replaceAll('-', ' ');
return words.replace(/\w\S*/g, (w) => (w.replace(/^\w/, (c) => c.toUpperCase())));
};
/* Round price to appropriate number of decimals */
@@ -122,6 +123,12 @@ export const getTimeAgo = (dateTime) => {
return 'unknown';
};
/* Given the name of a CSS variable, returns it's value */
export const getValueFromCss = (colorVar) => {
const cssProps = getComputedStyle(document.documentElement);
return cssProps.getPropertyValue(`--${colorVar}`).trim();
};
/* Given a currency code, return the corresponding unicode symbol */
export const findCurrencySymbol = (currencyCode) => {
const code = currencyCode.toUpperCase().trim();