@@ -2,10 +2,18 @@ import { LitElement, html } from 'lit';
22import { property } from 'lit/decorators.js' ;
33import IgcIconButtonComponent from '../button/icon-button.js' ;
44import { registerComponent } from '../common/definitions/register.js' ;
5+ import IgcExpansionPanelComponent from '../expansion-panel/expansion-panel.js' ;
56import IgcIconComponent from '../icon/icon.js' ;
67import { registerIconFromText } from '../icon/icon.registry.js' ;
78import { styles } from './themes/message-attachments.base.css' ;
8- import { type IgcMessageAttachment , closeIcon , fileIcon } from './types.js' ;
9+ import {
10+ type IgcMessageAttachment ,
11+ closeIcon ,
12+ fileIcon ,
13+ imageIcon ,
14+ moreIcon ,
15+ previewIcon ,
16+ } from './types.js' ;
917
1018/**
1119 *
@@ -23,7 +31,8 @@ export class IgcMessageAttachmentsComponent extends LitElement {
2331 registerComponent (
2432 IgcMessageAttachmentsComponent ,
2533 IgcIconComponent ,
26- IgcIconButtonComponent
34+ IgcIconButtonComponent ,
35+ IgcExpansionPanelComponent
2736 ) ;
2837 }
2938 @property ( { type : Array } )
@@ -36,6 +45,9 @@ export class IgcMessageAttachmentsComponent extends LitElement {
3645 super ( ) ;
3746 registerIconFromText ( 'close' , closeIcon , 'material' ) ;
3847 registerIconFromText ( 'file' , fileIcon , 'material' ) ;
48+ registerIconFromText ( 'image' , imageIcon , 'material' ) ;
49+ registerIconFromText ( 'preview' , previewIcon , 'material' ) ;
50+ registerIconFromText ( 'more' , moreIcon , 'material' ) ;
3951 }
4052
4153 private formatFileSize ( bytes = 0 ) : string {
@@ -52,41 +64,64 @@ export class IgcMessageAttachmentsComponent extends LitElement {
5264 this . previewImage = '' ;
5365 }
5466
67+ private preventToggle ( e : CustomEvent ) {
68+ e . preventDefault ( ) ;
69+ }
70+
5571 protected override render ( ) {
5672 return html `
5773 < div class ="attachments-container ">
58- ${ this . attachments . map ( ( attachment ) =>
59- attachment . type === 'image'
60- ? html `
61- < div class ="attachment-preview ">
62- < img
74+ ${ this . attachments . map (
75+ ( attachment ) => html `
76+ < igc-expansion-panel
77+ indicator-position ="none "
78+ .open =${ attachment . type === 'image' }
79+ @igcClosing =${ this . preventToggle }
80+ @igcOpening=${ this . preventToggle }
81+ >
82+ < div slot ="title " class ="attachment ">
83+ < div class ="details ">
84+ ${ attachment . type === 'image'
85+ ? html `< igc-icon
86+ name ="image "
87+ collection ="material "
88+ class ="medium "
89+ > </ igc-icon > `
90+ : html `< igc-icon
91+ name ="file "
92+ collection ="material "
93+ class ="medium "
94+ > </ igc-icon > ` }
95+ < span class ="file-name "> ${ attachment . name } </ span >
96+ </ div >
97+ < div class ="actions ">
98+ ${ attachment . type === 'image'
99+ ? html ` < igc-icon-button
100+ name ="preview "
101+ collection ="material "
102+ variant ="flat "
103+ class ="small "
104+ @click =${ ( ) => this . openImagePreview ( attachment . url ) }
105+ > </ igc-icon-button > `
106+ : '' }
107+ < igc-icon-button
108+ name ="more "
109+ collection ="material "
110+ variant ="flat "
111+ class ="small "
112+ > </ igc-icon-button >
113+ </ div >
114+ </ div >
115+
116+ ${ attachment . type === 'image'
117+ ? html ` < img
63118 class ="image-attachment "
64119 src =${ attachment . url }
65120 alt =${ attachment . name }
66- @click=${ ( ) => this . openImagePreview ( attachment . url ) }
67- />
68- </ div >
69- `
70- : html `
71- < a
72- class ="file-attachment "
73- href =${ attachment . url }
74- target ="_blank"
75- download=${ attachment . name }
76- >
77- < igc-icon
78- name ="file "
79- collection ="material "
80- class ="large "
81- > </ igc-icon >
82- < div class ="file-info ">
83- < div class ="file-name "> ${ attachment . name } </ div >
84- < div class ="file-size ">
85- ${ this . formatFileSize ( attachment . size ) }
86- </ div >
87- </ div >
88- </ a >
89- `
121+ /> `
122+ : '' }
123+ </ igc-expansion-panel >
124+ `
90125 ) }
91126 </ div >
92127
0 commit comments