Skip to content

Commit 8a8aea0

Browse files
author
Weblate
committed
Merge remote-tracking branch 'origin/develop' into develop
2 parents 89e9a6f + b8d9276 commit 8a8aea0

3 files changed

Lines changed: 34 additions & 36 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"react-dnd-html5-backend": "^2.1.2",
7676
"react-dom": "^15.6.0",
7777
"react-gemini-scrollbar": "matrix-org/react-gemini-scrollbar#5e97aef",
78+
"react-sticky": "^6.0.1",
7879
"sanitize-html": "^1.11.1",
7980
"text-encoding-utf-8": "^1.0.1",
8081
"ua-parser-js": "^0.7.10",

‎src/components/views/messages/DateSeparator.js‎

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,45 +15,26 @@ limitations under the License.
1515
*/
1616

1717
import React from 'react';
18-
import { _t } from 'matrix-react-sdk/lib/languageHandler';
1918
import DateUtils from 'matrix-react-sdk/lib/DateUtils';
20-
21-
function getdaysArray() {
22-
return [
23-
_t('Sunday'),
24-
_t('Monday'),
25-
_t('Tuesday'),
26-
_t('Wednesday'),
27-
_t('Thursday'),
28-
_t('Friday'),
29-
_t('Saturday'),
30-
];
31-
}
19+
import { Sticky } from 'react-sticky';
3220

3321
module.exports = React.createClass({
3422
displayName: 'DateSeparator',
3523
render: function() {
36-
var date = new Date(this.props.ts);
37-
var today = new Date();
38-
var yesterday = new Date();
39-
var days = getdaysArray();
40-
yesterday.setDate(today.getDate() - 1);
41-
var label;
42-
if (date.toDateString() === today.toDateString()) {
43-
label = _t('Today');
44-
}
45-
else if (date.toDateString() === yesterday.toDateString()) {
46-
label = _t('Yesterday');
47-
}
48-
else if (today.getTime() - date.getTime() < 6 * 24 * 60 * 60 * 1000) {
49-
label = days[date.getDay()];
50-
}
51-
else {
52-
label = DateUtils.formatFullDate(date, this.props.showTwelveHour);
53-
}
54-
24+
const date = new Date(this.props.ts);
25+
const label = DateUtils.formatDateSeparator(date);
5526
return (
56-
<h2 className="mx_DateSeparator">{ label }</h2>
27+
<Sticky relative={true} disableCompensation={true}>
28+
{({style, isSticky, wasSticky, distanceFromTop}) => {
29+
return (
30+
<div className={"mx_DateSeparator_container mx_DateSeparator_container" + (isSticky ? '_sticky' : '')}
31+
style={{top: isSticky ? -distanceFromTop + "px" : 0}}
32+
>
33+
<h2 className="mx_DateSeparator">{ label }</h2>
34+
</div>
35+
);
36+
}}
37+
</Sticky>
5738
);
58-
}
39+
},
5940
});

‎src/skins/vector/css/vector-web/views/messages/_DateSeparator.scss‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,26 @@ limitations under the License.
1616

1717
.mx_DateSeparator {
1818
clear: both;
19-
margin-top: 32px;
20-
margin-bottom: 8px;
19+
margin-top: 0px;
20+
margin-bottom: 0px;
2121
margin-left: 63px;
22+
padding-top: 5px;
2223
padding-bottom: 6px;
2324
border-bottom: 1px solid $primary-hairline-color;
2425
}
2526

27+
.mx_DateSeparator_container {
28+
margin-top: 27px;
29+
margin-bottom: 8px;
30+
background-color: $primary-bg-color;
31+
z-index: 3;
32+
}
33+
34+
.mx_DateSeparator_container_sticky {
35+
position: relative;
36+
border-bottom: 1px solid $primary-hairline-color;
37+
}
38+
39+
.mx_DateSeparator_container_sticky .mx_DateSeparator {
40+
border: 0px;
41+
}

0 commit comments

Comments
 (0)