Skip to content

Commit

Permalink
add top-bar
Browse files Browse the repository at this point in the history
  • Loading branch information
taomas committed Aug 11, 2016
1 parent 3efc2ca commit 8b084ad
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Expand Up @@ -19,5 +19,8 @@ module.exports = {
'generator-star-spacing': 0,
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
},
'globals': {
"$": true,
}
}
6 changes: 6 additions & 0 deletions build/webpack.dev.conf.js
Expand Up @@ -4,6 +4,7 @@ var merge = require('webpack-merge')
var utils = require('./utils')
var baseWebpackConfig = require('./webpack.base.conf')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var jquery = require('jquery')

// add hot-reload related code to entry chunks
Object.keys(baseWebpackConfig.entry).forEach(function (name) {
Expand All @@ -29,6 +30,11 @@ module.exports = merge(baseWebpackConfig, {
filename: 'index.html',
template: 'index.html',
inject: true
}),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery"
})
]
})
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -41,6 +41,7 @@
"html-webpack-plugin": "^2.8.1",
"http-proxy-middleware": "^0.12.0",
"install": "^0.8.1",
"jquery": "^3.1.0",
"json-loader": "^0.5.4",
"npm": "^3.10.5",
"ora": "^0.2.0",
Expand Down
119 changes: 112 additions & 7 deletions src/components/TopBar.vue
Expand Up @@ -3,7 +3,7 @@
<div class="top-bar clearfix">
<div class="topbar-nav">
<ul class="nav-wrap">
<li v-for="item in navs" class="nav">
<li v-for="item in navs" class="nav clearfix">
<a href="#" class="nav-name">{{item['name']}}</a>
<span class="nav-separate" v-show="$index !== 8">|</span>
</li>
Expand All @@ -14,9 +14,26 @@
<span class="nav-separate" v-show="$index !== 8">|</span>
<a href="#">注册</a>
</div>
<div class="topbar-cart">
<a href="#">购物车<span>0<span></a>
<div class="topbar-cart"
@mouseenter="evtCartEnter"
@mouseleave="evtCartOut">
<div class="cart"
:class="{'active': cartStatus}">
<i class="icon-cart"></i>
<a href="#">
购物车(
<span>0<span>
)
</a>
</div>
<div class="cart-list"
v-show="cartStatus"
transition="expand"
>
购物车中还没有商品,赶快选购吧!
</div>
</div>

</div>
</div>
</template>
Expand All @@ -35,11 +52,22 @@ export default {
{'name': '小米网移动版'},
{'name': '问题反馈'},
{'name': 'Select Region'}
]
],
timer: '',
cartStatus: false
}
},
methods: {
evtCartEnter: function () {
this.cartStatus = true
clearInterval(this.timer)
},
evtCartOut: function () {
var self = this
this.timer = setTimeout(function () {
self.cartStatus = false
}, 300)
}
},
components: {
// Hello
Expand All @@ -56,8 +84,10 @@ export default {
}
.top-bar {
position: relative;
width: 1226px;
margin: 0 auto;
font-size: 12px;
}
.topbar-nav {
Expand All @@ -78,16 +108,91 @@ export default {
text-decoration: none;
height: 40px;
line-height: 40px;
padding-left: 10px;
padding-left: 5px;
& :hover {
color: #fff;
}
& a {
.nav-name {
display: inline-block;
font-size: 12px;
color: #b0b0b0;
text-decoration: none;
}
.nav-separate {
display: inline-block;
color: #b0b0b0;
margin-left: 5px;
}
}
}
.topbar-info {
position: absolute;
top: 0;
right: 140px;
height: 40px;
line-height: 40px;
a {
color: #b0b0b0;
text-decoration: none;
&:hover {
color: #fff;
}
}
span {
color: #b0b0b0;
}
}
.topbar-cart {
position: relative;
float: right;
width: 120px;
background: #424242;
height: 40px;
line-height: 40px;
cursor: pointer;
.active {
background: #fff;
a {
color: #ff6700;
}
span {
color: #ff6700;
}
}
a {
display: block;
margin-left: 50px;
color: #b0b0b0;
text-decoration: none;
}
span {
color: #b0b0b0;
}
}
.expand-transition {
transition: height 0.3s ease;
height: 96px;
}
.expand-enter, .expand-leave {
transition: height 0.3s ease;
height: 0;
}
.cart-list {
position: absolute;
right: 0;
top: 40px;
width: 316px;
/*height: 96px;*/
line-height: 96px;
text-align: center;
color: #b0b0b0;
background: #fff;
box-shadow: 0 0 5px #ccc;
}
</style>
7 changes: 7 additions & 0 deletions src/components/TopHeader.vue
@@ -0,0 +1,7 @@
<template>
<div class="top-header">
<div class=container>

</div>
</div>
</template>

0 comments on commit 8b084ad

Please sign in to comment.