Created
December 17, 2021 16:35
-
-
Save colinfwren/225206212d94f147ac7e18dcbcdc890d to your computer and use it in GitHub Desktop.
Read and Update Miro Board Widgets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function updateWidgets(widgetIds) { | |
const widgetObjects = await Promise.all(widgetsIds.map(async (widgetId) => { | |
const widgets = await miro.board.widgets.get({ id: widgetId }) | |
if (widgets.length > 0) { | |
return widgets[0] | |
} | |
return null | |
})) | |
const widgets = widgetObjects.filter(x => x !== null) | |
widgets.forEach((widget) => { | |
switch(widget.type) { | |
case 'TEXT': | |
return widget.style.textColor = '#d5f692' | |
case 'LINE': | |
return widget.style.lineColor = '#8fd14f' | |
case 'STICKER': | |
return widget.style.stickerBackgroundColor = '#d5f692' | |
default: | |
return widget.style.backgroundColor = '#d5f692' | |
} | |
}) | |
try { | |
await miro.board.widgets.update(widgets) | |
} catch (err) { | |
console.error('Error updating widgets', err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment