Skip to content

Commit 0078251

Browse files
committed
feat(chat): focus styles and improvements
1 parent 87a2862 commit 0078251

17 files changed

+248
-152
lines changed

src/components/chat/chat-input.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { consume } from '@lit/context';
22
import { html, LitElement, nothing, type TemplateResult } from 'lit';
33
import { query, state } from 'lit/decorators.js';
4+
import { addThemingController } from '../../theming/theming-controller.js';
45
import IgcIconButtonComponent from '../button/icon-button.js';
56
import IgcChipComponent from '../chip/chip.js';
67
import { chatContext } from '../common/context.js';
@@ -12,6 +13,8 @@ import { registerIconFromText } from '../icon/icon.registry.js';
1213
import IgcTextareaComponent from '../textarea/textarea.js';
1314
import type { ChatState } from './chat-state.js';
1415
import { styles } from './themes/input.base.css.js';
16+
import { all } from './themes/input.js';
17+
import { styles as shared } from './themes/shared/input/input.common.css.js';
1518
import { attachmentIcon, sendButtonIcon } from './types.js';
1619

1720
/**
@@ -46,7 +49,7 @@ import { attachmentIcon, sendButtonIcon } from './types.js';
4649
export default class IgcChatInputComponent extends LitElement {
4750
public static readonly tagName = 'igc-chat-input';
4851

49-
public static override styles = styles;
52+
public static override styles = [styles, shared];
5053

5154
@consume({ context: chatContext, subscribe: true })
5255
private _chatState?: ChatState;
@@ -82,6 +85,7 @@ export default class IgcChatInputComponent extends LitElement {
8285

8386
constructor() {
8487
super();
88+
addThemingController(this, all);
8589
registerIconFromText('attachment', attachmentIcon, 'material');
8690
registerIconFromText('send-message', sendButtonIcon, 'material');
8791
}
@@ -164,7 +168,7 @@ export default class IgcChatInputComponent extends LitElement {
164168
const target = e.target as HTMLTextAreaElement;
165169
this.inputValue = target.value;
166170
this._chatState?.handleInputChange(this.inputValue);
167-
this.adjustTextareaHeight();
171+
// this.adjustTextareaHeight();
168172
}
169173

170174
private handleKeyDown(e: KeyboardEvent) {
@@ -263,14 +267,14 @@ export default class IgcChatInputComponent extends LitElement {
263267
this.requestUpdate();
264268
}
265269

266-
private adjustTextareaHeight() {
267-
const textarea = this.textInputElement;
268-
if (!textarea) return;
270+
// private adjustTextareaHeight() {
271+
// const textarea = this.textInputElement;
272+
// if (!textarea) return;
269273

270-
textarea.style.height = 'auto';
271-
const newHeight = Math.min(textarea.scrollHeight, 120);
272-
textarea.style.height = `${newHeight}px`;
273-
}
274+
// textarea.style.height = 'auto';
275+
// const newHeight = Math.min(textarea.scrollHeight, 120);
276+
// textarea.style.height = `${newHeight}px`;
277+
// }
274278

275279
private sendMessage() {
276280
if (

src/components/chat/chat-message-list.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { registerComponent } from '../common/definitions/register.js';
1414
import IgcChatMessageComponent from './chat-message.js';
1515
import type { ChatState } from './chat-state.js';
1616
import { styles } from './themes/message-list.base.css.js';
17+
import { styles as shared } from './themes/shared/message-list.common.css.js';
1718
import type { IgcMessage } from './types.js';
1819

1920
/**
@@ -38,7 +39,7 @@ export default class IgcChatMessageListComponent extends LitElement {
3839
public static readonly tagName = 'igc-chat-message-list';
3940

4041
/** Styles applied to the component */
41-
public static override styles = styles;
42+
public static override styles = [styles, shared];
4243

4344
/**
4445
* Consumed chat state context providing messages, options, and user data.

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ igc-chat-message-list,
2424
[part='suggestions-container'] {
2525
max-width: rem(760px);
2626
width: 100%;
27-
margin-inline: rem(16px);
27+
// margin-inline: rem(16px);
28+
}
29+
30+
[part='suggestions-header'] {
31+
@include type-style('subtitle-2') {
32+
margin: 0;
33+
};
2834
}
2935

3036
[part='empty-state'] {

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,6 @@
1818
gap: rem(8px);
1919
}
2020

21-
// should be changed when the design is ready
22-
[part~='dragging'] {
23-
igc-textarea::part(container) {
24-
background: color(gray, 300);
25-
26-
&::after {
27-
border-block-end: rem(2px) solid color(primary, 500);
28-
}
29-
}
30-
}
31-
3221
[part='buttons-container'] {
3322
display: flex;
3423
align-items: center;
@@ -43,12 +32,20 @@
4332
gap: rem(8px);
4433
}
4534

35+
igc-textarea::part(input) {
36+
// maximum eight lines
37+
max-height: rem(216px);
38+
overflow-y: auto;
39+
}
40+
4641
igc-file-input {
4742
width: fit-content;
4843
margin-inline-end: auto;
4944
}
5045

51-
igc-file-input::part(file-names) {
46+
igc-file-input::part(file-names),
47+
igc-file-input::part(start),
48+
igc-file-input::part(end) {
5249
display: none;
5350
}
5451

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { css } from 'lit';
2+
3+
import type { Themes } from '../../../theming/types.js';
4+
// Shared Styles
5+
import { styles as bootstrap } from './shared/input/input.bootstrap.css.js';
6+
import { styles as fluent } from './shared/input/input.fluent.css.js';
7+
import { styles as indigo } from './shared/input/input.indigo.css.js';
8+
import { styles as material } from './shared/input/input.material.css.js';
9+
10+
const light = {
11+
bootstrap: css`
12+
${bootstrap}
13+
`,
14+
fluent: css`
15+
${fluent}
16+
`,
17+
indigo: css`
18+
${indigo}
19+
`,
20+
material: css`
21+
${material}
22+
`,
23+
};
24+
25+
const dark = {
26+
bootstrap: css`
27+
${bootstrap}
28+
`,
29+
fluent: css`
30+
${fluent}
31+
`,
32+
indigo: css`
33+
${indigo}
34+
`,
35+
material: css`
36+
${material}
37+
`,
38+
};
39+
40+
export const all: Themes = { light, dark };
Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
1+
@use 'sass:map';
12
@use 'styles/utilities' as *;
23
@use 'igniteui-theming/sass/themes/schemas/components/light/chat' as *;
4+
@use 'components/input/themes/light/themes' as input-theme;
35

46
$base: digest-schema($light-chat);
5-
$material: digest-schema($material-chat);
6-
$bootstrap: digest-schema($bootstrap-chat);
7-
$fluent: digest-schema($fluent-chat);
8-
$indigo: digest-schema($indigo-chat);
7+
$material: map.merge(digest-schema($material-chat), (
8+
box-background-focus: map.get(input-theme.$material, 'box-background-focus'),
9+
focused-bottom-line-color: map.get(input-theme.$material, 'focused-bottom-line-color')
10+
));
11+
$bootstrap: map.merge(digest-schema($bootstrap-chat), (
12+
focused-border-color: map.get(input-theme.$bootstrap, 'focused-border-color'),
13+
focused-secondary-color: map.get(input-theme.$bootstrap, 'focused-secondary-color')
14+
));
15+
$fluent: map.merge(digest-schema($fluent-chat), (
16+
focused-border-color: map.get(input-theme.$fluent, 'focused-border-color'),
17+
));
18+
$indigo: map.merge(digest-schema($indigo-chat), (
19+
box-background-hover: map.get(input-theme.$indigo, 'box-background-hover'),
20+
focused-bottom-line-color: map.get(input-theme.$indigo, 'focused-bottom-line-color'),
21+
focused-text-color: map.get(input-theme.$indigo, 'focused-text-color')
22+
));

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

Lines changed: 28 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -3,116 +3,53 @@
33

44
:host {
55
display: block;
6-
margin-top: 0.5rem;
76
}
87

9-
.attachments-container {
8+
[part='attachments-container'] {
9+
display: flex;
1010
flex-wrap: wrap;
11-
gap: 0.5rem;
11+
gap: rem(16px);
1212
}
1313

14-
.attachment-preview {
15-
position: relative;
16-
border-radius: 0.375rem;
14+
[part='attachment'] {
15+
flex: 1 1;
16+
border-radius: rem(4px);
1717
overflow: hidden;
18-
max-width: 200px;
18+
min-width: rem(80px);
19+
max-width: rem(400px);
1920
}
2021

21-
.image-attachment {
22-
max-width: 250px;
23-
max-height: 250px;
24-
object-fit: cover;
25-
cursor: pointer;
26-
border-radius: 0.375rem;
22+
[part='attachment-header'] {
23+
padding: rem(8px) rem(12px) rem(8px) rem(16px);
24+
border-top-left-radius: inherit;
25+
border-top-right-radius: inherit;
2726
}
2827

29-
.file-attachment {
28+
[part='attachment-content'] {
3029
display: flex;
31-
align-items: center;
32-
padding: 0.5rem;
33-
background-color: var(--gray-100);
34-
border-radius: 0.375rem;
35-
max-width: 200px;
36-
}
37-
38-
.file-icon {
39-
margin-right: 0.5rem;
40-
color: var(--gray-600);
41-
}
42-
43-
.file-info {
44-
overflow: hidden;
45-
}
46-
47-
.file-name {
48-
font-size: 0.75rem;
49-
font-weight: 500;
50-
white-space: nowrap;
30+
border-bottom-left-radius: inherit;
31+
border-bottom-right-radius: inherit;
32+
max-height: rem(240px);
5133
overflow: hidden;
52-
text-overflow: ellipsis;
53-
color: var(--gray-800);
54-
}
55-
56-
.file-size {
57-
font-size: 0.625rem;
58-
color: var(--gray-500);
59-
}
60-
61-
.image-overlay {
62-
position: fixed;
63-
inset: 0;
64-
background-color: #1f1f1f;
65-
display: flex;
66-
align-items: center;
67-
justify-content: center;
68-
z-index: 1000;
6934
}
7035

71-
.overlay-image {
72-
max-width: 90%;
73-
max-height: 90%;
36+
[part='image-attachment'] {
37+
width: 100%;
38+
height: 100%;
39+
border-radius: inherit;
40+
object-fit: cover;
7441
}
7542

76-
.close-overlay {
77-
position: absolute;
78-
top: 1rem;
79-
right: 1rem;
80-
color: white;
81-
background: #1f1f1f;
82-
width: 2rem;
83-
height: 2rem;
84-
border-radius: 50%;
43+
[part='details'] {
8544
display: flex;
8645
align-items: center;
87-
justify-content: center;
88-
cursor: pointer;
89-
border: none;
90-
}
91-
92-
.close-overlay:hover {
93-
background: #1f1f1f;
46+
gap: rem(8px);
9447
}
9548

96-
.large {
97-
--ig-size: var(--ig-size-large);
98-
}
49+
[part='file-name'] {
50+
@include type-style('body-2') {
51+
margin: 0;
52+
};
9953

100-
.actions {
101-
display: flex;
54+
@include ellipsis();
10255
}
103-
104-
.attachment {
105-
display: flex;
106-
justify-content: space-between;
107-
gap: 2rem;
108-
}
109-
110-
.details {
111-
display: flex;
112-
align-items: center;
113-
gap: 0.2rem;
114-
}
115-
116-
igc-expansion-panel{
117-
width: 100%;
118-
}

0 commit comments

Comments
 (0)