Skip to content

Commit 0f5ba26

Browse files
committed
fix: Fix plaid background error.
1 parent d739e7d commit 0f5ba26

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

src/index.less

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,26 @@
2222
z-index: 99;
2323
}
2424
&-demo {
25+
border-radius: 3px;
2526
position: relative;
2627
overflow: auto;
2728
min-width: 100px;
28-
&-scroll {
29-
position: relative;
30-
padding: 15px;
31-
min-height: 80px;
32-
height: 100%;
33-
}
29+
position: relative;
30+
padding: 15px;
31+
min-height: 80px;
3432
&-error {
3533
z-index: 2;
3634
background: #fff;
3735
width: 100%;
3836
height: 100%;
3937
margin-bottom: 0 !important;
40-
color: #dc3545;
41-
background-color: #fbeff0;
38+
color: #dc3545 !important;
39+
}
40+
&-bgPlaid:not(&-error) {
41+
background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cpattern id='a' width='16' height='16' patternUnits='userSpaceOnUse'%3E%3Cpath fill='rgba(0, 0, 0, 0.06)' d='M0 0h8v8H0zM8 8h8v8H8z'/%3E%3C/pattern%3E%3Crect fill='url(%23a)' width='100%25' height='100%25'/%3E%3C/svg%3E");
42+
}
43+
&-source.error {
44+
display: none;
4245
}
4346
}
4447
&-bgPlaid {

src/index.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,23 +146,21 @@ export default class CodePreview extends React.PureComponent<ICodePreviewProps,
146146
{!noPreview && (
147147
<div
148148
ref={this.demoDom}
149-
className={`${prefixCls}-demo`}
149+
className={classnames(`${prefixCls}-demo`, {
150+
[`${prefixCls}-demo-bgPlaid`]: !bgWhite,
151+
[`${prefixCls}-demo-error`]: this.state.errorMessage,
152+
})}
150153
style={{
151154
flex: 1,
152155
...(this.state.width === 1 ? { width: '100%'} : {})
153156
}}
154157
>
155-
{!bgWhite && (
156-
<div className={`${prefixCls}-bgPlaid`}> {icon.bgPlaid} </div>
157-
)}
158158
{this.state.errorMessage && (
159-
<pre className={`${prefixCls}-demo-error`}>
159+
<pre>
160160
<code>{this.state.errorMessage}</code>
161161
</pre>
162162
)}
163-
<div className={classnames(`${prefixCls}-demo-scroll`)}>
164-
<div className={`${prefixCls}-demo-source`} id={this.playerId} />
165-
</div>
163+
<div className={classnames(`${prefixCls}-demo-source`, { ['error']: this.state.errorMessage })} id={this.playerId} />
166164
</div>
167165
)}
168166
{!noCode && (

0 commit comments

Comments
 (0)