Skip to content

Commit 83e3885

Browse files
committed
added placeholder image icon to file thumbnail symbol
1 parent 89bb132 commit 83e3885

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

packages/uui-file-preview/lib/uui-file-preview.element.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ export class UUIFilePreviewElement extends LitElement {
140140
@state()
141141
private _file?: File;
142142

143+
@state()
144+
private _isImage?: boolean;
145+
143146
@property({ attribute: false })
144147
public get file() {
145148
return this._file;
@@ -154,6 +157,7 @@ export class UUIFilePreviewElement extends LitElement {
154157
this._size = newValue.size;
155158

156159
if (this._isFileAnImage(newValue)) {
160+
this._isImage = true;
157161
this._getThumbnail(newValue).then(result => {
158162
this._src = result;
159163
});
@@ -179,7 +183,7 @@ export class UUIFilePreviewElement extends LitElement {
179183
if (this._isDirectory) {
180184
return html`<uui-symbol-folder id="file-symbol"></uui-symbol-folder>`;
181185
}
182-
if (this._src) {
186+
if (this._isImage) {
183187
return html`<uui-symbol-file-thumbnail
184188
.src=${this._src}
185189
.alt=${this._name}

packages/uui-input-file/lib/uui-input-file.element.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export class UUIInputFileElement extends FormControlMixin(LitElement) {
3838
justify-items: center;
3939
width: 100%;
4040
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
41+
grid-auto-rows: min-content;
4142
gap: 16px;
4243
padding: 16px;
4344
overflow: auto;

packages/uui-symbol-file-thumbnail/lib/uui-symbol-file-thumbnail.element.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { defineElement } from '@umbraco-ui/uui-base/lib/registration';
2+
import { demandCustomElement } from '@umbraco-ui/uui-base/lib/utils';
23
import { css, html, LitElement } from 'lit';
34
import { property } from 'lit/decorators.js';
45

6+
import { iconPicture } from '@umbraco-ui/uui-icon-registry-essential/lib/svgs';
7+
58
/**
69
* @element uui-symbol-file-thumbnail
710
* @description - Symbol to display a thumbnail.
@@ -21,6 +24,17 @@ export class UUISymbolFileThumbnailElement extends LitElement {
2124
height: 100%;
2225
width: 100%;
2326
}
27+
28+
uui-icon {
29+
width: 100%;
30+
height: 100%;
31+
max-width: 100%;
32+
display: flex;
33+
max-height: 100%;
34+
justify-content: center;
35+
color: var(--uui-color-white);
36+
background: var(--uui-color-white-dimmed);
37+
}
2438
`,
2539
];
2640

@@ -42,8 +56,19 @@ export class UUISymbolFileThumbnailElement extends LitElement {
4256
@property({ type: String })
4357
alt: string = '';
4458

59+
connectedCallback(): void {
60+
super.connectedCallback();
61+
this.setAttribute('role', 'img');
62+
63+
demandCustomElement(this, 'uui-icon');
64+
}
65+
4566
render() {
46-
return html`<img src=${this.src} alt=${this.alt} />`;
67+
return this.src
68+
? html`<img src=${this.src} alt=${this.alt} />`
69+
: html`<uui-icon
70+
name="picture"
71+
.fallback=${iconPicture.strings[0]}></uui-icon>`;
4772
}
4873
}
4974

0 commit comments

Comments
 (0)