File tree Expand file tree Collapse file tree 3 files changed +32
-2
lines changed
uui-symbol-file-thumbnail/lib Expand file tree Collapse file tree 3 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -140,6 +140,9 @@ export class UUIFilePreviewElement extends LitElement {
140
140
@state ( )
141
141
private _file ?: File ;
142
142
143
+ @state ( )
144
+ private _isImage ?: boolean ;
145
+
143
146
@property ( { attribute : false } )
144
147
public get file ( ) {
145
148
return this . _file ;
@@ -154,6 +157,7 @@ export class UUIFilePreviewElement extends LitElement {
154
157
this . _size = newValue . size ;
155
158
156
159
if ( this . _isFileAnImage ( newValue ) ) {
160
+ this . _isImage = true ;
157
161
this . _getThumbnail ( newValue ) . then ( result => {
158
162
this . _src = result ;
159
163
} ) ;
@@ -179,7 +183,7 @@ export class UUIFilePreviewElement extends LitElement {
179
183
if ( this . _isDirectory ) {
180
184
return html `< uui-symbol-folder id ="file-symbol "> </ uui-symbol-folder > ` ;
181
185
}
182
- if ( this . _src ) {
186
+ if ( this . _isImage ) {
183
187
return html `< uui-symbol-file-thumbnail
184
188
.src =${ this . _src }
185
189
.alt =${ this . _name }
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ export class UUIInputFileElement extends FormControlMixin(LitElement) {
38
38
justify-items: center;
39
39
width: 100%;
40
40
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
41
+ grid-auto-rows: min-content;
41
42
gap: 16px;
42
43
padding: 16px;
43
44
overflow: auto;
Original file line number Diff line number Diff line change 1
1
import { defineElement } from '@umbraco-ui/uui-base/lib/registration' ;
2
+ import { demandCustomElement } from '@umbraco-ui/uui-base/lib/utils' ;
2
3
import { css , html , LitElement } from 'lit' ;
3
4
import { property } from 'lit/decorators.js' ;
4
5
6
+ import { iconPicture } from '@umbraco-ui/uui-icon-registry-essential/lib/svgs' ;
7
+
5
8
/**
6
9
* @element uui-symbol-file-thumbnail
7
10
* @description - Symbol to display a thumbnail.
@@ -21,6 +24,17 @@ export class UUISymbolFileThumbnailElement extends LitElement {
21
24
height: 100%;
22
25
width: 100%;
23
26
}
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
+ }
24
38
` ,
25
39
] ;
26
40
@@ -42,8 +56,19 @@ export class UUISymbolFileThumbnailElement extends LitElement {
42
56
@property ( { type : String } )
43
57
alt : string = '' ;
44
58
59
+ connectedCallback ( ) : void {
60
+ super . connectedCallback ( ) ;
61
+ this . setAttribute ( 'role' , 'img' ) ;
62
+
63
+ demandCustomElement ( this , 'uui-icon' ) ;
64
+ }
65
+
45
66
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 > ` ;
47
72
}
48
73
}
49
74
You can’t perform that action at this time.
0 commit comments