SelectPanel messages API - Seeking feedback #5031
Replies: 3 comments 9 replies
-
Of the two options I prefer the However, one challenge I find is that some SelectPanels are used within Forms. As a Primer React user, I would expect to use the |
Beta Was this translation helpful? Give feedback.
-
This is the classic question that always comes up when designing component APIs: how much freedom should we give consumers? In my experience, the more freedom we give consumers, the greater the chance for incongruous outcomes. This case is even trickier than most because we can almost get away with a props-only approach. Unfortunately the designs show that consumers should be able to add links to the message description, and for error messages it would be nice to eventually be able to add a "Try again" button, etc etc. So I think we have to allow arbitrary content for both error messages and no items/matches. That being said, IMO we can still establish some guardrails. The designs have two bits of text, a title and a description, with specific font colors and sizes. Whatever API we choose, let's make it easy to do the default thing, eg. provide plaintext values for these fields, and style them appropriately. As far as behavior goes, I'm firmly in the camp of having the component manage showing/hiding the messages based on the current filter. Eg. if there is no filter text, show the "no items" message; if there is filter text, show the "no matches" message. I would really prefer to reduce the amount of knowledge a consumer has to have about how select panels are supposed to work in order to use them correctly. Requiring consumers to make decisions about when messages are shown or hidden exacerbates this knowledge gap and will lead to problems. Not only will they have to understand the API, but also implicit rules about how to use it appropriately that they may or may not have read in the documentation. The API should be clear enough to (largely) speak for itself. I'm curious what y'all think of an alternative approach where each message has two slots, a title and a description. I imagine it would look something like this: <SelectPanel.Message variant="no-items">
<SelectPanel.Message.Title>
No projects found.
</SelectPanel.Message.Title>
<SelectPanel.Message.Description>
Would you like to <Link href="/projects/create">create one</Link>?
</SelectPanel.Message.Description>
</SelectPanel.Message> That's kind of verbose. Maybe we can simplify it?
That's true. I would think we could add a prop for allowing the consumer to tell us what state the component should be in, which would let us to show the correct message depending on the component's internal state, eg. if items are visible or not.
I'm not sure I follow. If the Additional context
|
Beta Was this translation helpful? Give feedback.
-
Just summarising the API after evaluating all the feedback. I appreciate you all very much 🙏🏻 Children APIEmpty State (Initial)👉 Component manages the state of visibility of "noInitialItems" message along with the announcement of the message, style, UX etc. <SelectPanel.Message variant="noInitialItems" title="Custom title when there is no items available in the first load">
Custom message
</SelectPanel.Message> Empty State (Filtered)👉 Component manages the state of visibility of "noFilteredItems" message along with the announcement of the message, style, UX etc <SelectPanel.Message variant="noFilteredItems" title="Custom title when there is no matches found">
Custom message
</SelectPanel.Message>
</SelectPanel> Warning State👉 Consumers manage the state of the visibility of warning messages. { isWarning ? (
<SelectPanel.Message variant="warning" title="Custom warning title">
Custom warning message
</SelectPanel.Message>
) : null } Error State👉 Consumers manage the state of the visibility of error messages. { isError ? (
<SelectPanel.Message variant="error" title="Custom error title">
Custom error message
</SelectPanel.Message>
) : null } |
Beta Was this translation helpful? Give feedback.
-
Gathering the notes from our brainstorming sessions in a nicer format to present what API options we have so far with some extra content.
This discussion is primarily needed for empty states however we are designing the API in error and warning state in mind since they are a part of the feature improvements.
OPTION 1 - Children API
OPTION 2 - Messages object
Requirements
Facts
Takeaways
Proposal
Appreciate any feedback 🫶
@siddharthkp @camertron
Beta Was this translation helpful? Give feedback.
All reactions