This commit is contained in:
cookfront 2017-03-22 17:00:29 +08:00
parent 597d981f53
commit 76de16017d
4 changed files with 33 additions and 13 deletions

View File

@ -127,7 +127,7 @@ if (process.env.NODE_ENV === 'production') {
var content = tokens[idx + 1].content; var content = tokens[idx + 1].content;
var html = convert(striptags.strip(content, ['script', 'style'])); var html = convert(striptags.strip(content, ['script', 'style']));
return `<demo-block class="demo-box"> return `<demo-block class="demo-box" description="${description}">
<div class="examples" slot="examples">${html}</div> <div class="examples" slot="examples">${html}</div>
<div class="highlight" slot="highlight">`; <div class="highlight" slot="highlight">`;
} }
@ -183,7 +183,7 @@ if (process.env.NODE_ENV === 'production') {
var content = tokens[idx + 1].content; var content = tokens[idx + 1].content;
var html = convert(striptags.strip(content, ['script', 'style'])); var html = convert(striptags.strip(content, ['script', 'style']));
return `<demo-block class="demo-box"> return `<demo-block class="demo-box" description="${description}">
<div class="examples" slot="examples">${html}</div> <div class="examples" slot="examples">${html}</div>
<div class="highlight" slot="highlight">`; <div class="highlight" slot="highlight">`;
} }

View File

@ -3,13 +3,22 @@
class="demo-block" class="demo-block"
:class="blockClass"> :class="blockClass">
<slot name="examples"></slot> <slot name="examples"></slot>
<slot name="highlight"> <div class="highlight-wrapper">
</slot> <!-- <div class="highlight-toggle">
<span v-text="description"></span>
</div> -->
<slot name="highlight">
</slot>
</div>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
props: {
description: String
},
computed: { computed: {
blockClass() { blockClass() {
return `demo-${this.$route.path.split('/').pop()}`; return `demo-${this.$route.path.split('/').pop()}`;
@ -21,15 +30,13 @@ export default {
}, },
mounted() { mounted() {
this.$el.getElementsByClassName('highlight')[0].style.height = `${this.codeAreaHeight + 1}px`; // this.$el.getElementsByClassName('highlight')[0].style.height = `${this.codeAreaHeight + 1}px`;
} }
}; };
</script> </script>
<style> <style>
.demo-block { .demo-block {
border: solid 1px #eaeefb;
border-radius: 4px;
transition: .2s; transition: .2s;
overflow: hidden; overflow: hidden;
@ -38,19 +45,22 @@ export default {
} }
.examples { .examples {
width: 375px; width: 320px;
height: 568px;
background: url(https://b.yzcdn.cn/v2/image/wap/zanui-mobile-demo.png) no-repeat;
float: right; float: right;
box-sizing: border-box; box-sizing: border-box;
padding: 20px 0; padding: 74px 0 0;
min-height: 200px; min-height: 200px;
max-height: 600px; max-height: 600px;
overflow: auto; overflow: auto;
} }
.highlight { .highlight-wrapper {
margin-right: 375px; margin-right: 345px;
box-sizing: border-box; box-sizing: border-box;
border-right: solid 1px #eaeefb; border: 1px solid #E5E5E5;
border-radius: 4px;
pre { pre {
margin: 0; margin: 0;
@ -61,11 +71,19 @@ export default {
border: none; border: none;
max-height: none; max-height: none;
border-radius: 0; border-radius: 0;
padding: 20px;
background-color: #f8f8f8;
&::before { &::before {
content: none; content: none;
} }
} }
} }
.highlight-toggle {
padding: 20px;
border-bottom: 1px solid #e5e5e5;
color: #666;
}
} }
</style> </style>

View File

@ -7,7 +7,7 @@ export default {
computed: { computed: {
mobileUrl() { mobileUrl() {
return location.pathname + 'examples.html' + location.hash; return '/examples.html#' + location.pathname;
} }
}, },

View File

@ -5,6 +5,8 @@
.zan-icon { .zan-icon {
margin: 10px; margin: 10px;
font-size: 45px; font-size: 45px;
width: 56px;
text-align: center;
} }
} }
} }