Pen Settings

HTML

CSS

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.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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.

+ add another resource

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <div id="root"></div>

<iframe width="0" height="0" border="0" name="dummyframe" id="dummyframe"></iframe>
              
            
!

CSS

              
                body {
  padding: 5px;
}
body {
  background: #fafafa
    url(https://jackrugile.com/images/misc/noise-diagonal.png);
  color: #444;
  font: 100%/30px 'Helvetica Neue', helvetica, arial, sans-serif;
  text-shadow: 0 1px 0 #fff;
}

strong {
  font-weight: bold;
}

em {
  font-style: italic;
}

table {
  background: #f5f5f5;
  border-collapse: separate;
  box-shadow: inset 0 1px 0 #fff;
  font-size: 12px;
  line-height: 24px;
  margin: 30px auto;
  text-align: left;
  width: 800px;
}

th {
  background: url(https://jackrugile.com/images/misc/noise-diagonal.png),
    linear-gradient(#777, #444);
  border-left: 1px solid #555;
  border-right: 1px solid #777;
  border-top: 1px solid #555;
  border-bottom: 1px solid #333;
  box-shadow: inset 0 1px 0 #999;
  color: #fff;
  font-weight: bold;
  padding: 10px 15px;
  position: relative;
  text-shadow: 0 1px 0 #000;
  text-align:center;
}

th:after {
  background: linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, .08));
  content: '';
  display: block;
  height: 25%;
  left: 0;
  margin: 1px 0 0 0;
  position: absolute;
  top: 25%;
  width: 100%;
}

th:first-child {
  border-left: 1px solid #777;
  box-shadow: inset 1px 1px 0 #999;
}

th:last-child {
  box-shadow: inset -1px 1px 0 #999;
}

td {
  border-right: 1px solid #fff;
  border-left: 1px solid #e8e8e8;
  border-top: 1px solid #fff;
  border-bottom: 1px solid #e8e8e8;
  padding: 10px 15px;
  position: relative;
  transition: all 300ms;
  text-align:center;
}

td:first-child {
  box-shadow: inset 1px 0 0 #fff;
}

td:last-child {
  border-right: 1px solid #e8e8e8;
  box-shadow: inset -1px 0 0 #fff;
}

tr {
  background: url(https://jackrugile.com/images/misc/noise-diagonal.png);
}

tr:nth-child(odd) td {
  background: #f1f1f1
    url(https://jackrugile.com/images/misc/noise-diagonal.png);
}

tr:last-of-type td {
  box-shadow: inset 0 -1px 0 #fff;
}

tr:last-of-type td:first-child {
  box-shadow: inset 1px -1px 0 #fff;
}

tr:last-of-type td:last-child {
  box-shadow: inset -1px -1px 0 #fff;
}

.main_row {
  margin: 20px;
  text-align: center;
}

.race_checkbox {
  margin: 10px;
}
.inline_boxes {
  display: inline-flex;
  text-align:center;
}
              
            
!

JS

              
                console.clear();
//INITIAL DUMMY DATA
const dummyD = {
  past: [],
  present: [
    { id: 1, map: "Hurricane Isle", completed: false, players: 2, winner: 2 },
    {
      id: 2,
      map: "Golems in the Mist",
      completed: false,
      players: 4,
      winner: 1
    }
  ],
  future: []
};

const getRandomInt = (min, max) =>
  Math.floor(Math.random() * (max - min)) + min;

//ACTION CREATORS
const addMatch = (map, players) => {
  return {
    type: "ADD_MATCH",
    map,
    ply: players,
    win: getRandomInt(1, players),
    id: nextMatchId++
  };
};

const removeMatch = id => ({
  type: "REMOVE_MATCH",
  id
});

const undo = () => ({
  type: "UNDO"
});

const redo = () => ({
  type: "REDO"
});

//REDUCERS
const match = (state = undefined, action) => {
  switch (action.type) {
    case "ADD_MATCH":
      return {
        map: action.map,
        id: action.id,
        players: action.ply,
        winner: action.win,
        completed: false
      };

    default:
      return state;
  }
};
const matches = (state = dummyD, action) => {
  switch (action.type) {
    case "ADD_MATCH":
      let newPast = state.present;
      let newPresent = [...state.present, match(undefined, action)];
      return {
        past: newPast,
        present: newPresent,
        future: []
      };
    case "REMOVE_MATCH":
      newPast = state.present;
      newPresent = state.present.filter(el => el.id !== action.id);
      return {
        past: newPast,
        present: newPresent,
        future: []
      };
    case "UNDO":
      if (state.past.length) {
        let newFuture = state.present;
        let newPresent = state.past;
        let newPast = [];
        return {
          past: newPast,
          present: newPresent,
          future: newFuture
        };
      }
      return state;

    case "REDO":
      if (state.future.length) {
        let newPast = state.present;
        let newPresent = state.future;
        let newFuture = [];

        return {
          future: newFuture,
          present: newPresent,
          past: newPast
        };
      } else {
        return state;
      }
    default:
      return state;
  }
};

//MIDDLEWARE
const logger = store => next => action => {
  console.log("current state: ", store.getState());
  console.log("action: ", action);
  next(action);
  console.log("updated state: ", store.getState());
};

//STORE
const { combineReducers } = Redux;
const MatchListApp_R = combineReducers({ matches });

const { createStore } = Redux;
const store = createStore(MatchListApp_R, Redux.applyMiddleware(logger));

//AUX

const canUndo = state => {
  return state.matches.past.length == 0;
};
const canRedo = state => {
  return state.matches.future.length == 0;
};
//COMPONENTS

let nextMatchId = 3;

class CommandZone extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    let input;
    return (
      <div>
        <form target="dummyframe">
          <label>Map: </label>
          <input
            ref={node => {
              input = node;
            }}
          />
          <button
            onClick={() => {
              store.dispatch(addMatch(input.value, getRandomInt(1, 9)));
              input.value = "";
            }}
          >
            Generate Match
          </button>
        </form>
        <button
          onClick={() => {
            store.dispatch(undo());
          }}
          disabled={canUndo(store.getState())}
        >
          Undo
        </button>
        <button
          onClick={() => {
            store.dispatch(redo());
          }}
          disabled={canRedo(store.getState())}
        >
          Redo
        </button>
      </div>
    );
  }
}

class MatchListMain extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    let input;
    return (
      <div className="main_row">
        <CommandZone />
        <MatchesList_ matches={store.getState().matches.present} />
      </div>
    );
  }
}

const MatchesList_ = props => {
  return (
    <table>
      <thead>
        <tr>
          <th>ID</th>
          <th>Map</th>
          <th>Players</th>
          <th>Winner</th>
        </tr>
      </thead>
      <tbody>
        {props.matches.map(match =>
          <tr>
            <td>{match.id}</td><td>{match.map}</td>
            <td>{match.players}</td><td>{match.winner}</td>
            <td>
              <button
                onClick={() => {
                  store.dispatch(removeMatch(match.id));
                }}
              >
                Remove Match
              </button>
            </td>
          </tr>
        )}
      </tbody>
    </table>
  );
};

console.log(store.getState());
//render & bindings
const render = () => {
  ReactDOM.render(
    <MatchListMain matches={dummyD} />,
    document.getElementById("root")
  );
};
render();
store.subscribe(render);

              
            
!
999px

Console