Skip to content
Open
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
8 changes: 6 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"presets": ["es2015", "stage-2"],
"plugins": ["transform-runtime"],
"presets": [
["env", {"modules": false}]
],
"plugins": [
"transform-object-rest-spread"
]
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
node_modules/
.idea
npm-debug.log
27 changes: 11 additions & 16 deletions dist/build.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
</style>
</head>
<body>
<app></app>
<div id="app">
<app></app>
</div>
<script src="dist/build.js"></script>
</body>
</html>
35 changes: 18 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,34 @@
"description": "A Vue.js project",
"author": "coffcer",
"scripts": {
"dev": "webpack-dev-server --inline --hot",
"dev": "cross-env webpack-dev-server --inline --hot --open",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
},
"dependencies": {
"babel-polyfill": "^6.13.0",
"babel-runtime": "^6.0.0",
"vue": "^1.0.0",
"vuex": "^0.8.2"
"lodash": "^4.17.4",
"vue": "^2.5.13",
"vuex": "^3.0.1"
},
"devDependencies": {
"babel-core": "^6.0.0",
"babel-loader": "^6.0.0",
"babel-plugin-transform-runtime": "^6.0.0",
"babel-preset-es2015": "^6.0.0",
"babel-preset-stage-2": "^6.0.0",
"cross-env": "^1.0.6",
"css-loader": "^0.23.0",
"file-loader": "^0.8.4",
"babel-loader": "^7.1.2",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1",
"cross-env": "^5.1.3",
"css-loader": "^0.28.9",
"file-loader": "^1.1.6",
"json-loader": "^0.5.4",
"less": "^2.7.1",
"less-loader": "^2.2.3",
"url-loader": "^0.5.7",
"vue-hot-reload-api": "^1.2.0",
"less-loader": "^4.0.5",
"url-loader": "^0.6.2",
"vue-hot-reload-api": "^2.2.4",
"vue-html-loader": "^1.0.0",
"vue-loader": "^8.2.1",
"vue-style-loader": "^1.0.0",
"webpack": "^1.12.2",
"webpack-dev-server": "^1.12.0"
"vue-loader": "^13.7.0",
"vue-style-loader": "^3.0.3",
"vue-template-compiler": "^2.5.13",
"webpack": "^3.10.0",
"webpack-dev-server": "^2.11.1"
}
}
104 changes: 52 additions & 52 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
<script>
import { actions } from './store';
import {mapMutations} from 'vuex';

import Card from 'components/card';
import List from 'components/list';
import Text from 'components/text';
import Message from 'components/message';
import Card from 'components/card';
import List from 'components/list';
import TextInput from 'components/text-input';
import Message from 'components/message';

export default {
components: { Card, List, Text, Message },
vuex: {
actions: actions
},
created () {
this.initData();
}
}
export default {
components: {Card, List, TextInput, Message},
methods: mapMutations([
'initData',
]),
created() {
this.initData();
}
};
</script>

<template>
<div id="app">
<div class="sidebar">
<card></card>
<list></list>
</div>
<div class="main">
<message></message>
<text></text>
<div id="app">
<div class="sidebar">
<card></card>
<list></list>
</div>
<div class="main">
<message></message>
<text-input></text-input>
</div>
</div>
</div>
</template>

<style lang="less" scoped>
#app {
margin: 20px auto;
width: 800px;
height: 600px;
#app {
margin: 20px auto;
width: 800px;
height: 600px;

overflow: hidden;
border-radius: 3px;

.sidebar, .main {
height: 100%;
}
.sidebar {
float: left;
width: 200px;
color: #f4f4f4;
background-color: #2e3238;
}
.main {
position: relative;
overflow: hidden;
background-color: #eee;
}
.text {
position: absolute;
width: 100%;
bottom: 0;
left: 0;
}
.message {
height: ~'calc(100% - 160px)';
border-radius: 3px;

.sidebar, .main {
height: 100%;
}
.sidebar {
float: left;
width: 200px;
color: #f4f4f4;
background-color: #2e3238;
}
.main {
position: relative;
overflow: hidden;
background-color: #eee;
}
.text {
position: absolute;
width: 100%;
bottom: 0;
left: 0;
}
.message {
height: ~'calc(100% - 160px)';
}
}
}
</style>
105 changes: 53 additions & 52 deletions src/components/card.vue
Original file line number Diff line number Diff line change
@@ -1,65 +1,66 @@
<script>
import { actions } from '../store';
import _ from 'lodash';
import {mapMutations, mapState} from 'vuex';

export default {
vuex: {
actions: actions,
getters: {
user: ({ user }) => user,
filterKey: ({ filterKey }) => filterKey
export default {
computed: mapState([
'user',
'filterKey',
]),
methods: {
...mapMutations([
'setFilterKey',
]),
debounceOnKeyup: _.debounce(function (e) {
this.setFilterKey(e.target.value);
}, 150),
}
},
methods: {
onKeyup (e) {
this.search(e.target.value);
}
}
};
};
</script>

<template>
<div class="card">
<header>
<img class="avatar" width="40" height="40" :alt="user.name" :src="user.img">
<p class="name">{{user.name}}</p>
</header>
<footer>
<input class="search" type="text" placeholder="search user..." @keyup="onKeyup | debounce 150">
</footer>
</div>
<div class="card">
<header>
<img class="avatar" width="40" height="40" :alt="user.name" :src="user.img">
<p class="name">{{user.name}}</p>
</header>
<footer>
<input class="search" type="text" placeholder="search user..." @keyup="debounceOnKeyup">
</footer>
</div>
</template>

<style scoped lang="less">
.card {
padding: 12px;
border-bottom: solid 1px #24272C;
.card {
padding: 12px;
border-bottom: solid 1px #24272C;

footer {
margin-top: 10px;
}
footer {
margin-top: 10px;
}

.avatar, .name {
vertical-align: middle;
}
.avatar {
border-radius: 2px;
}
.name {
display: inline-block;
margin: 0 0 0 15px;
font-size: 16px;
}
.search {
padding: 0 10px;
width: 100%;
font-size: 12px;
color: #fff;
height: 30px;
line-height: 30px;
border: solid 1px #3a3a3a;
border-radius: 4px;
outline: none;
background-color: #26292E;
.avatar, .name {
vertical-align: middle;
}
.avatar {
border-radius: 2px;
}
.name {
display: inline-block;
margin: 0 0 0 15px;
font-size: 16px;
}
.search {
padding: 0 10px;
width: 100%;
font-size: 12px;
color: #fff;
height: 30px;
line-height: 30px;
border: solid 1px #3a3a3a;
border-radius: 4px;
outline: none;
background-color: #26292E;
}
}
}
</style>
Loading