@financial-times/qanda-ui 1.1.0 → 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.
|
@@ -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}`),
|
|
@@ -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}`),
|