@opentripplanner/building-blocks 3.0.2-alpha.1 → 3.1.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.
Files changed (42) hide show
  1. package/README.md +0 -4
  2. package/esm/alert/Alert.js +2 -1
  3. package/esm/alert/Alert.js.map +1 -1
  4. package/esm/index.js +2 -1
  5. package/esm/index.js.map +1 -1
  6. package/lib/alert/Alert.d.ts +3 -4
  7. package/lib/alert/Alert.d.ts.map +1 -1
  8. package/lib/alert/Alert.js +72 -103
  9. package/lib/alert/Alert.js.map +1 -1
  10. package/lib/colors/blue.js +18 -14
  11. package/lib/colors/blue.js.map +1 -1
  12. package/lib/colors/grey.js +18 -14
  13. package/lib/colors/grey.js.map +1 -1
  14. package/lib/colors/red.js +18 -14
  15. package/lib/colors/red.js.map +1 -1
  16. package/lib/dropdown/index.d.ts.map +1 -1
  17. package/lib/dropdown/index.js +101 -87
  18. package/lib/dropdown/index.js.map +1 -1
  19. package/lib/dropdown/styled.js +19 -72
  20. package/lib/dropdown/styled.js.map +1 -1
  21. package/lib/focus-trap-wrapper/dom-query.js +36 -20
  22. package/lib/focus-trap-wrapper/dom-query.js.map +1 -1
  23. package/lib/focus-trap-wrapper/index.d.ts.map +1 -1
  24. package/lib/focus-trap-wrapper/index.js +50 -52
  25. package/lib/focus-trap-wrapper/index.js.map +1 -1
  26. package/lib/index.d.ts +2 -1
  27. package/lib/index.d.ts.map +1 -1
  28. package/lib/index.js +47 -36
  29. package/lib/index.js.map +1 -1
  30. package/lib/stories/ColorPalette.d.ts +0 -1
  31. package/lib/stories/ColorPalette.d.ts.map +1 -1
  32. package/lib/stories/ColorPalette.js +26 -37
  33. package/lib/stories/ColorPalette.js.map +1 -1
  34. package/package.json +3 -3
  35. package/src/alert/Alert.tsx +11 -8
  36. package/src/index.ts +8 -1
  37. package/src/stories/__snapshots__/alerts.story.tsx.snap +88 -83
  38. package/src/stories/__snapshots__/dropdown.story.tsx.snap +1 -1
  39. package/src/stories/__snapshots__/focusTrapStory.story.tsx.snap +1 -1
  40. package/src/stories/__snapshots__/index.story.tsx.snap +1 -1
  41. package/src/stories/alerts.story.tsx +23 -14
  42. package/tsconfig.tsbuildinfo +1 -1
package/lib/index.js CHANGED
@@ -1,40 +1,51 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
17
6
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ Object.defineProperty(exports, "Alert", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _Alert.default;
11
+ }
12
+ });
13
+ Object.defineProperty(exports, "Dropdown", {
14
+ enumerable: true,
15
+ get: function () {
16
+ return _dropdown.default;
17
+ }
18
+ });
19
+ Object.defineProperty(exports, "FocusTrapWrapper", {
20
+ enumerable: true,
21
+ get: function () {
22
+ return _focusTrapWrapper.default;
23
+ }
24
+ });
25
+ exports.default = void 0;
26
+ Object.defineProperty(exports, "getNextSibling", {
27
+ enumerable: true,
28
+ get: function () {
29
+ return _focusTrapWrapper.getNextSibling;
30
+ }
31
+ });
32
+ Object.defineProperty(exports, "getPreviousSibling", {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _focusTrapWrapper.getPreviousSibling;
36
+ }
37
+ });
38
+ var _blue = _interopRequireDefault(require("./colors/blue"));
39
+ var _red = _interopRequireDefault(require("./colors/red"));
40
+ var _grey = _interopRequireDefault(require("./colors/grey"));
41
+ var _dropdown = _interopRequireDefault(require("./dropdown"));
42
+ var _focusTrapWrapper = _interopRequireWildcard(require("./focus-trap-wrapper"));
43
+ var _Alert = _interopRequireDefault(require("./alert/Alert"));
44
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
45
+ // TODO: Fix exports
46
+ var _default = exports.default = {
47
+ blue: _blue.default,
48
+ red: _red.default,
49
+ grey: _grey.default
27
50
  };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.getPreviousSibling = exports.getNextSibling = exports.FocusTrapWrapper = exports.Dropdown = void 0;
