@financial-times/qanda-ui 0.0.1-beta.9 → 1.0.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/README.md +2 -2
- package/dist/cjs/components/Author/index.js +2 -2
- package/dist/cjs/components/Calendar/Apps.js +34 -16
- package/dist/cjs/components/Calendar/CalendarListItem.js +5 -1
- package/dist/cjs/components/Calendar/index.js +7 -2
- package/dist/cjs/components/CountdownTimer/index.js +5 -1
- package/dist/cjs/components/EmbedFormField/index.js +15 -6
- package/dist/cjs/components/ErrorMessage/humanReadableError.js +81 -0
- package/dist/cjs/components/ErrorMessage/index.js +60 -0
- package/dist/cjs/components/Expander/index.js +16 -3
- package/dist/cjs/components/ExpertDrawer/index.js +8 -3
- package/dist/cjs/components/FloatingActionBar/index.js +54 -15
- package/dist/cjs/components/MessageBox/index.js +7 -0
- package/dist/cjs/components/Overlay/index.js +19 -5
- package/dist/cjs/components/Qanda.js +1 -7
- package/dist/cjs/components/QandaBlock/index.js +7 -4
- package/dist/cjs/components/QandaContainer.js +18 -3
- package/dist/cjs/components/QandaProvider.js +31 -1
- package/dist/cjs/components/QuestionForm/index.js +83 -35
- package/dist/cjs/components/QuestionForm/messagesByUserType.js +7 -5
- package/dist/cjs/components/Stream/index.js +32 -5
- package/dist/cjs/components/Survey/index.js +8 -0
- package/dist/cjs/config/qanda.js +6 -0
- package/dist/cjs/index.js +33 -4
- package/dist/cjs/services/comments-api.js +72 -12
- package/dist/cjs/services/listeners-middleware.js +170 -0
- package/dist/cjs/store/index.js +2 -0
- package/dist/cjs/store/stream.js +20 -2
- package/dist/cjs/store/updateComments.js +9 -4
- package/dist/cjs/utils/auth.js +3 -1
- package/dist/cjs/utils/strings.js +16 -0
- package/dist/cjs/utils/tracking.js +34 -0
- package/dist/esm/components/Author/index.js +1 -1
- package/dist/esm/components/Calendar/Apps.js +34 -16
- package/dist/esm/components/Calendar/CalendarListItem.js +5 -1
- package/dist/esm/components/Calendar/index.js +7 -2
- package/dist/esm/components/CountdownTimer/index.js +6 -2
- package/dist/esm/components/EmbedFormField/index.js +14 -8
- package/dist/esm/components/ErrorMessage/humanReadableError.js +78 -0
- package/dist/esm/components/ErrorMessage/index.js +54 -0
- package/dist/esm/components/Expander/index.js +16 -3
- package/dist/esm/components/ExpertDrawer/index.js +8 -3
- package/dist/esm/components/FloatingActionBar/index.js +55 -16
- package/dist/esm/components/MessageBox/index.js +5 -0
- package/dist/esm/components/Overlay/index.js +19 -5
- package/dist/esm/components/Qanda.js +2 -8
- package/dist/esm/components/QandaBlock/index.js +7 -4
- package/dist/esm/components/QandaContainer.js +20 -5
- package/dist/esm/components/QandaProvider.js +30 -1
- package/dist/esm/components/QuestionForm/index.js +82 -34
- package/dist/esm/components/QuestionForm/messagesByUserType.js +7 -5
- package/dist/esm/components/Stream/index.js +32 -5
- package/dist/esm/components/Survey/index.js +6 -0
- package/dist/esm/config/qanda.js +3 -0
- package/dist/esm/index.js +33 -4
- package/dist/esm/services/comments-api.js +71 -11
- package/dist/esm/services/listeners-middleware.js +167 -0
- package/dist/esm/store/expertSlice.js +1 -1
- package/dist/esm/store/index.js +2 -0
- package/dist/esm/store/questionSlice.js +1 -1
- package/dist/esm/store/stream.js +18 -1
- package/dist/esm/store/updateComments.js +9 -4
- package/dist/esm/utils/auth.js +3 -1
- package/dist/esm/utils/strings.js +13 -0
- package/dist/esm/utils/tracking.js +29 -0
- package/dist/qanda.scss +125 -43
- package/dist/types/components/Author/index.d.ts +1 -1
- package/dist/types/components/Calendar/Apps.d.ts +6 -2
- package/dist/types/components/Calendar/CalendarList.d.ts +1 -1
- package/dist/types/components/Calendar/CalendarListItem.d.ts +1 -1
- package/dist/types/components/EmbedFormField/index.d.ts +3 -1
- package/dist/types/components/ErrorMessage/humanReadableError.d.ts +29 -0
- package/dist/types/components/ErrorMessage/index.d.ts +8 -0
- package/dist/types/components/FloatingActionBar/index.d.ts +3 -1
- package/dist/types/components/Loader/index.d.ts +1 -1
- package/dist/types/components/{Overlay/MessageBox.d.ts → MessageBox/index.d.ts} +3 -2
- package/dist/types/components/Overlay/index.d.ts +3 -3
- package/dist/types/components/Qanda.d.ts +1 -1
- package/dist/types/components/QandaBlock/index.d.ts +1 -1
- package/dist/types/components/QandaProvider.d.ts +9 -1
- package/dist/types/components/QuestionForm/messagesByUserType.d.ts +2 -2
- package/dist/types/components/Stream/index.d.ts +4 -1
- package/dist/types/components/Survey/index.d.ts +7 -0
- package/dist/types/config/qanda.d.ts +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/services/comments-api.d.ts +30 -598
- package/dist/types/services/error-middleware.d.ts +2 -3
- package/dist/types/services/listeners-middleware.d.ts +11 -0
- package/dist/types/store/expertSlice.d.ts +9 -10
- package/dist/types/store/index.d.ts +72 -183
- package/dist/types/store/questionSlice.d.ts +9 -8
- package/dist/types/store/stream.d.ts +14 -7
- package/dist/types/store/user.d.ts +3 -2
- package/dist/types/utils/strings.d.ts +1 -0
- package/dist/types/utils/tracking.d.ts +4 -0
- package/package.json +18 -18
- package/dist/cjs/components/Overlay/MessageBox.js +0 -7
- package/dist/cjs/components/UserInfo.js +0 -22
- package/dist/esm/components/Overlay/MessageBox.js +0 -5
- package/dist/esm/components/UserInfo.js +0 -20
- package/dist/types/components/UserInfo.d.ts +0 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# QandA-UI
|
|
2
2
|
|
|
3
|
-
A library for the Live Q&A client-side component
|
|
3
|
+
A library for the Live Q&A (AKA Ask an Expert) client-side component
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
@@ -94,7 +94,7 @@ import QandaBlock from '@financial-times/qanda-ui';
|
|
|
94
94
|
body={body}
|
|
95
95
|
children={answers}
|
|
96
96
|
byline={byeline}
|
|
97
|
-
|
|
97
|
+
summary={lorem}
|
|
98
98
|
/>;
|
|
99
99
|
```
|
|
100
100
|
|
|
@@ -5,10 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const jsx_runtime_1 = require("preact/jsx-runtime");
|
|
7
7
|
const Headshot_1 = __importDefault(require("@financial-times/cp-content-pipeline-ui/lib/components/Headshot"));
|
|
8
|
-
const
|
|
8
|
+
const Byline_1 = __importDefault(require("@financial-times/cp-content-pipeline-ui/lib/components/Byline"));
|
|
9
9
|
function Author({ byline, headshot, prefLabel, role, streamPage, }) {
|
|
10
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)(
|
|
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)(Byline_1.default, { structuredContent: byline, showEditedBy: false }) }), (0, jsx_runtime_1.jsx)("div", { className: "o3-type-body-base", children: role })] })] }));
|
|
12
12
|
}
|
|
13
13
|
Author.defaultProps = {
|
|
14
14
|
byline: '',
|
|
@@ -1,48 +1,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const jsx_runtime_1 = require("preact/jsx-runtime");
|
|
4
|
-
|
|
4
|
+
const qanda_1 = require("../../config/qanda");
|
|
5
|
+
const tracking_1 = require("../../utils/tracking");
|
|
6
|
+
function formatDate(date) {
|
|
5
7
|
return date.replace(/-|:|\.\d+/g, '');
|
|
6
8
|
}
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
9
|
+
const CalendarLink = ({ href, isDownload = false, children, }) => {
|
|
10
|
+
const attirbutes = isDownload
|
|
11
|
+
? {
|
|
12
|
+
download: 'event.ics',
|
|
13
|
+
'data-trackable': (0, tracking_1.trackingNS)('calendar-link-download'),
|
|
14
|
+
}
|
|
15
|
+
: {
|
|
16
|
+
target: '_blank',
|
|
17
|
+
rel: 'noopener noreferrer',
|
|
18
|
+
'data-trackable': (0, tracking_1.trackingNS)('calendar-link'),
|
|
19
|
+
};
|
|
20
|
+
return ((0, jsx_runtime_1.jsx)("a", { href: href, ...attirbutes, role: "menuitem", className: "live-qa-calendar-list__item__link", children: children }));
|
|
21
|
+
};
|
|
14
22
|
function itemChildren(name, icon) {
|
|
15
23
|
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
24
|
}
|
|
17
|
-
const description = (
|
|
25
|
+
const description = (storyId) => `To join the ${qanda_1.PRODUCT_NAME} session, visit: https://www.ft.com/content/${storyId}`;
|
|
18
26
|
const apps = [
|
|
19
27
|
{
|
|
20
28
|
name: 'Gmail',
|
|
21
29
|
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,
|
|
30
|
+
getLink: ({ title, startDateTime, endDateTime, storyId }) => `https://www.google.com/calendar/render?action=TEMPLATE&text=${encodeURIComponent(title)}&dates=${formatDate(startDateTime)}/${formatDate(endDateTime)}&details=${encodeURIComponent(description(storyId))}&location=${encodeURIComponent(storyId)}`,
|
|
23
31
|
},
|
|
24
32
|
{
|
|
25
33
|
name: 'Outlook',
|
|
26
34
|
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,
|
|
35
|
+
getLink: ({ title, startDateTime, endDateTime, storyId }) => `https://outlook.live.com/calendar/0/deeplink/compose?subject=${encodeURIComponent(title)}&startdt=${startDateTime}&enddt=${endDateTime}&body=${encodeURIComponent(description(storyId))}&location=${encodeURIComponent(storyId)}`,
|
|
28
36
|
},
|
|
29
37
|
{
|
|
30
38
|
name: 'Apple',
|
|
31
39
|
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: ({
|
|
40
|
+
getLink: ({ storyId, useStaging, commentsAPIUrl }) => {
|
|
41
|
+
return `${commentsAPIUrl}/story/${storyId}/invitation${useStaging ? '?staging=1' : ''}`;
|
|
42
|
+
},
|
|
33
43
|
isDownload: true,
|
|
34
44
|
},
|
|
35
45
|
{
|
|
36
46
|
name: 'Yahoo',
|
|
37
47
|
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,
|
|
48
|
+
getLink: ({ title, startDateTime, endDateTime, storyId }) => `https://calendar.yahoo.com/?v=60&title=${encodeURIComponent(title)}&st=${formatDate(startDateTime)}&et=${formatDate(endDateTime)}&desc=${encodeURIComponent(description(storyId))}&in_loc=${encodeURIComponent(storyId)}`,
|
|
39
49
|
},
|
|
40
50
|
];
|
|
41
51
|
exports.default = apps.map(({ name, icon, getLink, isDownload }) => ({
|
|
42
52
|
name,
|
|
43
53
|
icon,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
54
|
+
isDownload,
|
|
55
|
+
link: ({ title, startDateTime, endDateTime, storyId, useStaging, commentsAPIUrl, }) => {
|
|
56
|
+
const href = getLink({
|
|
57
|
+
title,
|
|
58
|
+
startDateTime,
|
|
59
|
+
endDateTime,
|
|
60
|
+
storyId,
|
|
61
|
+
useStaging,
|
|
62
|
+
commentsAPIUrl,
|
|
63
|
+
});
|
|
64
|
+
return ((0, jsx_runtime_1.jsx)(CalendarLink, { href: href, isDownload: isDownload, children: itemChildren(name, icon) }));
|
|
47
65
|
},
|
|
48
66
|
}));
|
|
@@ -10,12 +10,16 @@ function CalendarListItem({ name, link }) {
|
|
|
10
10
|
storyId,
|
|
11
11
|
useStaging,
|
|
12
12
|
commentsAPIUrl,
|
|
13
|
+
// Calendar is only relevant for pre-live Q&A
|
|
14
|
+
status: 'pre-live',
|
|
13
15
|
});
|
|
14
16
|
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
17
|
title,
|
|
16
18
|
startDateTime: data.startDateTime,
|
|
17
19
|
endDateTime: data.endDateTime,
|
|
18
|
-
|
|
20
|
+
storyId,
|
|
21
|
+
useStaging,
|
|
22
|
+
commentsAPIUrl,
|
|
19
23
|
children: name,
|
|
20
24
|
}) })) }));
|
|
21
25
|
}
|
|
@@ -9,6 +9,7 @@ const react_1 = require("react");
|
|
|
9
9
|
const CalendarList_1 = __importDefault(require("./CalendarList"));
|
|
10
10
|
const comments_api_1 = require("../../services/comments-api");
|
|
11
11
|
const QandaProvider_1 = require("../QandaProvider");
|
|
12
|
+
const tracking_1 = require("../../utils/tracking");
|
|
12
13
|
function Calendar() {
|
|
13
14
|
const [dropDownVisible, setDropDownVisible] = (0, react_1.useState)(false);
|
|
14
15
|
const containerRef = (0, react_1.useRef)(null);
|
|
@@ -17,6 +18,9 @@ function Calendar() {
|
|
|
17
18
|
storyId,
|
|
18
19
|
useStaging,
|
|
19
20
|
commentsAPIUrl,
|
|
21
|
+
// Calendar is only relevant for pre-live Q&A
|
|
22
|
+
// so we can hardcode the status here
|
|
23
|
+
status: 'pre-live',
|
|
20
24
|
});
|
|
21
25
|
(0, react_1.useEffect)(() => {
|
|
22
26
|
const handleClickOutside = (event) => {
|
|
@@ -35,10 +39,11 @@ function Calendar() {
|
|
|
35
39
|
className: 'live-qa-calendar-button',
|
|
36
40
|
'aria-pressed': dropDownVisible,
|
|
37
41
|
'aria-haspopup': 'true',
|
|
38
|
-
'aria-
|
|
42
|
+
'aria-expanded': dropDownVisible,
|
|
43
|
+
'aria-controls': 'live-qa-calendar-list-menu',
|
|
39
44
|
id: 'live-qa-calendar-button-menu',
|
|
40
45
|
'data-testid': 'live-qa-calendar-button',
|
|
41
|
-
'data-trackable': '
|
|
46
|
+
'data-trackable': (0, tracking_1.trackingNS)('add-to-calendar-button'),
|
|
42
47
|
}, onClick: () => setDropDownVisible(!dropDownVisible) }), dropDownVisible && (0, jsx_runtime_1.jsx)(CalendarList_1.default, {})] })) }));
|
|
43
48
|
}
|
|
44
49
|
exports.default = Calendar;
|
|
@@ -4,6 +4,7 @@ exports.formatTime = formatTime;
|
|
|
4
4
|
const jsx_runtime_1 = require("preact/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const QandaProvider_1 = require("../QandaProvider");
|
|
7
|
+
const qanda_1 = require("../../config/qanda");
|
|
7
8
|
const comments_api_1 = require("../../services/comments-api");
|
|
8
9
|
function formatTime(remainingTime) {
|
|
9
10
|
const days = Math.floor(remainingTime / (1000 * 60 * 60 * 24));
|
|
@@ -29,6 +30,9 @@ function CountdownTimer({ container }) {
|
|
|
29
30
|
storyId,
|
|
30
31
|
useStaging,
|
|
31
32
|
commentsAPIUrl,
|
|
33
|
+
// Countdown is only relevant for pre-live Q&A
|
|
34
|
+
// so we can hardcode the status here
|
|
35
|
+
status: 'pre-live',
|
|
32
36
|
});
|
|
33
37
|
const updatedQA = (0, comments_api_1.useUpdatedQA)({
|
|
34
38
|
storyId,
|
|
@@ -82,7 +86,7 @@ function CountdownTimer({ container }) {
|
|
|
82
86
|
}, []);
|
|
83
87
|
const portalElement = data &&
|
|
84
88
|
((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.
|
|
89
|
+
(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.jsxs)("time", { datetime: status === 'pre-live' ? startDateTime : endDateTime, children: [(0, jsx_runtime_1.jsx)("span", { className: "o3-visually-hidden", children: qanda_1.PRODUCT_NAME }), ' ', count] })) }) }) }));
|
|
86
90
|
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, react_1.createPortal)(portalElement, portalTarget || document.body) });
|
|
87
91
|
}
|
|
88
92
|
exports.default = CountdownTimer;
|
|
@@ -1,28 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
const jsx_runtime_1 = require("preact/jsx-runtime");
|
|
7
|
+
const o_tracking_1 = __importDefault(require("@financial-times/o-tracking"));
|
|
4
8
|
const react_redux_1 = require("react-redux");
|
|
5
9
|
const questionSlice_1 = require("../../store/questionSlice");
|
|
6
10
|
const react_1 = require("react");
|
|
7
11
|
const react_dom_1 = require("react-dom");
|
|
8
|
-
|
|
12
|
+
const QandaProvider_1 = require("../QandaProvider");
|
|
13
|
+
const qanda_1 = require("../../config/qanda");
|
|
14
|
+
const tracking_1 = require("../../utils/tracking");
|
|
15
|
+
function EmbedFormField({ container, status = 'pre-live', }) {
|
|
9
16
|
const dispatch = (0, react_redux_1.useDispatch)();
|
|
10
17
|
const [portalTarget, setPortalTarget] = (0, react_1.useState)();
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
18
|
+
const modalOpenerRef = (0, react_1.useRef)(null);
|
|
19
|
+
const { setDialogOpener } = (0, react_1.useContext)(QandaProvider_1.QandaContext);
|
|
15
20
|
(0, react_1.useEffect)(() => {
|
|
16
21
|
if (container) {
|
|
17
22
|
const portalContainer = document.createElement('div');
|
|
18
23
|
container.prepend(portalContainer);
|
|
19
24
|
setPortalTarget(portalContainer);
|
|
25
|
+
o_tracking_1.default.click.init('cta', '[data-component=embed-form-field]');
|
|
20
26
|
return () => {
|
|
21
27
|
portalContainer.remove();
|
|
22
28
|
};
|
|
23
29
|
}
|
|
24
30
|
}, []);
|
|
25
|
-
const portalElement = ((0, jsx_runtime_1.jsxs)("div", { className: "qanda-portal embed-form-field__container o3-type-body-highlight", children: ["Submit your question
|
|
31
|
+
const portalElement = ((0, jsx_runtime_1.jsxs)("div", { className: "qanda-portal embed-form-field__container o3-type-body-highlight", children: ["Submit your question for ", qanda_1.PRODUCT_NAME, (0, jsx_runtime_1.jsxs)("button", { onClick: () => {
|
|
32
|
+
dispatch((0, questionSlice_1.openForm)());
|
|
33
|
+
setDialogOpener?.(modalOpenerRef.current);
|
|
34
|
+
}, className: "embed-form-field__text-input o3-type-body-lg", "data-testid": "embed-form-field", "data-trackable": (0, tracking_1.trackingNS)(`embed-form-field-${status}`), "data-component": "embed-form-field", "aria-haspopup": "dialog", ref: modalOpenerRef, type: "button", 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
35
|
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, react_dom_1.createPortal)(portalElement, portalTarget || document.body) });
|
|
27
36
|
}
|
|
28
37
|
exports.default = EmbedFormField;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const baseErrorMessages = {
|
|
4
|
+
generic: {
|
|
5
|
+
title: 'An error occurred',
|
|
6
|
+
message: 'Please try again later.',
|
|
7
|
+
},
|
|
8
|
+
serverError: {
|
|
9
|
+
title: 'Server error',
|
|
10
|
+
message: 'There was a server error. Please try again later.',
|
|
11
|
+
},
|
|
12
|
+
connectionError: {
|
|
13
|
+
title: 'Connection error',
|
|
14
|
+
message: 'Check your internet connection or browser settings and try again.',
|
|
15
|
+
},
|
|
16
|
+
timeoutError: {
|
|
17
|
+
title: 'Timeout error',
|
|
18
|
+
message: 'The request timed out. You may be on a slow connection. Please try again later.',
|
|
19
|
+
},
|
|
20
|
+
maintenanceMode: {
|
|
21
|
+
title: 'Sorry — this "Ask an Expert" page isn’t loading',
|
|
22
|
+
message: 'We’re working to fix the problem. Please check back soon.',
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
class HumanReadableError {
|
|
26
|
+
constructor(error, customErrorMessages = {}) {
|
|
27
|
+
// Default to generic error message
|
|
28
|
+
this._humanReadableError = baseErrorMessages.generic;
|
|
29
|
+
this._unMappedError = null;
|
|
30
|
+
const errorMessages = {
|
|
31
|
+
...baseErrorMessages,
|
|
32
|
+
...customErrorMessages,
|
|
33
|
+
};
|
|
34
|
+
try {
|
|
35
|
+
if ('status' in error) {
|
|
36
|
+
if (error.status === 'FETCH_ERROR') {
|
|
37
|
+
this._humanReadableError = errorMessages.connectionError;
|
|
38
|
+
}
|
|
39
|
+
else if (typeof error.status === 'number' && error.status >= 500) {
|
|
40
|
+
this._humanReadableError = errorMessages.serverError;
|
|
41
|
+
}
|
|
42
|
+
else if (typeof error.status === 'number' && error.status === 400) {
|
|
43
|
+
// Assuming as an error code otherwise will throw an error and we will fallback to generic error
|
|
44
|
+
const typedError = error;
|
|
45
|
+
this._humanReadableError =
|
|
46
|
+
errorMessages[typedError.data.error.errorCode];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else if ('name' in error) {
|
|
50
|
+
if (error.name === 'AbortError') {
|
|
51
|
+
this._humanReadableError = errorMessages.timeoutError;
|
|
52
|
+
}
|
|
53
|
+
if (error.name === 'maintenanceMode') {
|
|
54
|
+
this._humanReadableError = errorMessages.maintenanceMode;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
// Fallback to generic error message if we cannot parse the error correctly
|
|
60
|
+
this._humanReadableError = errorMessages.generic;
|
|
61
|
+
this._unMappedError = {
|
|
62
|
+
name: err && typeof err === 'object' && 'name' in err
|
|
63
|
+
? String(err.name)
|
|
64
|
+
: '',
|
|
65
|
+
message: err && typeof err === 'object' && 'message' in err
|
|
66
|
+
? String(err.message)
|
|
67
|
+
: '',
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
get title() {
|
|
72
|
+
return this._humanReadableError.title;
|
|
73
|
+
}
|
|
74
|
+
get message() {
|
|
75
|
+
return this._humanReadableError.message;
|
|
76
|
+
}
|
|
77
|
+
get unmappedError() {
|
|
78
|
+
return this._unMappedError;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.default = HumanReadableError;
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
exports.default = ErrorMessage;
|
|
7
|
+
const jsx_runtime_1 = require("preact/jsx-runtime");
|
|
8
|
+
const MessageBox_1 = __importDefault(require("../MessageBox"));
|
|
9
|
+
const tracking_1 = require("../../utils/tracking");
|
|
10
|
+
const humanReadableError_1 = __importDefault(require("./humanReadableError"));
|
|
11
|
+
const react_1 = require("react");
|
|
12
|
+
const strings_1 = require("../../utils/strings");
|
|
13
|
+
function ErrorMessage({ error, storyId, errorMapping = {}, operation = 'not-specified', id = '', }) {
|
|
14
|
+
const humanReadableError = new humanReadableError_1.default(error, errorMapping);
|
|
15
|
+
let errorDetails = [];
|
|
16
|
+
// If the error is unmapped, we log it for debugging purposes
|
|
17
|
+
if (humanReadableError.unmappedError) {
|
|
18
|
+
errorDetails = [
|
|
19
|
+
{
|
|
20
|
+
name: 'error_name',
|
|
21
|
+
value: humanReadableError.unmappedError.name,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'error_message',
|
|
25
|
+
value: humanReadableError.unmappedError.message,
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
errorDetails = [
|
|
31
|
+
{
|
|
32
|
+
name: 'error',
|
|
33
|
+
value: (0, strings_1.cleanString)(humanReadableError.title),
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'error_message',
|
|
37
|
+
value: (0, strings_1.cleanString)(humanReadableError.message),
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
(0, react_1.useEffect)(() => {
|
|
42
|
+
// Critical operation are tracked by the reliability service using AWS RUM
|
|
43
|
+
// We still log this to monitor untracked messages to the users.
|
|
44
|
+
(0, tracking_1.trackEvent)({
|
|
45
|
+
content: {
|
|
46
|
+
uuid: storyId,
|
|
47
|
+
},
|
|
48
|
+
trigger_action: operation,
|
|
49
|
+
custom: [
|
|
50
|
+
{
|
|
51
|
+
name: 'state',
|
|
52
|
+
value: 'error',
|
|
53
|
+
},
|
|
54
|
+
...errorDetails,
|
|
55
|
+
],
|
|
56
|
+
});
|
|
57
|
+
// Ensure trackEvent is only called once
|
|
58
|
+
}, []);
|
|
59
|
+
return ((0, jsx_runtime_1.jsx)(MessageBox_1.default, { color: "var(--o3-color-use-case-error)", extraClassNames: "o-message--alert o-message--error", title: humanReadableError.title, text: humanReadableError.message, id: id }));
|
|
60
|
+
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const jsx_runtime_1 = require("preact/jsx-runtime");
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const o3_button_1 = require("@financial-times/o3-button");
|
|
6
|
+
const tracking_1 = require("../../utils/tracking");
|
|
6
7
|
// Generic debounce function
|
|
7
8
|
function debounce(func, delay) {
|
|
8
9
|
let timerId;
|
|
@@ -14,6 +15,18 @@ function debounce(func, delay) {
|
|
|
14
15
|
}, delay);
|
|
15
16
|
};
|
|
16
17
|
}
|
|
18
|
+
// While comments submitted by Coral UI are always wrapped in paragraphs,
|
|
19
|
+
// comments submitted via our `Ask a question` form are just text.
|
|
20
|
+
// A wrapping paragraph is always needed for the expander to work correctly.
|
|
21
|
+
function EnsureParagraph({ children }) {
|
|
22
|
+
if (typeof children === 'object' &&
|
|
23
|
+
children !== null &&
|
|
24
|
+
'props' in children &&
|
|
25
|
+
children.props?.structuredContent?.tree?.children?.[0]?.type === 'text') {
|
|
26
|
+
return (0, jsx_runtime_1.jsx)("p", { children: children });
|
|
27
|
+
}
|
|
28
|
+
return children;
|
|
29
|
+
}
|
|
17
30
|
function Expander({ className = '', children = [], expandLabel = 'Expand', collapseLabel = 'Collapse', id, }) {
|
|
18
31
|
const textRef = (0, react_1.useRef)(null);
|
|
19
32
|
const [requiresExpander, setExpander] = (0, react_1.useState)(false);
|
|
@@ -45,10 +58,10 @@ function Expander({ className = '', children = [], expandLabel = 'Expand', colla
|
|
|
45
58
|
const label = state === 'expanded' ? collapseLabel : expandLabel;
|
|
46
59
|
const expandCollapseClass = state === 'expanded' ? 'expander--expanded' : 'expander--collapsed';
|
|
47
60
|
const componentClassName = `${expandCollapseClass} ${className}`;
|
|
48
|
-
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: 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
|
+
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: {
|
|
49
62
|
className: 'expander__link',
|
|
50
|
-
'data-trackable': `
|
|
51
|
-
'data-trackable-context-
|
|
63
|
+
'data-trackable': (0, tracking_1.trackingNS)(`expander-${state}`),
|
|
64
|
+
'data-trackable-context-trigger_action': label,
|
|
52
65
|
'aria-expanded': state === 'expanded' ? true : false,
|
|
53
66
|
'aria-controls': expanderContentID,
|
|
54
67
|
'data-action': state === 'expanded' ? 'collapse' : 'expand',
|
|
@@ -11,14 +11,16 @@ const expertSlice_1 = require("../../store/expertSlice");
|
|
|
11
11
|
const QandaProvider_1 = require("../QandaProvider");
|
|
12
12
|
const reliability_1 = require("../../services/reliability");
|
|
13
13
|
const Overlay_1 = __importDefault(require("../Overlay"));
|
|
14
|
+
const qanda_1 = require("../../config/qanda");
|
|
14
15
|
function ExpertDrawer() {
|
|
15
16
|
const dispatch = (0, react_redux_1.useDispatch)();
|
|
16
|
-
const { storyId, useStaging, title } = (0, react_1.useContext)(QandaProvider_1.QandaContext);
|
|
17
|
+
const { storyId, useStaging, title, focusDialogOpener } = (0, react_1.useContext)(QandaProvider_1.QandaContext);
|
|
17
18
|
const { isExpertFormOpen, expertView } = (0, react_redux_1.useSelector)((state) => state.expert);
|
|
18
19
|
(0, react_1.useEffect)(() => {
|
|
19
20
|
if (isExpertFormOpen) {
|
|
20
21
|
try {
|
|
21
22
|
o_comments_1.default.init();
|
|
23
|
+
reliability_1.qandaReliability.success('expert-load-coral-ui');
|
|
22
24
|
}
|
|
23
25
|
catch (error) {
|
|
24
26
|
reliability_1.qandaReliability.failure('expert-load-coral-ui', error);
|
|
@@ -28,9 +30,12 @@ function ExpertDrawer() {
|
|
|
28
30
|
if (!isExpertFormOpen) {
|
|
29
31
|
return null;
|
|
30
32
|
}
|
|
31
|
-
return ((0, jsx_runtime_1.jsx)(Overlay_1.default, { title:
|
|
33
|
+
return ((0, jsx_runtime_1.jsx)(Overlay_1.default, { title: qanda_1.PRODUCT_NAME, closeCallback: () => {
|
|
34
|
+
dispatch((0, expertSlice_1.closeExpertForm)());
|
|
35
|
+
focusDialogOpener?.();
|
|
36
|
+
}, options: {
|
|
32
37
|
shadow: true,
|
|
33
|
-
|
|
38
|
+
allowInteraction: true,
|
|
34
39
|
}, 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
40
|
}
|
|
36
41
|
exports.default = ExpertDrawer;
|
|
@@ -9,48 +9,87 @@ const useIsMobile_1 = require("../../hooks/useIsMobile");
|
|
|
9
9
|
const comments_api_1 = require("../../services/comments-api");
|
|
10
10
|
const updateComments_1 = require("../../store/updateComments");
|
|
11
11
|
const react_1 = require("react");
|
|
12
|
+
const o_utils_1 = require("@financial-times/o-utils");
|
|
12
13
|
const QandaProvider_1 = require("../QandaProvider");
|
|
13
|
-
|
|
14
|
+
const tracking_1 = require("../../utils/tracking");
|
|
15
|
+
function LiveIndicator() {
|
|
16
|
+
return ((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" }) }));
|
|
17
|
+
}
|
|
18
|
+
function useAlignToQanda(ref) {
|
|
19
|
+
(0, react_1.useEffect)(() => {
|
|
20
|
+
const align = () => {
|
|
21
|
+
const container = ref.current;
|
|
22
|
+
const qandaRoot = container?.closest('.qanda-container');
|
|
23
|
+
const target = qandaRoot?.querySelector('.qanda__blocks-container');
|
|
24
|
+
if (!target || !container)
|
|
25
|
+
return;
|
|
26
|
+
const rect = target.getBoundingClientRect();
|
|
27
|
+
container.style.left = `${rect.left}px`;
|
|
28
|
+
container.style.width = `${rect.width}px`;
|
|
29
|
+
};
|
|
30
|
+
align();
|
|
31
|
+
const debounced = (0, o_utils_1.debounce)(align, 100);
|
|
32
|
+
window.addEventListener('resize', debounced);
|
|
33
|
+
return () => window.removeEventListener('resize', debounced);
|
|
34
|
+
}, [ref]);
|
|
35
|
+
}
|
|
36
|
+
function FloatingActionBar({ isLive = true }) {
|
|
14
37
|
const dispatch = (0, react_redux_1.useDispatch)();
|
|
15
38
|
const isMobile = (0, useIsMobile_1.useIsMobile)();
|
|
16
|
-
const { storyId, useStaging, commentsAPIUrl } = (0, react_1.useContext)(QandaProvider_1.QandaContext);
|
|
39
|
+
const { storyId, useStaging, commentsAPIUrl, setDialogOpener } = (0, react_1.useContext)(QandaProvider_1.QandaContext);
|
|
40
|
+
const modalOpenerRef = (0, react_1.useRef)(null);
|
|
17
41
|
const updatedComments = (0, comments_api_1.useUpdatedComments)({
|
|
18
42
|
storyId,
|
|
19
43
|
useStaging,
|
|
20
44
|
commentsAPIUrl,
|
|
45
|
+
}, {
|
|
46
|
+
skip: !isLive,
|
|
21
47
|
});
|
|
22
48
|
const handleShowUpdates = () => {
|
|
23
49
|
(0, updateComments_1.updateComments)(dispatch, updatedComments, storyId, useStaging, commentsAPIUrl);
|
|
24
|
-
// Scrolling to start of qanda
|
|
25
|
-
const element = document.getElementById('
|
|
50
|
+
// Scrolling to start of qanda stream title
|
|
51
|
+
const element = document.getElementById('qanda__stream-title');
|
|
26
52
|
if (element) {
|
|
53
|
+
element.setAttribute('tabindex', '-1'); // Make it focusable
|
|
54
|
+
element.focus();
|
|
27
55
|
element.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
28
56
|
}
|
|
29
57
|
};
|
|
30
58
|
const showExpertView = (0, react_redux_1.useSelector)((state) => state.expert.expertView);
|
|
31
59
|
const userConfig = {
|
|
32
|
-
|
|
60
|
+
description: 'Ask a question',
|
|
33
61
|
testIdSuffix: 'ask-a-question-button',
|
|
34
|
-
onClick: () =>
|
|
62
|
+
onClick: () => {
|
|
63
|
+
// modalOpener set on div as Button does not support refs, therefore we need to find the button inside it
|
|
64
|
+
const { current: modalOpener } = modalOpenerRef;
|
|
65
|
+
const openerButton = modalOpener?.querySelector('button');
|
|
66
|
+
if (openerButton) {
|
|
67
|
+
setDialogOpener?.(openerButton);
|
|
68
|
+
}
|
|
69
|
+
dispatch((0, questionSlice_1.openForm)());
|
|
70
|
+
},
|
|
35
71
|
dataTrackable: 'open_question_form',
|
|
36
72
|
};
|
|
37
73
|
const expertConfig = {
|
|
38
|
-
|
|
74
|
+
description: 'Answer Q&A',
|
|
39
75
|
testIdSuffix: 'answer-a-qanda-button',
|
|
40
76
|
onClick: () => dispatch((0, expertSlice_1.openExpertForm)()),
|
|
41
77
|
dataTrackable: 'open_expert_drawer',
|
|
42
78
|
};
|
|
43
79
|
const view = showExpertView ? expertConfig : userConfig;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
80
|
+
const containerRef = (0, react_1.useRef)(null);
|
|
81
|
+
useAlignToQanda(containerRef);
|
|
82
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: containerRef, className: "floating-action-bar__container", "data-trackable": (0, tracking_1.trackingNS)('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)("span", { className: "o3-visually-hidden", "aria-live": "polite", role: "alert", children: isLive ? 'This session is now live' : '' }), isLive && (0, jsx_runtime_1.jsx)(LiveIndicator, {}), (0, jsx_runtime_1.jsxs)("div", { className: "floating-action-bar__buttons", ref: modalOpenerRef, children: [(0, jsx_runtime_1.jsx)(o3_button_1.Button, { attributes: {
|
|
83
|
+
ariaLabel: view.description,
|
|
84
|
+
'data-trackable': (0, tracking_1.trackingNS)(view.dataTrackable),
|
|
85
|
+
'data-trackable-context-action': view.description,
|
|
48
86
|
'data-testid': `floating-action-bar__${view.testIdSuffix}`,
|
|
49
|
-
|
|
87
|
+
ariaHasPopup: 'dialog',
|
|
88
|
+
}, label: view.description, type: "ghost", theme: "mono", icon: "edit", iconOnly: isMobile, onClick: view.onClick }), (0, jsx_runtime_1.jsx)(o3_button_1.Button, { attributes: {
|
|
50
89
|
ariaLabel: 'Back to top',
|
|
51
|
-
'data-trackable': 'back_to_top',
|
|
52
|
-
'data-trackable-context-
|
|
90
|
+
'data-trackable': (0, tracking_1.trackingNS)('back_to_top'),
|
|
91
|
+
'data-trackable-context-trigger_action': 'Back to top',
|
|
53
92
|
'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 }))] })] }));
|
|
93
|
+
}, 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", "aria-label": `${updatedComments.length} new ${updatedComments.length === 1 ? 'update' : 'updates'} available`, role: "status", "aria-live": "polite", children: updatedComments.length }))] })] }));
|
|
55
94
|
}
|
|
56
95
|
exports.default = FloatingActionBar;
|
|
@@ -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, extraClassNames = '', text, title, id = '', }) {
|
|
5
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: `o-message o-message--inner message-box__container ${extraClassNames}`, "data-o-message-close": "false", "data-o-component": "o-message", id: id, children: (0, jsx_runtime_1.jsx)("div", { className: "o-message__container", children: (0, jsx_runtime_1.jsxs)("div", { className: "message-box__content", children: [(0, jsx_runtime_1.jsx)("span", { style: { color }, className: "o3-type-body-highlight", children: title }), (0, jsx_runtime_1.jsx)("span", { style: { color }, className: "o3-type-body-base", children: text })] }) }) }));
|
|
6
|
+
}
|
|
7
|
+
exports.default = MessageBox;
|