Created
February 2, 2019 19:17
-
-
Save cxspxr/d5995c522855f34d58f5c37c6d06777f to your computer and use it in GitHub Desktop.
?
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
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