cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              @import url('https://fonts.googleapis.com/css?family=PT+Sans:400,400i,700,700i');

body {
  font-family: 'PT Sans', Arial, Helvetica, sans-serif;
  font-size: 17px;
  font-weight: 400;
  padding: 20px;
}

select {
  background: #eee right top no-repeat url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTkuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeD0iMHB4IiB5PSIwcHgiIHZpZXdCb3g9IjAgMCA0NTUgNDU1IiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA0NTUgNDU1OyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSIgd2lkdGg9IjUxMnB4IiBoZWlnaHQ9IjUxMnB4Ij4KPHBhdGggZD0iTTAsMHY0NTVoNDU1VjBIMHogTTIyNy41LDMwNy4yMzdMOTkuNDExLDE3OS41NjVsMjEuMTc4LTIxLjI0OEwyMjcuNSwyNjQuODhsMTA2LjkxMS0xMDYuNTYzbDIxLjE3OCwyMS4yNDhMMjI3LjUsMzA3LjIzN3ogICIgZmlsbD0iIzFiNmZhMCIvPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K');
  background-size: contain;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border: 1px solid #ddd;
  border-radius: 0;
  font-size: 1rem;
  padding: .75rem 4rem .75rem .75rem;

  &:focus {
    box-shadow: 0 0 0 3px lighten(#1b6fa0, 50%);
    outline: 0;
  }
}

select:-moz-focusring {
  outline: none;
  border: none;
}

.content-container {
  width: 600px;
}

.table-wrapper {
  border: 1px solid #ddd;
}

.table {
  border-collapse: collapse;
  width: 100%;
  
  th {
    background: #1b6fa0;
    color: #fff;
    text-align: left;
  }
  
  th, td {
    padding: 16px;
  }
  
  thead > tr {
    
    & > * + * {
      border-left: 1px solid darken(#1b6fa0, 6%);
    }
  }
  
  tbody > tr {
    
    &:nth-child(even) {
      background: #f0f0f0;
    }
    
    & > * + * {
      border-left: 1px solid #ddd;
    }
  }
}

.filters {
  margin-bottom: 16px;
}
            
          
!
            
              const { Component, PropTypes } = React;
const { render } = ReactDOM;

const people = [
  { id: 1, name: 'Fred Nelson', dateJoined: '07/05/2017', isPaid: true },
  { id: 2, name: 'Barry Johnson', dateJoined: '04/31/2014', isPaid: true },
  { id: 3, name: 'Joan Smith', dateJoined: '07/24/2017', isPaid: false },
  { id: 4, name: 'Robert Neilson', dateJoined: '12/22/2016', isPaid: true },
  { id: 5, name: 'Ted McKormick', dateJoined: '01/05/2010', isPaid: false },
  { id: 6, name: 'Sally Wilson', dateJoined: '08/24/2017', isPaid: true },
];

function generateRandomKey (label) {
  return `${label || 'key'}-${Math.round(Math.random() * 100000)}`;
}

class Table extends Component {
  constructor (props) {
    super(props);
  }
  
  static propTypes = {
    collection: PropTypes.array.isRequired,
    columns: PropTypes.array.isRequired,
    className: PropTypes.string,
  };

  static defaultProps = {
    columns: [],
    collection: [],
    className: '',
  };
  
  render () {
    
    const { 
      collection, 
      columns, 
      className, 
      ...other, } = this.props;
    
    return (
      <div className="table-wrapper">
        <table className="table">
          <thead>
            <tr>
              { _.map(columns, column => <th key={ generateRandomKey() }>{ column }</th>) }
            </tr>
          </thead>
          <tbody>
            {_.map(collection, item => {
              return (
                <tr key={ generateRandomKey() }>
                  <td>{ item.name }</td>
                  <td>{ item.dateJoined }</td>
                  <td>{ item.isPaid ? 'Yes' : 'No' }</td>
                </tr>
              );
            })}
          </tbody>
        </table>
      </div>
    );
  }
}

class App extends Component {
  constructor (props) {
    super(props);
    
    this.state = { 
      collection: people, 
    };
  }
  
  handleFilterChange = (collection, e) => {
    const filter = e.target.value;
            
    switch (filter) {
      case 'paid':
        this.setState({ collection: _.filter(collection, { isPaid: true }) });
        break;
      case 'unpaid':
        this.setState({ collection: _.filter(collection, { isPaid: false }) });
        break;
      case 'within last 30 days':
        this.setState({ collection: _.filter(collection, model => {
          return Date.parse(model.dateJoined) <= new Date().getTime() 
              && Date.parse(model.dateJoined) >= new Date().getTime() - (30 * 24 * 60 * 60 * 1000);
        }) });
        break;
      case 'within next 30 days':
        this.setState({ collection: _.filter(collection, model => {
          return Date.parse(model.dateJoined) >= new Date().getTime() 
              && Date.parse(model.dateJoined) <= new Date().getTime() + (30 * 24 * 60 * 60 * 1000);
        }) });
        break;
      case 'older than 30 days':
        this.setState({ collection: _.filter(collection, model => {
          return Date.parse(model.dateJoined) < new Date().getTime() - (30 * 24 * 60 * 60 * 1000);
        }) });
        break;
      default:
        this.setState({ collection: people });
        break;
    }
  };
  
  render () {
    
    const { handleFilterChange } = this;
    const { collection } = this.state;
    
    return (
      <div className="content-container">
        <select className="filters" onChange={ (e) => handleFilterChange(people, e) }>
          <option value="">All</option>
          <option value="within last 30 days">Within last 30 Days</option>
          <option value="within next 30 days">Within next 30 Days</option>
          <option value="older than 30 days">Older than 30 Days</option>
          <option value="paid">Paid</option>
          <option value="unpaid">Unpaid</option>
        </select>
        <Table
          columns={ ['Name','Date Joined','Paid'] }
          collection={ collection } />
      </div>
    );
  }
};

render(<App />, document.getElementById('root'));
            
          
!
999px
Loading ..................

Console