qpp-style 9.41.5 → 9.42.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/components/Error/Collapsible.jsx +88 -0
- package/components/Error/ErrorUI.jsx +31 -0
- package/components/Error/error.js +26 -0
- package/dist/browser.js +1 -1
- package/dist/browser.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/react/index.js +1 -1
- package/index.js +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React, { Component } from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
|
|
4
|
+
class Collapsible extends Component {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
super(props);
|
|
7
|
+
|
|
8
|
+
this.state = {
|
|
9
|
+
isExpanded: false,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
this._toggleExpanded = this.toggleExpanded.bind(this);
|
|
13
|
+
this._renderShowButton = this.renderShowButton.bind(this);
|
|
14
|
+
this._renderHideButton = this.renderHideButton.bind(this);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
toggleExpanded() {
|
|
18
|
+
this.setState({
|
|
19
|
+
isExpanded: !this.state.isExpanded,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
renderShowButton() {
|
|
24
|
+
return (
|
|
25
|
+
<span className="collapsible-show-label">{this.props.showLabel}</span>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
renderHideButton() {
|
|
30
|
+
if (this.props.hideLabel) {
|
|
31
|
+
return (
|
|
32
|
+
<span className="collapsible-hide-label">{this.props.hideLabel}</span>
|
|
33
|
+
);
|
|
34
|
+
} else {
|
|
35
|
+
return "";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
render() {
|
|
40
|
+
const isArray = Array.isArray(this.props.content);
|
|
41
|
+
const isHidden = this.state.isExpanded ? undefined : true;
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<div className="collapsible-container">
|
|
45
|
+
<button
|
|
46
|
+
onClick={this._toggleExpanded}
|
|
47
|
+
className="collapsible-summary"
|
|
48
|
+
type="button"
|
|
49
|
+
aria-expanded={this.state.isExpanded ? true : false}
|
|
50
|
+
>
|
|
51
|
+
{this._renderShowButton()}
|
|
52
|
+
{this._renderHideButton()}
|
|
53
|
+
</button>
|
|
54
|
+
|
|
55
|
+
<div className="collapsible-details" hidden={isHidden}>
|
|
56
|
+
{isArray ? (
|
|
57
|
+
<ul className="items">
|
|
58
|
+
{this.props.content.map((c) => (
|
|
59
|
+
<li key={c.contentTitle}>
|
|
60
|
+
<p>
|
|
61
|
+
<b>{c.contentTitle}</b>
|
|
62
|
+
</p>
|
|
63
|
+
<p>{c.content}</p>
|
|
64
|
+
</li>
|
|
65
|
+
))}
|
|
66
|
+
</ul>
|
|
67
|
+
) : (
|
|
68
|
+
<div>
|
|
69
|
+
<p>
|
|
70
|
+
<b>{this.props.contentTitle}</b>
|
|
71
|
+
</p>
|
|
72
|
+
<p>{this.props.content}</p>
|
|
73
|
+
</div>
|
|
74
|
+
)}
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
Collapsible.propTypes = {
|
|
82
|
+
showLabel: PropTypes.string.isRequired,
|
|
83
|
+
hideLabel: PropTypes.string.isRequired,
|
|
84
|
+
content: PropTypes.oneOfType([PropTypes.array, PropTypes.string]).isRequired,
|
|
85
|
+
contentTitle: PropTypes.string,
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export default Collapsible;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Collapsible from "./Collapsible";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
|
|
5
|
+
const ErrorUI = (props) => {
|
|
6
|
+
let errorTitle = `${props.type || "Error"} ${props.code || ""}`;
|
|
7
|
+
let errorDetails = props.message;
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<section className="page-error">
|
|
11
|
+
<div className="responsive-container">
|
|
12
|
+
<h1>We’re sorry.</h1>
|
|
13
|
+
<p className="h2">We cannot access this page.</p>
|
|
14
|
+
<Collapsible
|
|
15
|
+
showLabel="Open technical details about the error"
|
|
16
|
+
hideLabel="Close technical details about the error"
|
|
17
|
+
contentTitle={errorTitle}
|
|
18
|
+
content={errorDetails}
|
|
19
|
+
/>
|
|
20
|
+
</div>
|
|
21
|
+
</section>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
ErrorUI.propTypes = {
|
|
26
|
+
code: PropTypes.string,
|
|
27
|
+
message: PropTypes.oneOfType([PropTypes.array, PropTypes.string]),
|
|
28
|
+
type: PropTypes.string,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default ErrorUI;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "react-dom";
|
|
3
|
+
import ErrorUI from "./ErrorUI";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Renders the QPP Error Page content.
|
|
7
|
+
*/
|
|
8
|
+
export default class ErrorPage {
|
|
9
|
+
/**
|
|
10
|
+
* @param {Object} options - An object containing content and config data
|
|
11
|
+
* @param {String} options.type - The error type
|
|
12
|
+
* @param {String} options.code - The error code
|
|
13
|
+
* @param {String} options.message - The error message
|
|
14
|
+
* @param {HTMLElement} options.rootElement - Elem inside which to render
|
|
15
|
+
*/
|
|
16
|
+
constructor(options) {
|
|
17
|
+
render(
|
|
18
|
+
<ErrorUI
|
|
19
|
+
type={options.type}
|
|
20
|
+
code={options.code}
|
|
21
|
+
message={options.message}
|
|
22
|
+
/>,
|
|
23
|
+
options.rootElement,
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
}
|