Skip to content
Permalink
Browse files

Add react, babel and more

  • Loading branch information...
jacobtomlinson committed Jun 2, 2017
1 parent 7c410e2 commit a883bcd8948cf7ae4df54e3b4ba55ffddb2c433b
Showing with 50 additions and 8 deletions.
  1. +3 βˆ’0 .babelrc
  2. +1 βˆ’0 .gitignore
  3. +14 βˆ’3 gulpfile.js
  4. +1 βˆ’1 main.js
  5. +5 βˆ’0 package.json
  6. +3 βˆ’3 { β†’ src}/index.html
  7. +23 βˆ’1 { β†’ src}/index.js
  8. 0 { β†’ src}/index.scss
@@ -0,0 +1,3 @@
{
"presets": ["es2015", "react"]
}
@@ -1,5 +1,6 @@
.node-version
node_modules
release_builds
dist

*.css
@@ -1,13 +1,17 @@
'use strict';

var gulp = require('gulp');
var babel = require("gulp-babel");
var shell = require('gulp-shell')
var sass = require('gulp-sass');
var electron = require('electron-connect').server.create();
var package_info = require('./package.json')

gulp.task('serve', function () {

// Compile the JavaScript
gulp.start('babel');

// Compile the sass
gulp.start('sass');

@@ -18,7 +22,8 @@ gulp.task('serve', function () {
gulp.watch('main.js', electron.restart);

// Reload renderer process
gulp.watch(['index.js', 'index.html', 'index.scss'], function(){
gulp.watch(['src/index.js', 'src/index.html', 'src/index.scss'], function(){
gulp.start('babel');
gulp.start('sass');
electron.reload()
});
@@ -37,7 +42,13 @@ gulp.task('zip', shell.task([
]));

gulp.task('sass', function () {
return gulp.src('./*.scss')
return gulp.src('./src/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./'));
.pipe(gulp.dest('./dist/css'));
});

gulp.task("babel", function () {
return gulp.src("./src/index.js")
.pipe(babel())
.pipe(gulp.dest("./dist/js"));
});
@@ -17,7 +17,7 @@ function createWindow () {

// and load the index.html of the app.
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
pathname: path.join(__dirname, 'src/index.html'),
protocol: 'file:',
slashes: true
}))
@@ -11,14 +11,19 @@
"author": "Jacob Tomlinson",
"license": "",
"devDependencies": {
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"electron": "~1.6.2",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-sass": "^3.1.0",
"gulp-shell": "^0.6.3"
},
"dependencies": {
"electron-connect": "^0.6.1",
"electron-settings": "^3.0.14",
"react": "^15.5.4",
"react-dom": "^15.5.4",
"request": "^2.81.0",
"websocket": "^1.0.24"
}
@@ -3,10 +3,10 @@
<head>
<meta charset="UTF-8">
<title>Opsdroid Desktop</title>
<link rel="stylesheet" href="./index.css">
<link rel="stylesheet" href="../dist/css/index.css">
</head>
<body>
<img class="banner" src="./assets/banners/banner-eye-transparent.png" />
<img class="banner" src="../assets/banners/banner-eye-transparent.png" />

<ul id="conversation">
</ul>
@@ -27,6 +27,6 @@

<script>
require('electron-connect').client.create()
require('./index.js')
require('../dist/js/index.js')
</script>
</html>
@@ -1,11 +1,15 @@
'use strict';


//////
// Imports
import React from 'react';
import ReactDOM from 'react-dom';
var request = require('request');
var settings = require('electron-settings');
var WebSocketClient = require('websocket').client;


//////
// Global variables
var active_connection = undefined;
@@ -15,6 +19,19 @@ var client = new WebSocketClient();
var connectionCooldown = 0;
var connectionTimeout = undefined;


//////
// Components
const message = function(props){
return (
<li className={props.user}>{props.text}</li>
<li className="clearfix"></li>
<li className={props.user + " time"}>{props.time}</li>
<li className="clearfix"></li>
)
}


//////
// Functions
var displayMessage = function(message, sender){
@@ -217,6 +234,7 @@ var populateHostPort = function() {
}
}


//////
// Event listeners
client.on('connect', handleSocketConnection);
@@ -229,9 +247,13 @@ document.getElementById("port").addEventListener("input", updatePort);
document.getElementById("connect").addEventListener("click", reconnectToWebSocketImmediately);



//////
// Start
populateHostPort();
connectToWebsocket();
document.getElementById("input").focus();

ReactDOM.render(
<h1>Hello, world!</h1>,
document.getElementById('conversation')
);
File renamed without changes.

0 comments on commit a883bcd

Please sign in to comment.
You can’t perform that action at this time.