Skip to content

Commit

Permalink
Add delegate to filesafe-embed to expand when file clicked, 2.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
moughxyz committed May 16, 2019
1 parent ff8760c commit 2e0a540
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 17 deletions.
30 changes: 25 additions & 5 deletions app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,24 @@ export default class App extends React.Component {
this.filesafe.setCurrentNote(noteModel);
});

let delegate = {
onSelectFile: (fileDescriptor) => {
if(fileDescriptor) {
if(!this.state.expanded) {
this.expandedFromSelection = true;
this.expandForFileSelection();
}
} else {
if(this.expandedFromSelection) {
this.collapse();
this.expandedFromSelection = false;
}
}
}
}

let mountPoint = document.getElementById("embed");
FilesafeEmbed.FilesafeEmbed.renderInElement(mountPoint, this.filesafe);
FilesafeEmbed.FilesafeEmbed.renderInElement(mountPoint, this.filesafe, delegate);

this.recomputeHeight();
}
Expand Down Expand Up @@ -63,17 +79,21 @@ export default class App extends React.Component {

toggleHeight() {
if(this.state.expanded) {
this.setHeightCollapsed();
this.collapse();
} else {
this.setHeightExpanded();
this.expand();
}
}

setHeightExpanded() {
expandForFileSelection() {
this.componentManager.setSize("container", "100%", 130);
}

expand() {
this.setState({expanded: true}, this.recomputeHeight)
}

setHeightCollapsed() {
collapse() {
this.setState({expanded: false}, this.recomputeHeight);
}

Expand Down
2 changes: 1 addition & 1 deletion app/stylesheets/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ html, body {
}

#expand-button {
position: absolute;
position: fixed;
top: 1.1rem;
right: 2rem;
box-shadow: var(--sn-stylekit-border-color) 0 1px 2px;
Expand Down
19 changes: 11 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sn-filesafe",
"version": "2.0.3",
"version": "2.0.4",
"main": "dist/dist.js",
"scripts": {
"lint": "eslint --cache --ignore-path .gitignore --ext .jsx,.js --format=node_modules/eslint-formatter-pretty .",
Expand Down Expand Up @@ -33,8 +33,8 @@
"sass-loader": "^6.0.6",
"sn-components-api": "1.2.5",
"style-loader": "~0.13.1",
"filesafe-embed": "1.0.0",
"filesafe-js": "1.0.0",
"filesafe-embed": "1.0.2",
"filesafe-js": "1.0.3",
"webpack": "^3.8.1",
"webpack-dev-server": "^2.9.7",
"worker-loader": "^2.0.0"
Expand Down

0 comments on commit 2e0a540

Please sign in to comment.