ink icon indicating copy to clipboard operation
ink copied to clipboard

Add `truncationCharacter` prop for `Text` component

Open codemaster138 opened this issue 3 years ago • 6 comments

This PR adds a truncationCharacter prop to the Text component:

<Box width={7}>
	<Text wrap="truncate" truncationCharacter=".">Hello World</Text>
</Box>
//=> 'Hello.'

<Box width={7}>
	<Text wrap="truncate" truncationCharacter="+++">Hello World</Text>
</Box>
//=> 'Hel+++'

Resolves #480

codemaster138 avatar Oct 09 '21 14:10 codemaster138

@vadimdemedes Sorry to ping. I wrote tests, but I was unable to actually verify them because literally every single test in your test suite seems to fail for some reason.

codemaster138 avatar Oct 09 '21 14:10 codemaster138

Don't commit yarn.lock

sindresorhus avatar Oct 09 '21 16:10 sindresorhus

I wrote tests, but I was unable to actually verify them because literally every single test in your test suite seems to fail for some reason.

Tests are passing on CI, so this sounds like a problem with your setup.

sindresorhus avatar Oct 09 '21 16:10 sindresorhus

I'm a little concerned how this will affect layout calculation, since truncationCharacter can be longer than one character. I thought the initial feature request you've had was to simply truncate without the three dots at the end?

vadimdemedes avatar Feb 17 '22 17:02 vadimdemedes

This also can't be merged now, because cli-truncate moved to ESM and Ink didn't. Also, just found and reported an issue about incorrect behavior of that module → https://github.com/sindresorhus/cli-truncate/issues/23. Would you be able to take a look there, since you were the author of truncationCharacter PR?

vadimdemedes avatar Feb 18 '22 14:02 vadimdemedes

I realize it's been a long time, so it's ok if you're not interested anymore, completely understandable.

vadimdemedes avatar Feb 18 '22 14:02 vadimdemedes