From 414bdbc01fdcf57b8b92260be9e344c7b88caf1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Jyrki=C3=A4inen?= Date: Wed, 1 Nov 2023 17:34:28 +0200 Subject: [PATCH] L rail updates (#797) * L-rail updates * L-rail updates * codegen --- .env.dev | 1 + .env.local | 1 + .env.prod | 1 + .env.production | 4 ++- graphql.schema.json | 37 ++++++++++++++++++++++++--- schema-types.d.ts | 7 +++-- src/components/LineIcon.css | 5 ++++ src/components/map/Map.js | 2 +- src/components/transportModes.js | 13 +++++++++- src/helpers/getTransportType.js | 8 ++++++ src/helpers/vehicleColor.js | 1 + src/icon-L-rail.svg | 5 ++++ src/icons/LRail.js | 30 ++++++++++++++++++++++ src/icons/LRailRectangle.js | 44 ++++++++++++++++++++++++++++++++ src/index.css | 1 + 15 files changed, 151 insertions(+), 9 deletions(-) create mode 100644 src/icon-L-rail.svg create mode 100644 src/icons/LRail.js create mode 100644 src/icons/LRailRectangle.js diff --git a/.env.dev b/.env.dev index 5b57a230..57f6bc7d 100644 --- a/.env.dev +++ b/.env.dev @@ -25,5 +25,6 @@ REACT_APP_TIMEZONE=Europe/Helsinki # API key for weather data REACT_APP_FMI_APIKEY=4a22a195-10be-404f-8056-e8aaf5f7506a +REACT_APP_DIGITRANSIT_URL=https://api.digitransit.fi/ REACT_APP_MAPILLARY_CLIENT_TOKEN=MLY|4648891498509284|8e5e3395c54d64ca14b62c79ceb3e16c REACT_APP_DIGITRANSIT_API_KEY= \ No newline at end of file diff --git a/.env.local b/.env.local index 0a3a92b0..7d13536a 100644 --- a/.env.local +++ b/.env.local @@ -22,5 +22,6 @@ REACT_APP_PRODUCTION_URL=https://reittiloki.hsl.fi # transport networks. All times will be converted into this timezone. REACT_APP_TIMEZONE=Europe/Helsinki +REACT_APP_DIGITRANSIT_URL=https://api.digitransit.fi/ REACT_APP_MAPILLARY_CLIENT_TOKEN=MLY|4417181845065987|5e7cb47b1a13698f243e25f0cfdbf31f REACT_APP_DIGITRANSIT_API_KEY= \ No newline at end of file diff --git a/.env.prod b/.env.prod index 9142a673..b52dd70e 100644 --- a/.env.prod +++ b/.env.prod @@ -26,5 +26,6 @@ REACT_APP_TIMEZONE=Europe/Helsinki # API key for weather data REACT_APP_FMI_APIKEY=4a22a195-10be-404f-8056-e8aaf5f7506a +REACT_APP_DIGITRANSIT_URL=https://api.digitransit.fi/ REACT_APP_MAPILLARY_CLIENT_TOKEN=MLY|4699140670124156|c0617576966bc69ea39fb284a78df199 REACT_APP_DIGITRANSIT_API_KEY= \ No newline at end of file diff --git a/.env.production b/.env.production index 4df24fa1..fc93e74d 100644 --- a/.env.production +++ b/.env.production @@ -26,4 +26,6 @@ REACT_APP_TIMEZONE=Europe/Helsinki # API key for weather data REACT_APP_FMI_APIKEY=4a22a195-10be-404f-8056-e8aaf5f7506a -REACT_APP_MAPILLARY_CLIENT_TOKEN=MLY|4699140670124156|c0617576966bc69ea39fb284a78df199 \ No newline at end of file +REACT_APP_DIGITRANSIT_URL=https://api.digitransit.fi/ +REACT_APP_MAPILLARY_CLIENT_TOKEN=MLY|4699140670124156|c0617576966bc69ea39fb284a78df199 +REACT_APP_DIGITRANSIT_API_KEY= \ No newline at end of file diff --git a/graphql.schema.json b/graphql.schema.json index 67afb524..553c9cea 100644 --- a/graphql.schema.json +++ b/graphql.schema.json @@ -2443,6 +2443,12 @@ "description": null, "isDeprecated": false, "deprecationReason": null + }, + { + "name": "CHARGING_SERVICE", + "description": null, + "isDeprecated": false, + "deprecationReason": null } ], "possibleTypes": null @@ -3540,6 +3546,18 @@ "description": null, "isDeprecated": false, "deprecationReason": null + }, + { + "name": "OTHER_CHARGING_SERVICE", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "OPERATOR_CHARGING_SERVICE", + "description": null, + "isDeprecated": false, + "deprecationReason": null } ], "possibleTypes": null @@ -9789,7 +9807,11 @@ { "name": "skip", "description": "Directs the executor to skip this field or fragment when the `if` argument is true.", - "locations": ["FIELD", "FRAGMENT_SPREAD", "INLINE_FRAGMENT"], + "locations": [ + "FIELD", + "FRAGMENT_SPREAD", + "INLINE_FRAGMENT" + ], "args": [ { "name": "if", @@ -9810,7 +9832,11 @@ { "name": "include", "description": "Directs the executor to include this field or fragment only when the `if` argument is true.", - "locations": ["FIELD", "FRAGMENT_SPREAD", "INLINE_FRAGMENT"], + "locations": [ + "FIELD", + "FRAGMENT_SPREAD", + "INLINE_FRAGMENT" + ], "args": [ { "name": "if", @@ -9831,7 +9857,10 @@ { "name": "deprecated", "description": "Marks an element of a GraphQL schema as no longer supported.", - "locations": ["FIELD_DEFINITION", "ENUM_VALUE"], + "locations": [ + "FIELD_DEFINITION", + "ENUM_VALUE" + ], "args": [ { "name": "reason", @@ -9847,4 +9876,4 @@ } ] } -} +} \ No newline at end of file diff --git a/schema-types.d.ts b/schema-types.d.ts index 048f3f40..d460d028 100644 --- a/schema-types.d.ts +++ b/schema-types.d.ts @@ -75,7 +75,8 @@ export enum AlertCategory { PowerFailure = 'POWER_FAILURE', MisparkedVehicle = 'MISPARKED_VEHICLE', PublicEvent = 'PUBLIC_EVENT', - Hidden = 'HIDDEN' + Hidden = 'HIDDEN', + ChargingService = 'CHARGING_SERVICE' } export enum AlertDistribution { @@ -209,7 +210,9 @@ export enum CancellationSubcategory { OtherOperatorReason = 'OTHER_OPERATOR_REASON', DoorMalfunction = 'DOOR_MALFUNCTION', UnknownCause = 'UNKNOWN_CAUSE', - Hidden = 'HIDDEN' + Hidden = 'HIDDEN', + OtherChargingService = 'OTHER_CHARGING_SERVICE', + OperatorChargingService = 'OPERATOR_CHARGING_SERVICE' } export enum CancellationType { diff --git a/src/components/LineIcon.css b/src/components/LineIcon.css index c67e739f..857772e9 100644 --- a/src/components/LineIcon.css +++ b/src/components/LineIcon.css @@ -30,3 +30,8 @@ background-image: url("../icon-subway.svg"); color: var(--orange); } + +.L_RAIL:before { + background-image: url("../icon-L-rail.svg"); + color: #0098a1; +} diff --git a/src/components/map/Map.js b/src/components/map/Map.js index e6a8c3aa..c232ef48 100644 --- a/src/components/map/Map.js +++ b/src/components/map/Map.js @@ -177,7 +177,7 @@ const Map = decorate(({state, UI, children, className, detailsOpen}) => { }, [leafletMap]); const apikey = `?digitransit-subscription-key=${process.env.REACT_APP_DIGITRANSIT_API_KEY}`; - const mapUrl = `https://dev-api.digitransit.fi/map/v2/hsl-map/{z}/{x}/{y}@2x.png${apikey}`; + const mapUrl = `${process.env.REACT_APP_DIGITRANSIT_URL}map/v2/hsl-map/{z}/{x}/{y}@2x.png${apikey}`; return ( ), + L_RAIL: (size = 20) => + ReactDOMServer.renderToStaticMarkup( + + ), SUBWAY: (size = 20) => ReactDOMServer.renderToStaticMarkup( { let icon = getCachedIcon(name, size); - if (icon) { return icon; } @@ -102,6 +111,7 @@ export const transportIcons = { TRUNK: BusIcon, TRAM: TramIcon, RAIL: RailIcon, + L_RAIL: LRailIcon, SUBWAY: SubwayIcon, METRO: SubwayIcon, FERRY: FerryIcon, @@ -112,6 +122,7 @@ export const transportColor = { TRUNK: "var(--orange)", TRAM: "var(--green)", RAIL: "var(--purple)", + L_RAIL: "var(--l_rail-green)", SUBWAY: "var(--orange)", METRO: "var(--orange)", FERRY: "var(--light-blue)", diff --git a/src/helpers/getTransportType.js b/src/helpers/getTransportType.js index 7e98ceae..803e9d18 100644 --- a/src/helpers/getTransportType.js +++ b/src/helpers/getTransportType.js @@ -11,6 +11,14 @@ function getTransportType(lineId = "", numeric = false, trunk = false) { return "TRAM"; } + if (lineType == 2015) { + if (numeric) { + return 0; + } + + return "L_RAIL"; + } + // The only ferry routes are 1019 and 1019E. if (lineId.startsWith("1019")) { if (numeric) { diff --git a/src/helpers/vehicleColor.js b/src/helpers/vehicleColor.js index 2519f822..5b990b91 100644 --- a/src/helpers/vehicleColor.js +++ b/src/helpers/vehicleColor.js @@ -10,6 +10,7 @@ const vehicleColors = { SUBWAY: "var(--orange)", METRO: "var(--orange)", FERRY: "var(--light-blue)", + L_RAIL: "var(--l_rail-green)", default: "var(--blue)", unsigned: "var(--grey)", }; diff --git a/src/icon-L-rail.svg b/src/icon-L-rail.svg new file mode 100644 index 00000000..bfafcbc5 --- /dev/null +++ b/src/icon-L-rail.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/icons/LRail.js b/src/icons/LRail.js new file mode 100644 index 00000000..4751b3db --- /dev/null +++ b/src/icons/LRail.js @@ -0,0 +1,30 @@ +import React from "react"; +import {Svg, Path, G} from "react-primitives-svg"; +import PropTypes from "prop-types"; + +import {svgSize} from "../helpers/svg"; + +export default function Icon({fill, height, width, ...rest}) { + return ( + + + + + + ); +} + +Icon.propTypes = { + fill: PropTypes.string, + height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), +}; + +Icon.displayName = "Icons.Tram"; diff --git a/src/icons/LRailRectangle.js b/src/icons/LRailRectangle.js new file mode 100644 index 00000000..fe57cdaf --- /dev/null +++ b/src/icons/LRailRectangle.js @@ -0,0 +1,44 @@ +import React from "react"; +import {Svg, G, Path, Rect} from "react-primitives-svg"; +import PropTypes from "prop-types"; +import {svgSize} from "../helpers/svg"; +import {Colors} from "./HSL_COLORS"; + +export default function Icon({fill, height, width, ...rest}) { + return ( + + + + + + + ); +} + +Icon.propTypes = { + fill: PropTypes.shape({ + inner: PropTypes.string, + outer: PropTypes.string, + }), + height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), +}; + +Icon.defaultProps = { + fill: { + inner: Colors.primary.hslWhite, + outer: Colors.transport.rail, + }, +}; + +Icon.displayName = "Icons.LRailRectangle"; diff --git a/src/index.css b/src/index.css index 1d972cef..044ba820 100644 --- a/src/index.css +++ b/src/index.css @@ -6,6 +6,7 @@ --bus-blue: #0079c9; --green: #00985f; --purple: #8c4799; + --l_rail-green: #0098a1; --orange: #ff6319; --light-orange: #ffedf0; --teal: #00b2a9;