lingo3d
Version:
Lingo3D is a React/Vue 3d game development framework that ships with a complete visual editor
28 lines • 1.25 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
import ComponentIcon from "./ComponentIcon";
const getIconName = (name) => {
if (typeof name === "string") {
if (name.endsWith("Camera"))
return "camera";
if (name.endsWith("Light"))
return "light";
return name;
}
return Object.values(name)[0];
};
const getName = (name) => typeof name === "string" ? name : Object.keys(name)[0];
const Components = ({ names, onDragStart, onDragEnd }) => {
const groups = [];
let latestGroup = [];
let i = 0;
for (const name of names) {
if (i === 0)
groups.push((latestGroup = []));
latestGroup.push(name);
if (++i === 2)
i = 0;
}
return (_jsx(_Fragment, { children: groups.map(([name0, name1], i) => (_jsxs("div", { style: { display: "flex" }, children: [_jsx(ComponentIcon, { name: getName(name0), iconName: getIconName(name0), onDragStart: onDragStart, onDragEnd: onDragEnd }), name1 && (_jsx(ComponentIcon, { name: getName(name1), iconName: getIconName(name1), onDragStart: onDragStart, onDragEnd: onDragEnd }))] }, i))) }));
};
export default Components;
//# sourceMappingURL=Components.js.map