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

Add title and titleAlignment options #59

Merged
merged 24 commits into from
Sep 11, 2021

Conversation

Caesarovich
Copy link
Collaborator

@Caesarovich Caesarovich commented Sep 6, 2021

This PR adds a new feature allowing users to add titles to their boxes.
That is a very handful feature for building CLI Tools.

See example below:

const title = 'Beautiful title';
console.log('\n\n' + boxen('This box has a nice title', {title}) + '\n');
console.log('\n\n' + boxen('This box has a centered title', {title, titleAlign: 'center'}) + '\n');

// Output:

 Beautiful title ────────┐
│This box has a nice title│
└─────────────────────────┘

┌────── Beautiful title ──────┐
│This box has a centered title│
└─────────────────────────────┘
  • The titles can be left/center/right aligned.
  • The titles supports custom coloration (such as chalk...).
  • Titles are sliced if it were to exceed the terminal's size.
  • In this limit, the boxes width are extended to accommodate the title's size as much as possible.

Fixes #56

@sindresorhus
Copy link
Owner

The options need to be documented in the readme too.

@sindresorhus sindresorhus changed the title Feature: title Add title and titleAlign options Sep 7, 2021
index.d.ts Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
@Caesarovich
Copy link
Collaborator Author

I have effectuated the requested changes. I would like your point of view on the README especially.

readme.md Outdated Show resolved Hide resolved
readme.md Outdated Show resolved Hide resolved
readme.md Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
readme.md Show resolved Hide resolved
@sindresorhus sindresorhus changed the title Add title and titleAlign options Add title and titleAlignment options Sep 9, 2021
example.js Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
readme.md Outdated Show resolved Hide resolved
@Caesarovich
Copy link
Collaborator Author

It should be good now, sorry again for the typo and english errors.

@sindresorhus sindresorhus merged commit c50dad6 into sindresorhus:main Sep 11, 2021
@sindresorhus
Copy link
Owner

Looks good. Thank you 🙏

Do you plan anymore changes or should I do a new release?

@Caesarovich
Copy link
Collaborator Author

Looks good. Thank you 🙏

Do you plan anymore changes or should I do a new release?

Hi, I am working on another branch to add the 'width' option. But it is not ready yet so you can go on 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New option: title
2 participants