bvaughn / react-resizable-panels

https://react-resizable-panels.vercel.app/
MIT License
3.58k stars 124 forks source link

class for panel collapsed state #346

Closed Fabioni closed 2 months ago

Fabioni commented 2 months ago

Can we have a class or data attribute in the panel that toggles when the panel is collapsed? Currently we can only use onCollapse and onExpand, but that is kind of overkill for just styling.

bvaughn commented 2 months ago

If your'e looking for something that can be used for styling, or for e2e tests, then attributes like data-panel-collapsible and data-panel-size already exist (e.g. data-panel-size="0" is collapsed)

Fabioni commented 2 months ago

data-panel-size will have the collapsedSize and not 0, so it is not logically to use that.

bvaughn commented 2 months ago

If the collapsed size is not zero, then it will have whatever the collapsed size is. You know that size, Because you pass it in as a prop, so you can write your selector accordingly.

Fabioni commented 2 months ago

It's feels more idiomatic to have a dedicated data attribute for that. Otherwise I need to change a css/tailwind value somewhere else in the code if I change the collapsedSize value which is weird. Also css could be applied to many panels which all could have different collapsedSizes. Whether a panel is collapsed or not is idiomatic a different information than the current size of it, so it should also have separate representations.