ink icon indicating copy to clipboard operation
ink copied to clipboard

Add `overflow` props to `Box` component

Open vadimdemedes opened this issue 4 years ago • 7 comments

This PR adds overflowX, overflowY and overflow props to Box component to hide any content overflowing the element's bounds. Allowed values are visible (default) and hidden.

This is a follow up PR to https://github.com/vadimdemedes/ink/pull/393. Credit to @tin-t for submitting an initial implementation of this feature, which this PR is based on!

Everyone is welcome to try it out!

vadimdemedes avatar Feb 17 '22 16:02 vadimdemedes

I'm really excited to see this progress. I made a fun project over the holiday break and ran into some of these scroll/overflow issues others have been commenting on.

I have a few questions that could help explain how this overflow is supposed to work. I pulled down this branch locally and was modifying an example and wasn't quite able to get it to work. I then checked the tests and noticed they all required flexShrink={0} on the inner Box. This was a bit different than the way I expected it to work with CSS but this could just be a different mental model that I have.

For example:

<Box width={2} overflowX="hidden">
    <Box>
      <Text>Hello World</Text>
    </Box>
</Box>

I would expect to output:

He
Wo

Compared to the similar CSS example: image

Thanks again for this awesome project, ink has been really fun to work with.

chadian avatar Feb 21 '22 17:02 chadian

I would expect to output:

Great observation.

dustinlacewell avatar Feb 22 '22 18:02 dustinlacewell

What's the hold up for not merging this PR? Are there any blockers?

dsmyda avatar Jun 03 '22 05:06 dsmyda

@dsmyda https://github.com/vadimdemedes/ink/issues/506

mAAdhaTTah avatar Jun 03 '22 11:06 mAAdhaTTah

It may really be time to fork. Even before the war collaboration on this project was very slow.

Now there's the war, and the author has stated they aren't moving ahead on the project any more (which I personally respect, and sincerely hope they and people they care about are ok). #506

The thing is, evidenced by continued contributions, others are still interested in advancing the software. To this end I've forked Ink and renamed Ink Solid . It's name is a reflection of the project standing in solidarity with the original author. At this link you'll find an invitation to contribute ideas to move Ink forward through Ink Solid. When development resumes here, the author may find any progress useful.

P.S. this is my first time using Open Source to literally copy a project. If there's anything wrong with doing this either ethically, technically, or otherwise please do let me know...

zach-is-my-name avatar Jun 11 '22 03:06 zach-is-my-name

It may really be time to fork. Even before the war collaboration on this project was very slow.

Now there's the war, and the author has stated they aren't moving ahead on the project any more (which I personally respect, and sincerely hope they and people they care about are ok). #506

The thing is, evidenced by continued contributions, others are still interested in advancing the software. To this end I've forked Ink and renamed Ink Solid . It's name is a reflection of the project standing in solidarity with the original author. At this link you'll find an invitation to contribute ideas to move Ink forward through Ink Solid. When development resumes here, the author may find any progress useful.

P.S. this is my first time using Open Source to literally copy a project. If there's anything wrong with doing this either ethically, technically, or otherwise please do let me know...

I probably would've waited for someone with a bit more experience to lead the charge and do that.

dustinlacewell avatar Jun 13 '22 13:06 dustinlacewell

@vadimdemedes any progress on this? sorry to bother you, but I'm building something and this feature would help me quite a bit

cubiquitous avatar Aug 15 '22 18:08 cubiquitous

cc: @sindresorhus any chance this could be merged?

ProjectBarks avatar Nov 10 '22 04:11 ProjectBarks

Seeing that development was unpaused, could we please get this merged?

ad4mx avatar Feb 21 '23 17:02 ad4mx

Will take a look at it again soon.

vadimdemedes avatar Mar 03 '23 20:03 vadimdemedes

@ad4mx can you try it out by installing Ink from this branch and seeing if it works well?

vadimdemedes avatar Mar 03 '23 20:03 vadimdemedes

I currently don't have enough time to test it, perhaps @ProjectBarks, @Claudi0-V or @chadian could test it?

ad4mx avatar Mar 04 '23 09:03 ad4mx

I have a few questions that could help explain how this overflow is supposed to work. I pulled down this branch locally and was modifying an example and wasn't quite able to get it to work. I then checked the tests and noticed they all required flexShrink={0} on the inner Box. This was a bit different than the way I expected it to work with CSS but this could just be a different mental model that I have.

@chadian Ink tries to work more similar to React Native layout, rather than a browser layout. The overflow prop introduced in this PR is meant for clipping Boxes rather than Text nodes, since Text is already wrapped by default in Ink → https://github.com/vadimdemedes/ink#wrap.

If we look at your example, Ink lays out text as if you added word-break: break-all on the container.

CleanShot 2023-03-04 at 13 12 29@2x

vadimdemedes avatar Mar 04 '23 11:03 vadimdemedes