30
- const blue_1 = __importDefault(require("./colors/blue"));
31
- const red_1 = __importDefault(require("./colors/red"));
32
- const grey_1 = __importDefault(require("./colors/grey"));
33
- const dropdown_1 = __importDefault(require("./dropdown"));
34
- exports.Dropdown = dropdown_1.default;
35
- const focus_trap_wrapper_1 = __importStar(require("./focus-trap-wrapper"));
36
- exports.FocusTrapWrapper = focus_trap_wrapper_1.default;
37
- Object.defineProperty(exports, "getNextSibling", { enumerable: true, get: function () { return focus_trap_wrapper_1.getNextSibling; } });
38
- Object.defineProperty(exports, "getPreviousSibling", { enumerable: true, get: function () { return focus_trap_wrapper_1.getPreviousSibling; } });
39
- exports.default = { blue: blue_1.default, red: red_1.default, grey: grey_1.default };
40
51
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAAiC;AACjC,uDAA+B;AAC/B,yDAAiC;AACjC,0DAAkC;AAOzB,mBAPF,kBAAQ,CAOE;AANjB,2EAG8B;AAGX,2BANZ,4BAAgB,CAMY;AAAE,+FALnC,mCAAc,OAKmC;AAAE,mGAJnD,uCAAkB,OAImD;AACvE,kBAAe,EAAE,IAAI,EAAJ,cAAI,EAAE,GAAG,EAAH,aAAG,EAAE,IAAI,EAAJ,cAAI,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","names":["_blue","_interopRequireDefault","require","_red","_grey","_dropdown","_focusTrapWrapper","_interopRequireWildcard","_Alert","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_default","exports","blue","red","grey"],"sources":["../src/index.ts"],"sourcesContent":["import blue from \"./colors/blue\";\nimport red from \"./colors/red\";\nimport grey from \"./colors/grey\";\nimport Dropdown from \"./dropdown\";\nimport FocusTrapWrapper, {\n getNextSibling,\n getPreviousSibling\n} from \"./focus-trap-wrapper\";\nimport Alert from \"./alert/Alert\";\n\n// TODO: Fix exports\nexport {\n Alert,\n Dropdown,\n FocusTrapWrapper,\n getNextSibling,\n getPreviousSibling\n};\nexport default { blue, red, grey };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,SAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,iBAAA,GAAAC,uBAAA,CAAAL,OAAA;AAIA,IAAAM,MAAA,GAAAP,sBAAA,CAAAC,OAAA;AAAkC,SAAAK,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ,uBAAA,YAAAA,CAAAE,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAElC;AAAA,IAAAkB,QAAA,GAAAC,OAAA,CAAAV,OAAA,GAQe;EAAEW,IAAI,EAAJA,aAAI;EAAEC,GAAG,EAAHA,YAAG;EAAEC,IAAI,EAAJA;AAAK,CAAC","ignoreList":[]}
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export interface Hue {
3
2
  [key: number]: string;
4
3
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ColorPalette.d.ts","sourceRoot":"","sources":["../../src/stories/ColorPalette.tsx"],"names":[],"mappings":";AAOA,MAAM,WAAW,GAAG;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB;AAED,UAAU,KAAK;IACb,KAAK,EAAE,GAAG,CAAC;CACZ;AA0BD,QAAA,MAAM,YAAY,cAAe,KAAK,KAAG,WAiBxC,CAAC;AACF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"ColorPalette.d.ts","sourceRoot":"","sources":["../../src/stories/ColorPalette.tsx"],"names":[],"mappings":"AAOA,MAAM,WAAW,GAAG;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB;AAED,UAAU,KAAK;IACb,KAAK,EAAE,GAAG,CAAC;CACZ;AA0BD,QAAA,MAAM,YAAY,GAAI,WAAW,KAAK,KAAG,GAAG,CAAC,OAiB5C,CAAC;AACF,eAAe,YAAY,CAAC"}
@@ -1,41 +1,30 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const react_1 = __importDefault(require("react"));
7
- const styled_components_1 = __importDefault(require("styled-components"));
8
- const core_utils_1 = __importDefault(require("@opentripplanner/core-utils"));
9
- const { getMostReadableTextColor } = core_utils_1.default.route;
10
- const ColorBlock = styled_components_1.default.div `
11
- align-items: center;
12
- background-color: ${props => props.hex};
13
- color: ${props => getMostReadableTextColor(props.hex, "#ffffff")};
14
- text-shadow: ${props => getMostReadableTextColor(props.hex, "#ffffff") === "#ffffff"
15
- ? "1px 1px 2px black"
16
- : ""};
17
- display: flex;
18
- font-family: Arial, Helvetica, sans-serif;
19
- height: 40px;
20
- justify-content: space-between;
21
- margin: 0;
22
- padding: 10px;
23
- width: 300px;
24
2
 
25
- &:first-of-type {
26
- border-radius: 8px 8px 0 0;
27
- }
28
- &:last-of-type {
29
- border-radius: 0 0 8px 8px;
30
- }
31
- `;
32
- const ColorPalette = ({ color }) => {
33
- const colorArray = Object.entries(color);
34
- return (react_1.default.createElement(react_1.default.Fragment, null, colorArray.map((hue) => {
35
- return (react_1.default.createElement(ColorBlock, { key: hue[0], hex: hue[1] },
36
- react_1.default.createElement("p", null, hue[0]),
37
- react_1.default.createElement("p", null, hue[1])));
38
- })));
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
10
+ var _coreUtils = _interopRequireDefault(require("@opentripplanner/core-utils"));
11
+ const {
12
+ getMostReadableTextColor
13
+ } = _coreUtils.default.route;
14
+ const ColorBlock = _styledComponents.default.div.withConfig({
15
+ displayName: "ColorPalette__ColorBlock",
16
+ componentId: "sc-fil65c-0"
17
+ })(["align-items:center;background-color:", ";color:", ";text-shadow:", ";display:flex;font-family:Arial,Helvetica,sans-serif;height:40px;justify-content:space-between;margin:0;padding:10px;width:300px;&:first-of-type{border-radius:8px 8px 0 0;}&:last-of-type{border-radius:0 0 8px 8px;}"], props => props.hex, props => getMostReadableTextColor(props.hex, "#ffffff"), props => getMostReadableTextColor(props.hex, "#ffffff") === "#ffffff" ? "1px 1px 2px black" : "");
18
+ const ColorPalette = ({
19
+ color
20
+ }) => {
21
+ const colorArray = Object.entries(color);
22
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, colorArray.map(hue => {
23
+ return /*#__PURE__*/_react.default.createElement(ColorBlock, {
24
+ key: hue[0],
25
+ hex: hue[1]
26
+ }, /*#__PURE__*/_react.default.createElement("p", null, hue[0]), /*#__PURE__*/_react.default.createElement("p", null, hue[1]));
27
+ }));
39
28
  };
