@financial-times/qanda-ui 0.0.1-beta.1 → 0.0.1-beta.11
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/README.md +63 -15
- package/dist/cjs/components/Author/index.js +19 -0
- package/dist/cjs/components/Calendar/Apps.js +48 -0
- package/dist/cjs/components/Calendar/CalendarList.js +12 -0
- package/dist/cjs/components/Calendar/CalendarListItem.js +22 -0
- package/dist/cjs/components/Calendar/index.js +44 -0
- package/dist/cjs/components/CountdownTimer/index.js +88 -0
- package/dist/cjs/components/EmbedFormField/index.js +28 -0
- package/dist/cjs/components/Expander/index.js +71 -0
- package/dist/cjs/components/ExpertDrawer/index.js +36 -0
- package/dist/cjs/components/FloatingActionBar/index.js +56 -0
- package/dist/cjs/components/Loader/index.js +7 -0
- package/dist/cjs/components/Overlay/MessageBox.js +7 -0
- package/dist/cjs/components/Overlay/index.js +18 -0
- package/dist/cjs/components/Qanda.js +37 -0
- package/dist/cjs/components/QandaBlock/index.js +76 -0
- package/dist/cjs/components/QandaContainer.js +58 -0
- package/dist/cjs/components/QandaProvider.js +11 -0
- package/dist/cjs/components/QuestionForm/index.js +156 -0
- package/dist/cjs/components/QuestionForm/messagesByUserType.js +33 -0
- package/dist/cjs/components/Stream/index.js +36 -0
- package/dist/cjs/components/UserInfo.js +22 -0
- package/dist/cjs/hooks/useIsMobile.js +15 -0
- package/dist/cjs/index.js +53 -0
- package/dist/cjs/services/comments-api.js +152 -0
- package/dist/cjs/services/error-middleware.js +47 -0
- package/dist/cjs/services/reliability.js +79 -0
- package/dist/cjs/store/expertSlice.js +26 -0
- package/dist/cjs/store/index.js +30 -0
- package/dist/cjs/store/questionSlice.js +32 -0
- package/dist/cjs/store/stream.js +17 -0
- package/dist/cjs/store/updateComments.js +38 -0
- package/dist/cjs/store/user.js +51 -0
- package/dist/cjs/utils/auth.js +26 -0
- package/dist/cjs/utils/qandas.js +20 -0
- package/dist/cjs/utils/validate-display-name.js +22 -0
- package/dist/esm/components/Author/index.js +14 -0
- package/dist/esm/components/Calendar/Apps.js +46 -0
- package/dist/esm/components/Calendar/CalendarList.js +7 -0
- package/dist/esm/components/Calendar/CalendarListItem.js +20 -0
- package/dist/esm/components/Calendar/index.js +39 -0
- package/dist/esm/components/CountdownTimer/index.js +85 -0
- package/dist/esm/components/EmbedFormField/index.js +26 -0
- package/dist/esm/components/Expander/index.js +69 -0
- package/dist/esm/components/ExpertDrawer/index.js +31 -0
- package/dist/esm/components/FloatingActionBar/index.js +54 -0
- package/dist/esm/components/Loader/index.js +4 -0
- package/dist/esm/components/Overlay/MessageBox.js +5 -0
- package/dist/esm/components/Overlay/index.js +13 -0
- package/dist/esm/components/Qanda.js +32 -0
- package/dist/esm/components/QandaBlock/index.js +71 -0
- package/dist/esm/components/QandaContainer.js +53 -0
- package/dist/esm/components/QandaProvider.js +8 -0
- package/dist/esm/components/QuestionForm/index.js +150 -0
- package/dist/esm/components/QuestionForm/messagesByUserType.js +28 -0
- package/dist/esm/components/Stream/index.js +31 -0
- package/dist/esm/components/UserInfo.js +20 -0
- package/dist/esm/hooks/useIsMobile.js +12 -0
- package/dist/esm/index.js +46 -0
- package/dist/esm/services/comments-api.js +147 -0
- package/dist/esm/services/error-middleware.js +43 -0
- package/dist/esm/services/reliability.js +75 -0
- package/dist/esm/store/expertSlice.js +22 -0
- package/dist/esm/store/index.js +24 -0
- package/dist/esm/store/questionSlice.js +28 -0
- package/dist/esm/store/stream.js +14 -0
- package/dist/esm/store/updateComments.js +34 -0
- package/dist/esm/store/user.js +45 -0
- package/dist/esm/utils/auth.js +24 -0
- package/dist/esm/utils/qandas.js +16 -0
- package/dist/esm/utils/validate-display-name.js +19 -0
- package/dist/qanda.scss +777 -0
- package/dist/types/components/Author/index.d.ts +18 -0
- package/dist/types/components/Calendar/Apps.d.ts +14 -0
- package/dist/types/components/Calendar/CalendarList.d.ts +2 -0
- package/dist/types/components/Calendar/CalendarListItem.d.ts +8 -0
- package/dist/types/components/Calendar/index.d.ts +2 -0
- package/dist/types/components/CountdownTimer/index.d.ts +6 -0
- package/dist/types/components/EmbedFormField/index.d.ts +5 -0
- package/dist/types/components/Expander/index.d.ts +8 -0
- package/dist/types/components/ExpertDrawer/index.d.ts +2 -0
- package/dist/types/components/FloatingActionBar/index.d.ts +2 -0
- package/dist/types/components/Loader/index.d.ts +14 -0
- package/dist/types/components/Overlay/MessageBox.d.ts +9 -0
- package/dist/types/components/Overlay/index.d.ts +12 -0
- package/dist/types/components/Qanda.d.ts +3 -0
- package/dist/types/components/QandaBlock/index.d.ts +7 -0
- package/dist/types/components/QandaContainer.d.ts +6 -0
- package/dist/types/components/QandaProvider.d.ts +9 -0
- package/dist/types/components/QuestionForm/index.d.ts +1 -0
- package/dist/types/components/QuestionForm/messagesByUserType.d.ts +7 -0
- package/dist/types/components/Stream/index.d.ts +5 -0
- package/dist/types/components/UserInfo.d.ts +2 -0
- package/dist/types/hooks/useIsMobile.d.ts +1 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/services/comments-api.d.ts +49 -0
- package/dist/types/services/error-middleware.d.ts +2 -0
- package/dist/types/services/reliability.d.ts +19 -0
- package/dist/types/store/expertSlice.d.ts +14 -0
- package/dist/types/store/index.d.ts +210 -0
- package/dist/types/store/questionSlice.d.ts +16 -0
- package/dist/types/store/stream.d.ts +7 -0
- package/dist/types/store/updateComments.d.ts +3 -0
- package/dist/types/store/user.d.ts +26 -0
- package/dist/types/utils/auth.d.ts +6 -0
- package/dist/types/utils/qandas.d.ts +2 -0
- package/dist/types/utils/validate-display-name.d.ts +1 -0
- package/package.json +50 -19
- package/.prettierrc +0 -3
- package/.toolkitrc.yml +0 -34
- package/.vscode/settings.json +0 -4
- package/CODEOWNERS +0 -3
- package/babel.config.json +0 -10
- package/dist/index.html +0 -4
- package/dist/index.js +0 -2
- package/dist/index.js.LICENSE.txt +0 -15
- package/jest.setup.ts +0 -15
- package/server.js +0 -17
- package/src/client/styles.scss +0 -61
- package/src/components/Author.tsx +0 -45
- package/src/components/CountdownTimer.tsx +0 -73
- package/src/components/Network.tsx +0 -19
- package/src/components/Qanda.tsx +0 -51
- package/src/components/QandaBlock.tsx +0 -63
- package/src/components/QandaContainer.tsx +0 -60
- package/src/components/QandaOComments.tsx +0 -60
- package/src/components/QandaProvider.tsx +0 -13
- package/src/components/QuestionForm.tsx +0 -122
- package/src/components/Status.tsx +0 -20
- package/src/components/Stream.tsx +0 -49
- package/src/components/UITestBar.tsx +0 -76
- package/src/components/UpdatesButton.tsx +0 -45
- package/src/components/UserInfo.tsx +0 -57
- package/src/index.tsx +0 -58
- package/src/services/comments-api.ts +0 -217
- package/src/services/custom-sse.ts +0 -101
- package/src/services/mocks/api-endpoints.ts +0 -36
- package/src/services/mocks/mock-comments.json +0 -307
- package/src/services/mocks/msw-browser.ts +0 -4
- package/src/services/mocks/msw-server.ts +0 -4
- package/src/store/index.ts +0 -41
- package/src/store/network.ts +0 -23
- package/src/store/qa.ts +0 -22
- package/src/store/questionSlice.ts +0 -37
- package/src/store/stream.ts +0 -21
- package/src/store/updateComments.ts +0 -60
- package/src/store/user.ts +0 -55
- package/src/types/async-operation.d.ts +0 -4
- package/src/types/comment.d.ts +0 -19
- package/src/types/globals.d.ts +0 -1
- package/src/types/modules.d.ts +0 -1
- package/src/types/o-types.d.ts +0 -2
- package/src/types/qanda.d.ts +0 -7
- package/src/types/sse-events.d.ts +0 -6
- package/src/types/x-dash.d.ts +0 -6
- package/src/utils/auth.ts +0 -9
- package/src/utils/mocks/update.ts +0 -168
- package/src/utils/qandas.ts +0 -21
- package/tsconfig.json +0 -26
- package/webpack.common.js +0 -60
- package/webpack.dev.js +0 -26
- package/webpack.prod.js +0 -6
package/README.md
CHANGED
|
@@ -2,24 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
A library for the Live Q&A client-side component
|
|
4
4
|
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
5
|
## Usage
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
### Importing styles
|
|
8
|
+
|
|
9
|
+
This module comes with both a SASS export which you will need to import into your own sass file, and then run through your build process.
|
|
10
|
+
|
|
11
|
+
The Origami components required are listed as peer dependencies in package.json.
|
|
12
|
+
|
|
13
|
+
#### Example:
|
|
14
|
+
|
|
15
|
+
```scss
|
|
16
|
+
@import '@financial-times/qanda-ui/scss';
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Importing and running the component (JS)
|
|
20
|
+
|
|
21
|
+
This library exports a class which can be used to construct a new instance of QandaUI and exposes methods to initialise it and to destroy it.
|
|
22
|
+
|
|
23
|
+
It also exports QandaBlock, the UI that is used to show a question 'block' - a question and its answers along with the other data like poster name and expert details
|
|
24
|
+
|
|
25
|
+
#### QandaUI
|
|
10
26
|
|
|
11
27
|
You can pass the necessary settings to Qanda UI in either the JS or in the container element.
|
|
12
28
|
|
|
13
|
-
|
|
29
|
+
##### Example:
|
|
14
30
|
|
|
15
31
|
```jsx
|
|
16
|
-
|
|
32
|
+
// JSX
|
|
33
|
+
<div class="someclassname"></div>
|
|
17
34
|
```
|
|
18
35
|
|
|
19
36
|
```js
|
|
20
|
-
|
|
37
|
+
// JS
|
|
38
|
+
import { QandaUI } from '@financial-times/qanda-ui';
|
|
21
39
|
|
|
22
|
-
const qandaEl = document.querySelector('.
|
|
40
|
+
const qandaEl = document.querySelector('.someclassname');
|
|
23
41
|
const qandaUI = new QandaUI(qandaEl, {
|
|
24
42
|
storyId: '71539bd7-1818-4193-8a58-d5a4d914a012',
|
|
25
43
|
useStaging: true,
|
|
@@ -30,9 +48,10 @@ const qandaUI = new QandaUI(qandaEl, {
|
|
|
30
48
|
qandaUI.init();
|
|
31
49
|
```
|
|
32
50
|
|
|
33
|
-
|
|
51
|
+
##### Alternative:
|
|
34
52
|
|
|
35
53
|
```jsx
|
|
54
|
+
// JSX
|
|
36
55
|
<div
|
|
37
56
|
class="qanda"
|
|
38
57
|
data-qanda-storyId="71539bd7-1818-4193-8a58-d5a4d914a012"
|
|
@@ -44,25 +63,41 @@ Alternatively
|
|
|
44
63
|
```
|
|
45
64
|
|
|
46
65
|
```js
|
|
47
|
-
|
|
48
|
-
|
|
66
|
+
// JS
|
|
67
|
+
import { QandaUI } from '@financial-times/qanda-ui';
|
|
68
|
+
const qandaEl = document.querySelector('.someclassname');
|
|
49
69
|
const qandaUI = new QandaUI(qandaEl);
|
|
50
70
|
qandaUI.init();
|
|
51
71
|
```
|
|
52
72
|
|
|
53
|
-
|
|
73
|
+
##### Parameters
|
|
54
74
|
|
|
55
75
|
- storyId: (required) string, the ID of the article used for Live Q&A
|
|
56
76
|
- useStaging: (optional) boolean, set to true if you want to use the staging Coral
|
|
57
77
|
- title: (required) string, the article title, needed to set up Coral properly
|
|
58
78
|
- commentsAPIHost: (required) string, the host of the API to be used (include the protocol)
|
|
59
79
|
- commentsAPIVersion: (required) string, the version of the API to be used
|
|
80
|
+
- maxQuestionLength: (optional) number, set to the maximum allowable length (in characters) for the question text
|
|
60
81
|
|
|
61
|
-
|
|
82
|
+
##### Instance Methods
|
|
62
83
|
|
|
63
84
|
- `myInstance.init()` - render the Qanda UI
|
|
64
85
|
- `myInstance.destroy()` - remove the Qanda instance
|
|
65
86
|
|
|
87
|
+
### QandaBlock
|
|
88
|
+
|
|
89
|
+
```jsx
|
|
90
|
+
import QandaBlock from '@financial-times/qanda-ui';
|
|
91
|
+
|
|
92
|
+
<QandaBlock
|
|
93
|
+
id={questionId}
|
|
94
|
+
body={body}
|
|
95
|
+
children={answers}
|
|
96
|
+
byline={byeline}
|
|
97
|
+
subtitle={lorem}
|
|
98
|
+
/>;
|
|
99
|
+
```
|
|
100
|
+
|
|
66
101
|
## Development
|
|
67
102
|
|
|
68
103
|
### Prerequisites
|
|
@@ -94,9 +129,8 @@ You can customize the demo application by modifying the configuration files in t
|
|
|
94
129
|
|
|
95
130
|
These are the config settings you can work with:
|
|
96
131
|
|
|
132
|
+
- `export const COMMENTS_API_BASE_HOST = LOCAL_API;` // use one of the provided constants or set your own next comments api domain
|
|
97
133
|
- `export const USE_STAGING = true;` // use Coral staging or production
|
|
98
|
-
- `export const USE_LOCAL_API = true;` // use local next-comments-api or live
|
|
99
|
-
- `export const MOCK_SSE = true;` // use a dummy eventsource that lets you send mock events rather than listen to ones coming from next-comments-api
|
|
100
134
|
|
|
101
135
|
### Building and Running the Production Server
|
|
102
136
|
|
|
@@ -116,7 +150,7 @@ To run the Jest tests, use:
|
|
|
116
150
|
npm run test
|
|
117
151
|
```
|
|
118
152
|
|
|
119
|
-
|
|
153
|
+
### Technology
|
|
120
154
|
|
|
121
155
|
This uses React, Redux and RTK Query to create the components and manage their states.
|
|
122
156
|
|
|
@@ -124,6 +158,20 @@ This uses React, Redux and RTK Query to create the components and manage their s
|
|
|
124
158
|
- The store is used for non-API data that needs to be shared around the components
|
|
125
159
|
- The story ID and useStaging settings passed in when the Qanda compontent is set are saved into the Context.
|
|
126
160
|
|
|
161
|
+
### Architecture
|
|
162
|
+
|
|
163
|
+
Quanda UI is strongly coupled with next-comments-api. See [architectural documentation in next-comments-api repository](https://github.com/Financial-Times/next-comments-api/blob/main/docs/liveqa.md#live-qa).
|
|
164
|
+
|
|
165
|
+
## Support
|
|
166
|
+
|
|
167
|
+
### Client-side metrics
|
|
168
|
+
|
|
169
|
+
We send client-side metrics (Failures and optionally successes) to [Cloudwatch RUM in the `FT Tech Next Prod` account](https://eu-west-1.console.aws.amazon.com/cloudwatch/home?region=eu-west-1#rum:dashboard/cp-client-metrics?tab=events).
|
|
170
|
+
|
|
171
|
+
Failure events may contain error information for debugging.
|
|
172
|
+
|
|
173
|
+
Those events are also observable in a [Live Q&A Grafana dashboard](https://grafana.ft.com/d/fekh6pkkr80lcd/live-qanda).
|
|
174
|
+
|
|
127
175
|
### How updates work
|
|
128
176
|
|
|
129
177
|
In order to receive updates from the next comments API, we use an EventSource that listens to an EventEmitter endpoint on next-comments-api.
|
|
@@ -0,0 +1,19 @@
|
|
|
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 jsx_runtime_1 = require("preact/jsx-runtime");
|
|
7
|
+
const Headshot_1 = __importDefault(require("@financial-times/cp-content-pipeline-ui/lib/components/Headshot"));
|
|
8
|
+
const cp_content_pipeline_ui_1 = require("@financial-times/cp-content-pipeline-ui");
|
|
9
|
+
function Author({ byline, headshot, prefLabel, role, streamPage, }) {
|
|
10
|
+
const hasHeadshot = headshot && prefLabel;
|
|
11
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "qanda-block__answer__author", "data-testid": "qanda-block__answer__author", children: [hasHeadshot ? ((0, jsx_runtime_1.jsx)("div", { className: "qanda-block__answer__author-headshot", children: (0, jsx_runtime_1.jsx)(Headshot_1.default, { headshot: headshot, prefLabel: prefLabel, streamPage: streamPage, className: "qanda-block__answer__author-headshot" }) })) : ((0, jsx_runtime_1.jsx)("div", { className: "qanda-block__answer__author-opinion-icon" })), (0, jsx_runtime_1.jsxs)("div", { className: "qanda-block__answer__author-info", children: [(0, jsx_runtime_1.jsx)("div", { className: "o3-type-body-highlight qanda-block__answer__author-name", children: (0, jsx_runtime_1.jsx)(cp_content_pipeline_ui_1.Byline, { structuredContent: byline, showEditedBy: false }) }), (0, jsx_runtime_1.jsx)("div", { className: "o3-type-body-base", children: role })] })] }));
|
|
12
|
+
}
|
|
13
|
+
Author.defaultProps = {
|
|
14
|
+
byline: '',
|
|
15
|
+
headshot: false,
|
|
16
|
+
prefLabel: false,
|
|
17
|
+
streamPage: '',
|
|
18
|
+
};
|
|
19
|
+
exports.default = Author;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("preact/jsx-runtime");
|
|
4
|
+
function formatDateForIcs(date) {
|
|
5
|
+
return date.replace(/-|:|\.\d+/g, '');
|
|
6
|
+
}
|
|
7
|
+
function createIcsFile(title, startDateTime, endDateTime, url) {
|
|
8
|
+
const icsContent = `
|
|
9
|
+
BEGIN:VCALENDAR\nVERSION:2.0\nBEGIN:VEVENT\nSUMMARY:${title}\nDESCRIPTION:${description(url)}\nDTSTART:${formatDateForIcs(startDateTime)}\nDTEND:${formatDateForIcs(endDateTime)}\nLOCATION:${url}\nEND:VEVENT\nEND:VCALENDAR
|
|
10
|
+
`.trim();
|
|
11
|
+
return URL.createObjectURL(new Blob([icsContent], { type: 'title/calendar' }));
|
|
12
|
+
}
|
|
13
|
+
const CalendarLink = ({ href, children, }) => ((0, jsx_runtime_1.jsx)("a", { href: href, target: "_blank", rel: "noopener noreferrer", role: "menuitem", "data-trackable": "liveqa_calendar-link", className: "live-qa-calendar-list__item__link", children: children }));
|
|
14
|
+
function itemChildren(name, icon) {
|
|
15
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: "live-qa-calendar-list__item__icon", children: icon }), (0, jsx_runtime_1.jsx)("span", { className: "live-qa-calendar-list__item__text", children: name })] }));
|
|
16
|
+
}
|
|
17
|
+
const description = (url) => `To join the Q&A session, visit: ${url}`;
|
|
18
|
+
const apps = [
|
|
19
|
+
{
|
|
20
|
+
name: 'Gmail',
|
|
21
|
+
icon: ((0, jsx_runtime_1.jsx)("svg", { className: "live-qa-calendar-icon", xmlns: "http://www.w3.org/2000/svg", width: "24", height: "25", viewBox: "0 0 24 25", fill: "none", children: (0, jsx_runtime_1.jsxs)("g", { transform: "translate(4, 3.36)", children: [(0, jsx_runtime_1.jsx)("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M15.8514 7.64502H8.16309V10.8162H12.5564C12.3672 11.841 11.792 12.7093 10.9275 13.2906V15.3476H13.5657C15.1093 13.9204 15.9998 11.8187 15.9998 9.32193C15.9998 8.7406 15.9479 8.18163 15.8514 7.64502Z", fill: "black" }), (0, jsx_runtime_1.jsx)("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M8.16315 17.3339C10.3672 17.3339 12.2151 16.5998 13.5658 15.3477L10.9275 13.2907C10.1966 13.7826 9.26149 14.0733 8.16315 14.0733C6.037 14.0733 4.23737 12.6311 3.59544 10.6934H0.868164V12.8174C2.21139 15.4968 4.97206 17.3339 8.16315 17.3339Z", fill: "black" }), (0, jsx_runtime_1.jsx)("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M3.59555 10.6933C3.43228 10.2014 3.33952 9.67595 3.33952 9.13561C3.33952 8.59527 3.43228 8.06984 3.59555 7.57795V5.45386H0.868275C0.315399 6.56062 0 7.81272 0 9.13561C0 10.4585 0.315399 11.7106 0.868275 12.8174L3.59555 10.6933Z", fill: "black" }), (0, jsx_runtime_1.jsx)("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M8.16316 4.19816C9.36167 4.19816 10.4377 4.6118 11.2837 5.42417L13.6251 3.07277C12.2114 1.74987 10.3635 0.9375 8.16316 0.9375C4.97206 0.9375 2.21139 2.77465 0.868164 5.45399L3.59544 7.57808C4.23737 5.64031 6.037 4.19816 8.16316 4.19816Z", fill: "black" })] }) })),
|
|
22
|
+
getLink: ({ title, startDateTime, endDateTime, url }) => `https://www.google.com/calendar/render?action=TEMPLATE&text=${encodeURIComponent(title)}&dates=${startDateTime}/${endDateTime}&details=${encodeURIComponent(description(url))}&location=${encodeURIComponent(url)}`,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'Outlook',
|
|
26
|
+
icon: ((0, jsx_runtime_1.jsx)("svg", { className: "live-qa-calendar-icon", xmlns: "http://www.w3.org/2000/svg", width: "24", height: "25", viewBox: "0 0 24 25", fill: "none", children: (0, jsx_runtime_1.jsx)("path", { d: "M21.9979 8.49306V17.3819C22.0068 17.5304 21.987 17.6792 21.9399 17.8185C21.8927 17.9578 21.8194 18.0842 21.7247 18.1894C21.63 18.2946 21.5162 18.3761 21.3909 18.4285C21.2656 18.4809 21.1316 18.5029 20.9981 18.4931H13.9988V22.9375L2 20.9375V4.9375L13.9988 2.9375V7.38194H20.9981C21.1316 7.37212 21.2656 7.39413 21.3909 7.4465C21.5162 7.49886 21.63 7.58037 21.7247 7.68558C21.8194 7.79078 21.8927 7.91724 21.9399 8.0565C21.987 8.19576 22.0068 8.3446 21.9979 8.49306ZM20.9981 8.60417L16.9985 11.1597L13.9988 9.27083V11.0486L16.9985 12.9375L20.9981 10.3819V8.60417ZM7.91939 8.60417C5.81961 8.52639 4.78971 10.5819 4.78971 13.0486C4.78971 15.5153 5.8596 17.4931 7.91939 17.4931C9.7892 17.4931 10.9991 15.6153 10.9991 13.1708C10.9991 10.7264 10.1292 8.72639 7.91939 8.6375M7.60943 10.3819C8.44934 10.3819 9.19926 11.2042 9.19926 12.8819C9.19926 14.5597 8.44934 15.5042 7.60943 15.5042C6.76951 15.5042 6.09958 14.2708 6.09958 12.9375C6.09958 11.6042 6.77951 10.3819 7.60943 10.3819Z", fill: "black" }) })),
|
|
27
|
+
getLink: ({ title, startDateTime, endDateTime, url }) => `https://outlook.live.com/calendar/0/deeplink/compose?subject=${encodeURIComponent(title)}&startdt=${startDateTime}&enddt=${endDateTime}&body=${encodeURIComponent(description(url))}&location=${encodeURIComponent(url)}`,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'Apple',
|
|
31
|
+
icon: ((0, jsx_runtime_1.jsx)("svg", { className: "live-qa-calendar-icon", xmlns: "http://www.w3.org/2000/svg", width: "24", height: "25", viewBox: "0 0 24 25", fill: "none", children: (0, jsx_runtime_1.jsx)("path", { d: "M19.8023 9.75502C19.6851 9.84618 17.5884 11.002 17.5884 13.5675C17.5884 16.5367 20.2548 17.5851 20.3362 17.6111C20.3232 17.6762 19.9097 19.0501 18.9297 20.4501C18.0507 21.684 17.1358 22.9115 15.7424 22.9115C14.3522 22.9115 13.994 22.1236 12.3857 22.1236C10.8197 22.1236 10.263 22.9375 8.98671 22.9375C7.71371 22.9375 6.8249 21.798 5.80259 20.398C4.62076 18.7539 3.66357 16.1981 3.66357 13.7759C3.66357 9.88525 6.25189 7.82436 8.80113 7.82436C10.1523 7.82436 11.282 8.69365 12.1317 8.69365C12.9392 8.69365 14.2024 7.77227 15.7424 7.77227C16.3251 7.77227 18.4218 7.82436 19.8023 9.75502ZM15.0098 6.12487C15.6479 5.38907 16.0972 4.36351 16.0972 3.33796C16.0972 3.19796 16.0842 3.05471 16.0582 2.9375C15.0228 2.97657 13.7889 3.61144 13.0466 4.45467C12.4638 5.10257 11.9169 6.12487 11.9169 7.16345C11.9169 7.31972 11.9462 7.476 11.9559 7.52483C12.0243 7.53786 12.1285 7.55088 12.2359 7.55088C13.1671 7.55088 14.3359 6.94531 15.0098 6.12487Z", fill: "black" }) })),
|
|
32
|
+
getLink: ({ title, startDateTime, endDateTime, url }) => createIcsFile(title, startDateTime, endDateTime, url),
|
|
33
|
+
isDownload: true,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'Yahoo',
|
|
37
|
+
icon: ((0, jsx_runtime_1.jsx)("svg", { className: "live-qa-calendar-icon", xmlns: "http://www.w3.org/2000/svg", width: "24", height: "25", viewBox: "0 0 24 25", fill: "none", children: (0, jsx_runtime_1.jsx)("path", { d: "M15.3929 13.7528C15.3614 13.7513 15.3247 13.7506 15.2879 13.7506C13.8674 13.7506 12.7109 14.8793 12.6659 16.2886V16.2931C12.7049 17.6536 13.8172 18.7411 15.1837 18.7411C15.2182 18.7411 15.2519 18.7403 15.2857 18.7388H15.2812C15.3194 18.7411 15.3637 18.7418 15.4087 18.7418C16.8217 18.7418 17.9737 17.6228 18.0269 16.2226V16.2181C18.0037 14.8501 16.8892 13.7498 15.5174 13.7498C15.4739 13.7498 15.4304 13.7513 15.3869 13.7528H15.3929ZM0.75293 7.97933L5.57993 18.8138L3.84593 22.7221H8.09168L14.5214 7.97933H10.3042L7.67993 14.2868L5.08343 7.97933H0.75368H0.75293ZM18.4297 3.15308L14.1277 12.8161H18.9359L23.2469 3.15308H18.4297Z", fill: "black" }) })),
|
|
38
|
+
getLink: ({ title, startDateTime, endDateTime, url }) => `https://calendar.yahoo.com/?v=60&title=${encodeURIComponent(title)}&st=${formatDateForIcs(startDateTime)}&et=${formatDateForIcs(endDateTime)}&desc=${encodeURIComponent(description(url))}&in_loc=${encodeURIComponent(url)}`,
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
exports.default = apps.map(({ name, icon, getLink, isDownload }) => ({
|
|
42
|
+
name,
|
|
43
|
+
icon,
|
|
44
|
+
link: ({ title, startDateTime, endDateTime, url, }) => {
|
|
45
|
+
const href = getLink({ title, startDateTime, endDateTime, url });
|
|
46
|
+
return isDownload ? ((0, jsx_runtime_1.jsx)("a", { href: href, download: "event.ics", role: "menuitem", "data-trackable": "liveqa_calendar-link", className: "live-qa-calendar-list__item__link", children: itemChildren(name, icon) })) : ((0, jsx_runtime_1.jsx)(CalendarLink, { href: href, children: itemChildren(name, icon) }));
|
|
47
|
+
},
|
|
48
|
+
}));
|
|
@@ -0,0 +1,12 @@
|
|
|
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 jsx_runtime_1 = require("preact/jsx-runtime");
|
|
7
|
+
const CalendarListItem_1 = __importDefault(require("./CalendarListItem"));
|
|
8
|
+
const Apps_1 = __importDefault(require("./Apps"));
|
|
9
|
+
function CalendarList() {
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)("ul", { className: "live-qa-calendar-list", id: "live-qa-calendar-list-menu", "data-testid": "live-qa-calendar-list-menu", role: "menu", "aria-labelledby": "live-qa-calendar-button-menu", children: Apps_1.default && Apps_1.default.map((app) => (0, jsx_runtime_1.jsx)(CalendarListItem_1.default, { ...app })) }));
|
|
11
|
+
}
|
|
12
|
+
exports.default = CalendarList;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("preact/jsx-runtime");
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const QandaProvider_1 = require("../QandaProvider");
|
|
6
|
+
const comments_api_1 = require("../../services/comments-api");
|
|
7
|
+
function CalendarListItem({ name, link }) {
|
|
8
|
+
const { storyId, useStaging, commentsAPIUrl, title } = (0, react_1.useContext)(QandaProvider_1.QandaContext);
|
|
9
|
+
const { data } = (0, comments_api_1.useGetQandAStreamQuery)({
|
|
10
|
+
storyId,
|
|
11
|
+
useStaging,
|
|
12
|
+
commentsAPIUrl,
|
|
13
|
+
});
|
|
14
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: data?.startDateTime && data?.endDateTime && ((0, jsx_runtime_1.jsx)("li", { className: 'live-qa-calendar-list__item', role: "presentation", "data-testid": "live-qa-calendar-list-item", children: link({
|
|
15
|
+
title,
|
|
16
|
+
startDateTime: data.startDateTime,
|
|
17
|
+
endDateTime: data.endDateTime,
|
|
18
|
+
url: `https://www.ft.com/content/${storyId}`,
|
|
19
|
+
children: name,
|
|
20
|
+
}) })) }));
|
|
21
|
+
}
|
|
22
|
+
exports.default = CalendarListItem;
|
|
@@ -0,0 +1,44 @@
|
|
|
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 jsx_runtime_1 = require("preact/jsx-runtime");
|
|
7
|
+
const o3_button_1 = require("@financial-times/o3-button");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const CalendarList_1 = __importDefault(require("./CalendarList"));
|
|
10
|
+
const comments_api_1 = require("../../services/comments-api");
|
|
11
|
+
const QandaProvider_1 = require("../QandaProvider");
|
|
12
|
+
function Calendar() {
|
|
13
|
+
const [dropDownVisible, setDropDownVisible] = (0, react_1.useState)(false);
|
|
14
|
+
const containerRef = (0, react_1.useRef)(null);
|
|
15
|
+
const { storyId, useStaging, commentsAPIUrl } = (0, react_1.useContext)(QandaProvider_1.QandaContext);
|
|
16
|
+
const { data } = (0, comments_api_1.useGetQandAStreamQuery)({
|
|
17
|
+
storyId,
|
|
18
|
+
useStaging,
|
|
19
|
+
commentsAPIUrl,
|
|
20
|
+
});
|
|
21
|
+
(0, react_1.useEffect)(() => {
|
|
22
|
+
const handleClickOutside = (event) => {
|
|
23
|
+
if (containerRef.current &&
|
|
24
|
+
event.target instanceof Node &&
|
|
25
|
+
!containerRef.current.contains(event.target)) {
|
|
26
|
+
setDropDownVisible(false);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
document.addEventListener('click', handleClickOutside);
|
|
30
|
+
return () => {
|
|
31
|
+
document.removeEventListener('click', handleClickOutside);
|
|
32
|
+
};
|
|
33
|
+
}, []);
|
|
34
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: data?.status === 'pre-live' && ((0, jsx_runtime_1.jsxs)("div", { className: "live-qa-calendar-container", ref: containerRef, children: [(0, jsx_runtime_1.jsx)(o3_button_1.Button, { label: "Add to your calendar", type: "secondary", theme: "mono", icon: "calendar", iconOnly: false, attributes: {
|
|
35
|
+
className: 'live-qa-calendar-button',
|
|
36
|
+
'aria-pressed': dropDownVisible,
|
|
37
|
+
'aria-haspopup': 'true',
|
|
38
|
+
'aria-controls': 'menu',
|
|
39
|
+
id: 'live-qa-calendar-button-menu',
|
|
40
|
+
'data-testid': 'live-qa-calendar-button',
|
|
41
|
+
'data-trackable': 'liveqa_add-to-calendar-button',
|
|
42
|
+
}, onClick: () => setDropDownVisible(!dropDownVisible) }), dropDownVisible && (0, jsx_runtime_1.jsx)(CalendarList_1.default, {})] })) }));
|
|
43
|
+
}
|
|
44
|
+
exports.default = Calendar;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatTime = formatTime;
|
|
4
|
+
const jsx_runtime_1 = require("preact/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const QandaProvider_1 = require("../QandaProvider");
|
|
7
|
+
const comments_api_1 = require("../../services/comments-api");
|
|
8
|
+
function formatTime(remainingTime) {
|
|
9
|
+
const days = Math.floor(remainingTime / (1000 * 60 * 60 * 24));
|
|
10
|
+
if (days >= 1) {
|
|
11
|
+
return `${days} day${days === 1 ? '' : 's'} `;
|
|
12
|
+
}
|
|
13
|
+
const hours = Math.floor((remainingTime % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
|
14
|
+
if (hours >= 1) {
|
|
15
|
+
return `${hours} hour${hours === 1 ? '' : 's'}`;
|
|
16
|
+
}
|
|
17
|
+
const minutes = Math.floor((remainingTime % (1000 * 60 * 60)) / (1000 * 60));
|
|
18
|
+
if (minutes >= 1) {
|
|
19
|
+
return `${minutes} minute${minutes === 1 ? '' : 's'}`;
|
|
20
|
+
}
|
|
21
|
+
const seconds = Math.floor((remainingTime % (1000 * 60)) / 1000);
|
|
22
|
+
if (seconds >= 1) {
|
|
23
|
+
return `${seconds} second${seconds === 1 ? '' : 's'}`;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function CountdownTimer({ container }) {
|
|
27
|
+
const { storyId, useStaging, commentsAPIUrl } = (0, react_1.useContext)(QandaProvider_1.QandaContext);
|
|
28
|
+
const { data } = (0, comments_api_1.useGetQandAStreamQuery)({
|
|
29
|
+
storyId,
|
|
30
|
+
useStaging,
|
|
31
|
+
commentsAPIUrl,
|
|
32
|
+
});
|
|
33
|
+
const updatedQA = (0, comments_api_1.useUpdatedQA)({
|
|
34
|
+
storyId,
|
|
35
|
+
useStaging,
|
|
36
|
+
commentsAPIUrl,
|
|
37
|
+
});
|
|
38
|
+
const [count, setCount] = (0, react_1.useState)('');
|
|
39
|
+
const status = updatedQA?.status || data?.status || 'pre-live';
|
|
40
|
+
const startDateTime = updatedQA?.startDateTime || data?.startDateTime;
|
|
41
|
+
const endDateTime = updatedQA?.endDateTime || data?.endDateTime;
|
|
42
|
+
(0, react_1.useEffect)(() => {
|
|
43
|
+
function calculateTimeLeft() {
|
|
44
|
+
const currentDate = Date.now();
|
|
45
|
+
const isLive = status === 'live';
|
|
46
|
+
const timeForCountdown = isLive ? endDateTime : startDateTime;
|
|
47
|
+
if (!timeForCountdown) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const remainingTime = new Date(timeForCountdown).getTime() - currentDate;
|
|
51
|
+
const eventInfo = isLive ? 'Ending' : 'Starting';
|
|
52
|
+
if (remainingTime !== null && !isNaN(remainingTime)) {
|
|
53
|
+
if (remainingTime >= 1000) {
|
|
54
|
+
setCount(`${eventInfo} in ${formatTime(remainingTime)}`);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
setCount(`${eventInfo} Soon`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
calculateTimeLeft();
|
|
62
|
+
const interval = setInterval(calculateTimeLeft, 1000);
|
|
63
|
+
return () => clearInterval(interval);
|
|
64
|
+
}, [
|
|
65
|
+
data?.status,
|
|
66
|
+
data?.startDateTime,
|
|
67
|
+
data?.endDateTime,
|
|
68
|
+
updatedQA?.status,
|
|
69
|
+
updatedQA?.startDateTime,
|
|
70
|
+
updatedQA?.endDateTime,
|
|
71
|
+
]);
|
|
72
|
+
const [portalTarget, setPortalTarget] = (0, react_1.useState)();
|
|
73
|
+
(0, react_1.useEffect)(() => {
|
|
74
|
+
if (container) {
|
|
75
|
+
const portalContainer = document.createElement('div');
|
|
76
|
+
container.prepend(portalContainer);
|
|
77
|
+
setPortalTarget(portalContainer);
|
|
78
|
+
return () => {
|
|
79
|
+
portalContainer.remove();
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}, []);
|
|
83
|
+
const portalElement = data &&
|
|
84
|
+
((status === 'pre-live' && startDateTime) ||
|
|
85
|
+
(status === 'live' && endDateTime)) && ((0, jsx_runtime_1.jsx)("div", { className: "qanda-portal countdown-wrapper", children: (0, jsx_runtime_1.jsx)("div", { className: "countdown-block", children: (0, jsx_runtime_1.jsx)("p", { className: "countdown", children: count && ((0, jsx_runtime_1.jsx)("time", { datetime: status === 'pre-live' ? startDateTime : endDateTime, children: count })) }) }) }));
|
|
86
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, react_1.createPortal)(portalElement, portalTarget || document.body) });
|
|
87
|
+
}
|
|
88
|
+
exports.default = CountdownTimer;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("preact/jsx-runtime");
|
|
4
|
+
const react_redux_1 = require("react-redux");
|
|
5
|
+
const questionSlice_1 = require("../../store/questionSlice");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const react_dom_1 = require("react-dom");
|
|
8
|
+
function EmbedFormField({ container }) {
|
|
9
|
+
const dispatch = (0, react_redux_1.useDispatch)();
|
|
10
|
+
const [portalTarget, setPortalTarget] = (0, react_1.useState)();
|
|
11
|
+
const expertView = (0, react_redux_1.useSelector)((state) => state.expert.expertView);
|
|
12
|
+
if (expertView) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
(0, react_1.useEffect)(() => {
|
|
16
|
+
if (container) {
|
|
17
|
+
const portalContainer = document.createElement('div');
|
|
18
|
+
container.prepend(portalContainer);
|
|
19
|
+
setPortalTarget(portalContainer);
|
|
20
|
+
return () => {
|
|
21
|
+
portalContainer.remove();
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}, []);
|
|
25
|
+
const portalElement = ((0, jsx_runtime_1.jsxs)("div", { className: "qanda-portal embed-form-field__container o3-type-body-highlight", children: ["Submit your question to the Q&A", (0, jsx_runtime_1.jsxs)("div", { onClick: () => dispatch((0, questionSlice_1.openForm)()), className: "embed-form-field__text-input o3-type-body-lg", "data-testid": "embed-form-field", children: [(0, jsx_runtime_1.jsx)("span", { className: "embed-form-field__icon", children: (0, jsx_runtime_1.jsx)("i", { style: { maskImage: 'var(--o3-icon-user)' } }) }), "Enter your question"] })] }));
|
|
26
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, react_dom_1.createPortal)(portalElement, portalTarget || document.body) });
|
|
27
|
+
}
|
|
28
|
+
exports.default = EmbedFormField;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("preact/jsx-runtime");
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const o3_button_1 = require("@financial-times/o3-button");
|
|
6
|
+
// Generic debounce function
|
|
7
|
+
function debounce(func, delay) {
|
|
8
|
+
let timerId;
|
|
9
|
+
return (...args) => {
|
|
10
|
+
if (timerId)
|
|
11
|
+
clearTimeout(timerId);
|
|
12
|
+
timerId = setTimeout(() => {
|
|
13
|
+
func(...args);
|
|
14
|
+
}, delay);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
// While comments submitted by Coral UI are always wrapped in paragraphs,
|
|
18
|
+
// comments submitted via our `Ask a question` form are just text.
|
|
19
|
+
// A wrapping paragraph is always needed for the expander to work correctly.
|
|
20
|
+
function EnsureParagraph({ children }) {
|
|
21
|
+
if (typeof children === 'object' &&
|
|
22
|
+
children !== null &&
|
|
23
|
+
'props' in children &&
|
|
24
|
+
children.props?.structuredContent?.tree?.children?.[0]?.type === 'text') {
|
|
25
|
+
return (0, jsx_runtime_1.jsx)("p", { children: children });
|
|
26
|
+
}
|
|
27
|
+
return children;
|
|
28
|
+
}
|
|
29
|
+
function Expander({ className = '', children = [], expandLabel = 'Expand', collapseLabel = 'Collapse', id, }) {
|
|
30
|
+
const textRef = (0, react_1.useRef)(null);
|
|
31
|
+
const [requiresExpander, setExpander] = (0, react_1.useState)(false);
|
|
32
|
+
const [state, setState] = (0, react_1.useState)('collapsed');
|
|
33
|
+
const expanderContentID = `expander_content-${id}`;
|
|
34
|
+
(0, react_1.useEffect)(() => {
|
|
35
|
+
const checkNeedForExpanderButton = () => {
|
|
36
|
+
const element = textRef.current;
|
|
37
|
+
if (!element) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const numberOfCharacters = element.textContent?.length || 300;
|
|
41
|
+
const windowWidth = window.visualViewport?.width || window.innerWidth || 1200; // Fallback to desktop configuration.
|
|
42
|
+
// Check if the element's height exceeds 3 lines for mobile or 1 line for above mobile
|
|
43
|
+
// Note: This need to stay aligned with the CSS for the expander
|
|
44
|
+
const mobileNumberOfCharacters = 100;
|
|
45
|
+
const desktopNumberOfCharacters = 200;
|
|
46
|
+
const characterForExpander = windowWidth <= 490
|
|
47
|
+
? mobileNumberOfCharacters
|
|
48
|
+
: desktopNumberOfCharacters;
|
|
49
|
+
setExpander(numberOfCharacters > characterForExpander);
|
|
50
|
+
};
|
|
51
|
+
const debouncedCheck = debounce(checkNeedForExpanderButton, 250);
|
|
52
|
+
// Use requestAnimationFrame to ensure layout is complete
|
|
53
|
+
requestAnimationFrame(checkNeedForExpanderButton);
|
|
54
|
+
window.addEventListener('resize', debouncedCheck);
|
|
55
|
+
return () => window.removeEventListener('resize', debouncedCheck);
|
|
56
|
+
}, [children]); // re-run whenever the children change, although we don't expect it to
|
|
57
|
+
const label = state === 'expanded' ? collapseLabel : expandLabel;
|
|
58
|
+
const expandCollapseClass = state === 'expanded' ? 'expander--expanded' : 'expander--collapsed';
|
|
59
|
+
const componentClassName = `${expandCollapseClass} ${className}`;
|
|
60
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: `${componentClassName}`, children: [(0, jsx_runtime_1.jsx)("div", { className: `expander__text ${requiresExpander ? 'expander__text--multiline' : ''}`, id: expanderContentID, ref: textRef, children: (0, jsx_runtime_1.jsx)(EnsureParagraph, { children: children }) }), requiresExpander && ((0, jsx_runtime_1.jsx)(o3_button_1.Button, { label: label, type: "ghost", theme: "neutral", icon: state === 'expanded' ? 'chevron-up' : 'chevron-down', iconOnly: false, iconPosition: "end", attributes: {
|
|
61
|
+
className: 'expander__link',
|
|
62
|
+
'data-trackable': `liveqa_expander`,
|
|
63
|
+
'data-trackable-context-action': label,
|
|
64
|
+
'aria-expanded': state === 'expanded' ? true : false,
|
|
65
|
+
'aria-controls': expanderContentID,
|
|
66
|
+
'data-action': state === 'expanded' ? 'collapse' : 'expand',
|
|
67
|
+
}, onClick: () => {
|
|
68
|
+
setState((prevState) => prevState === 'expanded' ? 'collapsed' : 'expanded');
|
|
69
|
+
} }))] }));
|
|
70
|
+
}
|
|
71
|
+
exports.default = Expander;
|
|
@@ -0,0 +1,36 @@
|
|
|
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 jsx_runtime_1 = require("preact/jsx-runtime");
|
|
7
|
+
const o_comments_1 = __importDefault(require("@financial-times/o-comments"));
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const react_redux_1 = require("react-redux");
|
|
10
|
+
const expertSlice_1 = require("../../store/expertSlice");
|
|
11
|
+
const QandaProvider_1 = require("../QandaProvider");
|
|
12
|
+
const reliability_1 = require("../../services/reliability");
|
|
13
|
+
const Overlay_1 = __importDefault(require("../Overlay"));
|
|
14
|
+
function ExpertDrawer() {
|
|
15
|
+
const dispatch = (0, react_redux_1.useDispatch)();
|
|
16
|
+
const { storyId, useStaging, title } = (0, react_1.useContext)(QandaProvider_1.QandaContext);
|
|
17
|
+
const { isExpertFormOpen, expertView } = (0, react_redux_1.useSelector)((state) => state.expert);
|
|
18
|
+
(0, react_1.useEffect)(() => {
|
|
19
|
+
if (isExpertFormOpen) {
|
|
20
|
+
try {
|
|
21
|
+
o_comments_1.default.init();
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
reliability_1.qandaReliability.failure('expert-load-coral-ui', error);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}, [isExpertFormOpen]);
|
|
28
|
+
if (!isExpertFormOpen) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return ((0, jsx_runtime_1.jsx)(Overlay_1.default, { title: "Live Q&A", closeCallback: () => dispatch((0, expertSlice_1.closeExpertForm)()), options: {
|
|
32
|
+
shadow: true,
|
|
33
|
+
noBackground: true,
|
|
34
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { className: "o-comments", id: "o-comments-stream", "data-o-component": "o-comments", "data-o-comments-article-id": storyId, "data-o-comments-article-url": `https://www.ft.com/content/${storyId}`, "data-o-comments-use-staging-environment": useStaging, "data-o-comments-title": title }) }));
|
|
35
|
+
}
|
|
36
|
+
exports.default = ExpertDrawer;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("preact/jsx-runtime");
|
|
4
|
+
const react_redux_1 = require("react-redux");
|
|
5
|
+
const o3_button_1 = require("@financial-times/o3-button");
|
|
6
|
+
const questionSlice_1 = require("../../store/questionSlice");
|
|
7
|
+
const expertSlice_1 = require("../../store/expertSlice");
|
|
8
|
+
const useIsMobile_1 = require("../../hooks/useIsMobile");
|
|
9
|
+
const comments_api_1 = require("../../services/comments-api");
|
|
10
|
+
const updateComments_1 = require("../../store/updateComments");
|
|
11
|
+
const react_1 = require("react");
|
|
12
|
+
const QandaProvider_1 = require("../QandaProvider");
|
|
13
|
+
function FloatingActionBar() {
|
|
14
|
+
const dispatch = (0, react_redux_1.useDispatch)();
|
|
15
|
+
const isMobile = (0, useIsMobile_1.useIsMobile)();
|
|
16
|
+
const { storyId, useStaging, commentsAPIUrl } = (0, react_1.useContext)(QandaProvider_1.QandaContext);
|
|
17
|
+
const updatedComments = (0, comments_api_1.useUpdatedComments)({
|
|
18
|
+
storyId,
|
|
19
|
+
useStaging,
|
|
20
|
+
commentsAPIUrl,
|
|
21
|
+
});
|
|
22
|
+
const handleShowUpdates = () => {
|
|
23
|
+
(0, updateComments_1.updateComments)(dispatch, updatedComments, storyId, useStaging, commentsAPIUrl);
|
|
24
|
+
// Scrolling to start of qanda blocks container
|
|
25
|
+
const element = document.getElementById('qanda__blocks-container');
|
|
26
|
+
if (element) {
|
|
27
|
+
element.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const showExpertView = (0, react_redux_1.useSelector)((state) => state.expert.expertView);
|
|
31
|
+
const userConfig = {
|
|
32
|
+
descripton: 'Ask a question',
|
|
33
|
+
testIdSuffix: 'ask-a-question-button',
|
|
34
|
+
onClick: () => dispatch((0, questionSlice_1.openForm)()),
|
|
35
|
+
dataTrackable: 'open_question_form',
|
|
36
|
+
};
|
|
37
|
+
const expertConfig = {
|
|
38
|
+
descripton: 'Answer Q&A',
|
|
39
|
+
testIdSuffix: 'answer-a-qanda-button',
|
|
40
|
+
onClick: () => dispatch((0, expertSlice_1.openExpertForm)()),
|
|
41
|
+
dataTrackable: 'open_expert_drawer',
|
|
42
|
+
};
|
|
43
|
+
const view = showExpertView ? expertConfig : userConfig;
|
|
44
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "floating-action-bar__container", "data-trackable": "floating-action-bar", children: [(0, jsx_runtime_1.jsx)("div", { className: "floating-action-bar__fade-overlay" }), (0, jsx_runtime_1.jsxs)("div", { className: "floating-action-bar", "data-testid": "floating-action-bar", children: [(0, jsx_runtime_1.jsx)("div", { className: "o-labels-indicator--live o3-type-label floating-action-bar__live-container", children: (0, jsx_runtime_1.jsx)("span", { className: "o-labels-indicator__status floating-action-bar__live-label", children: "Live" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "floating-action-bar__buttons", children: [(0, jsx_runtime_1.jsx)(o3_button_1.Button, { attributes: {
|
|
45
|
+
ariaLabel: view.descripton,
|
|
46
|
+
'data-trackable': view.dataTrackable,
|
|
47
|
+
'data-trackable-context-action': view.descripton,
|
|
48
|
+
'data-testid': `floating-action-bar__${view.testIdSuffix}`,
|
|
49
|
+
}, label: view.descripton, type: "ghost", theme: "mono", icon: "edit", iconOnly: isMobile, onClick: view.onClick }), (0, jsx_runtime_1.jsx)(o3_button_1.Button, { attributes: {
|
|
50
|
+
ariaLabel: 'Back to top',
|
|
51
|
+
'data-trackable': 'back_to_top',
|
|
52
|
+
'data-trackable-context-action': 'Back to top',
|
|
53
|
+
'data-testid': 'floating-action-bar__back-to-top-button',
|
|
54
|
+
}, label: "Back to top", type: "ghost", theme: "mono", icon: "scroll-to", iconOnly: isMobile, onClick: handleShowUpdates })] }), updatedComments?.length > 0 && ((0, jsx_runtime_1.jsx)("div", { className: "floating-action-bar__updates-counter o3-type-detail", children: updatedComments.length }))] })] }));
|
|
55
|
+
}
|
|
56
|
+
exports.default = FloatingActionBar;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = Loader;
|
|
4
|
+
const jsx_runtime_1 = require("preact/jsx-runtime");
|
|
5
|
+
function Loader({ size = 'small', theme = 'light', extraClassNames = '', }) {
|
|
6
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: `o-loading o-loading--${theme} o-loading--${size} ${extraClassNames}`, role: "progressbar", "aria-label": "Loading content" }));
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("preact/jsx-runtime");
|
|
4
|
+
function MessageBox({ color, styles, text, title }) {
|
|
5
|
+
return ((0, jsx_runtime_1.jsx)("div", { class: `o-message o-message--inner ${styles} message-box__container`, "data-o-message-close": "false", "data-o-component": "o-message", children: (0, jsx_runtime_1.jsx)("div", { class: "o-message__container", children: (0, jsx_runtime_1.jsxs)("div", { class: "message-box__content", children: [(0, jsx_runtime_1.jsx)("span", { style: { color }, class: "o3-type-body-highlight", children: title }), (0, jsx_runtime_1.jsx)("span", { style: { color }, class: "o3-type-body-base", children: text })] }) }) }));
|
|
6
|
+
}
|
|
7
|
+
exports.default = MessageBox;
|
|
@@ -0,0 +1,18 @@
|
|
|
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 jsx_runtime_1 = require("preact/jsx-runtime");
|
|
7
|
+
const o3_button_1 = require("@financial-times/o3-button");
|
|
8
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
9
|
+
function Overlay({ title, children, closeCallback, options = {}, }) {
|
|
10
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "overlay", children: [(0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)([
|
|
11
|
+
'overlay__outer',
|
|
12
|
+
{ 'overlay__outer--no-background': options.noBackground },
|
|
13
|
+
]) }), (0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)([
|
|
14
|
+
'overlay__inner',
|
|
15
|
+
{ 'overlay__inner--shadow': options.shadow },
|
|
16
|
+
]), children: [(0, jsx_runtime_1.jsx)("div", { className: "overlay__header", children: (0, jsx_runtime_1.jsxs)("div", { className: "overlay__header-bar", children: [(0, jsx_runtime_1.jsx)("span", { className: "o3-type-body-highlight overlay__header-title", children: title }), (0, jsx_runtime_1.jsx)(o3_button_1.Button, { attributes: { className: 'overlay__header-close' }, iconOnly: true, icon: "cross", label: "Close", type: "ghost", theme: "mono", onClick: () => closeCallback() })] }) }), (0, jsx_runtime_1.jsx)("div", { className: "overlay__content", children: children })] })] }));
|
|
17
|
+
}
|
|
18
|
+
exports.default = Overlay;
|