From 910813e37018a548d37762f43d23c180c650f20b Mon Sep 17 00:00:00 2001 From: Gajus Kuizinas Date: Wed, 11 Jan 2017 15:28:28 +0200 Subject: [PATCH] fix: make the examples work locally (fixes #75) --- README.md | 2 +- examples/README.md | 14 ++++++++++++++ examples/card-stack/card-stack.js | 2 +- examples/card-stack/index.html | 2 +- examples/card-state/card-state.js | 4 ++-- examples/card-state/index.html | 2 +- examples/index.js | 1 + examples/package.json | 13 +++++++++++++ examples/throw-confidence/index.html | 2 +- examples/throw-confidence/throw-confidence.js | 2 +- 10 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 examples/README.md create mode 100644 examples/index.js create mode 100644 examples/package.json diff --git a/README.md b/README.md index 474308b..5eaf135 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Give it a [swing](http://gajus.com/sandbox/swing/examples/card-stack/)! and plea * [Programmatically control](http://gajus.com/sandbox/swing/examples/card-state/) the state of the card. * [Indicate the state of the drop](http://gajus.com/sandbox/swing/examples/throw-confidence/) using `throwConfidence` and `direction` [event object](#event-object) properties. -The code for all of the examples is in the [./examples/](https://github.com/gajus/swing/tree/master/examples/) folder. +The code for all of the examples is in the [./examples/](./examples/) folder. [Raise an issue](https://github.com/gajus/swing/issues) if you are missing an example. diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..1ac9796 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,14 @@ +To run locally: + +```bash +git clone git@github.com:gajus/swing.git +cd ./swing/examples +npm install +npm start +``` + +This will start server on port 8080: + +```bash +open http://localhost:8080/ +``` diff --git a/examples/card-stack/card-stack.js b/examples/card-stack/card-stack.js index eeb8cf4..380f1eb 100644 --- a/examples/card-stack/card-stack.js +++ b/examples/card-stack/card-stack.js @@ -1,7 +1,7 @@ document.addEventListener('DOMContentLoaded', function () { var stack; - stack = gajus.Swing.Stack(); + stack = window.swing.Stack(); [].forEach.call(document.querySelectorAll('.stack li'), function (targetElement) { stack.createCard(targetElement); diff --git a/examples/card-stack/index.html b/examples/card-stack/index.html index 2d1b78d..9b0ab1f 100644 --- a/examples/card-stack/index.html +++ b/examples/card-stack/index.html @@ -7,7 +7,7 @@ - + diff --git a/examples/card-state/card-state.js b/examples/card-state/card-state.js index 93f8f90..2be2cc8 100644 --- a/examples/card-state/card-state.js +++ b/examples/card-state/card-state.js @@ -1,5 +1,5 @@ document.addEventListener('DOMContentLoaded', function () { - var stack = gajus.Swing.Stack(), + var stack = window.swing.Stack(), cardElement = document.querySelector('.stack li'); window.card = stack.createCard(cardElement); @@ -11,4 +11,4 @@ document.addEventListener('DOMContentLoaded', function () { stack.on('throwin', function (e) { console.log(e.target.innerText || e.target.textContent, 'has been thrown into the stack from the', e.throwDirection, 'direction.'); }); -}); \ No newline at end of file +}); diff --git a/examples/card-state/index.html b/examples/card-state/index.html index 67a6578..96c91f3 100644 --- a/examples/card-state/index.html +++ b/examples/card-state/index.html @@ -7,7 +7,7 @@ - + diff --git a/examples/index.js b/examples/index.js new file mode 100644 index 0000000..faf6b6f --- /dev/null +++ b/examples/index.js @@ -0,0 +1 @@ +window.swing = require('swing'); diff --git a/examples/package.json b/examples/package.json new file mode 100644 index 0000000..2762a9f --- /dev/null +++ b/examples/package.json @@ -0,0 +1,13 @@ +{ + "dependencies": { + "swing": "^4.0.1" + }, + "devDependencies": { + "webpack": "^1.14.0", + "webpack-dev-server": "^1.16.2" + }, + "private": true, + "scripts": { + "start": "webpack-dev-server --entry ./index.js" + } +} diff --git a/examples/throw-confidence/index.html b/examples/throw-confidence/index.html index 782d71a..26367a9 100644 --- a/examples/throw-confidence/index.html +++ b/examples/throw-confidence/index.html @@ -8,7 +8,7 @@ - + diff --git a/examples/throw-confidence/throw-confidence.js b/examples/throw-confidence/throw-confidence.js index 99efcbc..f7699e4 100644 --- a/examples/throw-confidence/throw-confidence.js +++ b/examples/throw-confidence/throw-confidence.js @@ -5,7 +5,7 @@ document.addEventListener('DOMContentLoaded', function () { directionBind, throwOutConfidenceElements; - stack = gajus.Swing.Stack(); + stack = window.swing.Stack(); cardElement = document.querySelector('.stack li'); throwOutConfidenceBind = document.querySelector('#throw-out-confidence-bind'); directionBind = document.querySelector('#direction-bind');