Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chat: implement day headers #28160

Merged
merged 32 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
62b8f1d
Chat - add date headers
Zedwag Oct 9, 2024
6ab35ee
add qunits
Zedwag Oct 9, 2024
0cc3880
comment test case with flexible date
Zedwag Oct 9, 2024
eb676e3
update etanol
Zedwag Oct 9, 2024
eea7555
add option to disable date headers and use it in scrolling test
Zedwag Oct 9, 2024
d10f65d
add option to disable date headers and use it in scrolling test
Zedwag Oct 9, 2024
1fca9d7
revert one etalon
Zedwag Oct 9, 2024
965a841
update styles
Zedwag Oct 9, 2024
20d1cb0
refactor
Zedwag Oct 9, 2024
1fb98d8
add 'today' and 'yesterday' localization
Zedwag Oct 9, 2024
fadbe47
use localized text for day headers
Zedwag Oct 9, 2024
18333f3
add more tests
Zedwag Oct 10, 2024
ee93033
update etanol
Zedwag Oct 10, 2024
4dd647f
update etanol
Zedwag Oct 10, 2024
7207cd5
apply suggestions
Zedwag Oct 12, 2024
9702d47
merge upstream
Zedwag Oct 12, 2024
441cda4
update etanol
Zedwag Oct 12, 2024
22ef938
get rid of caching previous day header date
Zedwag Oct 14, 2024
f46646c
update etanol
Zedwag Oct 15, 2024
4d6e205
add masks for tests with today and yesterday date
Zedwag Oct 15, 2024
3a9ff44
Merge branch '24_2' into chatDateHeaders__24_2
EugeniyKiyashko Oct 15, 2024
15e5847
Merge branch '24_2' into chatDateHeaders__24_2
EugeniyKiyashko Oct 15, 2024
64eaa6b
make etalons great again
Zedwag Oct 15, 2024
8c78826
revert solution with cached last header date
Zedwag Oct 15, 2024
346f365
use the same dateHeader color as information text color
Zedwag Oct 15, 2024
ea0f08c
add cached dayHeader date reset on clean
Zedwag Oct 15, 2024
fa8feb6
remove duplicate color var
Zedwag Oct 15, 2024
8dea506
update etanol
Zedwag Oct 15, 2024
a731d23
remove etalons to get etalons with updated color
Zedwag Oct 15, 2024
8553707
add etanol with correct dayHeader color
Zedwag Oct 15, 2024
626b219
update last etanol
Zedwag Oct 15, 2024
f212e70
Merge branch 'DevExpress:24_2' into chatDateHeaders__24_2
Zedwag Oct 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions e2e/testcafe-devextreme/tests/chat/messageList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ test('Messagelist appearance with scrollbar', async (t) => {
user: userSecond,
width: 400,
height: 600,
showDayHeaders: false,
onMessageSend: (e) => {
const { component, message } = e;

Expand Down Expand Up @@ -150,3 +151,48 @@ test('Messagelist should scrolled to the latest messages after being rendered in
}],
});
});

test('Messagelist with date headers', async (t) => {
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);

await testScreenshot(t, takeScreenshot, 'Messagelist with date headers.png', { element: '#container' });
EugeniyKiyashko marked this conversation as resolved.
Show resolved Hide resolved

await t
.expect(compareResults.isValid())
.ok(compareResults.errorMessages());
}).before(async () => {
const userFirst = createUser(1, 'First');
const userSecond = createUser(2, 'Second');
const msInDay = 86400000;
const today = new Date().setHours(7, 22, 0, 0);
const yesterday = today - msInDay;

const items = [{
timestamp: new Date('05.01.2024'),
Zedwag marked this conversation as resolved.
Show resolved Hide resolved
author: userFirst,
text: 'AAA',
}, {
timestamp: new Date('06.01.2024'),
author: userFirst,
text: 'BBB',
}, {
timestamp: new Date('06.01.2024'),
author: userSecond,
text: 'CCC',
}, {
timestamp: yesterday,
author: userSecond,
text: 'DDD',
}, {
timestamp: today,
author: userFirst,
text: 'EEE',
}];

return createWidget('dxChat', {
items,
user: userSecond,
width: 400,
height: 600,
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@
border-radius: 999em;
}

.dx-chat-messagelist-day-header {
text-align: center;
}

Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
@use "sass:math";

@mixin chat-messagelist($padding) {
@mixin chat-messagelist(
$padding,
$day-header-color,
$day-header-padding-bottom,
$day-header-first-padding-top,
) {
.dx-chat-messagelist {
.dx-scrollable-content {
padding-inline: $padding;
}
}

.dx-chat-messagelist-day-header {
padding-bottom: $day-header-padding-bottom;
color: $day-header-color;

&:first-child {
padding-top: $day-header-first-padding-top;
}
}
}

@mixin chat-messagelist-empty(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ $chat-messagelist-empty-icon-color: null !default;
$chat-messagelist-empty-icon-background-color: null !default;
$chat-messagelist-empty-message-color: $base-text-color !default;
$chat-messagelist-empty-prompt-color: null !default;
$chat-messagelist-day-header-color: null !default;

@if $mode == "light" {
$chat-avatar-background-color: darken($base-bg, 12.16) !default; // #E0E0E0
Expand All @@ -26,6 +27,7 @@ $chat-messagelist-empty-prompt-color: null !default;
$chat-messagelist-empty-icon-color: lighten($base-icon-color, 32.16) !default; // #B3B3B3
$chat-messagelist-empty-icon-background-color: darken($base-bg, 3.92) !default; // #F5F5F5
$chat-messagelist-empty-prompt-color: darken($base-label-color, 5.88) !default; // #616161
$chat-messagelist-day-header-color: lighten($base-text-color, 65.5) !default; // #B3B3B3
}

@else if $mode == "dark" {
Expand All @@ -37,4 +39,5 @@ $chat-messagelist-empty-prompt-color: null !default;
$chat-messagelist-empty-icon-color: darken($base-icon-color, 25.88) !default; // #6B6B6B
$chat-messagelist-empty-icon-background-color: lighten($base-bg, 7.84) !default; // #3D3D3D
$chat-messagelist-empty-prompt-color: lighten($base-label-color, 7.84) !default; // #ADADAD
$chat-messagelist-day-header-color: darken($base-text-color, 58.9) !default; // #6B6B6B
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,9 @@
$chat-messagelist-empty-prompt-font-size,
$chat-messagelist-empty-prompt-color,
);
@include chat-messagelist($chat-messagelist-padding);
@include chat-messagelist(
$chat-messagelist-padding,
$chat-messagelist-day-header-color,
$chat-messagelist-day-header-padding-bottom,
$chat-messagelist-day-header-first-padding-top,
);
2 changes: 2 additions & 0 deletions packages/devextreme-scss/scss/widgets/fluent/chat/_sizes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ $chat-messagelist-empty-icon-margin-bottom: null !default;
$chat-messagelist-empty-row-gap: null !default;
$chat-messagelist-empty-message-font-size: null !default;
$chat-messagelist-empty-prompt-font-size: null !default;
$chat-messagelist-day-header-padding-bottom: 12px !default;
$chat-messagelist-day-header-first-padding-top: 20px !default;

@if $size == "default" {
$chat-bubble-border-radius: $fluent-base-border-radius * 3 !default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ $chat-messagelist-empty-icon-color: null !default;
$chat-messagelist-empty-icon-background-color: null !default;
$chat-messagelist-empty-message-color: null !default;
$chat-messagelist-empty-prompt-color: null !default;
$chat-messagelist-day-header-color: null !default;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to adjust the color values to support all color schemes. I know that Roman is working on this task. Please extract a separate task to 'check the color of the 'day-header' element in all color schemes.'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we should do immediately in context of this task because it's not related to variables Roman's is working on.
Alex, please review on Storybook that color text is expected for all color schemas in all themes

Copy link
Contributor Author

@Zedwag Zedwag Oct 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alex, please review on Storybook that color text is expected for all color schemas in all themes

I'm not sure what color are we expect in different themes. I checked all themes and the text is readable everywhere, is that what u asked to check?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are almost complete with the PR: #28171. It's better to wait until it is merged and then adjust colors fo the generic color schemes and fluent.saas if it needs.


@if $color == "light" {
$chat-avatar-background-color: darken($base-bg, 13.33) !default; // #DDDDDD
Expand All @@ -27,6 +28,7 @@ $chat-messagelist-empty-prompt-color: null !default;
$chat-messagelist-empty-icon-background-color: darken($base-bg, 7.84) !default; // #EBEBEB
$chat-messagelist-empty-message-color: darken($base-text-color, 6.67) !default; // #222222
$chat-messagelist-empty-prompt-color: lighten($base-label-color, 38.43) !default; // #959595
$chat-messagelist-day-header-color: lighten($base-text-color, 58.6) !default; // #AAAAAA
}

@else if $color == "dark" {
Expand All @@ -39,4 +41,5 @@ $chat-messagelist-empty-prompt-color: null !default;
$chat-messagelist-empty-icon-background-color: lighten($base-bg, 7.84) !default; // #3E3E3E
$chat-messagelist-empty-message-color: lighten($base-text-color, 12.94) !default; // #FFFFFF
$chat-messagelist-empty-prompt-color: darken($base-label-color, 38.04) !default; // #7D7D7D
$chat-messagelist-day-header-color: darken($base-text-color, 42.6) !default; // #7F7F7F
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,9 @@
$chat-messagelist-empty-prompt-font-size,
$chat-messagelist-empty-prompt-color,
);
@include chat-messagelist($chat-messagelist-padding);
@include chat-messagelist(
$chat-messagelist-padding,
$chat-messagelist-day-header-color,
$chat-messagelist-day-header-padding-bottom,
$chat-messagelist-day-header-first-padding-top,
);
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ $chat-messagelist-empty-icon-margin-bottom: null !default;
$chat-messagelist-empty-row-gap: null !default;
$chat-messagelist-empty-message-font-size: null !default;
$chat-messagelist-empty-prompt-font-size: null !default;
$chat-messagelist-day-header-padding-bottom: 12px !default;
$chat-messagelist-day-header-first-padding-top: 20px !default;

@if $size == "default" {
$chat-bubble-padding: 8px 12px !default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ $chat-messagelist-empty-icon-color: rgba($base-inverted-bg, 0.38) !default;
$chat-messagelist-empty-icon-background-color: rgba($base-inverted-bg, 0.08) !default;
$chat-messagelist-empty-message-color: rgba($base-inverted-bg, 0.87) !default;
$chat-messagelist-empty-prompt-color: rgba($base-inverted-bg, 0.6) !default;
$chat-messagelist-day-header-color: rgba($base-inverted-bg, 0.38) !default;

@if $mode == "light" {
$chat-avatar-background-color: darken($base-bg, 12.16) !default; // #E0E0E0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,9 @@
$chat-messagelist-empty-prompt-font-size,
$chat-messagelist-empty-prompt-color,
);
@include chat-messagelist($chat-messagelist-padding);
@include chat-messagelist(
$chat-messagelist-padding,
$chat-messagelist-day-header-color,
$chat-messagelist-day-header-padding-bottom,
$chat-messagelist-day-header-first-padding-top,
);
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ $chat-messagelist-empty-icon-margin-bottom: null !default;
$chat-messagelist-empty-row-gap: null !default;
$chat-messagelist-empty-message-font-size: null !default;
$chat-messagelist-empty-prompt-font-size: null !default;
$chat-messagelist-day-header-padding-bottom: 12px !default;
$chat-messagelist-day-header-first-padding-top: 20px !default;

@if $size == "default" {
$chat-messagebox-buton-gap: 10px !default;
Expand Down
9 changes: 7 additions & 2 deletions packages/devextreme/js/__internal/ui/chat/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import MessageList from './messagelist';
const CHAT_CLASS = 'dx-chat';
const TEXTEDITOR_INPUT_CLASS = 'dx-texteditor-input';

type Properties = ChatProperties & { title: string };
type Properties = ChatProperties & { title: string; showDayHeaders: boolean };
EugeniyKiyashko marked this conversation as resolved.
Show resolved Hide resolved

class Chat extends Widget<Properties> {
_chatHeader?: ChatHeader;
Expand All @@ -43,6 +43,7 @@ class Chat extends Widget<Properties> {
dataSource: null,
user: { id: new Guid().toString() },
onMessageSend: undefined,
showDayHeaders: true,
};
}

Expand Down Expand Up @@ -98,7 +99,7 @@ class Chat extends Widget<Properties> {
}

_renderMessageList(): void {
const { items = [], user } = this.option();
const { items = [], user, showDayHeaders } = this.option();

const currentUserId = user?.id;
const $messageList = $('<div>');
Expand All @@ -108,6 +109,7 @@ class Chat extends Widget<Properties> {
this._messageList = this._createComponent($messageList, MessageList, {
items,
currentUserId,
showDayHeaders,
});
}

Expand Down Expand Up @@ -214,6 +216,9 @@ class Chat extends Widget<Properties> {
case 'onMessageSend':
this._createMessageSendAction();
break;
case 'showDayHeaders':
this._messageList.option(name, value);
break;
default:
super._optionChanged(args);
}
Expand Down
Loading
Loading