Skip to content

Commit

Permalink
improve code expand style
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Aug 15, 2017
1 parent 59b11f3 commit 5443e79
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
23 changes: 17 additions & 6 deletions site/theme/static/demo.less
Original file line number Diff line number Diff line change
Expand Up @@ -109,26 +109,37 @@
border-bottom: 1px dashed @border-color-split;
}

.collapse {
.code-expand-icon {
position: absolute;
right: 16px;
bottom: 23px;
cursor: pointer;
width: 16px;
height: 16px;
line-height: 16px;
opacity: 0.55;
text-align: center;
transition: all 0.3s;
user-select: none;
}

.code-expand-icon-show,
.code-expand-icon-hide {
transition: all 0.4s;
user-select: none;
position: absolute;
left: 0;
top: 0;
&:hover {
opacity: 1;
}
}

&.expand .collapse {
transform: rotate(90deg);
.code-expand-icon-show {
opacity: 0.55;
pointer-events: auto;
}

.code-expand-icon-hide {
opacity: 0;
pointer-events: none;
}

.highlight-wrapper {
Expand Down
20 changes: 14 additions & 6 deletions site/theme/template/Content/Demo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,20 @@ export default class Demo extends React.Component {
</div>
{introChildren}
<Tooltip title={codeExpand ? 'Hide Code' : 'Show Code'}>
<img
alt="expand code"
src="https://gw.alipayobjects.com/zos/rmsportal/NBjNKmzFsnATotIWoZmP.svg"
className="collapse"
onClick={this.handleCodeExpand}
/>
<span className="code-expand-icon">
<img
alt="expand code"
src="https://gw.alipayobjects.com/zos/rmsportal/wSAkBuJFbdxsosKKpqyq.svg"
className={codeExpand ? 'code-expand-icon-hide' : 'code-expand-icon-show'}
onClick={this.handleCodeExpand}
/>
<img
alt="expand code"
src="https://gw.alipayobjects.com/zos/rmsportal/OpROPHYqWmrMDBFMZtKF.svg"
className={codeExpand ? 'code-expand-icon-show' : 'code-expand-icon-hide'}
onClick={this.handleCodeExpand}
/>
</span>
</Tooltip>
</section>
<section className={highlightClass}
Expand Down

0 comments on commit 5443e79

Please sign in to comment.