Skip to content

Commit b2794f4

Browse files
committed
main component & postcss (vuejs/vue#4332)
1 parent 17869be commit b2794f4

File tree

9 files changed

+97
-20
lines changed

9 files changed

+97
-20
lines changed

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"author": "swatekh",
1717
"license": "MIT",
1818
"devDependencies": {
19+
"autoprefixer": "^7.1.4",
1920
"babel-minify-webpack-plugin": "^0.2.0",
2021
"bootstrap-loader": "^2.2.0",
2122
"clean-webpack-plugin": "^0.1.16",
@@ -33,6 +34,7 @@
3334
"html-webpack-template-pug": "^1.1.1",
3435
"imports-loader": "^0.7.1",
3536
"node-sass": "4.0.0",
37+
"postcss-loader": "^2.0.6",
3638
"pug": "^2.0.0-rc.4",
3739
"pug-loader": "^2.3.0",
3840
"resolve-url-loader": "^2.1.0",
@@ -56,6 +58,7 @@
5658
},
5759
"dependencies": {
5860
"bootstrap-sass": "^3.3.7",
61+
"bourbon": "^4.3.4",
5962
"jquery": "^3.2.1",
6063
"vue": "^2.4.4"
6164
}

postcss.config.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
plugins: {
3+
// to edit target browsers: use "browserslist" field in package.json
4+
autoprefixer: {},
5+
},
6+
};
7+

src/App.vue

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
<template>
22
<!-- <nav class="navbar navbar-default" :class="{'navbar-fixed-top': top}">
33
</nav> -->
4-
<wl-slide-out-menu v-bind="menu" :loc="'left'"></wl-slide-out-menu>
4+
<div>
5+
<wl-nav-menu v-bind="menu" :loc="'left'"></wl-nav-menu>
6+
<wl-main-panel>
7+
<wl-top-nav-bar slot="header"></wl-top-nav-bar>
8+
</wl-main-panel>
9+
</div>
510
</template>
611

712
<script>
8-
import WlSlideOutMenu from './components/SlideOutMenu.vue';
13+
import WlNavMenu from './components/NavMenu.vue';
14+
import WlMainPanel from './components/MainPanel.vue';
15+
import WlTopNavBar from './components/TopNavBar.vue';
916
1017
export default {
1118
props: ['top'],
@@ -30,7 +37,9 @@ export default {
3037
}
3138
}),
3239
components: {
33-
WlSlideOutMenu
40+
WlNavMenu,
41+
WlMainPanel,
42+
WlTopNavBar
3443
}
3544
}
3645
</script>

src/assets/style/resources.scss

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,13 +1 @@
1-
@mixin padding($top, $right, $bottom, $left) {
2-
padding-bottom: $bottom;
3-
padding-left: $left;
4-
padding-right: $right;
5-
padding-top: $top;
6-
}
7-
8-
@mixin margin($top, $right, $bottom, $left) {
9-
margin-bottom: $bottom;
10-
margin-left: $left;
11-
margin-right: $right;
12-
margin-top: $top;
13-
}
1+
@import '~bourbon/app/assets/stylesheets/bourbon';

src/components/MainPanel.vue

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<template>
2+
<main :class="{ 'shrink': shrink }">
3+
<slot name="header" v-on:toggleShrink="slide()"></slot>
4+
<slot name="content" @toggleShrink="slide()"></slot>
5+
<slot name="footer" @toggleShrink="slide()"></slot>
6+
</main>
7+
</template>
8+
9+
<script>
10+
export default {
11+
data: () => ({
12+
shrink: false
13+
}),
14+
methods: {
15+
slide() {
16+
this.shrink = !this.shrink;
17+
}
18+
}
19+
}
20+
</script>
21+
22+
<style lang="scss" scoped>
23+
main {
24+
position: relative;
25+
z-index: 1;
26+
transition: transform 300ms;
27+
28+
width: 500px;
29+
height: 500px;
30+
background-color:cyan;
31+
32+
input {
33+
position: absolute;
34+
left: auto;
35+
right: 10px;
36+
}
37+
38+
&.shrink {
39+
transform: translateX(-400px);
40+
}
41+
}
42+
</style>
43+

