polaris-resource-list
implements the Polaris Resource list component. The renderItem
property has been replaced with an itemComponent
attribute which takes a component name as a string. The provided component will be passed the item
and its itemId
as attributes.
The itemComponent
property is required, so that polaris-resource-list
knows how to render individual items, and how those items should behave when the user interacts with them. A polaris-resource-list/item
component is provided as a quick starting point for this. It accepts the following properties: accessibilityLabel
, ariaControls
, ariaExpanded
, media
, persistActions
, shortcutActions
, children
, url
and onClick
.
#### Simple resource list
Define a tagless item component my-item-component
to render items:
/* app/components/my-item-component.js */
import Component from '@ember/component';
import { computed } from '@ember/object';
export default Component.extend({
tagName: '',
// `item` and `itemId` will be passed in by `polaris-resource-list`.
item: null,
itemId: null,
accessibilityLabel: computed('item.name', function() {
return `View details for ${this.get('item.name')}`;
}).readOnly(),
});
then use that component with polaris-resource-list
to render items (using ember-array-helper):
For additional examples, refer to the source code for the resource-list
page and associated components in the dummy app.