@financial-times/qanda-ui 1.0.7 → 1.1.1
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/dist/cjs/components/CountdownTimer/index.js +3 -3
- package/dist/cjs/components/Expander/index.js +8 -2
- package/dist/cjs/components/QuestionForm/index.js +1 -1
- package/dist/esm/components/CountdownTimer/index.js +3 -3
- package/dist/esm/components/Expander/index.js +5 -2
- package/dist/esm/components/QuestionForm/index.js +1 -1
- package/package.json +3 -3
|
@@ -7,11 +7,11 @@ const QandaProvider_1 = require("../QandaProvider");
|
|
|
7
7
|
const qanda_1 = require("../../config/qanda");
|
|
8
8
|
const comments_api_1 = require("../../services/comments-api");
|
|
9
9
|
function formatTime(remainingTime) {
|
|
10
|
-
const
|
|
11
|
-
if (
|
|
10
|
+
const hours = Math.floor(remainingTime / (1000 * 60 * 60));
|
|
11
|
+
if (hours >= 48) {
|
|
12
|
+
const days = Math.floor(hours / 24);
|
|
12
13
|
return `${days} day${days === 1 ? '' : 's'} `;
|
|
13
14
|
}
|
|
14
|
-
const hours = Math.floor((remainingTime % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
|
15
15
|
if (hours >= 1) {
|
|
16
16
|
return `${hours} hour${hours === 1 ? '' : 's'}`;
|
|
17
17
|
}
|
|
@@ -1,9 +1,13 @@
|
|
|
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");
|
|
4
7
|
const react_1 = require("react");
|
|
5
8
|
const o3_button_1 = require("@financial-times/o3-button");
|
|
6
9
|
const tracking_1 = require("../../utils/tracking");
|
|
10
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
7
11
|
// Generic debounce function
|
|
8
12
|
function debounce(func, delay) {
|
|
9
13
|
let timerId;
|
|
@@ -60,8 +64,10 @@ function Expander({ className = '', children = [], expandLabel = 'Expand', colla
|
|
|
60
64
|
return () => window.removeEventListener('resize', debouncedCheck);
|
|
61
65
|
}, [children]); // re-run whenever the children change, although we don't expect it to
|
|
62
66
|
const label = state === 'expanded' ? collapseLabel : expandLabel;
|
|
63
|
-
const
|
|
64
|
-
|
|
67
|
+
const componentClassName = (0, classnames_1.default)({
|
|
68
|
+
'expander--expanded': requiresExpander && state === 'expanded',
|
|
69
|
+
'expander--collapsed': requiresExpander && state !== 'expanded',
|
|
70
|
+
}, className);
|
|
65
71
|
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: {
|
|
66
72
|
className: 'expander__link',
|
|
67
73
|
'data-trackable': (0, tracking_1.trackingNS)(`expander-${state}`),
|
|
@@ -170,7 +170,7 @@ function QuestionForm() {
|
|
|
170
170
|
},
|
|
171
171
|
// @ts-expect-error - o3 Button is currently accepting a JSX element as label
|
|
172
172
|
// but the type definition needs to be updated by Origami team
|
|
173
|
-
label: isLoading ? (0, jsx_runtime_1.jsx)(Loader_1.default, {}) : 'Submit your question', type: "primary", theme: "mono" }), !profile?.token && ((0, jsx_runtime_1.jsx)("span", { className: "o3-type-detail", id: "question-form-disclaimer", children: "Submitting a question will create a community profile with FT." }))] }) })), isSuccess && ((0, jsx_runtime_1.jsx)("div", { role: "alert", "aria-live": "polite", children: (0, jsx_runtime_1.jsx)(MessageBox_1.default, { color: "#00572C", extraClassNames: "o-message--alert o-message--success", title: "Question sent", text: "Your question
|
|
173
|
+
label: isLoading ? (0, jsx_runtime_1.jsx)(Loader_1.default, {}) : 'Submit your question', type: "primary", theme: "mono" }), !profile?.token && ((0, jsx_runtime_1.jsx)("span", { className: "o3-type-detail", id: "question-form-disclaimer", children: "Submitting a question will create a community profile with FT." }))] }) })), isSuccess && ((0, jsx_runtime_1.jsx)("div", { role: "alert", "aria-live": "polite", children: (0, jsx_runtime_1.jsx)(MessageBox_1.default, { color: "#00572C", extraClassNames: "o-message--alert o-message--success", title: "Question sent", text: "Your question has been received and sent to our editorial team. If selected, you'll see it, along with the journalist's answer, published during the live Q&A." }) })), (0, jsx_runtime_1.jsx)("div", { "aria-live": "polite", role: "alert", id: "question-form-error-message", children: error && ((0, jsx_runtime_1.jsx)(ErrorMessage_1.default, { error: error, storyId: storyId, errorMapping: {
|
|
174
174
|
// Messages for specific error codes
|
|
175
175
|
REPEAT_POST: {
|
|
176
176
|
title: 'Question already submitted',
|
|
@@ -4,11 +4,11 @@ import { QandaContext } from '../QandaProvider';
|
|
|
4
4
|
import { PRODUCT_NAME } from '../../config/qanda';
|
|
5
5
|
import { useGetQandAStreamQuery, useUpdatedQA, } from '../../services/comments-api';
|
|
6
6
|
export function formatTime(remainingTime) {
|
|
7
|
-
const
|
|
8
|
-
if (
|
|
7
|
+
const hours = Math.floor(remainingTime / (1000 * 60 * 60));
|
|
8
|
+
if (hours >= 48) {
|
|
9
|
+
const days = Math.floor(hours / 24);
|
|
9
10
|
return `${days} day${days === 1 ? '' : 's'} `;
|
|
10
11
|
}
|
|
11
|
-
const hours = Math.floor((remainingTime % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
|
12
12
|
if (hours >= 1) {
|
|
13
13
|
return `${hours} hour${hours === 1 ? '' : 's'}`;
|
|
14
14
|
}
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
|
2
2
|
import { useState, useRef, useEffect } from 'react';
|
|
3
3
|
import { Button } from '@financial-times/o3-button';
|
|
4
4
|
import { trackingNS } from '../../utils/tracking';
|
|
5
|
+
import classNames from 'classnames';
|
|
5
6
|
// Generic debounce function
|
|
6
7
|
function debounce(func, delay) {
|
|
7
8
|
let timerId;
|
|
@@ -58,8 +59,10 @@ function Expander({ className = '', children = [], expandLabel = 'Expand', colla
|
|
|
58
59
|
return () => window.removeEventListener('resize', debouncedCheck);
|
|
59
60
|
}, [children]); // re-run whenever the children change, although we don't expect it to
|
|
60
61
|
const label = state === 'expanded' ? collapseLabel : expandLabel;
|
|
61
|
-
const
|
|
62
|
-
|
|
62
|
+
const componentClassName = classNames({
|
|
63
|
+
'expander--expanded': requiresExpander && state === 'expanded',
|
|
64
|
+
'expander--collapsed': requiresExpander && state !== 'expanded',
|
|
65
|
+
}, className);
|
|
63
66
|
return (_jsxs("div", { className: `${componentClassName}`, children: [_jsx("div", { className: `expander__text ${requiresExpander ? 'expander__text--multiline' : ''}`, id: expanderContentID, ref: textRef, children: _jsx(EnsureParagraph, { children: children }) }), requiresExpander && (_jsx(Button, { label: label, type: "ghost", theme: "neutral", icon: state === 'expanded' ? 'chevron-up' : 'chevron-down', iconOnly: false, iconPosition: "end", attributes: {
|
|
64
67
|
className: 'expander__link',
|
|
65
68
|
'data-trackable': trackingNS(`expander-${state}`),
|
|
@@ -164,7 +164,7 @@ export default function QuestionForm() {
|
|
|
164
164
|
},
|
|
165
165
|
// @ts-expect-error - o3 Button is currently accepting a JSX element as label
|
|
166
166
|
// but the type definition needs to be updated by Origami team
|
|
167
|
-
label: isLoading ? _jsx(Loader, {}) : 'Submit your question', type: "primary", theme: "mono" }), !profile?.token && (_jsx("span", { className: "o3-type-detail", id: "question-form-disclaimer", children: "Submitting a question will create a community profile with FT." }))] }) })), isSuccess && (_jsx("div", { role: "alert", "aria-live": "polite", children: _jsx(MessageBox, { color: "#00572C", extraClassNames: "o-message--alert o-message--success", title: "Question sent", text: "Your question
|
|
167
|
+
label: isLoading ? _jsx(Loader, {}) : 'Submit your question', type: "primary", theme: "mono" }), !profile?.token && (_jsx("span", { className: "o3-type-detail", id: "question-form-disclaimer", children: "Submitting a question will create a community profile with FT." }))] }) })), isSuccess && (_jsx("div", { role: "alert", "aria-live": "polite", children: _jsx(MessageBox, { color: "#00572C", extraClassNames: "o-message--alert o-message--success", title: "Question sent", text: "Your question has been received and sent to our editorial team. If selected, you'll see it, along with the journalist's answer, published during the live Q&A." }) })), _jsx("div", { "aria-live": "polite", role: "alert", id: "question-form-error-message", children: error && (_jsx(ErrorMessage, { error: error, storyId: storyId, errorMapping: {
|
|
168
168
|
// Messages for specific error codes
|
|
169
169
|
REPEAT_POST: {
|
|
170
170
|
title: 'Question already submitted',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@financial-times/qanda-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Components for the Live Q&A (AKA Ask an Expert) UI",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -101,10 +101,10 @@
|
|
|
101
101
|
"@financial-times/cp-content-pipeline-ui": "^9.2.1",
|
|
102
102
|
"@financial-times/n-tracking": "^7.7.0",
|
|
103
103
|
"@financial-times/o-colors": "^6.7",
|
|
104
|
-
"@financial-times/o-comments": "^13.0
|
|
104
|
+
"@financial-times/o-comments": "^13.1.0",
|
|
105
105
|
"@financial-times/o-forms": "^10.0.2",
|
|
106
106
|
"@financial-times/o-grid": "^6.1.8",
|
|
107
|
-
"@financial-times/o-icons": "^7.
|
|
107
|
+
"@financial-times/o-icons": "^7.10.0",
|
|
108
108
|
"@financial-times/o-labels": "^7.0.1",
|
|
109
109
|
"@financial-times/o-loading": "^6.0.0",
|
|
110
110
|
"@financial-times/o-message": "^6.0.0",
|