Skip to content

Commit 68b61c1

Browse files
committed
initial commit
1 parent 9d156f7 commit 68b61c1

File tree

12 files changed

+117
-92
lines changed

12 files changed

+117
-92
lines changed

README.md

Whitespace-only changes.

package-lock.json

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

package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
"lint": "vue-cli-service lint"
1010
},
1111
"dependencies": {
12+
"axios": "^0.18.0",
1213
"vue": "^2.5.13",
1314
"vue-class-component": "^6.0.0",
1415
"vue-property-decorator": "^6.0.0",
1516
"vue-router": "^3.0.1",
16-
"vuex": "^3.0.1"
17+
"vuex": "^3.0.1",
18+
"vuex-class": "^0.3.0"
1719
},
1820
"devDependencies": {
1921
"@types/jest": "^22.0.1",
@@ -28,11 +30,6 @@
2830
"ts-jest": "^22.0.1",
2931
"vue-template-compiler": "^2.5.13"
3032
},
31-
"babel": {
32-
"presets": [
33-
"@vue/app"
34-
]
35-
},
3633
"postcss": {
3734
"plugins": {
3835
"autoprefixer": {}

src/components/HelloWorld.vue

Lines changed: 0 additions & 58 deletions
This file was deleted.

src/components/Profile.vue

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<template>
2+
<div class="container">
3+
<div v-if="profile.user">
4+
<p>
5+
Full name: {{ fullName }}
6+
</p>
7+
<p>
8+
Email: {{ email }}
9+
</p>
10+
</div>
11+
<div v-if="profile.error">
12+
Oops an error occured
13+
</div>
14+
</div>
15+
</template>
16+
17+
<script lang="ts">
18+
import {Component, Prop, Vue} from 'vue-property-decorator';
19+
import {State, Action, Getter} from 'vuex-class';
20+
import {ProfileState} from '../store/profile/types';
21+
const namespace: string = 'profile';
22+
23+
@Component
24+
export default class HelloWorld extends Vue {
25+
26+
@Prop() private msg!: string;
27+
28+
constructor() {
29+
super();
30+
}
31+
32+
@State('profile') profile: ProfileState;
33+
@Action('fetchData', {namespace}) fetchData: any;
34+
@Getter('fullName', {namespace}) fullName: string;
35+
36+
mounted() {
37+
// fetching data as soon as the component's been mounted
38+
this.fetchData();
39+
}
40+
41+
// computed variable based on user's email
42+
get email() {
43+
const user = this.profile && this.profile.user;
44+
return (user && user.email) || '';
45+
}
46+
47+
}
48+
</script>
49+
50+
<!-- Add "scoped" attribute to limit CSS to this component only -->
51+
<style scoped lang="scss">
52+
h3 {
53+
margin: 40px 0 0;
54+
}
55+
56+
ul {
57+
list-style-type: none;
58+
padding: 0;
59+
}
60+
61+
li {
62+
display: inline-block;
63+
margin: 0 10px;
64+
}
65+
66+
a {
67+
color: #42b983;
68+
}
69+
</style>

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Vue from 'vue';
22
import App from './App.vue';
33
import router from './router';
4-
import store from './store';
4+
import store from './store/store';
55

66
Vue.config.productionTip = false;
77

src/store.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/store/store.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import Vue from 'vue';
2+
import Vuex from 'vuex';
3+
import { profile } from './profile/index';
4+
import { RootState } from './types';
5+
6+
Vue.use(Vuex);
7+
8+
export default new Vuex.Store<RootState>({
9+
state: {
10+
version: '1.0.0', // a simple property
11+
},
12+
modules: {
13+
profile,
14+
},
15+
mutations: {
16+
17+
},
18+
actions: {
19+
20+
},
21+
});

src/views/Home.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<template>
22
<div class="home">
33
<img src="../assets/logo.png">
4-
<HelloWorld msg="Welcome to Your Vue.js + TypeScript App"/>
4+
<Profile msg="Welcome to Your Vue.js + TypeScript App"/>
55
</div>
66
</template>
77

88
<script lang="ts">
99
import { Component, Vue } from 'vue-property-decorator';
10-
import HelloWorld from '@/components/HelloWorld.vue'; // @ is an alias to /src
10+
import Profile from '@/components/Profile.vue'; // @ is an alias to /src
1111
1212
@Component({
1313
components: {
14-
HelloWorld,
14+
Profile,
1515
},
1616
})
1717
export default class Home extends Vue {}

tests/unit/HelloWorld.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { shallow } from '@vue/test-utils';
2-
import HelloWorld from '@/components/HelloWorld.vue';
2+
import HelloWorld from '@/components/Profile.vue';
33

44
describe('HelloWorld.vue', () => {
55
it('renders props.msg when passed', () => {

0 commit comments

Comments
 (0)