@financial-times/qanda-ui 1.0.2 → 1.0.4

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.
@@ -30,7 +30,7 @@ function ExpertDrawer() {
30
30
  if (!isExpertFormOpen) {
31
31
  return null;
32
32
  }
33
- return ((0, jsx_runtime_1.jsx)(Overlay_1.default, { title: qanda_1.PRODUCT_NAME, closeCallback: () => {
33
+ return ((0, jsx_runtime_1.jsx)(Overlay_1.default, { title: qanda_1.PRODUCT_NAME, className: "expert-drawer", closeCallback: () => {
34
34
  dispatch((0, expertSlice_1.closeExpertForm)());
35
35
  focusDialogOpener?.();
36
36
  }, options: {
@@ -7,7 +7,7 @@ const jsx_runtime_1 = require("preact/jsx-runtime");
7
7
  const react_1 = require("react");
8
8
  const o3_button_1 = require("@financial-times/o3-button");
9
9
  const classnames_1 = __importDefault(require("classnames"));
10
- function Overlay({ title, children, closeCallback, options = {}, }) {
10
+ function Overlay({ title, className, children, closeCallback, options = {}, }) {
11
11
  // Trap keyboard focus within the overlay for accessibility
12
12
  const trapFocus = (event) => {
13
13
  if (event.key !== 'Tab')
@@ -27,6 +27,7 @@ function Overlay({ title, children, closeCallback, options = {}, }) {
27
27
  return ((0, jsx_runtime_1.jsxs)("div", { className: "overlay", role: "dialog", "aria-modal": "true", "aria-labelledby": "overlay-title", children: [!options.allowInteraction && (0, jsx_runtime_1.jsx)("div", { className: "overlay__outer" }), (0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)([
28
28
  'overlay__inner',
29
29
  { 'overlay__inner--shadow': options.shadow },
30
+ className,
30
31
  ]), 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", id: "overlay-title", tabIndex: 0, ref: titleRef, onKeyDown: trapFocus, 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 })] }), (0, jsx_runtime_1.jsx)("button", { className: "o3-visually-hidden", "aria-label": "Close", onClick: () => closeCallback(), ref: endFocusBtn, onKeyDown: trapFocus, type: "button", children: "Close" })] }));
31
32
  }
32
33
  exports.default = Overlay;
@@ -25,7 +25,7 @@ function ExpertDrawer() {
25
25
  if (!isExpertFormOpen) {
26
26
  return null;
27
27
  }
28
- return (_jsx(Overlay, { title: PRODUCT_NAME, closeCallback: () => {
28
+ return (_jsx(Overlay, { title: PRODUCT_NAME, className: "expert-drawer", closeCallback: () => {
29
29
  dispatch(closeExpertForm());
30
30
  focusDialogOpener?.();
31
31
  }, options: {
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
2
  import { useEffect, useRef } from 'react';
3
3
  import { Button } from '@financial-times/o3-button';
4
4
  import classNames from 'classnames';
5
- function Overlay({ title, children, closeCallback, options = {}, }) {
5
+ function Overlay({ title, className, children, closeCallback, options = {}, }) {
6
6
  // Trap keyboard focus within the overlay for accessibility
7
7
  const trapFocus = (event) => {
8
8
  if (event.key !== 'Tab')
@@ -22,6 +22,7 @@ function Overlay({ title, children, closeCallback, options = {}, }) {
22
22
  return (_jsxs("div", { className: "overlay", role: "dialog", "aria-modal": "true", "aria-labelledby": "overlay-title", children: [!options.allowInteraction && _jsx("div", { className: "overlay__outer" }), _jsxs("div", { className: classNames([
23
23
  'overlay__inner',
24
24
  { 'overlay__inner--shadow': options.shadow },
25
+ className,
25
26
  ]), children: [_jsx("div", { className: "overlay__header", children: _jsxs("div", { className: "overlay__header-bar", children: [_jsx("span", { className: "o3-type-body-highlight overlay__header-title", id: "overlay-title", tabIndex: 0, ref: titleRef, onKeyDown: trapFocus, children: title }), _jsx(Button, { attributes: { className: 'overlay__header-close' }, iconOnly: true, icon: "cross", label: "Close", type: "ghost", theme: "mono", onClick: () => closeCallback() })] }) }), _jsx("div", { className: "overlay__content", children: children })] }), _jsx("button", { className: "o3-visually-hidden", "aria-label": "Close", onClick: () => closeCallback(), ref: endFocusBtn, onKeyDown: trapFocus, type: "button", children: "Close" })] }));
26
27
  }
27
28
  export default Overlay;
package/dist/qanda.scss CHANGED
@@ -519,6 +519,19 @@ $app-header-color: #007acc;
519
519
  }
520
520
  }
521
521
 
522
+ /* Inlined from ../components/ExpertDrawer/styles.css */
523
+ @media (min-width: 740px) {
524
+ .overlay__inner--shadow.expert-drawer {
525
+ width: 45vw;
526
+ min-width: 420px;
527
+ }
528
+
529
+ /* Currently, although it also works on FT-app, we optimise the expert drawer for usage on tablet/desktop on FT.com only (where the 'article-content' selector is) */
530
+ .article-content:has(.expert-drawer) {
531
+ max-width: 50vw;
532
+ }
533
+ }
534
+
522
535
  /* Inlined from ../components/QandaBlock/styles.css */
523
536
  @import '@financial-times/o3-foundation/css/core.css';
524
537
 
@@ -683,9 +696,12 @@ $app-header-color: #007acc;
683
696
  }
684
697
 
685
698
  .input-textarea {
686
- min-height: 180px;
699
+ min-height: 120px;
687
700
  background-color: transparent;
688
701
  border: none;
702
+ @media (min-width: 740px) {
703
+ min-height: 180px;
704
+ }
689
705
  }
690
706
 
691
707
  .input-textarea:focus-visible {
@@ -812,6 +828,15 @@ $app-header-color: #007acc;
812
828
  )
813
829
  );
814
830
 
831
+ @media (max-width: 740px) {
832
+ // locks scrolling for narrow viewport on web
833
+ html:has(.qanda-container .overlay),
834
+ // locks scroll container for FT app
835
+ body:has(.qanda-container .overlay) .js-vertical-scroller {
836
+ overflow: hidden;
837
+ }
838
+ }
839
+
815
840
  .qanda-container {
816
841
  body {
817
842
  margin: 0;
@@ -4,9 +4,10 @@ type OverlayOptions = {
4
4
  };
5
5
  type OverlayProps = {
6
6
  title: string;
7
+ className?: string;
7
8
  children: React.ReactNode;
8
9
  closeCallback: () => void;
9
10
  options?: OverlayOptions;
10
11
  };
11
- declare function Overlay({ title, children, closeCallback, options, }: OverlayProps): import("react").JSX.Element;
12
+ declare function Overlay({ title, className, children, closeCallback, options, }: OverlayProps): import("react").JSX.Element;
12
13
  export default Overlay;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@financial-times/qanda-ui",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
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",