@financial-times/qanda-ui 1.0.0 → 1.0.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.
|
@@ -40,13 +40,17 @@ function Expander({ className = '', children = [], expandLabel = 'Expand', colla
|
|
|
40
40
|
}
|
|
41
41
|
const numberOfCharacters = element.textContent?.length || 300;
|
|
42
42
|
const windowWidth = window.visualViewport?.width || window.innerWidth || 1200; // Fallback to desktop configuration.
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
// Approximate cut-off using character counts
|
|
44
|
+
// On average: ~176 characters on mobile (4 lines) and ~374 on desktop (5 lines)
|
|
45
|
+
// We set thresholds slightly higher (250 / 425) to ensure some text is hidden
|
|
46
|
+
// before showing the expander
|
|
47
|
+
// Note: This needs to stay aligned with the CSS for the expander
|
|
48
|
+
const mobileNumberOfCharacters = 225;
|
|
49
|
+
const desktopNumberOfCharacters = 425;
|
|
47
50
|
const characterForExpander = windowWidth <= 490
|
|
48
51
|
? mobileNumberOfCharacters
|
|
49
52
|
: desktopNumberOfCharacters;
|
|
53
|
+
// Show the expander if character count exceeds the threshold
|
|
50
54
|
setExpander(numberOfCharacters > characterForExpander);
|
|
51
55
|
};
|
|
52
56
|
const debouncedCheck = debounce(checkNeedForExpanderButton, 250);
|
|
@@ -86,10 +86,10 @@ function FloatingActionBar({ isLive = true }) {
|
|
|
86
86
|
'data-testid': `floating-action-bar__${view.testIdSuffix}`,
|
|
87
87
|
ariaHasPopup: 'dialog',
|
|
88
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: {
|
|
89
|
-
ariaLabel: '
|
|
90
|
-
'data-trackable': (0, tracking_1.trackingNS)('
|
|
91
|
-
'data-trackable-context-trigger_action': '
|
|
92
|
-
'data-testid': 'floating-action-
|
|
93
|
-
}, label: "
|
|
89
|
+
ariaLabel: 'Latest answers',
|
|
90
|
+
'data-trackable': (0, tracking_1.trackingNS)('latest-answers'),
|
|
91
|
+
'data-trackable-context-trigger_action': 'Latest answers',
|
|
92
|
+
'data-testid': 'floating-action-bar__latest-answers-button',
|
|
93
|
+
}, label: "Latest answers", 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 }))] })] }));
|
|
94
94
|
}
|
|
95
95
|
exports.default = FloatingActionBar;
|
|
@@ -38,13 +38,17 @@ function Expander({ className = '', children = [], expandLabel = 'Expand', colla
|
|
|
38
38
|
}
|
|
39
39
|
const numberOfCharacters = element.textContent?.length || 300;
|
|
40
40
|
const windowWidth = window.visualViewport?.width || window.innerWidth || 1200; // Fallback to desktop configuration.
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
// Approximate cut-off using character counts
|
|
42
|
+
// On average: ~176 characters on mobile (4 lines) and ~374 on desktop (5 lines)
|
|
43
|
+
// We set thresholds slightly higher (250 / 425) to ensure some text is hidden
|
|
44
|
+
// before showing the expander
|
|
45
|
+
// Note: This needs to stay aligned with the CSS for the expander
|
|
46
|
+
const mobileNumberOfCharacters = 225;
|
|
47
|
+
const desktopNumberOfCharacters = 425;
|
|
45
48
|
const characterForExpander = windowWidth <= 490
|
|
46
49
|
? mobileNumberOfCharacters
|
|
47
50
|
: desktopNumberOfCharacters;
|
|
51
|
+
// Show the expander if character count exceeds the threshold
|
|
48
52
|
setExpander(numberOfCharacters > characterForExpander);
|
|
49
53
|
};
|
|
50
54
|
const debouncedCheck = debounce(checkNeedForExpanderButton, 250);
|
|
@@ -84,10 +84,10 @@ function FloatingActionBar({ isLive = true }) {
|
|
|
84
84
|
'data-testid': `floating-action-bar__${view.testIdSuffix}`,
|
|
85
85
|
ariaHasPopup: 'dialog',
|
|
86
86
|
}, label: view.description, type: "ghost", theme: "mono", icon: "edit", iconOnly: isMobile, onClick: view.onClick }), _jsx(Button, { attributes: {
|
|
87
|
-
ariaLabel: '
|
|
88
|
-
'data-trackable': trackingNS('
|
|
89
|
-
'data-trackable-context-trigger_action': '
|
|
90
|
-
'data-testid': 'floating-action-
|
|
91
|
-
}, label: "
|
|
87
|
+
ariaLabel: 'Latest answers',
|
|
88
|
+
'data-trackable': trackingNS('latest-answers'),
|
|
89
|
+
'data-trackable-context-trigger_action': 'Latest answers',
|
|
90
|
+
'data-testid': 'floating-action-bar__latest-answers-button',
|
|
91
|
+
}, label: "Latest answers", type: "ghost", theme: "mono", icon: "scroll-to", iconOnly: isMobile, onClick: handleShowUpdates })] }), updatedComments?.length > 0 && (_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 }))] })] }));
|
|
92
92
|
}
|
|
93
93
|
export default FloatingActionBar;
|
package/dist/qanda.scss
CHANGED
|
@@ -608,33 +608,24 @@ $app-header-color: #007acc;
|
|
|
608
608
|
}
|
|
609
609
|
}
|
|
610
610
|
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
text-overflow: ellipsis;
|
|
624
|
-
/* Without this the letter like `g` may be visually cut.
|
|
611
|
+
.qanda-block__text.expander--collapsed
|
|
612
|
+
.expander__text--multiline
|
|
613
|
+
> p:first-of-type {
|
|
614
|
+
display: block;
|
|
615
|
+
display: -webkit-box;
|
|
616
|
+
/* Note: This need to stay aligned with the JS for the expander */
|
|
617
|
+
line-clamp: 4;
|
|
618
|
+
-webkit-line-clamp: 4;
|
|
619
|
+
-webkit-box-orient: vertical;
|
|
620
|
+
overflow: hidden;
|
|
621
|
+
text-overflow: ellipsis;
|
|
622
|
+
/* Without this the letter like `g` may be visually cut.
|
|
625
623
|
To be tested with final font */
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
@container (min-width: 491px) {
|
|
632
|
-
.qanda-block__text.expander--collapsed
|
|
633
|
-
.expander__text--multiline
|
|
634
|
-
> p:first-of-type {
|
|
635
|
-
white-space: nowrap;
|
|
636
|
-
text-overflow: ellipsis;
|
|
637
|
-
overflow: hidden;
|
|
624
|
+
padding-bottom: 1px;
|
|
625
|
+
@container (min-width: 491px) {
|
|
626
|
+
/* Note: This need to stay aligned with the JS for the expander */
|
|
627
|
+
line-clamp: 5;
|
|
628
|
+
-webkit-line-clamp: 5;
|
|
638
629
|
}
|
|
639
630
|
}
|
|
640
631
|
}
|