Skip to content
This repository was archived by the owner on Sep 11, 2018. It is now read-only.

Commit 51c3b9b

Browse files
author
Claudio Ludovico Panetta
committed
Carousel minor update for v0.4.3
This update brings some minor improvements to the source code. First I removed the HTTP request from the Photos component because it does not belongs to it, instead I've created "actions" inside the Vuex store, which is async and now the component can call the action in order to load the photos using the HTTP get request. This allows everyone to have a source-agnostic gallery. To prove that I changed the HTTP library from vue-resource to Axios, which is better in my opinion. I've also improved the README. Patch notes: - Add new action file for the Vuex store. - Add new "hot to install" section inside readme - Add new "Contributing guidelines" section inside readme - Bump the version to v0.4.3 - Add new Axios library for HTTP calls
1 parent c0abea4 commit 51c3b9b

File tree

7 files changed

+296
-61
lines changed

7 files changed

+296
-61
lines changed

CHANGELOG

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
All notable changes to this project will be documented in this file.
33

44

5+
## [0.4.3]
6+
7+
### Added
8+
- Add new action file for the Vuex store.
9+
- Add new "hot to install" section inside readme
10+
- Add new Axios library for HTTP calls
11+
- Add new "Contributing guidelines" section inside readme
12+
13+
514
## [0.4.2]
615

716
### Added

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@
1717

1818
## How to install
1919

20-
- Either download or clone this repository
21-
- Run `npm install` this will install all the necessary tools from NPM
22-
- Run `npm run build` this will create the dist folder
23-
- Grab the file inside the dist folder and follow the [How to use section](#how-to-use)
20+
In order to use the carousel you have to follow 3 simple steps:
21+
22+
- Install the package from npm `npm install vuejs-carousel --save`
23+
- Go into your Vue main file or main javascript file
24+
- Import the carousel `import {Photo, Photos, Theater} from "vuejs-carousel"`
25+
- Add the component inside your views
26+
2427

2528

2629
## How to use
@@ -55,7 +58,12 @@ possible soon...
5558

5659
## Contributing
5760

58-
If you want to contribute to this project issues and pull requests are welcome!
61+
If you want to contribute to this project issues and pull requests are welcome! In order to get started with the code you should:
62+
63+
- Either download or clone this repository
64+
- Run `npm install` this will install all the necessary dependencies
65+
- Run `npm run dev`
66+
- Start coding :smile:
5967

6068
## License
6169

dist/carousel.js

Lines changed: 247 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vuejs-carousel",
33
"description": "Complete photo carousel build with VueJS and web standards in mind",
4-
"version": "0.4.2",
4+
"version": "0.4.3",
55
"author": "Claudio Ludovico Panetta <ludovico1990@hotmail.it>",
66
"private": false,
77
"license": "MIT",
@@ -23,6 +23,7 @@
2323
"url": "https://github.com/ludo237/vuejs-carousel.git"
2424
},
2525
"dependencies": {
26+
"axios": "^0.15.3",
2627
"vue": "^2.1.6",
2728
"vue-resource": "^1.0.3",
2829
"vuex": "^2.1.1"

src/components/Photos.vue

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,8 @@
2727
},
2828
2929
mounted() {
30-
this.$http.get(this.source).then((response) => {
31-
this.$store.commit("writePhotos", response.data);
32-
}, (response) => {
33-
console.error(response);
34-
});
35-
},
30+
this.$store.dispatch("loadPhotos", this.source);
31+
}
3632
}
3733
</script>
3834

src/store/actions.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import Axios from "axios";
2+
3+
export const actions = {
4+
5+
/**
6+
* Load the photo from the source provided by
7+
* the gallery
8+
*
9+
* @param commit
10+
* @param {String} source
11+
*/
12+
loadPhotos: ({commit}, source) => {
13+
Axios.get(source).then(function (response) {
14+
commit("writePhotos", response.data);
15+
}).catch(function (error) {
16+
console.error(error);
17+
});
18+
}
19+
};

src/store/store.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import Vue from "vue";
22
import Vuex from "vuex";
3-
Vue.use(Vuex);
4-
53
import {state} from "./states";
64
import {getters} from "./getters";
75
import {mutations} from "./mutations";
6+
import {actions} from "./actions";
7+
Vue.use(Vuex);
88

99
/**
1010
* Carousel main store
@@ -18,5 +18,6 @@ import {mutations} from "./mutations";
1818
export const store = new Vuex.Store({
1919
state,
2020
getters,
21-
mutations
21+
mutations,
22+
actions
2223
});

0 commit comments

Comments
 (0)