Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using consola.box with colors in the body adds extra padding #316

Closed
TheDutchCoder opened this issue Oct 11, 2024 · 2 comments · Fixed by #336
Closed

Using consola.box with colors in the body adds extra padding #316

TheDutchCoder opened this issue Oct 11, 2024 · 2 comments · Fixed by #336
Labels
bug Something isn't working

Comments

@TheDutchCoder
Copy link

TheDutchCoder commented Oct 11, 2024

Environment

Node: v20.13.0
OS: MacOS Sequoia 15
consola: 3.2.3

Reproduction

consola.box({
  title: ' RVezy Nuxt tools' ,
  message: ` Tools and commands for a better Developer Experience `,
  style: {
    padding: 1,
    borderColor: "cyan",
  },
});

// Outputs
// ╭─────────────────── RVezy Nuxt tools ─────────────────────╮
// │                                                          │
// │   Tools and commands for a better Developer Experience   │
// │                                                          │
// ╰──────────────────────────────────────────────────────────╯

However

consola.box({
  title: ` ${colors.blue('RVezy')} ${colors.cyan('Nuxt')} ${colors.blue('tools')} `,
  message: ` ${colors.blue('Tools')} and ${colors.blue('commands')} for a better Developer Experience`,
  style: {
    padding: 1,
    borderColor: "cyan",
  },
});

// Outputs
// ╭──────────────────────────── RVezy Nuxt tools ───────────────────────────────╮
// │                                                                             │
// │   Tools and commands for a better Developer Experience                      │
// │                                                                             │
// ╰─────────────────────────────────────────────────────────────────────────────╯

Describe the bug

When using colors in the body part of a box, it adds a lot of padding at the end.

Additional context

No response

Logs

No response

@TheDutchCoder TheDutchCoder added the bug Something isn't working label Oct 11, 2024
@yongqi14
Copy link
Contributor

yongqi14 commented Jan 5, 2025

I think this should not be described as a bug.
When using 'colors.blue', special characters are added to the front and back of the string to indicate the color.
Therefore, in the code, the length of the lower string is longer than the upper one.

import { consola } from "consola";
import { colors } from "consola/utils";

consola.box(`Tools`);
consola.box(`${colors.blue('Tools')}`);
屏幕截图 2025-01-06 015951

@pi0
Copy link
Member

pi0 commented Jan 6, 2025

(the bug is, we should avoid counting escape sequence chars for box line-length)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants