Skip to content

Commit 22d88da

Browse files
committed
refactor(chat): udate attachments styling
1 parent a649390 commit 22d88da

File tree

8 files changed

+86
-28
lines changed

8 files changed

+86
-28
lines changed

package-lock.json

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"globby": "^14.1.0",
8080
"husky": "^9.1.7",
8181
"ig-typedoc-theme": "^6.2.3",
82-
"igniteui-theming": "^19.3.0-beta.3",
82+
"igniteui-theming": "^19.3.0-beta.4",
8383
"keep-a-changelog": "^2.6.2",
8484
"lint-staged": "^16.1.4",
8585
"lit-analyzer": "^2.0.3",

src/components/chat/message-attachments.ts

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,20 @@ export default class IgcMessageAttachmentsComponent extends LitElement {
135135
? this._chatState.options.templates.attachmentHeaderTemplate(
136136
this.message
137137
)
138-
: html`${attachment.type === 'image' ||
139-
attachment.file?.type.startsWith('image/')
140-
? html`<igc-icon
141-
name="image"
142-
collection="material"
143-
part="attachment-icon"
144-
></igc-icon>`
145-
: html`<igc-icon
146-
name="file"
147-
collection="material"
148-
part="attachment-icon"
149-
></igc-icon>`}
138+
: html`${this.message?.sender !== this._chatState?.currentUserId
139+
? html`${attachment.type === 'image' ||
140+
attachment.file?.type.startsWith('image/')
141+
? html`<igc-icon
142+
name="image"
143+
collection="material"
144+
part="attachment-icon"
145+
></igc-icon>`
146+
: html`<igc-icon
147+
name="file"
148+
collection="material"
149+
part="attachment-icon"
150+
></igc-icon>`}`
151+
: nothing}
150152
<span part="file-name">${attachment.name}</span> `}
151153
</div>`;
152154
}
@@ -163,7 +165,11 @@ export default class IgcMessageAttachmentsComponent extends LitElement {
163165
}
164166

165167
private renderAttachmentContent(attachment: IgcMessageAttachment) {
166-
return html`<div part="attachment-content">
168+
const parts = {
169+
'attachment-content': true,
170+
sent: this.message?.sender === this._chatState?.currentUserId,
171+
};
172+
return html`<div part=${partMap(parts)}>
167173
${this._chatState?.options?.templates?.attachmentContentTemplate &&
168174
this.message
169175
? this._chatState.options.templates.attachmentContentTemplate(
@@ -175,18 +181,23 @@ export default class IgcMessageAttachmentsComponent extends LitElement {
175181

176182
private renderDefaultAttachmentsTemplate() {
177183
const parts = {
184+
attachment: true,
185+
sent: this.message?.sender === this._chatState?.currentUserId,
186+
};
187+
188+
const headerParts = {
178189
'attachment-header': true,
179190
sent: this.message?.sender === this._chatState?.currentUserId,
180191
};
181192

182193
return html`${this.message?.attachments?.map(
183194
(attachment) =>
184-
html`<div part="attachment">
195+
html`<div part=${partMap(parts)}>
185196
${this.message?.sender === this._chatState?.currentUserId
186197
? this.renderAttachmentContent(attachment)
187198
: nothing}
188199
<div
189-
part=${partMap(parts)}
200+
part=${partMap(headerParts)}
190201
role="button"
191202
@click=${() => this.handleHeaderClick(attachment)}
192203
>

src/components/chat/themes/message-attachments.base.scss

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,50 @@
1919
max-width: rem(400px);
2020
}
2121

22-
[part='attachment-header'] {
22+
[part='attachment sent'] {
23+
border-radius: rem(2px);
24+
max-width: rem(80px);
25+
}
26+
27+
[part~='attachment-header'] {
2328
padding: rem(8px) rem(12px) rem(8px) rem(16px);
2429
border-top-left-radius: inherit;
2530
border-top-right-radius: inherit;
2631
}
2732

28-
[part='attachment-content'] {
33+
[part='attachment-header sent'] {
34+
padding: rem(6px) 0 0;
35+
}
36+
37+
[part~='attachment-content'] {
2938
display: flex;
3039
border-bottom-left-radius: inherit;
3140
border-bottom-right-radius: inherit;
3241
max-height: rem(240px);
3342
overflow: hidden;
3443
}
3544

45+
[part='attachment-content sent'] {
46+
border-top-left-radius: inherit;
47+
border-top-right-radius: inherit;
48+
width: rem(78px);
49+
aspect-ratio: 1;
50+
}
51+
3652
[part='image-attachment'] {
3753
width: 100%;
3854
height: 100%;
3955
border-radius: inherit;
4056
object-fit: cover;
4157
}
4258

59+
[part='file-attachment'] {
60+
display: block;
61+
width: 100%;
62+
height: 100%;
63+
object-fit: cover;
64+
}
65+
4366
[part='details'] {
4467
display: flex;
4568
align-items: center;

src/components/chat/themes/message.base.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,3 @@ pre, code {
4343
word-wrap: break-word;
4444
overflow-x: auto;
4545
}
46-

src/components/chat/themes/shared/chat-message/chat-message.common.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,9 @@ $theme: $material;
1010
[part~='bubble'] {
1111
color: var-get($theme, 'message-color');
1212
}
13+
14+
[part~='message-actions'] {
15+
igc-icon-button::part(icon) {
16+
color: var-get($theme, 'message-actions-color');
17+
}
18+
}

src/components/chat/themes/shared/chat.bootstrap.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
@use 'styles/utilities' as *;
2+
@use '../light/themes' as *;
3+
4+
$theme: $bootstrap;
5+
6+
[part='header'] {
7+
box-shadow: none;
8+
border-block-end: rem(1px) solid var-get($theme, 'header-border');
9+
}
210

311
igc-list {
412
border: none;
513
}
614

15+
igc-list,
716
igc-list-item:not(:hover),
817
igc-list-header {
918
background: initial;

src/components/chat/themes/shared/message-attachments.common.scss

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,22 @@
33

44
$theme: $material;
55

6+
[part='attachment-header'],
7+
[part='attachment-content'],
8+
[part='attachment-content sent'] {
9+
border: rem(1px) solid var-get($theme, 'image-border');
10+
}
11+
612
[part='attachment-header'] {
713
background: var-get($theme, 'image-background');
8-
border: rem(1px) solid var-get($theme, 'image-border');
914
border-block-end: none;
1015
}
1116

17+
[part~='attachment-content'] {
18+
// background: var-get($theme, 'file-background');
19+
background: white;
20+
}
21+
1222
[part='attachment-content'] {
13-
border: rem(1px) solid var-get($theme, 'image-border');
14-
border-block-start: none
15-
}
23+
border-block-start: none;
24+
}

0 commit comments

Comments
 (0)