Print a shield to the console.
console.shield('Version', '1.0.0')
console.shield('Version', '1.0.0', { labelBackgroundColor: '#ff0000', messageBackgroundColor: '#fafafa', messageTextColor: '#222' })
(console.shield = (label, message, options = {}) => { | |
const { | |
labelBackgroundColor, | |
messageBackgroundColor, | |
labelTextColor, | |
messageTextColor | |
} = Object.assign({ | |
labelBackgroundColor: '#555', | |
messageBackgroundColor: '#97ca00', | |
labelTextColor: '#fff', | |
messageTextColor: '#fff' | |
}, options) | |
console.log( | |
`%c ${label} %c ${message} %c`, | |
`background:${labelBackgroundColor} ; padding: 1px; border-radius: 3px 0 0 3px; color: ${labelTextColor}`, | |
`background:${messageBackgroundColor} ; padding: 1px; border-radius: 0 3px 3px 0; color: ${messageTextColor}`, | |
'background:transparent' | |
) | |
})() |