-
Notifications
You must be signed in to change notification settings - Fork 50
Item Collection: Enhance API #218
Comments
Tech Design for Item Collection EnhancementSummaryTech Design Considerations:
Item Collection API Enhancement
This component will export the following components: ItemCollection.Item, ItemCollection.Display and ItemCollection.Comment. Later will also export ItemCollection.Header and ItemCollection.Subheader. Item ComponentSummaryThis component would handle the rendering of a list item or table row for the ItemCollection. By default, this would render an ListItem with an ItemView as the content. Else it will render a TableRow with the element layout (startAccessory, displays, comment, endAccessory). This component would not handle missing element logic, but provides a clean way to represent an item within the item collection. Additionally, this component will export the ItemView.Display and ItemView.Comment components as Item.Display & Item.Comment. React Props:As a replacement to the
Implementation:<Item
startAccessory={ <Accessory />}
comment={ <Item.Comment />}
endAcessory={ <Accessory />}
itemViewStyles={{ isTruncated: true }}
>
<Item.Display />
<Item.Display />
<Item.Display />
</Item> Header & Subheader ComponentThere are some design/behavior aspects that need to be considered and will land this work in a separate PR/tech design. New Proposed ItemCollection ImplementationBasic Construction Overview <ItemCollection {...ItemCollectionProps}>
<ItemCollection.Item startAccessory={} endAccessory={} comment={}>
<ItemCollection.Display />
<ItemCollection.Display />
<ItemCollection.Display />
</ItemCollection.Item>
<ItemCollection.Item />
<ItemCollection.Item />
</ItemCollection> Actual Example # Example
import React form 'terra-item-collection';
import ItemCollection from 'terra-clinical-item-collection';
<ItemCollection
breakpoint="small"
type="static"
tableStyles={{ isPadded: true }}
listStyles={{ isDivided: true }}
requiredElements={{ startAccessory: true, endAccessory: true, displays: 3, comment: true }}
>
<ItemCollection.Item
startAccessory={<IconAlert />}
comment={ <ItemCollection.Comment text="Faint red rash appeared at 08-05-2016 13:24:00" />}
endAcessory={<IconInformation />}
itemViewStyles={{ isTruncated: true }}
>
<ItemCollection.Display icon={<IconPerson />} text="Asif Khan" />
<ItemCollection.Display text="Care Position: Primary" />
<ItemCollection.Display text="Room 100A" />
</ItemCollection.Item>
<ItemCollection.Item
endAcessory={<IconInformation />}
itemViewStyles={{ isTruncated: true }}
>
<ItemCollection.Display icon={<IconPerson />} text="John Doe" />
<ItemCollection.Display text="Care Position: Secondary" />
</ItemCollection.Item>
</ItemCollection> |
+1. This looks really good. The one concern I do have is providing an uncontrolled (i.e. internally stateful) Single-/MultiSelect-ItemCollection at all. I'm sure I haven't thought through every scenario, but a majority of the scenarios that I have thought of will require the (consumer) controlled component. It wouldn't necessarily hurt to continue providing uncontrolled components (in addition to controlled), but it may cause confusion among the consumer base unless we can provide documentation that clearly communicates "These are the scenarios in which using the uncontrolled component is possible." I just fear that that list of scenarios will be pretty short (and not justify the cost of development/maintenance/confusion). Maybe we could start with the controlled version and see what consumers ask for? Regardless, we should develop a canonical example for maintaining selections that people can reference when building their own components. That may just be the current SingleSelectItemCollection (just in a non-released form? I dunno 🤷♂️). |
Updating
|
After some offline discussions with @tbiethman , I support his suggestion to not offer a single-/multiselect item collection initially. While I can see value in providing built in selection functionality there is a concern that we don't know enough yet to implement it correctly. In this case, not doing something is preferred to doing something wrong. After we gather some more feedback on consumers using the uncontrolled item collection we can revisit this topic to see if a controlled single/multiselect makes sense. Adding components later would be passive. Removing them if we make a mistake or they aren't used would be non passive. |
I will be removing the |
Issue Description
The current prop
row
takes an array of hashes to generate the list and table displays. This is hard to use and inflexible for future enhancements.Tech Design Considerations:
Issue Type
NOTE: This will be a major version bump.
The text was updated successfully, but these errors were encountered: