@opentripplanner/trip-details 2.2.8 → 2.2.9
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/esm/index.js +3 -1
- package/esm/index.js.map +1 -1
- package/esm/styled.js +3 -5
- package/esm/styled.js.map +1 -1
- package/esm/trip-detail.js +64 -63
- package/esm/trip-detail.js.map +1 -1
- package/i18n/en-US.yml +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/styled.d.ts +2 -4
- package/lib/styled.d.ts.map +1 -1
- package/lib/styled.js +3 -5
- package/lib/styled.js.map +1 -1
- package/lib/trip-detail.d.ts +3 -12
- package/lib/trip-detail.d.ts.map +1 -1
- package/lib/trip-detail.js +65 -51
- package/lib/trip-detail.js.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +2 -1
- package/src/styled.ts +3 -4
- package/src/trip-detail.tsx +70 -47
- package/tsconfig.tsbuildinfo +1 -1
package/lib/trip-detail.d.ts
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactElement } from "react";
|
|
2
2
|
declare type Props = {
|
|
3
3
|
description?: ReactElement | string;
|
|
4
4
|
icon: ReactElement;
|
|
5
5
|
summary: ReactElement | string;
|
|
6
6
|
};
|
|
7
|
-
declare
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
export default class TripDetail extends Component<Props, State> {
|
|
11
|
-
constructor(props: Props);
|
|
12
|
-
toggle: () => void;
|
|
13
|
-
onExpandClick: () => void;
|
|
14
|
-
onHideClick: () => void;
|
|
15
|
-
render(): ReactElement;
|
|
16
|
-
}
|
|
17
|
-
export {};
|
|
7
|
+
declare const TripDetail: ({ icon, summary, description }: Props) => JSX.Element;
|
|
8
|
+
export default TripDetail;
|
|
18
9
|
//# sourceMappingURL=trip-detail.d.ts.map
|
package/lib/trip-detail.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trip-detail.d.ts","sourceRoot":"","sources":["../src/trip-detail.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"trip-detail.d.ts","sourceRoot":"","sources":["../src/trip-detail.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAQtD,aAAK,KAAK,GAAG;IACX,WAAW,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC;IACpC,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,EAAE,YAAY,GAAG,MAAM,CAAC;CAChC,CAAC;AAsBF,QAAA,MAAM,UAAU,mCAAoC,KAAK,KAAG,WAmD3D,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
package/lib/trip-detail.js
CHANGED
|
@@ -15,64 +15,78 @@ var _TimesCircle = require("@styled-icons/fa-solid/TimesCircle");
|
|
|
15
15
|
|
|
16
16
|
var _reactAnimateHeight = _interopRequireDefault(require("react-animate-height"));
|
|
17
17
|
|
|
18
|
+
var _reactIntl = require("react-intl");
|
|
19
|
+
|
|
18
20
|
var S = _interopRequireWildcard(require("./styled"));
|
|
19
21
|
|
|
20
22
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
23
|
|
|
22
24
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
this.onHideClick = () => {
|
|
42
|
-
this.setState({
|
|
43
|
-
expanded: false
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
this.state = {
|
|
48
|
-
expanded: false
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
render() {
|
|
53
|
-
const {
|
|
54
|
-
icon,
|
|
55
|
-
summary,
|
|
56
|
-
description
|
|
57
|
-
} = this.props;
|
|
58
|
-
const {
|
|
59
|
-
expanded
|
|
60
|
-
} = this.state;
|
|
61
|
-
return /*#__PURE__*/_react.default.createElement(S.TripDetail, null, /*#__PURE__*/_react.default.createElement(S.TripDetailIcon, null, icon), /*#__PURE__*/_react.default.createElement(S.TripDetailSummary, null, summary, description && /*#__PURE__*/_react.default.createElement(S.ExpandButton, {
|
|
62
|
-
onClick: this.toggle
|
|
63
|
-
}, /*#__PURE__*/_react.default.createElement(_QuestionCircle.QuestionCircle, {
|
|
64
|
-
size: "0.92em"
|
|
65
|
-
}))), /*#__PURE__*/_react.default.createElement(_reactAnimateHeight.default, {
|
|
66
|
-
duration: 300,
|
|
67
|
-
height: expanded ? "auto" : 0
|
|
68
|
-
}, /*#__PURE__*/_react.default.createElement(S.TripDetailDescription, null, /*#__PURE__*/_react.default.createElement(S.HideButton, {
|
|
69
|
-
onClick: this.onHideClick
|
|
70
|
-
}, /*#__PURE__*/_react.default.createElement(_TimesCircle.TimesCircle, {
|
|
71
|
-
size: "0.92em"
|
|
72
|
-
})), description)));
|
|
73
|
-
}
|
|
26
|
+
// TODO: Remove these two helper methods by moving to semantically correct HTML
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Copied from https://stackoverflow.com/questions/50940640/how-to-determine-if-jest-is-running-the-code-or-not
|
|
30
|
+
*/
|
|
31
|
+
function isRunningJest() {
|
|
32
|
+
return process.env.JEST_WORKER_ID !== undefined;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function uuidv4() {
|
|
36
|
+
if (isRunningJest()) return "mocked-random-id";
|
|
37
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
|
38
|
+
// eslint-disable-next-line no-bitwise
|
|
39
|
+
const r = Math.random() * 16 | 0; // eslint-disable-next-line no-bitwise
|
|
74
40
|
|
|
41
|
+
const v = c === "x" ? r : r & 0x3 | 0x8;
|
|
42
|
+
return v.toString(16);
|
|
43
|
+
});
|
|
75
44
|
}
|
|
76
45
|
|
|
77
|
-
|
|
46
|
+
const TripDetail = ({
|
|
47
|
+
icon,
|
|
48
|
+
summary,
|
|
49
|
+
description
|
|
50
|
+
}) => {
|
|
51
|
+
const intl = (0, _reactIntl.useIntl)();
|
|
52
|
+
const [expanded, setExpanded] = (0, _react.useState)(false);
|
|
53
|
+
const id = uuidv4();
|
|
54
|
+
|
|
55
|
+
const toggle = () => {
|
|
56
|
+
setExpanded(!expanded);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return /*#__PURE__*/_react.default.createElement(S.TripDetail, {
|
|
60
|
+
role: "group"
|
|
61
|
+
}, /*#__PURE__*/_react.default.createElement(S.TripDetailIcon, {
|
|
62
|
+
role: "presentation"
|
|
63
|
+
}, icon), /*#__PURE__*/_react.default.createElement(S.TripDetailSummary, null, summary, description && /*#__PURE__*/_react.default.createElement(S.ExpandButton, {
|
|
64
|
+
"aria-label": expanded ? intl.formatMessage({
|
|
65
|
+
id: "otpUi.TripDetails.hideDetail"
|
|
66
|
+
}) : intl.formatMessage({
|
|
67
|
+
id: "otpUi.TripDetails.showDetail"
|
|
68
|
+
}),
|
|
69
|
+
"aria-controls": id,
|
|
70
|
+
"aria-expanded": expanded,
|
|
71
|
+
id: "expand-button",
|
|
72
|
+
onClick: toggle,
|
|
73
|
+
tabIndex: 0
|
|
74
|
+
}, /*#__PURE__*/_react.default.createElement(_QuestionCircle.QuestionCircle, {
|
|
75
|
+
size: "0.92em"
|
|
76
|
+
}))), /*#__PURE__*/_react.default.createElement(_reactAnimateHeight.default, {
|
|
77
|
+
duration: 300,
|
|
78
|
+
height: expanded ? "auto" : 0
|
|
79
|
+
}, /*#__PURE__*/_react.default.createElement(S.TripDetailDescription, {
|
|
80
|
+
"aria-labelledby": "expand-button",
|
|
81
|
+
id: id
|
|
82
|
+
}, /*#__PURE__*/_react.default.createElement(S.HideButton, {
|
|
83
|
+
role: "presentation",
|
|
84
|
+
onClick: () => setExpanded(false)
|
|
85
|
+
}, /*#__PURE__*/_react.default.createElement(_TimesCircle.TimesCircle, {
|
|
86
|
+
size: "0.92em"
|
|
87
|
+
})), description)));
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
var _default = TripDetail;
|
|
91
|
+
exports.default = _default;
|
|
78
92
|
//# sourceMappingURL=trip-detail.js.map
|
package/lib/trip-detail.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/trip-detail.tsx"],"names":["
|
|
1
|
+
{"version":3,"sources":["../src/trip-detail.tsx"],"names":["isRunningJest","process","env","JEST_WORKER_ID","undefined","uuidv4","replace","c","r","Math","random","v","toString","TripDetail","icon","summary","description","intl","expanded","setExpanded","id","toggle","formatMessage"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;AAQA;;AACA;AACA;AACA;AACA,SAASA,aAAT,GAAyB;AACvB,SAAOC,OAAO,CAACC,GAAR,CAAYC,cAAZ,KAA+BC,SAAtC;AACD;;AAED,SAASC,MAAT,GAA0B;AACxB,MAAIL,aAAa,EAAjB,EAAqB,OAAO,kBAAP;AAErB,SAAO,uCAAuCM,OAAvC,CAA+C,OAA/C,EAAwD,UAASC,CAAT,EAAY;AACzE;AACA,UAAMC,CAAC,GAAIC,IAAI,CAACC,MAAL,KAAgB,EAAjB,GAAuB,CAAjC,CAFyE,CAGzE;;AACA,UAAMC,CAAC,GAAGJ,CAAC,KAAK,GAAN,GAAYC,CAAZ,GAAiBA,CAAC,GAAG,GAAL,GAAY,GAAtC;AACA,WAAOG,CAAC,CAACC,QAAF,CAAW,EAAX,CAAP;AACD,GANM,CAAP;AAOD;;AAED,MAAMC,UAAU,GAAG,CAAC;AAAEC,EAAAA,IAAF;AAAQC,EAAAA,OAAR;AAAiBC,EAAAA;AAAjB,CAAD,KAAwD;AACzE,QAAMC,IAAI,GAAG,yBAAb;AACA,QAAM,CAACC,QAAD,EAAWC,WAAX,IAA0B,qBAAS,KAAT,CAAhC;AAEA,QAAMC,EAAE,GAAGf,MAAM,EAAjB;;AAEA,QAAMgB,MAAM,GAAG,MAAY;AACzBF,IAAAA,WAAW,CAAC,CAACD,QAAF,CAAX;AACD,GAFD;;AAIA,sBACE,6BAAC,CAAD,CAAG,UAAH;AAAc,IAAA,IAAI,EAAC;AAAnB,kBACE,6BAAC,CAAD,CAAG,cAAH;AAAkB,IAAA,IAAI,EAAC;AAAvB,KAAuCJ,IAAvC,CADF,eAIE,6BAAC,CAAD,CAAG,iBAAH,QACGC,OADH,EAEGC,WAAW,iBACV,6BAAC,CAAD,CAAG,YAAH;AACE,kBACEE,QAAQ,GACJD,IAAI,CAACK,aAAL,CAAmB;AACjBF,MAAAA,EAAE,EAAE;AADa,KAAnB,CADI,GAIJH,IAAI,CAACK,aAAL,CAAmB;AACjBF,MAAAA,EAAE,EAAE;AADa,KAAnB,CANR;AAUE,qBAAeA,EAVjB;AAWE,qBAAeF,QAXjB;AAYE,IAAA,EAAE,EAAC,eAZL;AAaE,IAAA,OAAO,EAAEG,MAbX;AAcE,IAAA,QAAQ,EAAE;AAdZ,kBAgBE,6BAAC,8BAAD;AAAgB,IAAA,IAAI,EAAC;AAArB,IAhBF,CAHJ,CAJF,eA2BE,6BAAC,2BAAD;AAAe,IAAA,QAAQ,EAAE,GAAzB;AAA8B,IAAA,MAAM,EAAEH,QAAQ,GAAG,MAAH,GAAY;AAA1D,kBACE,6BAAC,CAAD,CAAG,qBAAH;AAAyB,uBAAgB,eAAzC;AAAyD,IAAA,EAAE,EAAEE;AAA7D,kBAIE,6BAAC,CAAD,CAAG,UAAH;AAAc,IAAA,IAAI,EAAC,cAAnB;AAAkC,IAAA,OAAO,EAAE,MAAMD,WAAW,CAAC,KAAD;AAA5D,kBACE,6BAAC,wBAAD;AAAa,IAAA,IAAI,EAAC;AAAlB,IADF,CAJF,EAOGH,WAPH,CADF,CA3BF,CADF;AAyCD,CAnDD;;eAqDeH,U","sourcesContent":["import React, { ReactElement, useState } from \"react\";\nimport { QuestionCircle } from \"@styled-icons/fa-solid/QuestionCircle\";\nimport { TimesCircle } from \"@styled-icons/fa-solid/TimesCircle\";\n\nimport AnimateHeight from \"react-animate-height\";\nimport { useIntl } from \"react-intl\";\nimport * as S from \"./styled\";\n\ntype Props = {\n description?: ReactElement | string;\n icon: ReactElement;\n summary: ReactElement | string;\n};\n\n// TODO: Remove these two helper methods by moving to semantically correct HTML\n/**\n * Copied from https://stackoverflow.com/questions/50940640/how-to-determine-if-jest-is-running-the-code-or-not\n */\nfunction isRunningJest() {\n return process.env.JEST_WORKER_ID !== undefined;\n}\n\nfunction uuidv4(): string {\n if (isRunningJest()) return \"mocked-random-id\";\n\n return \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, function(c) {\n // eslint-disable-next-line no-bitwise\n const r = (Math.random() * 16) | 0;\n // eslint-disable-next-line no-bitwise\n const v = c === \"x\" ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\n\nconst TripDetail = ({ icon, summary, description }: Props): JSX.Element => {\n const intl = useIntl();\n const [expanded, setExpanded] = useState(false);\n\n const id = uuidv4();\n\n const toggle = (): void => {\n setExpanded(!expanded);\n };\n\n return (\n <S.TripDetail role=\"group\">\n <S.TripDetailIcon role=\"presentation\">{icon}</S.TripDetailIcon>\n {/* TODO: Adjust the summary and description to be a `summary`/`details` pair, therefore semantically correct */}\n {/* https://github.com/opentripplanner/otp-ui/pull/530#discussion_r1074006057 */}\n <S.TripDetailSummary>\n {summary}\n {description && (\n <S.ExpandButton\n aria-label={\n expanded\n ? intl.formatMessage({\n id: \"otpUi.TripDetails.hideDetail\"\n })\n : intl.formatMessage({\n id: \"otpUi.TripDetails.showDetail\"\n })\n }\n aria-controls={id}\n aria-expanded={expanded}\n id=\"expand-button\"\n onClick={toggle}\n tabIndex={0}\n >\n <QuestionCircle size=\"0.92em\" />\n </S.ExpandButton>\n )}\n </S.TripDetailSummary>\n <AnimateHeight duration={300} height={expanded ? \"auto\" : 0}>\n <S.TripDetailDescription aria-labelledby=\"expand-button\" id={id}>\n {/** This button isn't needed for screen readers as the main expand-button is\n * more convenient.\n */}\n <S.HideButton role=\"presentation\" onClick={() => setExpanded(false)}>\n <TimesCircle size=\"0.92em\" />\n </S.HideButton>\n {description}\n </S.TripDetailDescription>\n </AnimateHeight>\n </S.TripDetail>\n );\n};\n\nexport default TripDetail;\n"],"file":"trip-detail.js"}
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -258,7 +258,8 @@ export function TripDetails({
|
|
|
258
258
|
|
|
259
259
|
return (
|
|
260
260
|
<S.TripDetails className={className}>
|
|
261
|
-
|
|
261
|
+
{/* this can be presentation as S.TripDetails is already labeled by this */}
|
|
262
|
+
<S.TripDetailsHeader id="trip-details-header">
|
|
262
263
|
<FormattedMessage
|
|
263
264
|
defaultMessage={defaultMessages["otpUi.TripDetails.title"]}
|
|
264
265
|
description="Title (heading) text of the component."
|
package/src/styled.ts
CHANGED
|
@@ -25,9 +25,7 @@ export const CO2Description = styled.span``;
|
|
|
25
25
|
|
|
26
26
|
export const CO2Summary = styled.span``;
|
|
27
27
|
|
|
28
|
-
export const ExpandButton = styled(BaseButton)
|
|
29
|
-
"aria-label": "What does this mean?"
|
|
30
|
-
})`
|
|
28
|
+
export const ExpandButton = styled(BaseButton)`
|
|
31
29
|
color: #00f;
|
|
32
30
|
font-size: 16px;
|
|
33
31
|
margin-left: 6px;
|
|
@@ -89,9 +87,10 @@ export const TripDetails = styled.div`
|
|
|
89
87
|
|
|
90
88
|
export const TripDetailsBody = styled.div``;
|
|
91
89
|
|
|
92
|
-
export const TripDetailsHeader = styled.
|
|
90
|
+
export const TripDetailsHeader = styled.h2`
|
|
93
91
|
font-size: 18px;
|
|
94
92
|
font-weight: 600;
|
|
93
|
+
margin: 0;
|
|
95
94
|
`;
|
|
96
95
|
|
|
97
96
|
export const TripDetailSummary = styled.div`
|
package/src/trip-detail.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { ReactElement, useState } from "react";
|
|
2
2
|
import { QuestionCircle } from "@styled-icons/fa-solid/QuestionCircle";
|
|
3
3
|
import { TimesCircle } from "@styled-icons/fa-solid/TimesCircle";
|
|
4
4
|
|
|
5
5
|
import AnimateHeight from "react-animate-height";
|
|
6
|
+
import { useIntl } from "react-intl";
|
|
6
7
|
import * as S from "./styled";
|
|
7
8
|
|
|
8
9
|
type Props = {
|
|
@@ -11,55 +12,77 @@ type Props = {
|
|
|
11
12
|
summary: ReactElement | string;
|
|
12
13
|
};
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
// TODO: Remove these two helper methods by moving to semantically correct HTML
|
|
16
|
+
/**
|
|
17
|
+
* Copied from https://stackoverflow.com/questions/50940640/how-to-determine-if-jest-is-running-the-code-or-not
|
|
18
|
+
*/
|
|
19
|
+
function isRunningJest() {
|
|
20
|
+
return process.env.JEST_WORKER_ID !== undefined;
|
|
21
|
+
}
|
|
17
22
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
super(props);
|
|
21
|
-
this.state = {
|
|
22
|
-
expanded: false
|
|
23
|
-
};
|
|
24
|
-
}
|
|
23
|
+
function uuidv4(): string {
|
|
24
|
+
if (isRunningJest()) return "mocked-random-id";
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
27
|
+
// eslint-disable-next-line no-bitwise
|
|
28
|
+
const r = (Math.random() * 16) | 0;
|
|
29
|
+
// eslint-disable-next-line no-bitwise
|
|
30
|
+
const v = c === "x" ? r : (r & 0x3) | 0x8;
|
|
31
|
+
return v.toString(16);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
31
34
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
const TripDetail = ({ icon, summary, description }: Props): JSX.Element => {
|
|
36
|
+
const intl = useIntl();
|
|
37
|
+
const [expanded, setExpanded] = useState(false);
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
const id = uuidv4();
|
|
40
|
+
|
|
41
|
+
const toggle = (): void => {
|
|
42
|
+
setExpanded(!expanded);
|
|
38
43
|
};
|
|
39
44
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
45
|
+
return (
|
|
46
|
+
<S.TripDetail role="group">
|
|
47
|
+
<S.TripDetailIcon role="presentation">{icon}</S.TripDetailIcon>
|
|
48
|
+
{/* TODO: Adjust the summary and description to be a `summary`/`details` pair, therefore semantically correct */}
|
|
49
|
+
{/* https://github.com/opentripplanner/otp-ui/pull/530#discussion_r1074006057 */}
|
|
50
|
+
<S.TripDetailSummary>
|
|
51
|
+
{summary}
|
|
52
|
+
{description && (
|
|
53
|
+
<S.ExpandButton
|
|
54
|
+
aria-label={
|
|
55
|
+
expanded
|
|
56
|
+
? intl.formatMessage({
|
|
57
|
+
id: "otpUi.TripDetails.hideDetail"
|
|
58
|
+
})
|
|
59
|
+
: intl.formatMessage({
|
|
60
|
+
id: "otpUi.TripDetails.showDetail"
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
aria-controls={id}
|
|
64
|
+
aria-expanded={expanded}
|
|
65
|
+
id="expand-button"
|
|
66
|
+
onClick={toggle}
|
|
67
|
+
tabIndex={0}
|
|
68
|
+
>
|
|
69
|
+
<QuestionCircle size="0.92em" />
|
|
70
|
+
</S.ExpandButton>
|
|
71
|
+
)}
|
|
72
|
+
</S.TripDetailSummary>
|
|
73
|
+
<AnimateHeight duration={300} height={expanded ? "auto" : 0}>
|
|
74
|
+
<S.TripDetailDescription aria-labelledby="expand-button" id={id}>
|
|
75
|
+
{/** This button isn't needed for screen readers as the main expand-button is
|
|
76
|
+
* more convenient.
|
|
77
|
+
*/}
|
|
78
|
+
<S.HideButton role="presentation" onClick={() => setExpanded(false)}>
|
|
79
|
+
<TimesCircle size="0.92em" />
|
|
80
|
+
</S.HideButton>
|
|
81
|
+
{description}
|
|
82
|
+
</S.TripDetailDescription>
|
|
83
|
+
</AnimateHeight>
|
|
84
|
+
</S.TripDetail>
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export default TripDetail;
|