Skip to content

Commit 143452b

Browse files
author
Fabian Stoehr
committed
fixed sizing of workspaceAddBug
1 parent 04c5b67 commit 143452b

File tree

3 files changed

+37
-10
lines changed

3 files changed

+37
-10
lines changed

src/components/WorkspaceAdd.js

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,20 @@ export class WorkspaceAdd extends Component {
2828
constructor(props) {
2929
super(props);
3030

31-
this.state = { addResourcesOpen: false };
3231
this.ref = createRef();
32+
this.state = { addResourcesOpen: false, refWidth: '100%' };
3333

3434
this.onSubmit = this.onSubmit.bind(this);
3535
this.setAddResourcesVisibility = this.setAddResourcesVisibility.bind(this);
3636
this.handleDrop = this.handleDrop.bind(this);
37+
38+
this.updateRefWidth = this.updateRefWidth.bind(this);
39+
}
40+
41+
/** */
42+
componentDidMount() {
43+
window.addEventListener('resize', this.updateRefWidth);
44+
this.updateRefWidth();
3745
}
3846

3947
/** */
@@ -70,14 +78,22 @@ export class WorkspaceAdd extends Component {
7078
}
7179
}
7280

81+
/** Update ref width */
82+
updateRefWidth() {
83+
if (this.ref.current) {
84+
const refWidth = this.ref.current.offsetWidth;
85+
this.setState({ refWidth });
86+
}
87+
}
88+
7389
/**
7490
* render
7591
*/
7692
render() {
7793
const {
78-
catalog, setWorkspaceAddVisibility, t, classes,
94+
catalog, setWorkspaceAddVisibility, t, classes, isWorkspaceControlPanelVisible,
7995
} = this.props;
80-
const { addResourcesOpen } = this.state;
96+
const { addResourcesOpen, refWidth } = this.state;
8197

8298
const manifestList = catalog.map((resource, index) => (
8399
<ManifestListItem
@@ -91,7 +107,14 @@ export class WorkspaceAdd extends Component {
91107

92108
return (
93109
<IIIFDropTarget onDrop={this.handleDrop}>
94-
<div ref={this.ref} className={classNames(ns('workspace-add'), classes.workspaceAdd)}>
110+
<div
111+
ref={this.ref}
112+
className={classNames(
113+
ns('workspace-add'),
114+
classes.workspaceAdd,
115+
{ [classes.workspaceAddMargin]: isWorkspaceControlPanelVisible },
116+
)}
117+
>
95118
{catalog.length < 1 ? (
96119
<Grid
97120
alignItems="center"
@@ -146,6 +169,9 @@ export class WorkspaceAdd extends Component {
146169
hideBackdrop: true,
147170
style: { position: 'absolute' },
148171
}}
172+
PaperProps={{
173+
style: { width: refWidth },
174+
}}
149175
>
150176
<Paper
151177
className={classes.form}
@@ -172,6 +198,7 @@ export class WorkspaceAdd extends Component {
172198
</Paper>
173199
</Drawer>
174200
</div>
201+
175202
</IIIFDropTarget>
176203
);
177204
}
@@ -184,6 +211,7 @@ WorkspaceAdd.propTypes = {
184211
provider: PropTypes.string,
185212
})),
186213
classes: PropTypes.objectOf(PropTypes.string),
214+
isWorkspaceControlPanelVisible: PropTypes.bool.isRequired,
187215
setWorkspaceAddVisibility: PropTypes.func.isRequired,
188216
t: PropTypes.func,
189217
};

src/components/WorkspaceArea.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class WorkspaceArea extends Component {
4242
>
4343
{
4444
isWorkspaceAddVisible
45-
? <WorkspaceAdd />
45+
? <WorkspaceAdd isWorkspaceControlPanelVisible={isWorkspaceControlPanelVisible} />
4646
: <Workspace />
4747
}
4848
<ErrorDialog />

src/containers/WorkspaceAdd.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@ const styles = theme => ({
6363
},
6464
paper: {
6565
borderTop: '0',
66-
left: '0',
67-
[theme.breakpoints.up('sm')]: {
68-
left: '65px',
69-
},
66+
left: 'unset',
7067
},
7168
typographyBody: {
7269
flexGrow: 1,
@@ -82,9 +79,11 @@ const styles = theme => ({
8279
// eslint-disable-next-line sort-keys
8380
'@media (min-width: 600px)': {
8481
workspaceAdd: {
85-
paddingLeft: 68,
8682
paddingTop: 0,
8783
},
84+
workspaceAddMargin: {
85+
marginLeft: 68,
86+
},
8887
},
8988
});
9089

0 commit comments

Comments
 (0)