40
- exports.default = ColorPalette;
29
+ var _default = exports.default = ColorPalette;
41
30
  //# sourceMappingURL=ColorPalette.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ColorPalette.js","sourceRoot":"","sources":["../../src/stories/ColorPalette.tsx"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAE1B,0EAAuC;AACvC,6EAAoD;AAEpD,MAAM,EAAE,wBAAwB,EAAE,GAAG,oBAAS,CAAC,KAAK,CAAC;AAUrD,MAAM,UAAU,GAAG,2BAAM,CAAC,GAAG,CAAiB;;sBAExB,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG;WAC7B,KAAK,CAAC,EAAE,CAAC,wBAAwB,CAAC,KAAK,CAAC,GAAG,EAAE,SAAS,CAAC;iBACjD,KAAK,CAAC,EAAE,CACrB,wBAAwB,CAAC,KAAK,CAAC,GAAG,EAAE,SAAS,CAAC,KAAK,SAAS;IAC1D,CAAC,CAAC,mBAAmB;IACrB,CAAC,CAAC,EAAE;;;;;;;;;;;;;;;CAeT,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,EAAE,KAAK,EAAS,EAAe,EAAE;IACrD,MAAM,UAAU,GAAe,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAErD,OAAO,CACL,8DACG,UAAU,CAAC,GAAG,CACb,CAAC,GAAQ,EAAe,EAAE;QACxB,OAAO,CACL,8BAAC,UAAU,IAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;YAClC,yCAAI,GAAG,CAAC,CAAC,CAAC,CAAK;YACf,yCAAI,GAAG,CAAC,CAAC,CAAC,CAAK,CACJ,CACd,CAAC;IACJ,CAAC,CACF,CACA,CACJ,CAAC;AACJ,CAAC,CAAC;AACF,kBAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"ColorPalette.js","names":["_react","_interopRequireDefault","require","_styledComponents","_coreUtils","getMostReadableTextColor","coreUtils","route","ColorBlock","styled","div","withConfig","displayName","componentId","props","hex","ColorPalette","color","colorArray","Object","entries","default","createElement","Fragment","map","hue","key","_default","exports"],"sources":["../../src/stories/ColorPalette.tsx"],"sourcesContent":["import React from \"react\";\n\nimport styled from \"styled-components\";\nimport coreUtils from \"@opentripplanner/core-utils\";\n\nconst { getMostReadableTextColor } = coreUtils.route;\n\nexport interface Hue {\n [key: number]: string;\n}\n\ninterface Props {\n color: Hue;\n}\n\nconst ColorBlock = styled.div<{ hex: string }>`\n align-items: center;\n background-color: ${props => props.hex};\n color: ${props => getMostReadableTextColor(props.hex, \"#ffffff\")};\n text-shadow: ${props =>\n getMostReadableTextColor(props.hex, \"#ffffff\") === \"#ffffff\"\n ? \"1px 1px 2px black\"\n : \"\"};\n display: flex;\n font-family: Arial, Helvetica, sans-serif;\n height: 40px;\n justify-content: space-between;\n margin: 0;\n padding: 10px;\n width: 300px;\n\n &:first-of-type {\n border-radius: 8px 8px 0 0;\n }\n &:last-of-type {\n border-radius: 0 0 8px 8px;\n }\n`;\n\nconst ColorPalette = ({ color }: Props): JSX.Element => {\n const colorArray: Array<Hue> = Object.entries(color);\n\n return (\n <>\n {colorArray.map(\n (hue: Hue): JSX.Element => {\n return (\n <ColorBlock key={hue[0]} hex={hue[1]}>\n <p>{hue[0]}</p>\n <p>{hue[1]}</p>\n </ColorBlock>\n );\n }\n )}\n </>\n );\n};\nexport default ColorPalette;\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,UAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,MAAM;EAAEG;AAAyB,CAAC,GAAGC,kBAAS,CAACC,KAAK;AAUpD,MAAMC,UAAU,GAAGC,yBAAM,CAACC,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,mSAEPC,KAAK,IAAIA,KAAK,CAACC,GAAG,EAC7BD,KAAK,IAAIT,wBAAwB,CAACS,KAAK,CAACC,GAAG,EAAE,SAAS,CAAC,EACjDD,KAAK,IAClBT,wBAAwB,CAACS,KAAK,CAACC,GAAG,EAAE,SAAS,CAAC,KAAK,SAAS,GACxD,mBAAmB,GACnB,EAAE,CAeT;AAED,MAAMC,YAAY,GAAGA,CAAC;EAAEC;AAAa,CAAC,KAAkB;EACtD,MAAMC,UAAsB,GAAGC,MAAM,CAACC,OAAO,CAACH,KAAK,CAAC;EAEpD,oBACEjB,MAAA,CAAAqB,OAAA,CAAAC,aAAA,CAAAtB,MAAA,CAAAqB,OAAA,CAAAE,QAAA,QACGL,UAAU,CAACM,GAAG,CACZC,GAAQ,IAAkB;IACzB,oBACEzB,MAAA,CAAAqB,OAAA,CAAAC,aAAA,CAACd,UAAU;MAACkB,GAAG,EAAED,GAAG,CAAC,CAAC,CAAE;MAACV,GAAG,EAAEU,GAAG,CAAC,CAAC;IAAE,gBACnCzB,MAAA,CAAAqB,OAAA,CAAAC,aAAA,YAAIG,GAAG,CAAC,CAAC,CAAK,CAAC,eACfzB,MAAA,CAAAqB,OAAA,CAAAC,aAAA,YAAIG,GAAG,CAAC,CAAC,CAAK,CACJ,CAAC;EAEjB,CACF,CACA,CAAC;AAEP,CAAC;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAP,OAAA,GACaL,YAAY","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentripplanner/building-blocks",
