npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-comparison-table

v1.0.0

Published

Comparison table with fixed header for React Native

Downloads

114

Readme

react-native-comparison-table

MIT License npm version

Comparison table with fixed header for React Native

Getting started

yarn add react-native-comparison-table

or

npm install react-native-comparison-table --save

Usage

import {
  ComparisonTable,
  ComparisonTableSection,
  ComparisonTableRow
} from 'react-native-comparison-table';
  const phones = [
    {
      id: 1,
      name: 'iPhone 11 Pro',
      image: require('./images/iphone11_pro.jpg'),
      screenSize: '5.8',
      display: 'Super Retina XDR display',
      height: '144.0',
      width: '71.4',
      depth: '8.1',
      weight: '188',
      videoPlayback: '18',
      audioPlayback: '65'
    },
    {
      id: 2,
      name: 'iPhone 11',
      image: require('./images/iphone11.jpg'),
      screenSize: '6.1',
      display: 'Liquid Retina HD display',
      height: '150.9',
      width: '75.7',
      depth: '8.3',
      weight: '194',
      videoPlayback: '17',
      audioPlayback: '65'
    },
    {
      id: 3,
      name: 'iPhone SE (2nd generation)',
      image: require('./images/iphoneSE.jpg'),
      screenSize: '4.7',
      display: 'Retina HD display',
      height: '138.4',
      width: '67.3',
      depth: '7.3',
      weight: '148',
      videoPlayback: '13',
      audioPlayback: '40'
    }
  ]

  <ComparisonTable
    height={600}
    headerCellWidth={110}
    cellWidth={200}
  >
    <ComparisonTableRow
      fixed
      headerCellContent="Model"
      data={phones}
      comparing="name"
      rowStyle={styles.rowShadow}
    />
    <ComparisonTableRow
      headerCellContent=""
      data={phones}
      cellContent={({ item }) => (
        <Image
          source={item.image}
          resizeMode="contain"
          style={{
            width: 80,
            height: 120
          }}
        />
      )}
      cellStyle={styles.alignCenter}
    />
    <ComparisonTableSection title="Size and Weight">
      <ComparisonTableRow
        headerCellContent="Height"
        data={phones}
        comparing="height"
      />
      <ComparisonTableRow
        headerCellContent="Width"
        data={phones}
        comparing="width"
      />
      <ComparisonTableRow
        headerCellContent="Weight"
        data={phones}
        getBestBy="asc"
        comparing="weight"
      />
    </ComparisonTableSection>
  </ComparisonTable>

Check out the example project for more examples.

Props

<ComparisonTable />

| Prop name | Type | Description | Default | | --------------- | ------- | ------------------------------------------------------------------------------ | ------- | | isHighlightBest | boolean | If false the cell with the best compared value won't be highlighted | true | | headerCellWidth | number | Width of the header cell | 90 | | cellWidth | number | Width of the body cell | 156 | | height | number | The height of the table. It is required if the top ComparisonTableRow is fixed | 400 |

<ComparisonTableSection />

| Prop name | Type | Description | Default | | --------- | ------ | ------------------------ | ------- | | title | string | The title of the section | |

<ComparisonTableRow />

| Prop name | Type | Description | Default | | ----------------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | | data | array | Array of objects to compare. Data structure can refer to the example above. Required | | | comparing | string/function | string: The key of the object to compare. function: need to return an array of data to compare, e.g. (data) => data.map(item => item.count). Required if the best value need to be highlighted | | | getBestBy | string/function | string: asc or desc. The values will be sorted in specified order and the first item would be the best. function: custom compare function be passed to array.sort(). The first item will be the best. Required if the best value need to be highlighted | | | fixed | boolean | Fixes the row position. Normally would apply to the first row | false | | cellTextAlign | string | Setting the textAlign of the body cell text | left | | headerCellContent | string/function | The content of the header cell. Use function to render custom content. You can pass empty string if you want the header cell to be empty | | | headerCellStyle | object | The style of the header cell. | | | cellContent | function | Customise the content of body cell. By default the body cell will display the comparing value ({ item, index, isBest, cellTextStyle, bestCellTextStyle }) => {} | | | cellStyle | object | The style of the body cell. | | | rowStyle | object | The style of the row. | | | bestCellStyle | object | The style of the cell containing best value. Expected to apply to <View> | | | bestCellTextStyle | object | The text style of the cell containing best value. Expected to apply to <Text> | | | mergeCells | boolean | Merges the body cells. Combining with empty headerCellContent and custom cellContent, you can create a row with custom content | false |

Contributors

Issues and pull requests are welcomed. For issues, please attach a screenshot showing the bug along with code snippet.

License

The library is released under the MIT licence.