Skip to content

Commit ccdd371

Browse files
committed
Modify the demo preview styles.
1 parent 0828574 commit ccdd371

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

theme/default/lib/markdown/InlineCode.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,23 @@ export default class Canvas extends PureComponent {
2424
</code>
2525
</pre>
2626
);
27+
const isPreview = /^(html|htm)$/.test(this.props.language);
28+
2729
if (/^__dome__/.test(this.props.value)) {
2830
return (
2931
<div className={styles.demo}>
30-
<div className={styles.demoBody} id={this.playerId}>
31-
{/^(html|htm)$/.test(this.props.language) && <div dangerouslySetInnerHTML={{ __html: code }} />}
32-
</div>
32+
{isPreview && (
33+
<div className={styles.demoBody} id={this.playerId}>
34+
<div dangerouslySetInnerHTML={{ __html: code }} />
35+
</div>
36+
)}
3337
{PreCode(this.state.height)}
34-
<div className={styles.demoControl} onClick={this.onClick.bind(this)}>
38+
<div
39+
className={classNames(styles.demoControl, {
40+
[styles.isPreview]: !isPreview && this.state.height !== 0,
41+
})}
42+
onClick={this.onClick.bind(this)}
43+
>
3544
{this.state.height === 0 ? '显示' : '隐藏'}代码
3645
</div>
3746
</div>

theme/default/lib/markdown/InlineCode.less

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,16 @@
1313
padding: 10px;
1414
}
1515
}
16+
.demoBody + pre.highlight + .demoControl {
17+
border-top: 1px solid #d5d5d5;
18+
}
19+
.isPreview {
20+
border-top: 1px solid #d5d5d5;
21+
}
1622
.demoControl {
1723
padding: 3px 8px;
18-
cursor: pointer;
24+
line-height: 20px;
1925
background-color: rgba(0,0,0,.03);
20-
border-top: 1px solid #d5d5d5;
26+
cursor: pointer;
2127
}
2228
}

0 commit comments

Comments
 (0)