@financial-times/cp-content-pipeline-ui 7.5.0 → 7.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/lib/components/Topper/LiveBlogIndicator.js +4 -6
- package/lib/components/Topper/LiveBlogIndicator.js.map +1 -1
- package/lib/components/Topper/LiveBlogIndicator.spec.d.ts +1 -0
- package/lib/components/Topper/LiveBlogIndicator.spec.js +31 -0
- package/lib/components/Topper/LiveBlogIndicator.spec.js.map +1 -0
- package/package.json +1 -1
- package/src/components/Topper/LiveBlogIndicator.spec.tsx +38 -0
- package/src/components/Topper/LiveBlogIndicator.tsx +12 -17
- package/src/components/Topper/__snapshots__/LiveBlogIndicator.spec.tsx.snap +62 -0
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -574,6 +574,13 @@
|
|
|
574
574
|
* @financial-times/cp-content-pipeline-client bumped from ^3.7.2 to ^3.7.3
|
|
575
575
|
* @financial-times/cp-content-pipeline-schema bumped from ^2.10.1 to ^2.10.2
|
|
576
576
|
|
|
577
|
+
## [7.6.0](https://github.com/Financial-Times/cp-content-pipeline/compare/cp-content-pipeline-ui-v7.5.0...cp-content-pipeline-ui-v7.6.0) (2024-11-15)
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
### Features
|
|
581
|
+
|
|
582
|
+
* ci-2559 remove closed label from live blogs ([b61114a](https://github.com/Financial-Times/cp-content-pipeline/commit/b61114a60f8bf32c32f9f72c15f8c4f6ef6c6efc))
|
|
583
|
+
|
|
577
584
|
## [7.5.0](https://github.com/Financial-Times/cp-content-pipeline/compare/cp-content-pipeline-ui-v7.4.4...cp-content-pipeline-ui-v7.5.0) (2024-11-12)
|
|
578
585
|
|
|
579
586
|
|
|
@@ -4,16 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const react_1 = __importDefault(require("react"));
|
|
7
|
-
const classnames_1 = __importDefault(require("classnames"));
|
|
8
7
|
const ft_date_format_1 = __importDefault(require("@financial-times/ft-date-format"));
|
|
9
8
|
const LiveBlogIndicator = ({ realtime, lastUpdatedDateTime, }) => {
|
|
10
|
-
const
|
|
11
|
-
const indicatorStatusClasses = (0, classnames_1.default)('o-labels-indicator', `o-labels-indicator--${liveBlogStatus}`, 'o-labels-indicator--inverse', 'live-blog-indicator__status', `live-blog-indicator__status--${liveBlogStatus}`);
|
|
9
|
+
const isLive = Boolean(realtime);
|
|
12
10
|
return (react_1.default.createElement("div", { className: "live-blog-indicator" },
|
|
13
|
-
react_1.default.createElement("span", { className:
|
|
14
|
-
react_1.default.createElement("span", { className: "o-labels-indicator__status", "data-live-blog-status":
|
|
11
|
+
isLive && (react_1.default.createElement("span", { className: "o-labels-indicator o-labels-indicator--live o-labels-indicator--inverse live-blog-indicator__status live-blog-indicator__status--live" },
|
|
12
|
+
react_1.default.createElement("span", { className: "o-labels-indicator__status", "data-live-blog-status": "live" },
|
|
15
13
|
' ',
|
|
16
|
-
|
|
14
|
+
"Live"))),
|
|
17
15
|
react_1.default.createElement("time", { id: "live-blog-updated-timestamp", "data-o-component": "o-date", className: "o-date live-blog-indicator__timestamp", dateTime: lastUpdatedDateTime, "data-o-date-format": "time-ago-no-seconds" },
|
|
18
16
|
react_1.default.createElement("span", null, "Updated "),
|
|
19
17
|
react_1.default.createElement("span", { "data-o-date-printer": true }, ft_date_format_1.default.timeAgo(lastUpdatedDateTime)))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LiveBlogIndicator.js","sourceRoot":"","sources":["../../../src/components/Topper/LiveBlogIndicator.tsx"],"names":[],"mappings":";;;;;AAAA,kDAAyB;AACzB,
|
|
1
|
+
{"version":3,"file":"LiveBlogIndicator.js","sourceRoot":"","sources":["../../../src/components/Topper/LiveBlogIndicator.tsx"],"names":[],"mappings":";;;;;AAAA,kDAAyB;AACzB,qFAA0D;AAa1D,MAAM,iBAAiB,GAAqC,CAAC,EAC3D,QAAQ,EACR,mBAAmB,GACpB,EAAE,EAAE;IACH,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;IAEhC,OAAO,CACL,uCAAK,SAAS,EAAC,qBAAqB;QACjC,MAAM,IAAI,CACT,wCAAM,SAAS,EAAC,uIAAuI;YACrJ,wCACE,SAAS,EAAC,4BAA4B,2BAChB,MAAM;gBAE6C,GAAG;uBAEvE,CACF,CACR;QAED,wCACE,EAAE,EAAC,6BAA6B,sBACf,QAAQ,EACzB,SAAS,EAAC,uCAAuC,EACjD,QAAQ,EAAE,mBAAmB,wBACV,qBAAqB;YAExC,uDAAqB;YACrB,uEACG,wBAAY,CAAC,OAAO,CAAC,mBAAmB,CAAC,CACrC,CACF,CACH,CACP,CAAA;AACH,CAAC,CAAA;AAED,kBAAe,iBAAiB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const react_2 = require("@testing-library/react");
|
|
8
|
+
const LiveBlogIndicator_1 = __importDefault(require("./LiveBlogIndicator"));
|
|
9
|
+
describe('LiveBlogIndicator component', () => {
|
|
10
|
+
// times are set to absolute in the datetime attribute of the time element, but relative (e.g. 1 month ago) in the text body
|
|
11
|
+
// therefore we have to set a specific time for 'now', otherwise snapshots will be out of date instantly
|
|
12
|
+
beforeAll(() => {
|
|
13
|
+
jest.useFakeTimers();
|
|
14
|
+
const fakeSystemTime = new Date('2024-11-15T10:48:03.442Z');
|
|
15
|
+
jest.setSystemTime(fakeSystemTime);
|
|
16
|
+
});
|
|
17
|
+
afterAll(() => {
|
|
18
|
+
jest.useRealTimers();
|
|
19
|
+
});
|
|
20
|
+
it('shows a live label and the last updated time when the live blog is active', () => {
|
|
21
|
+
const tenMinutesAgo = new Date(Date.now() - 1000 * 60 * 10);
|
|
22
|
+
const { container } = (0, react_2.render)(react_1.default.createElement(LiveBlogIndicator_1.default, { realtime: true, lastUpdatedDateTime: tenMinutesAgo.toISOString() }));
|
|
23
|
+
expect(container).toMatchSnapshot();
|
|
24
|
+
});
|
|
25
|
+
it('does not show a label but does show the last updated time when the live blog is no longer active', () => {
|
|
26
|
+
const tenDaysAgo = new Date(Date.now() - 1000 * 60 * 60 * 24 * 10);
|
|
27
|
+
const { container } = (0, react_2.render)(react_1.default.createElement(LiveBlogIndicator_1.default, { realtime: false, lastUpdatedDateTime: tenDaysAgo.toISOString() }));
|
|
28
|
+
expect(container).toMatchSnapshot();
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=LiveBlogIndicator.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LiveBlogIndicator.spec.js","sourceRoot":"","sources":["../../../src/components/Topper/LiveBlogIndicator.spec.tsx"],"names":[],"mappings":";;;;;AAAA,kDAAyB;AACzB,kDAA+C;AAC/C,4EAAmD;AAEnD,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;IAC3C,4HAA4H;IAC5H,wGAAwG;IACxG,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,aAAa,EAAE,CAAA;QACpB,MAAM,cAAc,GAAG,IAAI,IAAI,CAAC,0BAA0B,CAAC,CAAA;QAC3D,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,CAAA;IACpC,CAAC,CAAC,CAAA;IACF,QAAQ,CAAC,GAAG,EAAE;QACZ,IAAI,CAAC,aAAa,EAAE,CAAA;IACtB,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,2EAA2E,EAAE,GAAG,EAAE;QACnF,MAAM,aAAa,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC,CAAA;QAC3D,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,cAAM,EAC1B,8BAAC,2BAAiB,IAChB,QAAQ,EAAE,IAAI,EACd,mBAAmB,EAAE,aAAa,CAAC,WAAW,EAAE,GAChD,CACH,CAAA;QACD,MAAM,CAAC,SAAS,CAAC,CAAC,eAAe,EAAE,CAAA;IACrC,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,kGAAkG,EAAE,GAAG,EAAE;QAC1G,MAAM,UAAU,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAA;QAClE,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,cAAM,EAC1B,8BAAC,2BAAiB,IAChB,QAAQ,EAAE,KAAK,EACf,mBAAmB,EAAE,UAAU,CAAC,WAAW,EAAE,GAC7C,CACH,CAAA;QACD,MAAM,CAAC,SAAS,CAAC,CAAC,eAAe,EAAE,CAAA;IACrC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { render } from '@testing-library/react'
|
|
3
|
+
import LiveBlogIndicator from './LiveBlogIndicator'
|
|
4
|
+
|
|
5
|
+
describe('LiveBlogIndicator component', () => {
|
|
6
|
+
// times are set to absolute in the datetime attribute of the time element, but relative (e.g. 1 month ago) in the text body
|
|
7
|
+
// therefore we have to set a specific time for 'now', otherwise snapshots will be out of date instantly
|
|
8
|
+
beforeAll(() => {
|
|
9
|
+
jest.useFakeTimers()
|
|
10
|
+
const fakeSystemTime = new Date('2024-11-15T10:48:03.442Z')
|
|
11
|
+
jest.setSystemTime(fakeSystemTime)
|
|
12
|
+
})
|
|
13
|
+
afterAll(() => {
|
|
14
|
+
jest.useRealTimers()
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('shows a live label and the last updated time when the live blog is active', () => {
|
|
18
|
+
const tenMinutesAgo = new Date(Date.now() - 1000 * 60 * 10)
|
|
19
|
+
const { container } = render(
|
|
20
|
+
<LiveBlogIndicator
|
|
21
|
+
realtime={true}
|
|
22
|
+
lastUpdatedDateTime={tenMinutesAgo.toISOString()}
|
|
23
|
+
/>
|
|
24
|
+
)
|
|
25
|
+
expect(container).toMatchSnapshot()
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('does not show a label but does show the last updated time when the live blog is no longer active', () => {
|
|
29
|
+
const tenDaysAgo = new Date(Date.now() - 1000 * 60 * 60 * 24 * 10)
|
|
30
|
+
const { container } = render(
|
|
31
|
+
<LiveBlogIndicator
|
|
32
|
+
realtime={false}
|
|
33
|
+
lastUpdatedDateTime={tenDaysAgo.toISOString()}
|
|
34
|
+
/>
|
|
35
|
+
)
|
|
36
|
+
expect(container).toMatchSnapshot()
|
|
37
|
+
})
|
|
38
|
+
})
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import classnames from 'classnames'
|
|
3
2
|
import ftDateFormat from '@financial-times/ft-date-format'
|
|
4
3
|
|
|
5
4
|
/**
|
|
@@ -17,26 +16,22 @@ const LiveBlogIndicator: React.FC<LiveBlogIndicatorProps> = ({
|
|
|
17
16
|
realtime,
|
|
18
17
|
lastUpdatedDateTime,
|
|
19
18
|
}) => {
|
|
20
|
-
const
|
|
21
|
-
const indicatorStatusClasses = classnames(
|
|
22
|
-
'o-labels-indicator',
|
|
23
|
-
`o-labels-indicator--${liveBlogStatus}`,
|
|
24
|
-
'o-labels-indicator--inverse',
|
|
25
|
-
'live-blog-indicator__status',
|
|
26
|
-
`live-blog-indicator__status--${liveBlogStatus}`
|
|
27
|
-
)
|
|
19
|
+
const isLive = Boolean(realtime)
|
|
28
20
|
|
|
29
21
|
return (
|
|
30
22
|
<div className="live-blog-indicator">
|
|
31
|
-
|
|
32
|
-
<span
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
23
|
+
{isLive && (
|
|
24
|
+
<span className="o-labels-indicator o-labels-indicator--live o-labels-indicator--inverse live-blog-indicator__status live-blog-indicator__status--live">
|
|
25
|
+
<span
|
|
26
|
+
className="o-labels-indicator__status"
|
|
27
|
+
data-live-blog-status="live"
|
|
28
|
+
>
|
|
29
|
+
{/* Origami o-label component expects whitespace to output correctly */}{' '}
|
|
30
|
+
Live
|
|
31
|
+
</span>
|
|
38
32
|
</span>
|
|
39
|
-
|
|
33
|
+
)}
|
|
34
|
+
|
|
40
35
|
<time
|
|
41
36
|
id="live-blog-updated-timestamp"
|
|
42
37
|
data-o-component="o-date"
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`LiveBlogIndicator component does not show a label but does show the last updated time when the live blog is no longer active 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<div
|
|
6
|
+
class="live-blog-indicator"
|
|
7
|
+
>
|
|
8
|
+
<time
|
|
9
|
+
class="o-date live-blog-indicator__timestamp"
|
|
10
|
+
data-o-component="o-date"
|
|
11
|
+
data-o-date-format="time-ago-no-seconds"
|
|
12
|
+
datetime="2024-11-05T10:48:03.442Z"
|
|
13
|
+
id="live-blog-updated-timestamp"
|
|
14
|
+
>
|
|
15
|
+
<span>
|
|
16
|
+
Updated
|
|
17
|
+
</span>
|
|
18
|
+
<span
|
|
19
|
+
data-o-date-printer="true"
|
|
20
|
+
>
|
|
21
|
+
10 days ago
|
|
22
|
+
</span>
|
|
23
|
+
</time>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
exports[`LiveBlogIndicator component shows a live label and the last updated time when the live blog is active 1`] = `
|
|
29
|
+
<div>
|
|
30
|
+
<div
|
|
31
|
+
class="live-blog-indicator"
|
|
32
|
+
>
|
|
33
|
+
<span
|
|
34
|
+
class="o-labels-indicator o-labels-indicator--live o-labels-indicator--inverse live-blog-indicator__status live-blog-indicator__status--live"
|
|
35
|
+
>
|
|
36
|
+
<span
|
|
37
|
+
class="o-labels-indicator__status"
|
|
38
|
+
data-live-blog-status="live"
|
|
39
|
+
>
|
|
40
|
+
|
|
41
|
+
Live
|
|
42
|
+
</span>
|
|
43
|
+
</span>
|
|
44
|
+
<time
|
|
45
|
+
class="o-date live-blog-indicator__timestamp"
|
|
46
|
+
data-o-component="o-date"
|
|
47
|
+
data-o-date-format="time-ago-no-seconds"
|
|
48
|
+
datetime="2024-11-15T10:38:03.442Z"
|
|
49
|
+
id="live-blog-updated-timestamp"
|
|
50
|
+
>
|
|
51
|
+
<span>
|
|
52
|
+
Updated
|
|
53
|
+
</span>
|
|
54
|
+
<span
|
|
55
|
+
data-o-date-printer="true"
|
|
56
|
+
>
|
|
57
|
+
10 minutes ago
|
|
58
|
+
</span>
|
|
59
|
+
</time>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
`;
|