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-tournament

v0.1.1

Published

React Tournament component

Downloads

11

Readme

Dev Peer Size GitHub issues GitHub pull requests GitHub followers

NPM

react-tournament

🏆 React Tournament component 🔝

Demo

React Stories are available here

DOCs are available here

Usage :-------------------------:

700 width table :-------------------------:

Auto width table :-------------------------:

Big table :-------------------------:

Table with custom styles :-------------------------:

How to use

To install package:

# npm
npm install react-tournament --save

#yarn
yarn add react-tournament

Use in JS:

// CommonJS
const { ReactTournament } = require('react-tournament');
// or
const ReactTournament = require('react-tournament').default;

// ES6 modules
import { ReactTournament } from 'react-tournament';
//or
import ReactTournament from 'react-tournament';

// In browser
const ReactTournament = window.ReactTournament;

Render in JavaScript:

export const Table = ({
  aspectRatio,
  data,
  theme,
  width,
}) => (
  <ReactTournament
    aspectRatio={aspectRatio}
    data={data}
    theme={theme}
    width={width}
  />
)

DOCS

The only component exposed in library is ReactTournament component. All props usage is described below:

ReactTournament.propTypes = {
  aspectRatio: PropTypes.number,
  data: PropTypes.arrayOf(
    PropTypes.arrayOf(
      PropTypes.arrayOf(PropTypes.shape({
        isWinner: PropTypes.bool,
        user: PropTypes.string.isRequired,
        userLink: PropTypes.string,
        score: PropTypes.number.isRequired,
        scoreLink: PropTypes.string,
      })),
    ),
  ).isRequired,
  theme: PropTypes.shape({
    primary: PropTypes.shape({
      default: PropTypes.string,
      dark: PropTypes.string,
      darkest: PropTypes.string,
      light: PropTypes.string,
    }),
    success: PropTypes.shape({
      default: PropTypes.string,
      dark: PropTypes.string,
      darkest: PropTypes.string,
      light: PropTypes.string,
    }),
    fail: PropTypes.shape({
      default: PropTypes.string,
      dark: PropTypes.string,
      darkest: PropTypes.string,
      light: PropTypes.string,
    }),
    textSmall: PropTypes.string,
    textMedium: PropTypes.string,
    textLarge: PropTypes.string,

    textDark: PropTypes.string,
    textLight: PropTypes.string,
  }),
  width: PropTypes.string,
};

Props

aspectRatio

Prop aspectRatio is designed to set a ratio of width and height. aspectRatio is 2 means that pair box's width 2 times more than height

data

Prop data is designed to pass information about users in tournament. data should be passed as array of rounds. Each round is array of pairs. Each pair is array with length equals 2 of people (oponents). Each oponent has next shape:

shape({
  isWinner: PropTypes.bool,
  user: PropTypes.string.isRequired,
  userLink: PropTypes.string,
  score: PropTypes.number.isRequired,
  scoreLink: PropTypes.string,
})

Example:

const data = export const data = [
  // 1st round
  [
    // 1st pair
    [
      // 1st person
      {
        user: 'yankouskia',
        userLink: 'https://github.com/yankouskia',
        score: 87,
        scoreLink: 'https://github.com/yankouskia/react-tournament',
        isWinner: true,
      },
      // 2nd person
      {
        user: 'Alex',
        userLink: 'https://github.com/yankouskia',
        score: 32,
        scoreLink: 'https://github.com/yankouskia/react-tournament',
      }
    ],
    // 2nd pair
    [
      // 3rd person
      {
        user: 'yankouskia',
        userLink: 'https://github.com/yankouskia',
        score: 56,
        scoreLink: 'https://github.com/yankouskia/react-tournament',
        isWinner: true,
      },
      // 4th person
      {
        user: 'Alex',
        userLink: 'https://github.com/yankouskia',
        score: 54,
        scoreLink: 'https://github.com/yankouskia/react-tournament',
      }
    ]
  ],
  // 2nd round
  [
    // 1st pair
    [
      // 1st person
      {
        user: 'yankouskia',
        userLink: 'https://github.com/yankouskia',
        score: 34,
        scoreLink: 'https://github.com/yankouskia/react-tournament',
      },
      // 2nd person
      {
        user: 'Alex',
        userLink: 'https://github.com/yankouskia',
        score: 98,
        scoreLink: 'https://github.com/yankouskia/react-tournament',
      }
    ]
  ],
];

theme

Prop theme is designed to create custom styles for the tournament table. theme props has next shape:

shape({
  primary: PropTypes.shape({
    default: PropTypes.string,
    dark: PropTypes.string,
    darkest: PropTypes.string,
    light: PropTypes.string,
  }),
  success: PropTypes.shape({
    default: PropTypes.string,
    dark: PropTypes.string,
    darkest: PropTypes.string,
    light: PropTypes.string,
  }),
  fail: PropTypes.shape({
    default: PropTypes.string,
    dark: PropTypes.string,
    darkest: PropTypes.string,
    light: PropTypes.string,
  }),
  textSmall: PropTypes.string,
  textMedium: PropTypes.string,
  textLarge: PropTypes.string,

  textDark: PropTypes.string,
  textLight: PropTypes.string,
})

Any or all values could be overrided. Custom configuration will be merged with default one. Default theme is next:

{
  primary: {
    default: '#64b5f6',
    dark: '#1565c0',
    darkest: '#002171',
    light: '#bbdefb',
  },
  success: {
    default: '#81c784',
    dark: '#388e3c',
    darkest: '#003300',
    light: '#c8e6c9',
  },
  fail: {
    default: '#e57373',
    dark: '#c62828',
    darkest: '#7f0000',
    light: '#ffcdd2',
  },
  textSmall: '12px',
  textMedium: '16px',
  textLarge: '22px',

  textDark: '#000000',
  textLight: '#ffffff',
};

width

Prop width is designed to set width for the tournament table. Value auto is applied for width prop by default. Could be any CSS valid value (800px, auto, 50%, ...).

Support

You can support via GitHub stars Twitter Follow

Restriction

React >=16.0.0 and styled-components >=4.0.0 should be installed for using this library

Contributing

react-tournament is open-source library, opened for contributions

License

react-tournament is MIT licensed