Skip to content
This repository has been archived by the owner on Feb 17, 2021. It is now read-only.

[WIP] Use webpacker for react #204

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"presets": [
[
"env",
{
"modules": false,
"targets": {
"browsers": "> 1%",
"uglify": true
},
"useBuiltIns": true
}
],
"react",
"stage-2"
],
"plugins": [
"syntax-dynamic-import",
[
"transform-class-properties",
{
"spec": true
}
]
]
}
5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
"extends": "airbnb",
"globals": {
"React": true
}
},
"env": {
"browser": true
},
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ node_modules

# Ignore redis dumps
*.rdb
/public/packs
/node_modules
4 changes: 4 additions & 0 deletions .postcssrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
plugins:
postcss-smart-import: {}
precss: {}
autoprefixer: {}
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ rvm:
dist: trusty
sudo: false
before_script:
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 0.27.5
- export PATH=$HOME/.yarn/bin:$PATH
- pip3 install https://github.com/sul-cidr/histonets-cv/archive/master.zip
- RAILS_ENV=test bundle exec rake db:migrate
- RAILS_ENV=test bundle exec rake assets:precompile
cache:
yarn: true
# sudo: false Leaving this commented out, as we may need this to install the correct python version etc.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ gem 'coffee-rails', '~> 4.2'
gem 'jquery-rails'
gem 'react-rails'

gem 'webpacker'

# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
Expand All @@ -45,8 +47,6 @@ gem 'honeybadger', '~> 3.1'

source 'https://rails-assets.org' do
gem 'rails-assets-tether', '>= 1.1.0' # Required for tooltips/popover for twbs
gem 'rails-assets-leaflet-iiif', '~> 1.0'
gem 'rails-assets-leaflet', '~> 1.0'
gem 'rails-assets-css-toggle-switch'
end

Expand Down
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,6 @@ GEM
railties (= 5.0.4)
sprockets-rails (>= 2.0.0)
rails-assets-css-toggle-switch (4.0.2)
rails-assets-leaflet (1.0.2)
rails-assets-leaflet-iiif (1.0.2)
rails-assets-tether (1.3.7)
rails-controller-testing (1.0.1)
actionpack (~> 5.x)
Expand All @@ -216,9 +214,8 @@ GEM
rb-fsevent (0.9.8)
rb-inotify (0.9.7)
ffi (>= 0.5.0)
react-rails (1.9.0)
react-rails (2.2.1)
babel-transpiler (>= 0.7.0)
coffee-script-source (~> 1.8)
connection_pool
execjs
railties (>= 3.2)
Expand Down Expand Up @@ -298,6 +295,10 @@ GEM
activemodel (>= 5.0)
debug_inspector
railties (>= 5.0)
webpacker (2.0)
activesupport (>= 4.2)
multi_json (~> 1.2)
railties (>= 4.2)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
Expand Down Expand Up @@ -334,8 +335,6 @@ DEPENDENCIES
puma (~> 3.0)
rails (~> 5.0.4)
rails-assets-css-toggle-switch!
rails-assets-leaflet (~> 1.0)!
rails-assets-leaflet-iiif (~> 1.0)!
rails-assets-tether (>= 1.1.0)!
rails-controller-testing
react-rails
Expand All @@ -350,6 +349,7 @@ DEPENDENCIES
tzinfo-data
uglifier (>= 1.3.0)
web-console
webpacker
wicked

BUNDLED WITH
Expand Down
5 changes: 0 additions & 5 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,11 @@
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require leaflet
//= require leaflet-iiif
//= require leaflet-areaselect
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require tether
//= require bootstrap-sprockets
//= require react
//= require react_ujs
//= require components
//= require image-picker.min
//= require_tree .
1 change: 0 additions & 1 deletion app/assets/javascripts/components.js

This file was deleted.

