grommet / grommet-index

UI and example server for searching, filtering, and displaying mass quantities of items.
Apache License 2.0
10 stars 16 forks source link

Indexes of components are not displaying correctly #75

Closed liuwei-HP closed 7 years ago

liuwei-HP commented 8 years ago

Expected Behavior

The second column shows on the right or provide a property for our own definition

Actual Behavior

Shows on the left and is not aligned

URL, screen shot, or Codepen exhibiting the issue

clipboard

Steps to Reproduce

  1. Use Index with "list" view type to display data.
  2. Open the page Use with Chrome browser.
  3. Shows not as expected.

    Your Environment

nickjvm commented 8 years ago

@liuwei-HP I believe this can be achieved with existing props (using justify="between"):

<ListItem justify="between">
  <Box>Left-aligned content</Box>
  <Box>Right-aligned content</Box>
</ListItem>

Codepen

christinHP commented 8 years ago

@nickjvm we use gromment-index/components/Index.js, not grommet/components/ListItem.js

nickjvm commented 8 years ago

@christinHP You can combine the usage of both to achieve the layout you need. Use ListItem from Grommet and pass your own component to Index to use for each item via the itemComponent prop.

import Index from 'grommet-index/components/Index';
import ListItem from 'grommet/components/ListItem';

const MyItemComponent = ({item}) => {
  return (
     <ListItem justify="between">
       <Box>{item.name}</Box> {/*left-aligned*/}
       <Box>{item.somethingElse}</Box> {/*right-aligned*/}
     </ListItem>
  );
}

...

export function MyIndex() {
  return (
    <Index view="list" itemComponent={MyItemComponent} ... />
  );
}
christinHP commented 8 years ago

@nickjvm Thank you, we will try with itemComponent

tracybarmore commented 7 years ago

Thanks for the collaboration! We are closing this issue for now. Feel free to reopen if there are more concerns. Thanks!