Skip to content

Commit

Permalink
Modify the demo preview styles.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jun 11, 2018
1 parent 0828574 commit ccdd371
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
17 changes: 13 additions & 4 deletions theme/default/lib/markdown/InlineCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,23 @@ export default class Canvas extends PureComponent {
</code>
</pre>
);
const isPreview = /^(html|htm)$/.test(this.props.language);

if (/^__dome__/.test(this.props.value)) {
return (
<div className={styles.demo}>
<div className={styles.demoBody} id={this.playerId}>
{/^(html|htm)$/.test(this.props.language) && <div dangerouslySetInnerHTML={{ __html: code }} />}
</div>
{isPreview && (
<div className={styles.demoBody} id={this.playerId}>
<div dangerouslySetInnerHTML={{ __html: code }} />
</div>
)}
{PreCode(this.state.height)}
<div className={styles.demoControl} onClick={this.onClick.bind(this)}>
<div
className={classNames(styles.demoControl, {
[styles.isPreview]: !isPreview && this.state.height !== 0,
})}
onClick={this.onClick.bind(this)}
>
{this.state.height === 0 ? '显示' : '隐藏'}代码
</div>
</div>
Expand Down
10 changes: 8 additions & 2 deletions theme/default/lib/markdown/InlineCode.less
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@
padding: 10px;
}
}
.demoBody + pre.highlight + .demoControl {
border-top: 1px solid #d5d5d5;
}
.isPreview {
border-top: 1px solid #d5d5d5;
}
.demoControl {
padding: 3px 8px;
cursor: pointer;
line-height: 20px;
background-color: rgba(0,0,0,.03);
border-top: 1px solid #d5d5d5;
cursor: pointer;
}
}

0 comments on commit ccdd371

Please sign in to comment.