Skip to content

Commit

Permalink
feat: 添加暗色主题 (#45)
Browse files Browse the repository at this point in the history
同时修复 webpack Uglify 配置
  • Loading branch information
Snokier committed Jul 26, 2018
1 parent 489e29f commit fcef532
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 14 deletions.
42 changes: 37 additions & 5 deletions examples/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@
<nav>
<h3>
<span>示例</span>
<button type="button" @click="changeTheme">切换主题</button>
<div class="theme-select">
<input v-model="theme" type="radio" value="default" name="theme" id="theme-default" />
<label for="theme-default">默认</label>
<input v-model="theme" type="radio" value="bright" name="theme" id="theme-bright" />
<label for="theme-bright">亮色</label>
<input v-model="theme" type="radio" value="dark" name="theme" id="theme-dark" />
<label for="theme-dark">暗色</label>
</div>
</h3>
<ul :class="['nav-list', theme]">
<li
Expand Down Expand Up @@ -106,7 +113,7 @@
}]
export default {
name: 'app',
name: 'App',
components: {
Simple,
Expand Down Expand Up @@ -149,21 +156,32 @@
this.currentExample = value
window.location.hash = value
},
changeTheme () {
this.theme = this.theme === 'default' ? 'bright' : 'default'
},
},
}
</script>

<style scoped lang="stylus">
main-color = #46a0fc
main-color-bright = #ef5350
main-color-dark = #2d3035
#app
max-width: 1000px
margin: 0 auto
.theme-select
display inline-block
font-size 14px
font-weight normal
cursor pointer
input,
label
cursor pointer
input
margin-left 10px
.usage-link
color: main-color
border-bottom: 1px solid main-color
Expand All @@ -173,6 +191,10 @@
color: main-color-bright
border-bottom: 1px solid main-color-bright
&.dark
color: main-color-dark
border-bottom: 1px solid main-color-dark
&:hover
opacity: 0.8
Expand All @@ -199,6 +221,9 @@
&.bright
background-color: main-color-bright
&.dark
background-color: main-color-dark
.nav-item
position: relative
display: inline-block
Expand Down Expand Up @@ -234,11 +259,15 @@
&.bright
background-color: main-color-bright
&.dark
background-color: main-color-dark
</style>

<style lang="stylus">
main-color = #46a0fc
main-color-bright = #ef5350
main-color-dark = #2d3035
@font-face
font-family: "feather"
Expand Down Expand Up @@ -273,6 +302,9 @@
&.bright
border-color: main-color-bright
&.dark
border-color: main-color-dark
& + .box
border-top: none
Expand Down
22 changes: 15 additions & 7 deletions examples/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const path = require('path')
const webpack = require('webpack')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')

module.exports = {
entry: './examples/main.js',
Expand Down Expand Up @@ -83,19 +84,26 @@ module.exports = {

if (process.env.NODE_ENV === 'production') {
module.exports.devtool = '#source-map'
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.optimization = {
minimizer: [
new UglifyJsPlugin({
cache: true,
parallel: true,
uglifyOptions: {
compress: false,
ecma: 6,
mangle: true
},
sourceMap: true
})
]
}
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "v-contextmenu",
"description": "ContextMenu based on Vue 2.0",
"version": "2.7.0",
"version": "2.8.0",
"author": "snokier <me@snokier.com>",
"main": "dist/index.common.js",
"files": [
Expand Down Expand Up @@ -52,6 +52,7 @@
"style-loader": "^0.21.0",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.2",
"uglifyjs-webpack-plugin": "^1.2.5",
"url-loader": "^1.0.0",
"vue-loader": "^15.0.0",
"vue-template-compiler": "^2.5.16",
Expand Down
4 changes: 4 additions & 0 deletions src/styles/contextmenu.styl
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,7 @@
.v-contextmenu--bright
.v-contextmenu-item--hover
background-color: active-color-bright

.v-contextmenu--dark
.v-contextmenu-item--hover
background-color: active-color-dark
1 change: 1 addition & 0 deletions src/styles/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ padding-vertical = 5px
contextmenu-item-padding-horizonal = 14px

active-color-bright = #ef5350
active-color-dark = #2d3035

@import "./iconfont.styl"
@import "./contextmenu.styl"

0 comments on commit fcef532

Please sign in to comment.