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 width option #70

Merged
merged 14 commits into from
Oct 7, 2021
Merged

Conversation

Caesarovich
Copy link
Collaborator

@Caesarovich Caesarovich commented Oct 6, 2021

Hello, here is the awaited width option. ( fixes #51 ). This PR comes with a little re-arrangement of the code. I moved all the code responsible for determining how to resize/shrink/disable options into a function determineDimensions. From now on, code that handles resizing, shrinking, etc... Should be place in that function.

Features:

  • The width option allows to set a fixed size for the box. This is useful in the cases where a user wants a box to be rendered regardless of current terminal dimensions.
  • Bug fix: padding overflow. If there wasn't enough space to fit the text (at least one character per line) inside the box, padding would overflow on the side. (This issue has never come before because of the low probability of a padding to be larger than terminalColumns - bordersWidth - 1)

Thanks for reviewing !

@Caesarovich
Copy link
Collaborator Author

I'm too used to use it my bad.

@Caesarovich Caesarovich linked an issue Oct 6, 2021 that may be closed by this pull request
index.d.ts Outdated
@@ -176,6 +176,19 @@ export interface Options {
```
*/
readonly titleAlignment?: 'left' | 'right' | 'center';

/**
Set a fix width for the box. (This disables terminal overflow safeties !)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Set a fix width for the box. (This disables terminal overflow safeties !)
Set a fixed width for the box.
*Note:* This disables terminal overflow handling and may cause the box to look broken if the user's terminal is not wide enough.

index.d.ts Outdated
// ┌─────────────┐
// │foo bar │
// └─────────────┘

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```

index.d.ts Show resolved Hide resolved
index.js Show resolved Hide resolved
@sindresorhus sindresorhus changed the title New Width option Add width option Oct 6, 2021
@sindresorhus sindresorhus merged commit 9555d3f into sindresorhus:main Oct 7, 2021
@Caesarovich
Copy link
Collaborator Author

Very well, you're much better than me at making meaningful phrases ^^'

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 width
2 participants