Files
ezbookkeeping/src/lib/icon.js
T
2023-08-13 15:03:31 +08:00

27 lines
638 B
JavaScript

export function getIconsInRows(allIconInfos, itemPerRow) {
const ret = [];
let rowCount = 0;
for (let iconInfoId in allIconInfos) {
if (!Object.prototype.hasOwnProperty.call(allIconInfos, iconInfoId)) {
continue;
}
const iconInfo = allIconInfos[iconInfoId];
if (!ret[rowCount]) {
ret[rowCount] = [];
} else if (ret[rowCount] && ret[rowCount].length >= itemPerRow) {
rowCount++;
ret[rowCount] = [];
}
ret[rowCount].push({
id: iconInfoId,
icon: iconInfo.icon
});
}
return ret;
}