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 all 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 @@ -14,13 +14,15 @@ $chat-bubble-background-color-primary: null !default;
$chat-bubble-background-color-secondary: $base-border-color !default;
$chat-information-color: null !default;

$chat-messagelist-day-header-color: null !default;
$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;

@if $mode == "light" {
$chat-information-color: darken($base-bg, 56.08) !default;
$chat-messagelist-day-header-color: darken($base-bg, 56.08) !default;
$chat-messagelist-empty-icon-color: lighten($base-icon-color, 32.16) !default;
$chat-messagelist-empty-icon-background-color: darken($base-bg, 3.92) !default;
$chat-messagelist-empty-prompt-color: darken($base-label-color, 5.88) !default;
Expand All @@ -39,7 +41,8 @@ $chat-messagelist-empty-prompt-color: null !default;
@if $mode == "dark" {
$chat-bubble-background-color-primary: darken(desaturate(adjust-hue($base-accent, 356.3), 14.7), 49.4) !default;
$chat-information-color: lighten($base-bg, 43.92) !default;


$chat-messagelist-day-header-color: lighten($base-bg, 43.92) !default;
$chat-messagelist-empty-icon-color: darken($base-icon-color, 25.88) !default;
$chat-messagelist-empty-icon-background-color: lighten($base-bg, 7.84) !default;
$chat-messagelist-empty-prompt-color: lighten($base-label-color, 7.84) !default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,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
24 changes: 16 additions & 8 deletions packages/devextreme-scss/scss/widgets/generic/chat/_colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ $chat-background-color: $base-bg !default;
$chat-border-color: $base-border-color !default;
$chat-avatar-color: null !default;
$chat-messagebox-border-color: $base-border-color !default;
$chat-avatar-background-color: null !default;
$chat-bubble-color-primary: null !default;
$chat-bubble-background-color-primary: null !default;
$chat-bubble-background-color-secondary: null !default;
$chat-information-color: null !default;

$chat-messagelist-day-header-color: null !default;
$chat-messagelist-empty-icon-color: null !default;
$chat-messagelist-empty-icon-background-color: null !default;
$chat-messagelist-empty-message-color: null !default;
Expand All @@ -28,6 +28,7 @@ $chat-avatar-background-color: $base-border-color !default;
$chat-bubble-background-color-secondary: darken($base-element-bg, 4%) !default;
$chat-information-color: darken($base-bg, 41.57) !default;

$chat-messagelist-day-header-color: darken($base-bg, 41.57) !default;
$chat-messagelist-empty-icon-color: lighten($base-icon-color, 46.67) !default;
$chat-messagelist-empty-icon-background-color: darken($base-bg, 7.84) !default;
$chat-messagelist-empty-message-color: darken($base-text-color, 6.67) !default;
Expand All @@ -40,7 +41,8 @@ $chat-avatar-background-color: $base-border-color !default;
$chat-bubble-background-color-primary: color.change(darken($base-accent, 5%), $alpha: 0.1) !default;
$chat-bubble-background-color-secondary: lighten($base-element-bg, 4%) !default;
$chat-information-color: lighten($base-bg, 32.55) !default;


$chat-messagelist-day-header-color: lighten($base-bg, 32.55) !default;
$chat-messagelist-empty-icon-color: darken($base-icon-color, 37.25) !default;
$chat-messagelist-empty-icon-background-color: lighten($base-bg, 7.84) !default;
$chat-messagelist-empty-message-color: lighten($base-text-color, 12.94) !default;
Expand All @@ -53,7 +55,8 @@ $chat-avatar-background-color: $base-border-color !default;
$chat-bubble-background-color-primary: color.change(darken($base-accent, 5%), $alpha: 0.1) !default;
$chat-bubble-background-color-secondary: darken($base-element-bg, 4%) !default;
$chat-information-color: darken($base-bg, 41.57) !default;


$chat-messagelist-day-header-color: darken($base-bg, 41.57) !default;
$chat-messagelist-empty-icon-color: $base-icon-color !default;
$chat-messagelist-empty-icon-background-color: darken($base-bg, 7.84) !default;
$chat-messagelist-empty-message-color: $base-text-color !default;
Expand All @@ -66,7 +69,8 @@ $chat-avatar-background-color: $base-border-color !default;
$chat-bubble-background-color-primary: $base-inverted-bg !default;
$chat-bubble-background-color-secondary: $base-hover-color !default;
$chat-information-color: $base-text-color !default;


$chat-messagelist-day-header-color: $base-text-color !default;
$chat-messagelist-empty-icon-color: $base-bg !default;
$chat-messagelist-empty-icon-background-color: $base-inverted-bg !default;
$chat-messagelist-empty-message-color: $base-text-color !default;
Expand All @@ -79,7 +83,8 @@ $chat-avatar-background-color: $base-border-color !default;
$chat-bubble-background-color-primary: color.change(darken($base-accent, 5%), $alpha: 0.1) !default;
$chat-bubble-background-color-secondary: lighten($base-element-bg, 4%) !default;
$chat-information-color: lighten($base-bg, 32.55) !default;


$chat-messagelist-day-header-color: lighten($base-bg, 32.55) !default;
$chat-messagelist-empty-icon-color: $base-icon-color !default;
$chat-messagelist-empty-icon-background-color: darken($base-bg, 7.84) !default;
$chat-messagelist-empty-message-color: $base-text-color !default;
Expand All @@ -92,7 +97,8 @@ $chat-avatar-background-color: $base-border-color !default;
$chat-bubble-background-color-primary: color.change(darken($base-accent, 5%), $alpha: 0.1) !default;
$chat-bubble-background-color-secondary: lighten($base-element-bg, 4%) !default;
$chat-information-color: lighten($base-bg, 32.55) !default;


$chat-messagelist-day-header-color: lighten($base-bg, 32.55) !default;
$chat-messagelist-empty-icon-color: darken($base-icon-color, 37.25) !default;
$chat-messagelist-empty-icon-background-color: lighten($base-bg, 7.84) !default;
$chat-messagelist-empty-message-color: lighten($base-text-color, 12.94) !default;
Expand All @@ -104,7 +110,8 @@ $chat-avatar-background-color: $base-border-color !default;
$chat-bubble-background-color-primary: color.change(darken($base-accent, 5%), $alpha: 0.1) !default;
$chat-bubble-background-color-secondary: darken($base-element-bg, 4%) !default;
$chat-information-color: darken($base-bg, 41.57) !default;


$chat-messagelist-day-header-color: darken($base-bg, 41.57) !default;
$chat-messagelist-empty-icon-color: $base-icon-color !default;
$chat-messagelist-empty-icon-background-color: darken($base-bg, 7.84) !default;
$chat-messagelist-empty-message-color: $base-text-color !default;
Expand All @@ -117,7 +124,8 @@ $chat-avatar-background-color: $base-border-color !default;
$chat-bubble-background-color-primary: color.change(darken($base-accent, 5%), $alpha: 0.1) !default;
$chat-bubble-background-color-secondary: darken($base-element-bg, 4%) !default;
$chat-information-color: darken($base-bg, 41.57) !default;


$chat-messagelist-day-header-color: darken($base-bg, 41.57) !default;
$chat-messagelist-empty-icon-color: $base-icon-color !default;
$chat-messagelist-empty-icon-background-color: darken($base-bg, 7.84) !default;
$chat-messagelist-empty-message-color: $base-text-color !default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,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 @@ -29,6 +29,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 @@ -14,6 +14,7 @@ $chat-bubble-background-color-primary: null !default;
$chat-bubble-background-color-secondary: null !default;
$chat-information-color: null !default;

$chat-messagelist-day-header-color: null !default;
$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;
Expand All @@ -23,10 +24,12 @@ $chat-messagelist-empty-prompt-color: rgba($base-inverted-bg, 0.6) !default;
$chat-bubble-background-color-primary: rgba($base-accent, 0.08) !default;
$chat-bubble-background-color-secondary: rgba($base-inverted-bg, 0.08) !default;
$chat-information-color: rgba(darken($base-bg, 100.00), 0.6) !default;
$chat-messagelist-day-header-color: rgba(darken($base-bg, 100.00), 0.6) !default;
}

@else if $mode == "dark" {
$chat-bubble-background-color-primary: rgba(lighten($base-accent, 19.22), 0.08) !default;
$chat-bubble-background-color-secondary: rgba(lighten(desaturate(adjust-hue($base-bg, -240), 8.47), 76.86), 0.08) !default;
$chat-information-color: rgba(lighten(desaturate(adjust-hue($base-bg, -240), 8.47), 76.86), 0.6) !default;
$chat-messagelist-day-header-color: rgba(lighten(desaturate(adjust-hue($base-bg, -240), 8.47), 76.86), 0.6) !default;
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,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