MCPcopy Create free account
hub / github.com/cifertech/DisplayKit / addElement

Function addElement

app.js:6304–6454  ·  view source on GitHub ↗
(type)

Source from the content-addressed store, hash-verified

6302
6303
6304function addElement(type) {
6305 const id = makeId();
6306 let baseW = 80;
6307 let baseH = 30;
6308 let text = "";
6309 let textSize = 2;
6310 let value = 50;
6311
6312 // Enhanced element properties based on type
6313 if (type === "text") {
6314 baseW = 120;
6315 baseH = 20;
6316 text = "Text";
6317 } else if (type === "label") {
6318 baseW = 80;
6319 baseH = 20;
6320 text = "Label";
6321 } else if (type === "button") {
6322 baseW = 80;
6323 baseH = 28;
6324 text = "Button";
6325 } else if (type === "header") {
6326 baseW = Math.min(dispWidth - 20, 200); // Responsive width
6327 baseH = 24;
6328 text = "Header";
6329 } else if (type === "card") {
6330 baseW = 120;
6331 baseH = 60;
6332 text = "Card";
6333 } else if (type === "divider") {
6334 baseW = Math.min(dispWidth - 40, 150);
6335 baseH = 2;
6336 } else if (type === "progress") {
6337 baseW = 120;
6338 baseH = 16;
6339 value = 60;
6340 } else if (type === "slider") {
6341 baseW = 120;
6342 baseH = 18;
6343 value = 40;
6344 } else if (type === "toggle") {
6345 baseW = 50;
6346 baseH = 20;
6347 value = 0;
6348 } else if (type === "circle") {
6349 baseW = 40;
6350 baseH = 40;
6351 } else if (type === "triangle") {
6352 baseW = 44;
6353 baseH = 40;
6354 } else if (type === "polygon") {
6355 baseW = 46;
6356 baseH = 46;
6357 } else if (type === "arc") {
6358 baseW = 70;
6359 baseH = 40;
6360 value = 75;
6361 } else if (type === "gauge") {

Callers 1

app.jsFile · 0.85

Calls 11

makeIdFunction · 0.85
getContrastingColorFunction · 0.85
isLightColorFunction · 0.85
getCurrentDriverModeFunction · 0.85
syncActiveScreenElementsFunction · 0.85
updatePreviewSizeFunction · 0.85
renderElementsFunction · 0.85
updatePropsInputsFunction · 0.85
updateCodeFunction · 0.85
pushHistoryFunction · 0.85

Tested by

no test coverage detected