src/components/SlideOutMenu.vue renamed to src/components/NavMenu.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ export default {
2626
<style lang="scss" scoped>
2727
nav {
2828
position: fixed;
29+
z-index: 0;
2930
3031
ul {
3132
list-style: none;
32-
@include margin(1em, 0, 0, 0);
3333
}
3434
3535
&.left {

src/components/TopNavBar.vue

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<template>
2+
<input type="button" value="child toggle" @click="slide()" />
3+
</template>
4+
5+
<script>
6+
export default {
7+
methods: {
8+
slide() {
9+
this.$emit('toggleShrink');
10+
}
11+
}
12+
}
13+
</script>

webpack.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const commonConfig = {
4444
scss: [
4545
'vue-style-loader',
4646
'css-loader',
47+
'postcss-loader',
4748
'sass-loader',
4849
{
4950
loader: 'sass-resources-loader',

yarn.lock

+16-3
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ autoprefixer@^6.3.1:
268268
postcss "^5.2.16"
269269
postcss-value-parser "^3.2.3"
270270

271-
autoprefixer@^7.1.2:
271+
autoprefixer@^7.1.2, autoprefixer@^7.1.4:
272272
version "7.1.4"
273273
resolved "http://registry.npm.taobao.org/autoprefixer/download/autoprefixer-7.1.4.tgz#960847dbaa4016bc8e8e52ec891cbf8f1257a748"
274274
dependencies:
@@ -676,6 +676,10 @@ bootstrap-sass@^3.3.7:
676676
version "3.3.7"
677677
resolved "http://registry.npm.taobao.org/bootstrap-sass/download/bootstrap-sass-3.3.7.tgz#6596c7ab40f6637393323ab0bc80d064fc630498"
678678

679+
bourbon@^4.3.4:
680+
version "4.3.4"
681+
resolved "http://registry.npm.taobao.org/bourbon/download/bourbon-4.3.4.tgz#4da380029e92c0c8f9764c779451a134b11e7cc3"
682+
679683
brace-expansion@^1.1.7:
680684
version "1.1.8"
681685
resolved "http://registry.npm.taobao.org/brace-expansion/download/brace-expansion-1.1.8.tgz#c07b211c7c952ec1f8efd51a77ef0d1d3990a292"
@@ -3938,7 +3942,7 @@ postcss-less@^1.1.0:
39383942
dependencies:
39393943
postcss "^5.2.16"
39403944

3941-
postcss-load-config@^1.1.0:
3945+
postcss-load-config@^1.1.0, postcss-load-config@^1.2.0:
39423946
version "1.2.0"
39433947
resolved "http://registry.npm.taobao.org/postcss-load-config/download/postcss-load-config-1.2.0.tgz#539e9afc9ddc8620121ebf9d8c3673e0ce50d28a"
39443948
dependencies:
@@ -3961,6 +3965,15 @@ postcss-load-plugins@^2.3.0:
39613965
cosmiconfig "^2.1.1"
39623966
object-assign "^4.1.0"
39633967

3968+
postcss-loader@^2.0.6:
3969+
version "2.0.6"
3970+
resolved "http://registry.npm.taobao.org/postcss-loader/download/postcss-loader-2.0.6.tgz#8c7e0055a3df1889abc6bad52dd45b2f41bbc6fc"
3971+
dependencies:
3972+
loader-utils "^1.1.0"
3973+
postcss "^6.0.2"
3974+
postcss-load-config "^1.2.0"
3975+
schema-utils "^0.3.0"
3976+
39643977
postcss-media-query-parser@^0.2.3:
39653978
version "0.2.3"
39663979
resolved "http://registry.npm.taobao.org/postcss-media-query-parser/download/postcss-media-query-parser-0.2.3.tgz#27b39c6f4d94f81b1a73b8f76351c609e5cef244"
@@ -4168,7 +4181,7 @@ postcss@^5.0.10, postcss@^5.0.11, postcss@^5.0.12, postcss@^5.0.13, postcss@^5.0
41684181
source-map "^0.5.6"
41694182
supports-color "^3.2.3"
41704183

4171-
postcss@^6.0.0, postcss@^6.0.1, postcss@^6.0.11, postcss@^6.0.3, postcss@^6.0.6, postcss@^6.0.7, postcss@^6.0.8:
4184+
postcss@^6.0.0, postcss@^6.0.1, postcss@^6.0.11, postcss@^6.0.2, postcss@^6.0.3, postcss@^6.0.6, postcss@^6.0.7, postcss@^6.0.8:
41724185
version "6.0.12"
41734186
resolved "http://registry.npm.taobao.org/postcss/download/postcss-6.0.12.tgz#6b0155089d2d212f7bd6a0cecd4c58c007403535"
41744187
dependencies:

0 commit comments

Comments
 (0)