Skip to content

Commit

Permalink
file attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
targoninc-alex committed Jul 2, 2024
1 parent 4897b87 commit 8ffae35
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
3 changes: 3 additions & 0 deletions ui/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ label {

button {
cursor: pointer;
}

button.flex {
align-items: center;
}

Expand Down
4 changes: 4 additions & 0 deletions ui/classes.css
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@
font-size: 0.8em;
}

.text-tiny {
font-size: 0.6em;
}

.chat-content {
height: 100%;
}
Expand Down
29 changes: 22 additions & 7 deletions ui/components/attachment.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,32 @@ export class AttachmentTemplates {
.attributes("scrolling", "no")
.attributes("frameborder", "0")
.attributes("allowfullscreen", "true")
.build()
).build();
}

static fileAttachment(attachment, url) {
return CommonTemplates.buttonWithIcon("download", attachment.filename, () => {
const link = document.createElement('a');
link.href = url;
link.download = attachment.filename;
link.click();
});
const mb = (attachment.size / 1024 / 1024).toFixed(2);

return create("button")
.classes("flex-v", "small-gap")
.onclick(() => {
const link = document.createElement('a');
link.href = url;
link.download = attachment.filename;
link.click();
}).children(
create("div")
.classes("flex")
.children(
CommonTemplates.icon("download"),
create("span")
.classes("text-small")
.text(attachment.filename)
),
create("span")
.classes("text-tiny")
.text("Download (" + mb + " MB)")
).build();
}

static imageAttachment(attachment, url) {
Expand Down

0 comments on commit 8ffae35

Please sign in to comment.