mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-01-01 13:12:23 +00:00
* I need that gitignore file * Temp Commit - DOES NOT COMPILE * THE SHIT WORKS * Readme change * Disposal Unit --> TGUI * mmmm yes CI which may not actually work * New GitIgnore * ITS TGUI-NEXT BABY * Doc update * CI tweak * Chmod * And again * *sigh* * Lets appreciate the irony of me failing CI stages * 0/1 --> True/False * Fixes some update nonsense * CI Update * Lets try this * What about this maybe * NVM is hurting me * I swear to god * A little bit of validation in my life * V3 BABYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY * Fixes * Fixes NaN appearing for a few frames when UIs open * Fixes + Crew Monitor * Corn + Steel + Mochi Fixes * Forgot this * Fixes from stylemistake * Code Change * Adds logout proc * Offline implications + Resizeable crew monitor * Change locate() to locateUID() * Change div --> box
68 lines
1.3 KiB
JavaScript
68 lines
1.3 KiB
JavaScript
/**
|
|
* Helper for conditionally adding/removing classes in React
|
|
*
|
|
* @param {any[]} classNames
|
|
* @return {string}
|
|
*/
|
|
export const classes = classNames => {
|
|
let className = '';
|
|
for (let i = 0; i < classNames.length; i++) {
|
|
const part = classNames[i];
|
|
if (typeof part === 'string') {
|
|
className += part + ' ';
|
|
}
|
|
}
|
|
return className;
|
|
};
|
|
|
|
/**
|
|
* Normalizes children prop, so that it is always an array of VDom
|
|
* elements.
|
|
*/
|
|
export const normalizeChildren = children => {
|
|
if (Array.isArray(children)) {
|
|
return children.flat().filter(value => value);
|
|
}
|
|
if (typeof children === 'object') {
|
|
return [children];
|
|
}
|
|
return [];
|
|
};
|
|
|
|
/**
|
|
* Shallowly checks if two objects are different.
|
|
* Credit: https://github.com/developit/preact-compat
|
|
*/
|
|
export const shallowDiffers = (a, b) => {
|
|
let i;
|
|
for (i in a) {
|
|
if (!(i in b)) {
|
|
return true;
|
|
}
|
|
}
|
|
for (i in b) {
|
|
if (a[i] !== b[i]) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
|
|
/**
|
|
* Default inferno hooks for pure components.
|
|
*/
|
|
export const pureComponentHooks = {
|
|
onComponentShouldUpdate: (lastProps, nextProps) => {
|
|
return shallowDiffers(lastProps, nextProps);
|
|
},
|
|
};
|
|
|
|
/**
|
|
* A helper to determine whether to render an item.
|
|
*/
|
|
export const isFalsy = value => {
|
|
return value === undefined
|
|
|| value === null
|
|
|| value === false;
|
|
};
|