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

TreeView: Add support for external styling #4487

Closed
ayy-bc opened this issue Apr 10, 2024 · 3 comments
Closed

TreeView: Add support for external styling #4487

ayy-bc opened this issue Apr 10, 2024 · 3 comments
Labels
component: TreeView Issues related to the TreeView component

Comments

@ayy-bc
Copy link
Contributor

ayy-bc commented Apr 10, 2024

Description

We are using TreeView in the NestedListView and we needed to override some styling to match the design needs for using NestedListView for SubIssues.

Currently, we are using css selectors to override some of the styles (which seems a little hacky) and thought it would be helpful we could pass styles using a prop.

Example PRs:

@ayy-bc ayy-bc added component: TreeView Issues related to the TreeView component and removed react labels Apr 10, 2024
@siddharthkp
Copy link
Member

Hi! Thanks for taking the time!

Currently, we are using css selectors to override some of the styles (which seems a little hacky) and thought it would be helpful we could pass styles using a prop.

I see TreeView doesn't support sx for all the child items. This was partially intentional at the time of building it so that the design does not deviate too much. The use cases however are many and varied now (like NestedListView!)

We want to phase out styling through a prop (sx) over time, so I would recommend using classNames. However, TreeView does not have reliable selectors that you can target yet. Would that be a useful change for you?

@iansan5653
Copy link
Contributor

iansan5653 commented Apr 11, 2024

@siddharthkp I think a good solution would be to support custom styling on TreeView and TreeView.Item. That could be via the sx prop or className prop (or maybe both for this in-between time).

However, TreeView does not have reliable selectors that you can target yet.

I think we should probably avoid getting into the habit of exposing targetable selectors, because it makes things difficult to change. Long term, it will make it harder for PRC to move to CSS Modules because the class names would need to remain static.

If there's specific things we want to support styling internally, I think we should either add props for the required variants, like hideNestingIndicators, or we should add support for more externally defined classnames rather than defining new internal classnames. This could look like a new nestingIndicatorClassName prop or maybe even a whole new standard PRC pattern where we have an internalClassNames prop that accepts an object: <TreeView.Item internalClassNames={{nestingIndicator: styles.hidden}} />

Or, one more option might be to set data- attributes for selection instead of classes, which preserves encapsulation. But I think we'd want to document those and personally I'd prefer some props-based approach that can be typechecked vs an approach that requires more complex CSS selectors.

@JelloBagel
Copy link
Contributor

Closed by #4512

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: TreeView Issues related to the TreeView component
Projects
None yet
Development

No branches or pull requests

4 participants