From cc68e75e23e6ec4559c4082a0ecf50c0ad878327 Mon Sep 17 00:00:00 2001 From: makotot Date: Sat, 22 Apr 2017 22:10:47 +0900 Subject: [PATCH 1/4] export as default --- docs.sh | 2 +- gulpfile.js | 85 ---------------------------------------- src/js/app.jsx | 4 +- src/js/lib/Scrollspy.jsx | 2 +- 4 files changed, 4 insertions(+), 89 deletions(-) delete mode 100644 gulpfile.js diff --git a/docs.sh b/docs.sh index d93a64b..e3c309a 100755 --- a/docs.sh +++ b/docs.sh @@ -5,7 +5,7 @@ mkdir gh_pages ls -la cd gh_pages -cp -r ../build/* . +cp -r ../dist/* . git init git config user.name "${GIT_COMITTER_NAME}" diff --git a/gulpfile.js b/gulpfile.js deleted file mode 100644 index 93615e2..0000000 --- a/gulpfile.js +++ /dev/null @@ -1,85 +0,0 @@ -var gulp = require('gulp'), - browserSync = require('browser-sync').create(), - del = require('del'), - runSequence = require('run-sequence'), - source = require('vinyl-source-stream'), - browserify = require('browserify'), - babelify = require('babelify'), - ejs = require('gulp-ejs'), - sass = require('gulp-sass'), - eslint = require('gulp-eslint'); - - -gulp.task('clean', function (done) { - - del(['./build']).then(function () { - done(); - }); -}); - -gulp.task('lint', function () { - - gulp - .src(['./src/js/**/*.js', './src/js/**/*.jsx']) - .pipe(eslint()) - .pipe(eslint.format()) - .pipe(eslint.failOnError()); -}); - -gulp.task('template', function () { - - return gulp.src(['./src/templates/*.ejs', '!./src/templates/_*.ejs']) - .pipe(ejs()) - .pipe(gulp.dest('./build')); -}); - -gulp.task('script', function () { - - return browserify({ - entries: ['src/js/app.jsx'] - }) - .transform([babelify]) - .bundle() - .pipe(source('app.js')) - .pipe(gulp.dest('./build/js')) - .pipe(browserSync.stream()); -}); - -gulp.task('css', function () { - - return gulp - .src('./src/scss/*.scss') - .pipe(sass()) - .pipe(gulp.dest('./build/css')) - .pipe(browserSync.stream()); -}); - - -gulp.task('compile', ['template', 'script', 'css']); - -gulp.task('serve', function () { - - runSequence('clean', 'lint', 'compile', function () { - browserSync.init({ - server: './build', - open: false - }); - }); - - gulp - .watch(['./build/*.html']) - .on('change', browserSync.reload); - - gulp.watch(['./src/templates/*.ejs'], ['template']); - gulp.watch(['./src/js/**/*.jsx', './src/js/**/*.js'], ['script']); - gulp.watch(['./src/scss/**/*.scss'], ['css']); -}); - -gulp.task('build', function () { - runSequence('clean', 'lint', 'compile', function () { - }); -}); - -gulp.task('default', ['clean', 'lint'], function () { -}); - diff --git a/src/js/app.jsx b/src/js/app.jsx index e9fee8f..9b9a682 100644 --- a/src/js/app.jsx +++ b/src/js/app.jsx @@ -1,6 +1,6 @@ import React from 'react' import ReactDOM from 'react-dom' -import { Scrollspy } from './lib/Scrollspy.jsx' +import Scrollspy from './lib/Scrollspy.jsx' import Highlight from 'react-highlight' import 'style-loader!css-loader!postcss-loader!sass-loader!../scss/app.scss' @@ -64,7 +64,7 @@ const App = React.createClass({

Then, import this library in your JS.

-                    {'import { Scrollspy } from \'react-scrollspy\''}
+                    {'import Scrollspy from \'react-scrollspy\''}
                   
diff --git a/src/js/lib/Scrollspy.jsx b/src/js/lib/Scrollspy.jsx index b24fe91..9f002d3 100644 --- a/src/js/lib/Scrollspy.jsx +++ b/src/js/lib/Scrollspy.jsx @@ -3,7 +3,7 @@ import React from 'react' import classNames from 'classnames' import throttle from './throttle' -export class Scrollspy extends React.Component { +export default class Scrollspy extends React.Component { static get PropTypes () { return { From e0ba8f50774c0b8e9baadd89e8e71b03e52dc6dc Mon Sep 17 00:00:00 2001 From: makotot Date: Sat, 22 Apr 2017 22:23:44 +0900 Subject: [PATCH 2/4] fix test --- README.md | 2 +- __test__/index.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index def6164..79030a4 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ $ npm i react-scrollspy ## Usage ```js -var Scrollspy = require('react-scrollspy').Scrollspy; +import Scrollspy from 'react-scrollspy' ... diff --git a/__test__/index.js b/__test__/index.js index d6dff0e..ba110b4 100644 --- a/__test__/index.js +++ b/__test__/index.js @@ -1,7 +1,7 @@ import test from 'ava' import React from 'react' import { shallow, mount, render } from 'enzyme' -import { Scrollspy } from '../src/js/lib/Scrollspy' +import Scrollspy from '../src/js/lib/Scrollspy' test('renders correct children length', (t) => { const wrapper = shallow( @@ -22,3 +22,12 @@ test('renders children with correct props', (t) => { ) t.is(wrapper.find('li').prop('randomProp'), 'someText') }) + +test('renders expected html tag', (t) => { + const defaultTag = shallow() + const customTag = shallow() + + t.is(defaultTag.type(), 'ul') + t.is(customTag.type(), 'div') +}) + From 783abda22d5ae3bea4f17edc35295c60d8ba3a2c Mon Sep 17 00:00:00 2001 From: makotot Date: Sat, 22 Apr 2017 22:50:15 +0900 Subject: [PATCH 3/4] rm script tag --- src/templates/index.ejs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/templates/index.ejs b/src/templates/index.ejs index 509269c..24d09eb 100644 --- a/src/templates/index.ejs +++ b/src/templates/index.ejs @@ -9,6 +9,5 @@
- From 25351cb95d15dbf1179b756cfa78f5175fce4325 Mon Sep 17 00:00:00 2001 From: makotot Date: Sat, 22 Apr 2017 22:57:35 +0900 Subject: [PATCH 4/4] fix html --- src/templates/index.ejs | 1 + webpack.config.babel.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/templates/index.ejs b/src/templates/index.ejs index 24d09eb..509269c 100644 --- a/src/templates/index.ejs +++ b/src/templates/index.ejs @@ -9,5 +9,6 @@
+ diff --git a/webpack.config.babel.js b/webpack.config.babel.js index b50d2ff..07e73e0 100644 --- a/webpack.config.babel.js +++ b/webpack.config.babel.js @@ -62,7 +62,7 @@ export default { plugins: [ new HtmlWebpackPlguin({ filename: 'index.html', - inject: true, + inject: false, template: './src/templates/index.ejs', }), new webpack.LoaderOptionsPlugin({