Skip to content

Commit

Permalink
Fix show-avatar-image
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed Nov 20, 2024
1 parent 28365c7 commit 8712e7f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 8 additions & 4 deletions ui/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import "../src/elements/upload-files.ts";
import "../src/elements/file-storage-context.ts";
import "../src/elements/show-image.ts";
import "../src/elements/show-avatar-image.ts";
import { css, html, LitElement } from "lit";
import { ContextProvider } from "@lit/context";
import { AppWebsocket } from "@holochain/client";
Expand Down Expand Up @@ -56,39 +57,42 @@
<form ${onSubmit((data) => {
console.log(data);
this.shadowRoot.querySelector("form").reset();
})} style="display: flex; flex-direction: column; flex: 1">
})} style="display: flex; flex-direction: row; flex: 1">
<div style="display: flex; flex-direction: column;" >
<upload-files
id="uf"
.oneFile=${true}
required
name="file_hash"
style="max-width: 20px; max-height:20px"
@file-uploaded=${(e) => {
this.hash = e.detail.file.hash;
}}
></upload-files>
<input type="submit"></input>
</div>
${
this.hash
? html`
<div
style="display: flex; flex-direction: row; flex: 1"
>
<show-avatar-image
.imageHash=${this.hash}
></show-avatar-image>
<show-image
.imageHash=${this.hash}
style="width: 500px; height: 500px; border-radius: 12px"
></show-image>
<upload-files
.defaultValue=${this.hash}
style="flex: 1"
.oneFile=${true}
name="file_hash"
></upload-files>
</div>
`
: html``
}
<input type="submit"></input>
</form>
</file-storage-context>
</app-client-context>
Expand Down
8 changes: 6 additions & 2 deletions ui/src/elements/show-avatar-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { hashProperty, sharedStyles } from "@tnesh-stack/elements";
import { consume } from "@lit/context";

import "@shoelace-style/shoelace/dist/components/skeleton/skeleton.js";
import "@shoelace-style/shoelace/dist/components/avatar/avatar.js";
import "@tnesh-stack/elements/dist/elements/display-error.js";

import { EntryHash } from "@holochain/client";
Expand Down Expand Up @@ -62,8 +63,7 @@ export class ShowAvatarImage extends LitElement {
renderImage(data: string) {
return html`
<sl-avatar
.src=${data}
style="--size: var(--size)"
.image=${data}
part="image"
.initials=${this.initials.slice(0, 2)}
></sl-avatar>
Expand Down Expand Up @@ -94,6 +94,10 @@ export class ShowAvatarImage extends LitElement {
:host {
display: contents;
--size: 32px;
--size2: var(--size);
}
sl-avatar {
--size: var(--size2);
}
`,
];
Expand Down

0 comments on commit 8712e7f

Please sign in to comment.