Skip to content

Instantly share code, notes, and snippets.

View sethdorris's full-sized avatar

Seth Dorris sethdorris

  • Fort Collins, CO
View GitHub Profile
@sethdorris
sethdorris / actions.js
Created April 27, 2016 19:32
Working with redux
const actions = (username) => {
return {
type: 'SET_USERNAME',
value: username
}
}
export default actions;
import React from 'react';
import {Link} from 'react-router';
import {connect} from 'react-redux';
import {setUsername} from './actions/index';
class Landing extends React.Component {
constructor(props) {
super();
this.connectButton = this.connectButton.bind(this);
import React from 'react';
import {Link} from 'react-router';
import {connect} from 'react-redux';
import {setUsername} from './actions/index';
class Landing extends React.Component {
constructor(props) {
super();
this.connectButton = this.connectButton.bind(this);
import React from 'react';
import {Link} from 'react-router';
import {connect} from 'react-redux';
import {setUsername} from './actions/index';
class Landing extends React.Component {
constructor(props) {
super();
this.connectButton = this.connectButton.bind(this);
import React from 'react';
const Menu = (props) => {
return (
<div className="col-md-4 col-xs-4 text-center menu">
<div>
<h3>Online Users</h3>
{props.username}
</div>
</div>
/App
/Build
/client
--app.js
/server
--server.js
--index.html
main.css
@sethdorris
sethdorris / gulpfile.js
Created April 29, 2016 21:27
Gulp tasks
const gulp = require('gulp');
const browserify = require('browserify');
const babelify = require('babelify');
const source = require('vinyl-source-stream');
const babel = require('gulp-babel');
gulp.task('server-to-es2015', () => {
return gulp.src('./server/server.js')
.pipe(babel({
presets: ['es2015']
@sethdorris
sethdorris / chatcontainer.js
Last active May 2, 2016 20:48
Chat Container
import React from 'react';
import Menu from './Menu';
import Content from './Content';
import Message from './Message';
import {connect} from 'react-redux';
const PropTypes = React.PropTypes;
import {sendMessage} from './actions/index';
class ChatContainer extends React.Component {
constructor(props, context) {
import React from 'react';
import Message from './Message';
import {connect} from 'react-redux';
const ChatWindow = (props) => {
const {message} = this.props;
return (
<div className="row">
<div className="col-md-12 col-xs-12 chatwindow">
@sethdorris
sethdorris / server.js
Created May 3, 2016 15:30
Server side
import express from "express";
import url from 'url';
import path from 'path';
const WebSocketServer = require('ws').Server;
const http = require('http').Server(app);
const wss = new WebSocketServer({server: http});
const app = express();
app.use(express.static(path.resolve('../')));