1.1.0 • Published 3 years ago

@pmwcs/list v1.1.0

Weekly downloads
5
License
MIT
Repository
github
Last release
3 years ago

Lists

Lists are continuous, vertical indexes of text or images.

  • Module @pmwcs/list
  • Import styles:
    • Using CSS Loader
      • import '@pmwcs/list/styles';
    • Or include stylesheets
      • '@material/list/dist/mdc.list.css'
      • '@material/ripple/dist/mdc.ripple.css'
      • '@pmwcs/icon/icon.css'
  • MDC Docs: https://material.io/develop/web/components/lists/

Basic Usage

<List>
  <ListItem>Cookies</ListItem>
  <ListItem>Pizza</ListItem>
  <ListItem>Icecream</ListItem>
</List>
<List twoLine>
  <ListItem>
    <ListItemGraphic icon="star_border" />
    <ListItemText>
      <ListItemPrimaryText>Cookies</ListItemPrimaryText>
      <ListItemSecondaryText>$4.99 a dozen</ListItemSecondaryText>
    </ListItemText>
    <ListItemMeta icon="info" />
  </ListItem>
  <ListItem>
    <ListItemGraphic icon="local_pizza" />
    <ListItemText>
      <ListItemPrimaryText>Pizza</ListItemPrimaryText>
      <ListItemSecondaryText>$1.99 a slice</ListItemSecondaryText>
    </ListItemText>
    <ListItemMeta icon="info" />
  </ListItem>
  <ListItem activated>
    <ListItemGraphic icon="mood" />
    <ListItemText>
      <ListItemPrimaryText>Icecream</ListItemPrimaryText>
      <ListItemSecondaryText>$0.99 a scoop</ListItemSecondaryText>
    </ListItemText>
    <ListItemMeta>Winner!</ListItemMeta>
  </ListItem>
</List>

Simplified Usage

While there are siutations where you would need / want to compose the entire list yourself, it can be quite verbose. SimpleListItem provides a compact syntax that allows you to pass all options as props. The following example is roughly equivalent to the one above.

<List twoLine>
  <SimpleListItem
    graphic="star_border"
    text="Cookies"
    secondaryText="Chocolate chip"
    metaIcon="info"
  />
  <SimpleListItem
    graphic="local_pizza"
    text="Pizza"
    secondaryText="Pepperoni"
    metaIcon="info"
  />
  <SimpleListItem
    activated
    graphic="mood"
    text="Icecream"
    secondaryText="Chocolate cookie dough"
    meta="Winner!"
  />
</List>

List

A List Component

Props

NameTypeDescription
apiRefundefined \| (api: ListApi \| null) => voidAn internal api used for cross component communication
avatarListundefined \| false \| trueMakes the list start detail circular for avatars.
denseundefined \| false \| trueReduces the padding on List items.
foundationRefReact.Ref<MDCListFoundation \| null>Advanced: A reference to the MDCFoundation.
nonInteractiveundefined \| false \| trueMakes the list non interactive. In addition, you'll have to set ripple={false} on the individual ListItems.
onActionundefined \| (evt: ListOnActionEventT) => voidA callback for when a list item is interacted with. evt.detail = number
twoLineundefined \| false \| trueGives more space for dual lined list items.
verticalundefined \| false \| trueSets the lists vertical orientation. Defaults to true
wrapFocusundefined \| false \| trueSets the list to allow the up arrow on the first element to focus the
last element of the list and vice versa. Defaults to true

ListItem

A ListItem component.

Props

NameTypeDescription
activatedundefined \| false \| trueA modifier for an active state.
disabledundefined \| false \| trueA modifier for a disabled state.
rippleRipplePropTAdds a ripple effect to the component
selectedundefined \| false \| trueA modifier for a selected state.

ListItemPrimaryText

Primary Text for the ListItem

ListItemSecondaryText

Secondary text for the ListItem

ListItemGraphic

A graphic / icon for the ListItem

Props

NameTypeDescription
iconPMWCS.IconPropTThe icon to use. This can be a string for a font icon, a url, or whatever the selected strategy needs.

ListItemMeta

Meta content for the ListItem. This can either by an icon by setting the icon prop, or any other kind of content.

Props

NameTypeDescription
iconPMWCS.IconPropTThe icon to use. This can be a string for a font icon, a url, or whatever the selected strategy needs.

ListDivider

A divider for the List

ListGroup

A container to group ListItems

ListGroupSubheader

A subheader for the ListGroup

SimpleListItem

A simple list item template.

Props

NameTypeDescription
activatedundefined \| false \| trueA modifier for an active state.
childrenReact.ReactNodeChildren to render
disabledundefined \| false \| trueA modifier for a disabled state.
graphicPMWCS.IconPropTA graphic icon for the ListItem.
metaReact.ReactNodeMeta content for the ListItem instead of an icon.
metaIconPMWCS.IconPropTA meta icon for the ListItem
rippleRipplePropTAdds a ripple effect to the component
secondaryTextReact.ReactNodeSecondary Text for the ListItem.
selectedundefined \| false \| trueA modifier for a selected state.
textReact.ReactNodeText for the ListItem.