Skip to content

Commit

Permalink
Fix display tabs of open files on one line + Fix dropdown position wh…
Browse files Browse the repository at this point in the history
…en scrolled too far
  • Loading branch information
Spejbl committed Nov 23, 2018
1 parent b459dc1 commit 373d4ac
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 44 deletions.
60 changes: 31 additions & 29 deletions src/components/projecteditor/panes.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export default class Panes extends Component {
super(props);
this.panes = [];
this.activePaneId = null;
this.state = {
mousePosition: 0
}
props.router.register('panes', this);
}

Expand Down Expand Up @@ -161,7 +164,7 @@ export default class Panes extends Component {
tabRightClicked = (e, id) => {
// We save the pane id for when closing all other panes.
e.preventDefault();
this.setState({ showContextMenuPaneId: id });
this.setState({ showContextMenuPaneId: id, mousePosition: e.pageX });
};

tabClicked = (e, id) => {
Expand Down Expand Up @@ -247,7 +250,7 @@ export default class Panes extends Component {
const selected = style.selected;
const html = this.panes.map((pane, index) => {
const contextMenu = (
<div className={style.contextMenu}>
<div className={classnames([style.contextMenu])} style={{left: this.state.mousePosition}}>
<div className={style.item} onClick={this.closeAllPanes}>
Close all
</div>
Expand All @@ -261,41 +264,40 @@ export default class Panes extends Component {
cls[tab] = true;
cls[selected] = isSelected;
return (
<div key={index}>
<div
<div
key={index}
onMouseDown={e => this.tabClicked(e, pane.id)}
onContextMenu={e => this.tabRightClicked(e, pane.id)}
>
<DropdownContainer
className={classnames(cls)}
onMouseDown={e => this.tabClicked(e, pane.id)}
onContextMenu={e => this.tabRightClicked(e, pane.id)}
dropdownContent={contextMenu}
useRightClick={true}
>
<DropdownContainer
dropdownContent={contextMenu}
useRightClick={true}
>
<div className={style.tabContainer}>
<div className={style.title}>
<div className={style.icon}>
{pane.getIcon()}
</div>
<div className={style.title2}>
{pane.getTitle()}
</div>
<div className={style.tabContainer}>
<div className={style.title}>
<div className={style.icon}>
{pane.getIcon()}
</div>
<div className={style.close}>
<button className="btnNoBg"
onClick={ e =>
this.tabClickedClose(e, pane.id)
}
>
<IconClose />
</button>
<div className={style.title2}>
{pane.getTitle()}
</div>
</div>
</DropdownContainer>
</div>
<div className={style.close}>
<button className="btnNoBg"
onClick={ e =>
this.tabClickedClose(e, pane.id)
}
>
<IconClose />
</button>
</div>
</div>
</DropdownContainer>
</div>
);
});
return <div>{html}</div>;
return <React.Fragment>{html}</React.Fragment>;
};

getPaneHeight = () => {
Expand Down
23 changes: 8 additions & 15 deletions src/components/projecteditor/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,20 @@
width: 100%;
overflow-y: hidden;
overflow-x: auto;
display: flex;
.tab {
padding: 10px 12px 10px 12px;
display: flex;
align-items: center;
align-content: center;
float: left;
min-width: 60px;
background-color: #2D2D2D;
cursor: pointer;
color: #969696;
.tabContainer {
div {
float: left;
}
display: flex;
.title {
padding-right: 10px;
padding-right: 10px;
display: flex;
div {
display: flex;
}
.icon {
margin-right: 10px;
}
Expand All @@ -95,7 +93,7 @@
.contextMenu {
display: block;
position: fixed;
margin-left: 40px;
margin-left: -40px;
margin-top: 15px;
background-color: #141414;
z-index: 1;
Expand Down Expand Up @@ -124,11 +122,6 @@
.panes {
width: 100%;
height: 100%;
/*&:after {*/
/*content: " ";*/
/*display: block;*/
/*clear: both;*/
/*}*/
.pane {
display: none;
&.visible {
Expand Down

0 comments on commit 373d4ac

Please sign in to comment.