Skip to content

Instantly share code, notes, and snippets.

@cxspxr
Created February 2, 2019 19:17
Show Gist options
  • Save cxspxr/d5995c522855f34d58f5c37c6d06777f to your computer and use it in GitHub Desktop.
Save cxspxr/d5995c522855f34d58f5c37c6d06777f to your computer and use it in GitHub Desktop.
?
const actionSellRenderer = params =>
Object.keys(params.actions)
.filter(actionName => params.actions[actionName].showInTable !== false)
.map(actionName => {
const action = params.actions[actionName];
const button = document.createElement('button');
button.classList.add('btn', 'grid-action');
button.type = 'button';
button.style.backgroundColor = action.backgroundColor;
button.style.borderColor = action.borderColor;
button.style.color = action.textColor;
button.title = action.description;
button.addEventListener('click', params.showModal);
const icon = document.createElement('i');
icon.classList.add('fa', `fa-${action.icon.link}`);
button.appendChild(icon);
return button;
})
.reduce(
(parent => (obj, button) => parent.appendChild(button))(
document.createElement('span'),
),
);
export default actionSellRenderer;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment