-
Notifications
You must be signed in to change notification settings - Fork 208
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Describe the feature
box it's a great tool to add borders to logs, if you pass a title, this is centered.
A new parameter to align title to left or right should be great to get something like this:
For now I was able to do this using this portion of code:
const isEven = (num) => num % 2 === 0;
function printWarningBox(message) {
// Calculate the padding needed to push the title to the left
// The box width is determined by the message length or a minimum width
const title = ' Warning ';
const messageLength = message.length;
const boxWidth = Math.max(messageLength, 10); // minimum box width of 10
// Create a title with spaces to push it left
// Add a few spaces after "Warning" to separate it from the border
const finalTitle = title + '─'.repeat(boxWidth - (title.length + (isEven(boxWidth) ? 1 : 2)));
consola.box({
title: finalTitle,
message: message,
style: {
borderColor: 'yellow',
},
});
}
printWarningBox('This is a warning message.');
Additional information
- Would you be willing to help implement this feature?
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request