3
- "version": "3.0.2-alpha.1",
3
+ "version": "3.1.0",
4
4
  "description": "Styling and UI Component Library",
5
5
  "author": "@binh-dam-ibigroup",
6
6
  "homepage": "https://github.com/opentripplanner/otp-ui/#readme",
@@ -9,8 +9,8 @@
9
9
  "module": "esm/index.js",
10
10
  "private": false,
11
11
  "devDependencies": {
12
- "@opentripplanner/types": "9.0.0-alpha.1",
13
- "@opentripplanner/core-utils": "15.0.0-alpha.1"
12
+ "@opentripplanner/types": "8.3.1",
13
+ "@opentripplanner/core-utils": "15.0.0"
14
14
  },
15
15
  "peerDependencies": {
16
16
  "react": "^18.2.0",
@@ -1,4 +1,4 @@
1
- import React, { ReactChild, useState } from "react";
1
+ import React, { useState } from "react";
2
2
  import styled from "styled-components";
3
3
  import AnimateHeight from "react-animate-height";
4
4
  import { ChevronUp } from "@styled-icons/bootstrap/ChevronUp";
@@ -8,11 +8,13 @@ import { useIntl } from "react-intl";
8
8
  import blue from "../colors/blue";
9
9
 
10
10
  interface Props {
11
- alertHeader: string;
12
- alertSubheader?: string;
11
+ alertHeader: JSX.Element | string;
12
+ alertSubheader?: JSX.Element | string;
13
13
  backgroundColor?: string;
14
+ /* If true, adds a toggle that expands/collapses the alert content */
14
15
  collapsible?: boolean;
15
- children?: ReactChild;
16
+ children?: JSX.Element | string;
17
+ /* Icon displayed on Alert - default is Bell */
16
18
  Icon?: StyledIcon;
17
19
  }
18
20
 
@@ -26,17 +28,17 @@ const AlertContainer = styled.div<{
26
28
  display: grid;
27
29
  grid-template-columns: 50px auto auto;
28
30
  grid-template-rows: minmax(25px, auto) auto;
29
- max-width: 715px;
30
- padding: 1.5em 2em;
31
+ column-gap: 1em;
32
+ padding: 1.5em;
31
33
 
32
34
  svg {
33
35
  align-self: center;
34
36
  grid-column: 1;
35
37
  grid-row: 1 / span 2;
36
- justify-self: start;
38
+ justify-self: center;
37
39
  }
38
40
 
39
- button {
41
+ button.toggle-btn {
40
42
  background: transparent;
41
43
  border: none;
42
44
  width: 40px;
@@ -108,6 +110,7 @@ const Alert = ({
108
110
  {collapsible && (
109
111
  <button
110
112
  type="button"
113
+ className="toggle-btn"
111
114
  onClick={() => setExpandAlert(!expandAlert)}
112
115
  aria-label={label}
113
116
  title={label}
package/src/index.ts CHANGED
@@ -6,7 +6,14 @@ import FocusTrapWrapper, {
6
6
  getNextSibling,
7
7
  getPreviousSibling
8
8
  } from "./focus-trap-wrapper";
9
+ import Alert from "./alert/Alert";
9
10
 
10
11
  // TODO: Fix exports
11
- export { Dropdown, FocusTrapWrapper, getNextSibling, getPreviousSibling };
12
+ export {
13
+ Alert,
14
+ Dropdown,
15
+ FocusTrapWrapper,
16
+ getNextSibling,
17
+ getPreviousSibling
18
+ };
12
19
  export default { blue, red, grey };
@@ -1,35 +1,37 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
1
+ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2
2
 
3
3
  exports[`Building-Blocks/Alert BasicAlert smoke-test 1`] = `
4
- <div class="Alert__AlertContainer-sc-2vlo3n-0 bVfQIo">
5
- <svg viewbox="0 0 16 16"
6
- height="24"
7
- width="24"
8
- aria-hidden="true"
9
- focusable="false"
10
- fill="currentColor"
11
- xmlns="http://www.w3.org/2000/svg"
12
- class="StyledIconBase-sc-ea9ulj-0 ebjPRL"
13
- >
14
- <path d="M8 16a2 2 0 0 0 2-2H6a2 2 0 0 0 2 2zM8 1.918l-.797.161A4.002 4.002 0 0 0 4 6c0 .628-.134 2.197-.459 3.742-.16.767-.376 1.566-.663 2.258h10.244c-.287-.692-.502-1.49-.663-2.258C12.134 8.197 12 6.628 12 6a4.002 4.002 0 0 0-3.203-3.92L8 1.917zM14.22 12c.223.447.481.801.78 1H1c.299-.199.557-.553.78-1C2.68 10.2 3 6.88 3 6c0-2.42 1.72-4.44 4.005-4.901a1 1 0 1 1 1.99 0A5.002 5.002 0 0 1 13 6c0 .88.32 4.2 1.22 6z">
15
- </path>
16
- </svg>
17
- <span class="Alert__AlertHeader-sc-2vlo3n-2 fpauiN">
18
- Next trip starts on Wednesday April 17th
19
- </span>
20
- <span class="Alert__ButtonContainer-sc-2vlo3n-1 cKzYKK">
21
- </span>
22
- <span class="Alert__AlertHeader-sc-2vlo3n-2 Alert__AlertSubheader-sc-2vlo3n-3 fpauiN dYdxsJ">
23
- Trip is due to begin at 7:43 AM (Realtime monitoring will being at 7:13 AM)
24
- </span>
25
- <div class="Alert__AlertContent-sc-2vlo3n-4 UrwUS">
26
- <div aria-hidden="false"
27
- class="rah-static rah-static--height-auto "
28
- style="height: auto; overflow: visible;"
4
+ <div class="alertsstory__AlertContainer-sc-19s77d-0 fgnBDZ">
5
+ <div class="Alert__AlertContainer-sc-2vlo3n-0 bVfQIo">
6
+ <svg viewbox="0 0 16 16"
7
+ height="24"
8
+ width="24"
9
+ aria-hidden="true"
10
+ focusable="false"
11
+ fill="currentColor"
12
+ xmlns="http://www.w3.org/2000/svg"
13
+ class="StyledIconBase-sc-ea9ulj-0 ebjPRL"
29
14
  >
30
- <div>
31
- <div class="Alert__ContentPadding-sc-2vlo3n-5 isIayL">
32
- Here is more content
15
+ <path d="M8 16a2 2 0 0 0 2-2H6a2 2 0 0 0 2 2zM8 1.918l-.797.161A4.002 4.002 0 0 0 4 6c0 .628-.134 2.197-.459 3.742-.16.767-.376 1.566-.663 2.258h10.244c-.287-.692-.502-1.49-.663-2.258C12.134 8.197 12 6.628 12 6a4.002 4.002 0 0 0-3.203-3.92L8 1.917zM14.22 12c.223.447.481.801.78 1H1c.299-.199.557-.553.78-1C2.68 10.2 3 6.88 3 6c0-2.42 1.72-4.44 4.005-4.901a1 1 0 1 1 1.99 0A5.002 5.002 0 0 1 13 6c0 .88.32 4.2 1.22 6z">
16
+ </path>
17
+ </svg>
18
+ <span class="Alert__AlertHeader-sc-2vlo3n-2 fpauiN">
19
+ Next trip starts on Wednesday April 17th
20
+ </span>
21
+ <span class="Alert__ButtonContainer-sc-2vlo3n-1 cKzYKK">
22
+ </span>
23
+ <span class="Alert__AlertHeader-sc-2vlo3n-2 Alert__AlertSubheader-sc-2vlo3n-3 fpauiN dYdxsJ">
24
+ Trip is due to begin at 7:43 AM (Realtime monitoring will being at 7:13 AM)
25
+ </span>
26
+ <div class="Alert__AlertContent-sc-2vlo3n-4 UrwUS">
27
+ <div aria-hidden="false"
28
+ class="rah-static rah-static--height-auto "
29
+ style="height: auto; overflow: visible;"
30
+ >
31
+ <div>
32
+ <div class="Alert__ContentPadding-sc-2vlo3n-5 isIayL">
33
+ Here is more content
34
+ </div>
33
35
  </div>
34
36
  </div>
35
37
  </div>
@@ -38,64 +40,67 @@ exports[`Building-Blocks/Alert BasicAlert smoke-test 1`] = `
38
40
  `;
39
41
 
40
42
  exports[`Building-Blocks/Alert CollapsibleAlertWithTransitAlerts smoke-test 1`] = `
41
- <div class="Alert__AlertContainer-sc-2vlo3n-0 bqBujX">
42
- <svg viewbox="0 0 16 16"
43
- height="24"
44
- width="24"
45
- aria-hidden="true"
46
- focusable="false"
47
- fill="currentColor"
48
- xmlns="http://www.w3.org/2000/svg"
49
- class="StyledIconBase-sc-ea9ulj-0 ebjPRL"
50
- >
51
- <path d="M7.938 2.016A.13.13 0 0 1 8.002 2a.13.13 0 0 1 .063.016.146.146 0 0 1 .054.057l6.857 11.667c.036.06.035.124.002.183a.163.163 0 0 1-.054.06.116.116 0 0 1-.066.017H1.146a.115.115 0 0 1-.066-.017.163.163 0 0 1-.054-.06.176.176 0 0 1 .002-.183L7.884 2.073a.147.147 0 0 1 .054-.057zm1.044-.45a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566z">
52
- </path>
53
- <path d="M7.002 12a1 1 0 1 1 2 0 1 1 0 0 1-2 0zM7.1 5.995a.905.905 0 1 1 1.8 0l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995z">
54
- </path>
55
- </svg>
56
- <span class="Alert__AlertHeader-sc-2vlo3n-2 fpauiN">
57
- Your trip has alerts
58
- </span>
59
- <span class="Alert__ButtonContainer-sc-2vlo3n-1 cKzYKK">
60
- <button type="button"
61
- aria-label="Expand"
62
- title="Expand"
43
+ <div class="alertsstory__AlertContainer-sc-19s77d-0 fgnBDZ">
44
+ <div class="Alert__AlertContainer-sc-2vlo3n-0 bqBujX">
45
+ <svg viewbox="0 0 16 16"
46
+ height="24"
47
+ width="24"
48
+ aria-hidden="true"
49
+ focusable="false"
50
+ fill="currentColor"
51
+ xmlns="http://www.w3.org/2000/svg"
52
+ class="StyledIconBase-sc-ea9ulj-0 ebjPRL"
63
53
  >
64
- <svg viewbox="0 0 16 16"
65
- height="16"
66
- width="16"
67
- aria-hidden="true"
68
- focusable="false"
69
- fill="currentColor"
70
- xmlns="http://www.w3.org/2000/svg"
71
- class="StyledIconBase-sc-ea9ulj-0 ebjPRL"
54
+ <path d="M7.938 2.016A.13.13 0 0 1 8.002 2a.13.13 0 0 1 .063.016.146.146 0 0 1 .054.057l6.857 11.667c.036.06.035.124.002.183a.163.163 0 0 1-.054.06.116.116 0 0 1-.066.017H1.146a.115.115 0 0 1-.066-.017.163.163 0 0 1-.054-.06.176.176 0 0 1 .002-.183L7.884 2.073a.147.147 0 0 1 .054-.057zm1.044-.45a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566z">
55
+ </path>
56
+ <path d="M7.002 12a1 1 0 1 1 2 0 1 1 0 0 1-2 0zM7.1 5.995a.905.905 0 1 1 1.8 0l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995z">
57
+ </path>
58
+ </svg>
59
+ <span class="Alert__AlertHeader-sc-2vlo3n-2 fpauiN">
60
+ Your trip has alerts
61
+ </span>
62
+ <span class="Alert__ButtonContainer-sc-2vlo3n-1 cKzYKK">
63
+ <button type="button"
64
+ class="toggle-btn"
65
+ aria-label="Expand"
66
+ title="Expand"
72
67
  >
73
- <path fill-rule="evenodd"
74
- d="M7.646 4.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1-.708.708L8 5.707l-5.646 5.647a.5.5 0 0 1-.708-.708l6-6z"
68
+ <svg viewbox="0 0 16 16"
69
+ height="16"
70
+ width="16"
71
+ aria-hidden="true"
72
+ focusable="false"
73
+ fill="currentColor"
74
+ xmlns="http://www.w3.org/2000/svg"
75
+ class="StyledIconBase-sc-ea9ulj-0 ebjPRL"
75
76
  >
76
- </path>
77
- </svg>
78
- </button>
79
- </span>
80
- <div class="Alert__AlertContent-sc-2vlo3n-4 UrwUS">
81
- <div aria-hidden="true"
82
- class="rah-static rah-static--height-zero "
83
- style="height: 0px; overflow: hidden;"
84
- >
85
- <div style="display: none;">
86
- <div class="Alert__ContentPadding-sc-2vlo3n-5 esOwtt">
87
- <div>
88
- 1) TriMet Customer Service will be unavailable to serve text messages or Twitter responses from 9:00 p.m.- 11:30 p.m. For immediate assistance regarding safety or security concerns, please contact the police via 911.
89
- </div>
90
- <br>
91
- <div>
92
- 2) The Park and Ride garage elevator at Sunset Transit Center is closed for approximately 3 months for improvements. During this time garage users must use the stairs or find alternate parking. Visit trimet.org/parkandride for a complete list of Park and Ride garages.
93
- </div>
94
- <br>
95
- <div>
96
- 3) The west elevators at the Washington Park MAX Station are out of service. Please use east elevators to access street level and platforms.
77
+ <path fill-rule="evenodd"
78
+ d="M7.646 4.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1-.708.708L8 5.707l-5.646 5.647a.5.5 0 0 1-.708-.708l6-6z"
79
+ >
80
+ </path>
81
+ </svg>
82
+ </button>
83
+ </span>
84
+ <div class="Alert__AlertContent-sc-2vlo3n-4 UrwUS">
85
+ <div aria-hidden="true"
86
+ class="rah-static rah-static--height-zero "
87
+ style="height: 0px; overflow: hidden;"
88
+ >
89
+ <div style="display: none;">
90
+ <div class="Alert__ContentPadding-sc-2vlo3n-5 esOwtt">
91
+ <div>
92
+ 1) TriMet Customer Service will be unavailable to serve text messages or Twitter responses from 9:00 p.m.- 11:30 p.m. For immediate assistance regarding safety or security concerns, please contact the police via 911.
93
+ </div>
94
+ <br>
95
+ <div>
96
+ 2) The Park and Ride garage elevator at Sunset Transit Center is closed for approximately 3 months for improvements. During this time garage users must use the stairs or find alternate parking. Visit trimet.org/parkandride for a complete list of Park and Ride garages.
97
+ </div>
98
+ <br>
99
+ <div>
100
+ 3) The west elevators at the Washington Park MAX Station are out of service. Please use east elevators to access street level and platforms.
101
+ </div>
102
+ <br>
97
103
  </div>
98
- <br>
99
104
  </div>
100
105
  </div>
101
106
  </div>
@@ -1,4 +1,4 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
1
+ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2
2
 
3
3
  exports[`Building-Blocks/Dropdown DropdownAsOtprrNavItem smoke-test 1`] = `
4
4
  <div class="dropdownstory__NavItemWrapper-sc-giygrt-0 jFfMlb">
@@ -1,4 +1,4 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
1
+ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2
2
 
3
3
  exports[`Building-Blocks/FocusTrapWrapper FocusTrapAroundButtonSet smoke-test 1`] = `
4
4
  <div id="button-set-story-focus-trap"
@@ -1,4 +1,4 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
1
+ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2
2
 
3
3
  exports[`Building-Blocks/Colors Blue smoke-test 1`] = `
4
4
  <div class="ColorPalette__ColorBlock-sc-fil65c-0 iEijBb">
@@ -1,6 +1,7 @@
1
1
  import React, { ReactElement } from "react";
2
2
  import { Meta } from "@storybook/react-vite";
3
3
  import { ExclamationTriangle } from "@styled-icons/bootstrap/ExclamationTriangle";
4
+ import styled from "styled-components";
4
5
  import Alert from "../alert/Alert";
5
6
  import red from "../colors/red";
6
7
 
@@ -33,6 +34,10 @@ const alerts = [
33
34
  }
34
35
  ];
35
36
 
37
+ const AlertContainer = styled.div`
38
+ max-width: 700px;
39
+ `;
40
+
36
41
  const AlertContent = () => {
37
42
  return (
38
43
  <>
@@ -54,24 +59,28 @@ const AlertContent = () => {
54
59
 
55
60
  export const BasicAlert = (): ReactElement => {
56
61
  return (
57
- <Alert
58
- alertHeader="Next trip starts on Wednesday April 17th"
59
- alertSubheader="Trip is due to begin at 7:43 AM (Realtime monitoring will being at 7:13 AM)"
60
- >
61
- Here is more content
62
- </Alert>
62
+ <AlertContainer>
63
+ <Alert
64
+ alertHeader="Next trip starts on Wednesday April 17th"
65
+ alertSubheader="Trip is due to begin at 7:43 AM (Realtime monitoring will being at 7:13 AM)"
66
+ >
67
+ Here is more content
68
+ </Alert>
69
+ </AlertContainer>
63
70
  );
64
71
  };
65
72
 
66
73
  export const CollapsibleAlertWithTransitAlerts = (): ReactElement => {
67
74
  return (
68
- <Alert
69
- backgroundColor={red[50]}
70
- collapsible
71
- Icon={ExclamationTriangle}
72
- alertHeader="Your trip has alerts"
73
- >
74
- <AlertContent />
75
- </Alert>
75
+ <AlertContainer>
76
+ <Alert
77
+ backgroundColor={red[50]}
78
+ collapsible
79
+ Icon={ExclamationTriangle}
80
+ alertHeader="Your trip has alerts"
81
+ >
82
+ <AlertContent />
83
+ </Alert>
84
+ </AlertContainer>
76
85
  );
77
86
  };