File details can now be hidden

This commit is contained in:
n1474335 2022-12-09 19:24:43 +00:00
parent a116a2a423
commit c1d2970f1e
3 changed files with 68 additions and 2 deletions

View file

@ -563,6 +563,43 @@
height: 100%; height: 100%;
} }
.file-details-toggle-shown,
.file-details-toggle-hidden {
width: 8px;
height: 40px;
border: 1px solid var(--secondary-border-colour);
position: absolute;
top: calc(50% - 20px);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
background-color: var(--secondary-border-colour);
color: var(--subtext-font-colour);
z-index: 1;
}
.file-details-toggle-shown {
left: 0;
border-left: none;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
}
.file-details-toggle-hidden {
left: -8px;
border-right: none;
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
}
.file-details-toggle-shown:hover,
.file-details-toggle-hidden:hover {
background-color: var(--primary-border-colour);
border-color: var(--primary-border-colour);
color: var(--primary-font-colour);
}
.file-details-heading { .file-details-heading {
font-weight: bold; font-weight: bold;
margin: 10px 0 10px 0; margin: 10px 0 10px 0;

View file

@ -23,6 +23,8 @@ class FileDetailsPanel {
this.status = opts?.status; this.status = opts?.status;
this.buffer = opts?.buffer; this.buffer = opts?.buffer;
this.renderPreview = opts?.renderPreview; this.renderPreview = opts?.renderPreview;
this.toggleHandler = opts?.toggleHandler;
this.hidden = opts?.hidden;
this.dom = this.buildDOM(); this.dom = this.buildDOM();
this.renderFileThumb(); this.renderFileThumb();
} }
@ -37,6 +39,11 @@ class FileDetailsPanel {
dom.className = "cm-file-details"; dom.className = "cm-file-details";
const fileThumb = require("../static/images/file-128x128.png"); const fileThumb = require("../static/images/file-128x128.png");
dom.innerHTML = ` dom.innerHTML = `
<div class="${this.hidden ? "file-details-toggle-hidden" : "file-details-toggle-shown"}"
data-toggle="tooltip"
title="${this.hidden ? "Show" : "Hide"} file details">
${this.hidden ? "&#10096;" : "&#10097;"}
</div>
<p class="file-details-heading">File details</p> <p class="file-details-heading">File details</p>
<img aria-hidden="true" src="${fileThumb}" alt="File icon" class="file-details-thumbnail"/> <img aria-hidden="true" src="${fileThumb}" alt="File icon" class="file-details-thumbnail"/>
<table class="file-details-data"> <table class="file-details-data">
@ -67,6 +74,9 @@ class FileDetailsPanel {
</table> </table>
`; `;
dom.querySelector(".file-details-toggle-shown,.file-details-toggle-hidden")
.addEventListener("click", this.toggleHandler, false);
return dom; return dom;
} }
@ -116,8 +126,11 @@ function makePanel(opts) {
return (view) => { return (view) => {
return { return {
dom: fdPanel.dom, dom: fdPanel.dom,
width: 200, width: opts?.hidden ? 1 : 200,
update(update) { update(update) {
},
mount() {
$("[data-toggle='tooltip']").tooltip();
} }
}; };
}; };

View file

@ -548,7 +548,9 @@ class InputWaiter {
progress: inputData.progress, progress: inputData.progress,
status: inputData.status, status: inputData.status,
buffer: inputData.buffer, buffer: inputData.buffer,
renderPreview: this.app.options.imagePreview renderPreview: this.app.options.imagePreview,
toggleHandler: this.toggleFileDetails.bind(this),
hidden: false
}; };
this.inputEditorView.dispatch({ this.inputEditorView.dispatch({
effects: this.inputEditorConf.fileDetailsPanel.reconfigure( effects: this.inputEditorConf.fileDetailsPanel.reconfigure(
@ -572,6 +574,20 @@ class InputWaiter {
}); });
} }
/**
* Handler for file details toggle clicks
* @param {event} e
*/
toggleFileDetails(e) {
$("[data-toggle='tooltip']").tooltip("hide");
this.fileDetails.hidden = !this.fileDetails.hidden;
this.inputEditorView.dispatch({
effects: this.inputEditorConf.fileDetailsPanel.reconfigure(
fileDetailsPanel(this.fileDetails)
)
});
}
/** /**
* Update file details when a file completes loading * Update file details when a file completes loading
* *