lifeomic / chroma-react

Open source design system from LifeOmic, built with React
https://lifeomic.github.io/chroma-react/
MIT License
48 stars 9 forks source link

[PHC-4158] SelectOption Title Typing #329

Closed MMFane closed 1 year ago

MMFane commented 1 year ago

What Was Changed

Questions for the Team

Screenshots

see linked PR for a visual example

evanheisler commented 1 year ago

There are currently no stories for SelectOption in the storybook - do you think I should create some?

I don't know if more stories provide much value, if the options are essentially just styled text w/o any behavior of their own.

This could be potentially useful in other components where people might want to use these styled sub elements

I'd say be fairly prescriptive where to add looser types, if for no other reason than to avoid opening up a bunch of new edge cases and test scenarios. Technically, allowing an array of ReactNode's as an option title could create problems, even if the use case here is an i18n object.

dexterca commented 1 year ago

There are currently no stories for SelectOption in the storybook - do you think I should create some?

Can we include an example in Select.stories.tsx? I think it would be handy for me to reference some kind of example in storybook.

Should we make an effort to update all potentially applicable use cases now, or go on a need-to-build basis?

I'm good with going on a need-to-build basis

MMFane commented 1 year ago

I'd say be fairly prescriptive where to add looser types, if for no other reason than to avoid opening up a bunch of new edge cases and test scenarios. Technically, allowing an array of ReactNode's as an option title could create problems, even if the use case here is an i18n object.

I think it makes sense to be cautious. I'm curious, what's on your mind in terms of problems and risks introduced by adding ReactNode[]? Trying to gauge if this change is worth it.

If we decide to move forward with this I can add a story to Select for an example, @dexterca.

evanheisler commented 1 year ago

I'd say be fairly prescriptive where to add looser types, if for no other reason than to avoid opening up a bunch of new edge cases and test scenarios. Technically, allowing an array of ReactNode's as an option title could create problems, even if the use case here is an i18n object.

I think it makes sense to be cautious. I'm curious, what's on your mind in terms of problems and risks introduced by adding ReactNode[]? Trying to gauge if this change is worth it.

My mind went to someone trying to add some sort of complex interactive component as a "title", which I guess isn't really a problem for the library, we just wouldn't be warning someone of a potential mistake when in most cases this prop is just a simple string.

I think you have a legitimate use case, but for arguments' sake I wonder if you should just cast it locally to override the type as needed, or if we want this type to be unknown.

MMFane commented 1 year ago

@evanheisler Yeah, casting would be a great solution for now. Since this is the only use-case so far, I agree that modifying Chrōma is a little extreme. And I think making the type unknown could potentially be more confusing or open to interpretation. Thanks for thinking through this with me.