Empty file.
2 changes: 0 additions & 2 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import "leaflet";
@import "leaflet-areaselect";
@import "css-toggle-switch";
@import "bootstrap_custom_variables";
@import "bootstrap";
Expand Down
1 change: 1 addition & 0 deletions app/javascript/app-styles.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import '~leaflet/dist/leaflet'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to use .scss for consistency?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be possible.

Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
class Histogram extends React.Component {
import React from 'react';
import PropTypes from 'prop-types';

export default class Histogram extends React.Component {
// Tried to push some of this into a seperate es6 model, but PhantomJS would
// not comply. :(
static formattedColor(color) {
Expand Down Expand Up @@ -69,12 +72,12 @@ class Histogram extends React.Component {
}

Histogram.propTypes = {
histogram: React.PropTypes.arrayOf(
React.PropTypes.string,
histogram: PropTypes.arrayOf(
PropTypes.string,
),
pathName: React.PropTypes.string.isRequired,
imagePaths: React.PropTypes.arrayOf(
React.PropTypes.string,
pathName: PropTypes.string.isRequired,
imagePaths: PropTypes.arrayOf(
PropTypes.string,
),
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* global L, LeafletIiif, LeafletIiifCropper */
import React from 'react';
import PropTypes from 'prop-types';
import LeafletIiif from './leaflet_iiif';
import LeafletIiifCropper from './leaflet_iiif_cropper';

class IiifCropper extends React.Component {
export default class IiifCropper extends React.Component {
constructor(props) {
super(props);
this.state = {
Expand All @@ -20,7 +23,7 @@ class IiifCropper extends React.Component {
}

onLoad(leafletState) {
this.setState({ ...leafletState });
this.setState(leafletState);
}

onRegionChanged(region) {
Expand Down Expand Up @@ -50,6 +53,6 @@ class IiifCropper extends React.Component {
}

IiifCropper.propTypes = {
iiifImage: React.PropTypes.string.isRequired,
cropperName: React.PropTypes.string.isRequired,
iiifImage: PropTypes.string.isRequired,
cropperName: PropTypes.string.isRequired,
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* global L, LeafletIiif, LeafletGeometry */
import React from 'react';
import PropTypes from 'prop-types';
import LeafletIiif from './leaflet_iiif';
import LeafletGeometry from './leaflet_geometry';

class ImageMatchResults extends React.Component {
export default class ImageMatchResults extends React.Component {
constructor(props) {
super(props);
this.state = {
Expand All @@ -18,7 +21,7 @@ class ImageMatchResults extends React.Component {
}

onLoad(leafletState) {
this.setState({ ...leafletState });
this.setState(leafletState);
}

render() {
Expand All @@ -42,8 +45,8 @@ class ImageMatchResults extends React.Component {
}

ImageMatchResults.propTypes = {
iiifImage: React.PropTypes.string.isRequired,
matches: React.PropTypes.arrayOf(
React.PropTypes.array,
iiifImage: PropTypes.string.isRequired,
matches: PropTypes.arrayOf(
PropTypes.array,
),
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
/* global ImageTemplateCropper, ImageTemplateList, $ */
/* global $ */

class ImageTemplateContainer extends React.Component {
import React from 'react';
import PropTypes from 'prop-types';
import ImageTemplateCropper from './image_template_cropper';
import ImageTemplateList from './image_template_list';

export default class ImageTemplateContainer extends React.Component {
constructor(props) {
super(props);
this.state = {
Expand Down Expand Up @@ -82,11 +87,11 @@ class ImageTemplateContainer extends React.Component {
}

ImageTemplateContainer.propTypes = {
imageTemplates: React.PropTypes.arrayOf(
React.PropTypes.object,
imageTemplates: PropTypes.arrayOf(
PropTypes.object,
),
iiifImage: React.PropTypes.string,
templateDestroyRoute: React.PropTypes.string,
iiifImage: PropTypes.string,
templateDestroyRoute: PropTypes.string,
};

ImageTemplateContainer.defaultProps = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* global IiifCropper */
import React from 'react';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module 'react' import/no-unresolved
Missing file extension for "react" import/extensions

import PropTypes from 'prop-types';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module 'prop-types' import/no-unresolved
Missing file extension for "prop-types" import/extensions

import IiifCropper from './iiif_cropper';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module './iiif_cropper' import/no-unresolved
Missing file extension for "./iiif_cropper" import/extensions


class ImageTemplateCropper extends React.Component {
export default class ImageTemplateCropper extends React.Component {
addTemplate() {
this.props.onAddNewTemplate(this.cropper.state);
}
Expand All @@ -27,5 +29,5 @@ class ImageTemplateCropper extends React.Component {
}

ImageTemplateCropper.propTypes = {
onAddNewTemplate: () => {},
onAddNewTemplate: PropTypes.func,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

propType "onAddNewTemplate" is not required, but has no corresponding defaultProp declaration react/require-default-props

};
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* global ImageTemplateViewer */
import React from 'react';
import PropTypes from 'prop-types';
import ImageTemplateViewer from './image_template_viewer';

class ImageTemplateList extends React.Component {
export default class ImageTemplateList extends React.Component {
constructor(props) {
super(props);

Expand Down Expand Up @@ -45,11 +47,11 @@ class ImageTemplateList extends React.Component {
}

ImageTemplateList.propTypes = {
imageTemplates: React.PropTypes.arrayOf(
React.PropTypes.object,
imageTemplates: PropTypes.arrayOf(
PropTypes.object,
),
updateRemovedItems: React.PropTypes.func,
updateImageTemplates: React.PropTypes.func,
updateRemovedItems: PropTypes.func,
updateImageTemplates: PropTypes.func,
};

ImageTemplateList.defaultProps = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* global Range */
import React from 'react';
import PropTypes from 'prop-types';
import Range from './range';

class ImageTemplateViewer extends React.Component {
export default class ImageTemplateViewer extends React.Component {
constructor(props) {
super(props);
this.state = { value: parseInt(props.match_options.threshold, 10) };
Expand Down Expand Up @@ -84,20 +86,20 @@ class ImageTemplateViewer extends React.Component {
}

ImageTemplateViewer.propTypes = {
image_url: React.PropTypes.string,
id: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.number,
image_url: PropTypes.string,
id: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
]),
match_options: React.PropTypes.shape({
threshold: React.PropTypes.oneOfType([
React.PropTypes.number,
React.PropTypes.string,
match_options: PropTypes.shape({
threshold: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string,
]),
}),
removeItem: React.PropTypes.func,
index: React.PropTypes.number,
updateImageTemplates: React.PropTypes.func,
removeItem: PropTypes.func,
index: PropTypes.number,
updateImageTemplates: PropTypes.func,
};

ImageTemplateViewer.defaultProps = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* global L */
import L from 'leaflet';
import React from 'react';
import PropTypes from 'prop-types';

class LeafletGeometry extends React.Component {
export default class LeafletGeometry extends React.Component {
constructor(props) {
super(props);
this.state = {
Expand All @@ -27,8 +29,8 @@ class LeafletGeometry extends React.Component {
}

LeafletGeometry.propTypes = {
matches: React.PropTypes.arrayOf(
React.PropTypes.array,
matches: PropTypes.arrayOf(
PropTypes.array,
),
unprojectZoom: React.PropTypes.number,
unprojectZoom: PropTypes.number,
};
Loading