Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/webpack #212

Merged
merged 11 commits into from
Aug 15, 2018
Merged
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
2 changes: 1 addition & 1 deletion .stylelintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
extends: 'stylelint-config-ship-shape'
};
};
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ cache:
yarn: true

install:
- yarn global add postcss-cli
- yarn global add autoprefixer
- yarn install --ignore-engines

jobs:
Expand Down Expand Up @@ -57,7 +55,7 @@ jobs:
fi
- stage: gh-pages release
script:
- yarn docs
- yarn build
before_deploy:
- git add -f --all dist/
deploy:
Expand Down
151 changes: 96 additions & 55 deletions docs/welcome/css/welcome.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions docs/welcome/css/welcome.css.map

This file was deleted.

29 changes: 16 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,28 @@
"Chuck Carpenter <charleswcarpenter3@gmail.com>"
],
"scripts": {
"build": "webpack && yarn copy-deps",
"build": "yarn clean && webpack --mode production",
"postbuild": "rm -f dist/removable-*",
"clean": "rm -rf dist",
"copy-deps": "cp -R ./node_modules/popper.js/dist/umd/. dist/js",
"cy:open": "./node_modules/.bin/cypress open",
"cy:run": "./node_modules/.bin/cypress run",
"prebuild:css": "node-sass --source-map true ./docs/welcome/sass/*.scss -o ./docs/welcome/css",
"prefix:css": "postcss --use autoprefixer -b 'last 2 versions' < ./docs/welcome/css/welcome.css",
"docs": "yarn build && yarn prebuild:css && yarn prefix:css",
"lint:js": "eslint .",
"lint:styles": "stylelint ./src/css/**/*.scss ./docs/welcome/sass/welcome.scss",
"lint": "yarn lint:js && yarn lint:styles",
"start": "webpack-dev-server --open",
"start": "yarn watch",
"start-test-server": "http-server",
"test:ci": "yarn test:unit:ci && yarn test:cy:ci",
"test:cy:ci": "start-server-and-test start-test-server http://localhost:8080 cy:run",
"test:cy:watch": "start-server-and-test start-test-server http://localhost:8080 cy:open",
"test:unit:ci": "karma start --single-run --browsers ChromeHeadlessNoSandbox",
"test:unit:watch": "karma start --browsers Chrome",
"test": "mocha",
"watch": "webpack --watch"
"watch": "yarn clean && webpack --watch --mode development"
},
"homepage": "http://shipshapecode.github.io/shepherd/docs/welcome/",
"license": "MIT",
"main": "dist/js/shepherd.js",
"module": "src/js/shepherd.js",
"spm": {
"main": "shepherd.js"
},
Expand All @@ -53,18 +51,23 @@
"babel-loader": "^7.1.4",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-env": "^1.6.1",
"browser-sync": "^2.24.6",
"browser-sync-webpack-plugin": "^2.2.2",
"chai": "^4.1.2",
"codeclimate-test-reporter": "^0.5.0",
"copy-webpack-plugin": "^4.5.2",
"css-loader": "^1.0.0",
"cypress": "^3.0.3",
"del": "^3.0.0",
"eslint": "^5.1.0",
"eslint-plugin-mocha": "^5.1.0",
"eslint-plugin-ship-shape": "^0.6.0",
"extract-loader": "^2.0.1",
"file-loader": "^1.1.11",
"glob": "^7.1.2",
"http-server": "^0.11.1",
"istanbul-instrumenter-loader": "^3.0.1",
"karma": "^2.0.5",
"karma": "^3.0.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage": "^1.1.2",
Expand All @@ -73,18 +76,18 @@
"karma-mocha-reporter": "^2.2.5",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^3.0.0",
"mini-css-extract-plugin": "^0.4.1",
"mocha": "^5.2.0",
"node-sass": "^4.9.2",
"postcss": "^7.0.2",
"postcss-loader": "^2.1.6",
"postcss-loader": "^3.0.0",
"sass-loader": "^7.1.0",
"source-map-loader": "^0.2.3",
"start-server-and-test": "^1.7.0",
"style-loader": "^0.21.0",
"stylelint": "^9.3.0",
"style-loader": "^0.22.1",
"stylelint": "^9.4.0",
"stylelint-config-ship-shape": "^0.4.0",
"uglifyjs-webpack-plugin": "^1.2.7",
"stylelint-webpack-plugin": "^0.10.5",
"uglifyjs-webpack-plugin": "^1.3.0",
"webpack": "^4.16.3",
"webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.5"
Expand Down
2 changes: 1 addition & 1 deletion src/css/_rounded.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/css/_square.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@

.shepherd-start-tour-button.shepherd-element {
@include start-tour-button;
}
}
71 changes: 71 additions & 0 deletions src/js/evented.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
export class Evented {
constructor(/* options = {}*/) {
Copy link
Member

Choose a reason for hiding this comment

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

if we're not using constructors or static methods, why use a class? I'd say export a default object.

// TODO: do we need this empty constructor?
}

on(event, handler, ctx) {
const once = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3];

if (typeof this.bindings === 'undefined') {
this.bindings = {};
}
if (typeof this.bindings[event] === 'undefined') {
this.bindings[event] = [];
}
this.bindings[event].push({ handler, ctx, once });
}

once(event, handler, ctx) {
this.on(event, handler, ctx, true);
}

off(event, handler) {
if (typeof this.bindings === 'undefined' || typeof this.bindings[event] === 'undefined') {
return;
}

if (typeof handler === 'undefined') {
delete this.bindings[event];
} else {
let i = 0;
while (i < this.bindings[event].length) {
if (this.bindings[event][i].handler === handler) {
this.bindings[event].splice(i, 1);
} else {
++i;
}
}
}
}

trigger(event) {
if (typeof this.bindings !== 'undefined' && this.bindings[event]) {
const _len = arguments.length;
const args = Array(_len > 1 ? _len - 1 : 0);
let i = 0;

for (let _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}

while (i < this.bindings[event].length) {
const _bindings$event$i = this.bindings[event][i];
const { ctx, handler, once } = _bindings$event$i;

let context = ctx;
if (typeof context === 'undefined') {
context = this;
}

handler.apply(context, args);

if (once) {
this.bindings[event].splice(i, 1);
} else {
++i;
}
}
}
}

}
Loading