diff --git a/app/component/AlertBanner.js b/app/component/AlertBanner.js
index 222f73c02a..7629dcb5c9 100644
--- a/app/component/AlertBanner.js
+++ b/app/component/AlertBanner.js
@@ -17,7 +17,8 @@ const AlertBanner = ({ alerts, linkAddress }, { config }) => {
alert.alertSeverityLevel !== 'INFO'
? 'icon_caution_white_exclamation'
: 'icon_info';
- const iconColor = alert.alertSeverityLevel !== 'INFO' ? '#DC0451' : '#888';
+ const iconColor =
+ alert.alertSeverityLevel !== 'INFO' ? config.colors.caution : '#888';
return (
{
const alerts = [...getAlertsForObject(route)];
@@ -51,7 +51,7 @@ export default function DepartureRow(
let backgroundClass;
let sr;
if (
- route?.alerts?.filter(alert => isAlertValid(alert, props.currentTime))
+ route.alerts?.filter(alert => isAlertValid(alert, props.currentTime))
?.length > 0
) {
const alert = getMostSevereAlert(route);
@@ -65,17 +65,17 @@ export default function DepartureRow(
if (alert.alertSeverityLevel === 'INFO') {
icon = 'icon_info';
iconColor = '#888';
- background = ;
+ background = ;
backgroundClass = 'circle';
} else {
icon = 'icon_caution-white-excl-stroke';
- iconColor = '#DC0451';
+ iconColor = config.colors.caution;
}
}
const headsign =
departure.headsign ||
trip.tripHeadsign ||
- getHeadsignFromRouteLongName(trip.route);
+ getHeadsignFromRouteLongName(route);
let shownTime;
if (timeDiffInMinutes <= 0) {
shownTime = intl.formatMessage({
@@ -93,7 +93,7 @@ export default function DepartureRow(
{ minutes: timeDiffInMinutes },
);
}
- const { shortName } = trip.route;
+ const { shortName } = route;
const lowerCaseShortName = shortName?.toLowerCase();
const nameOrIcon =
shortName?.length > 6 || !shortName?.length ? (
@@ -166,7 +166,7 @@ export default function DepartureRow(
className={cx('route-number-container', {
long: shortName && shortName.length <= 6 && shortName.length >= 5,
})}
- style={{ backgroundColor: `#${trip.route.color}` }}
+ style={{ backgroundColor: `#${route.color}` }}
>
{nameOrIcon}
@@ -188,7 +188,7 @@ export default function DepartureRow(
- {headsign} {departure.bottomRow && departure.bottomRow}
+ {headsign} {departure.bottomRow}
|
diff --git a/app/component/FavouritesContainer.js b/app/component/FavouritesContainer.js
index 1717bcc4d0..50cf392476 100644
--- a/app/component/FavouritesContainer.js
+++ b/app/component/FavouritesContainer.js
@@ -20,7 +20,6 @@ import {
} from '../action/FavouriteActions';
import FavouriteStore from '../store/FavouriteStore';
import { addAnalyticsEvent } from '../util/analyticsUtils';
-import { LightenDarkenColor } from '../util/colorUtils';
const AutoSuggestWithSearchContext = withSearchContext(AutoSuggest);
@@ -54,8 +53,6 @@ class FavouritesContainer extends React.Component {
favouriteModalAction: PropTypes.string,
requireLoggedIn: PropTypes.bool,
isLoggedIn: PropTypes.bool,
- color: PropTypes.string,
- hoverColor: PropTypes.string,
};
static defaultProps = {
@@ -65,8 +62,6 @@ class FavouritesContainer extends React.Component {
requireLoggedIn: false,
isLoggedIn: false,
favouriteModalAction: undefined,
- color: undefined,
- hoverColor: undefined,
lang: undefined,
};
@@ -250,8 +245,7 @@ class FavouritesContainer extends React.Component {
loginModalOpen: false,
});
}}
- color={this.props.color}
- hoverColor={this.props.hoverColor}
+ colors={this.context.config.colors}
/>
);
};
@@ -358,7 +352,7 @@ class FavouritesContainer extends React.Component {
}
lang={this.props.lang}
isLoading={isLoading}
- color={this.props.color}
+ colors={config.colors}
fontWeights={fontWeights}
/>
}
- color={this.props.color}
- hoverColor={this.props.hoverColor}
/>
{this.renderLoginModal()}
@@ -434,10 +425,6 @@ const connectedComponent = connectToStores(
isLoggedIn:
context.config.allowLogin &&
context.getStore('UserStore').getUser().sub !== undefined,
- color: context.config.colors.primary,
- hoverColor:
- context.config.colors.hover ||
- LightenDarkenColor(context.config.colors.primary, -20),
}),
);
diff --git a/app/component/IconWithIcon.js b/app/component/IconWithIcon.js
index e47193b328..cbf0b1d2d0 100644
--- a/app/component/IconWithIcon.js
+++ b/app/component/IconWithIcon.js
@@ -49,9 +49,7 @@ const IconWithIcon = (
- }
+ background={subIconShape && }
/>
)}
diff --git a/app/component/IndexPage.js b/app/component/IndexPage.js
index e0d612b60f..7191284bfa 100644
--- a/app/component/IndexPage.js
+++ b/app/component/IndexPage.js
@@ -34,7 +34,6 @@ import { addAnalyticsEvent } from '../util/analyticsUtils';
import withBreakpoint from '../util/withBreakpoint';
import Geomover from './Geomover';
import scrollTop from '../util/scroll';
-import { LightenDarkenColor } from '../util/colorUtils';
import { getRefPoint } from '../util/apiUtils';
import { filterObject } from '../util/filterUtils';
import {
@@ -229,19 +228,18 @@ class IndexPage extends React.Component {
const { intl, config } = this.context;
const { colors, fontWeights } = config;
const { lang } = this.props;
- const transportModes = getTransportModes(config);
const nearYouModes = getNearYouModes(config);
-
- // Styles are defined by which button type is configured (narrow/wide)
- const narrowButtons = config.narrowNearYouButtons;
- const modeTitles = filterObject(
- transportModes,
- 'availableForSelection',
- true,
- );
// If nearYouModes is configured, display those. Otherwise, display all configured transport modes
- const modes =
- nearYouModes?.length > 0 ? nearYouModes : Object.keys(modeTitles);
+ const modeArray =
+ nearYouModes.length > 0
+ ? nearYouModes
+ : Object.keys(
+ filterObject(
+ getTransportModes(config),
+ 'availableForSelection',
+ true,
+ ),
+ );
const alertsContext = {
currentTime: this.props.currentTime,
@@ -249,29 +247,33 @@ class IndexPage extends React.Component {
feedIds: config.feedIds,
};
+ const directionProps = config.narrowNearYouButtons
+ ? {}
+ : { horizontal: false };
+
return config.showNearYouButtons ? (
) : (
{intl.formatMessage({
- id: 'stop-near-you-title',
- defaultMessage: 'Stops and lines near you',
+ id: 'near-you-search',
+ defaultMessage: 'Search stops and routes',
})}
@@ -282,18 +284,18 @@ class IndexPage extends React.Component {
render() {
const { intl, config } = this.context;
const { trafficNowLink, colors, fontWeights } = config;
- const color = colors.primary;
- const hoverColor = colors.hover || LightenDarkenColor(colors.primary, -20);
- const accessiblePrimaryColor = colors.accessiblePrimary || colors.primary;
const { breakpoint, lang } = this.props;
const origin = this.pendingOrigin || this.props.origin;
const destination = this.pendingDestination || this.props.destination;
+ const locationSources = ['History', 'Datasource'];
const sources = ['Favourite', 'History', 'Datasource'];
const stopAndRouteSearchTargets = ['Stations', 'Stops', 'Routes'];
const targets = getLocationSearchTargets(config, breakpoint !== 'large');
targets.push('FutureRoutes');
-
+ if (this.context.getStore('FavouriteStore').getLocationCount()) {
+ locationSources.push('Favourite');
+ }
if (!config.targetsFromOTP) {
if (useCitybikes(config.vehicleRental?.networks, config)) {
stopAndRouteSearchTargets.push('VehicleRentalStations');
@@ -312,11 +314,8 @@ class IndexPage extends React.Component {
origin,
destination,
lang,
- sources,
+ locationSources,
targets,
- color,
- hoverColor,
- accessiblePrimaryColor,
refPoint,
searchPanelText: intl.formatMessage({
id: 'where',
@@ -329,7 +328,7 @@ class IndexPage extends React.Component {
onGeolocationStart: this.onSelectLocation,
fromMap: this.props.fromMap,
fontWeights,
- modeIconColors: colors.iconColors,
+ colors,
modeSet: config.iconModeSet,
};
@@ -343,13 +342,10 @@ class IndexPage extends React.Component {
getAutoSuggestIcons: config.getAutoSuggestIcons,
value: '',
lang,
- color,
- hoverColor,
- accessiblePrimaryColor,
sources,
targets: stopAndRouteSearchTargets,
fontWeights,
- modeIconColors: colors.iconColors,
+ colors,
modeSet: config.iconModeSet,
geocodingSize: 25,
};
@@ -375,13 +371,7 @@ class IndexPage extends React.Component {
-
+
-
+
{!config.hideFavourites && (
<>
@@ -433,19 +427,18 @@ class IndexPage extends React.Component {
backgroundColor: '#ffffff',
}}
>
-
+
-
+
@@ -205,29 +208,31 @@ function ParkAndRideContent(
)}
-
-
- {intl.formatMessage({ id: `${prePostFix}-disclaimer-header` })}
-
-
+ )}
);
}
@@ -236,11 +241,17 @@ ParkAndRideContent.propTypes = {
vehicleParking: parkShape,
error: errorShape,
currentLanguage: PropTypes.string.isRequired,
+ mode: PropTypes.oneOf(['CARPARK', 'BIKEPARK']),
+ showInfo: PropTypes.bool,
+ backButton: PropTypes.bool,
};
ParkAndRideContent.defaultProps = {
vehicleParking: undefined,
error: undefined,
+ mode: undefined,
+ showInfo: true,
+ backButton: true,
};
ParkAndRideContent.contextTypes = {
diff --git a/app/component/ParkContainer.js b/app/component/ParkContainer.js
index 1da8696a5e..3fb359e087 100644
--- a/app/component/ParkContainer.js
+++ b/app/component/ParkContainer.js
@@ -8,7 +8,7 @@ const containerComponent = createFragmentContainer(ParkAndRideContent, {
bicycleSpaces
carSpaces
}
- capacity {
+ parkCapacity: capacity {
carSpaces
}
name
diff --git a/app/component/ParkOrStationHeader.js b/app/component/ParkOrStationHeader.js
index 01cb60afb4..4f8009ae96 100644
--- a/app/component/ParkOrStationHeader.js
+++ b/app/component/ParkOrStationHeader.js
@@ -3,17 +3,17 @@ import React, { useEffect, useState } from 'react';
import { FormattedMessage } from 'react-intl';
import { configShape } from '../util/shapes';
import StopCode from './StopCode';
+import withBreakpoint from '../util/withBreakpoint';
import BackButton from './BackButton';
import { getJson } from '../util/xhrPromise';
import getZoneId from '../util/zoneIconUtils';
import ZoneIcon from './ZoneIcon';
-import withBreakpoint from '../util/withBreakpoint';
import { hasVehicleRentalCode } from '../util/vehicleRentalUtils';
import { getIdWithoutFeed } from '../util/feedScopedIdUtils';
import FavouriteVehicleRentalStationContainer from './FavouriteVehicleRentalStationContainer';
const ParkOrBikeStationHeader = (
- { parkOrStation, breakpoint, parkType },
+ { parkOrStation, breakpoint, parkType, backButton },
{ config },
) => {
const [zoneId, setZoneId] = useState(undefined);
@@ -48,7 +48,7 @@ const ParkOrBikeStationHeader = (
return (
- {breakpoint === 'large' && (
+ {breakpoint === 'large' && backButton && (
{
}
}, [query]);
- const color = colors.primary;
- const hoverColor = colors.hover;
const appElement = 'embedded-root';
let titleText;
if (bikeOnly) {
@@ -220,8 +218,6 @@ const EmbeddedSearch = (props, context) => {
lang,
sources,
targets: getLocationSearchTargets(config, false),
- color,
- hoverColor,
refPoint,
searchPanelText: titleText,
originPlaceHolder: 'search-origin-index',
@@ -229,7 +225,7 @@ const EmbeddedSearch = (props, context) => {
selectHandler: onSelectLocation,
onGeolocationStart: onSelectLocation,
fontWeights,
- modeIconColors: config.colors.iconColors,
+ colors,
modeSet: config.iconModeSet,
isMobile: true,
showScroll: true,
diff --git a/app/component/embedded/EmbeddedSearchGenerator.js b/app/component/embedded/EmbeddedSearchGenerator.js
index d1d42c856a..6415522739 100644
--- a/app/component/embedded/EmbeddedSearchGenerator.js
+++ b/app/component/embedded/EmbeddedSearchGenerator.js
@@ -78,11 +78,9 @@ const EmbeddedSearchGenerator = (props, context) => {
sources,
targets: getLocationSearchTargets(config, false),
isMobile: breakpoint !== 'large',
- color: colors.primary,
- hoverColor: colors.hover,
fontWeights,
modeSet: config.iconModeSet,
- modeIconColors: config.colors.modeIconColors,
+ colors,
selectHandler: onSelectLocation,
getAutoSuggestIcons: context.config.getAutoSuggestIcons,
};
diff --git a/app/component/icon/IconBackground.js b/app/component/icon/IconBackground.js
index 4486ee5207..70c91d0671 100644
--- a/app/component/icon/IconBackground.js
+++ b/app/component/icon/IconBackground.js
@@ -4,35 +4,41 @@ import PropTypes from 'prop-types';
const STOP_SIGN_POLE_WIDTH = 4;
const STOP_SIGN_POLE_X = 20 - STOP_SIGN_POLE_WIDTH / 2;
-const IconBackground = ({ backgroundShape, backgroundColor }) => (
- <>
-
- {backgroundShape === 'stopsign' && (
- {
+ if (shape === undefined) {
+ return null;
+ }
+ return (
+ <>
+
- )}
- >
-);
+ {shape === 'stopsign' && (
+
+ )}
+ >
+ );
+};
IconBackground.propTypes = {
- backgroundShape: PropTypes.oneOf(['circle', 'stopsign']).isRequired,
- backgroundColor: PropTypes.string,
+ shape: PropTypes.oneOf(['circle', 'stopsign']),
+ color: PropTypes.string,
};
IconBackground.defaultProps = {
- backgroundColor: 'white',
+ shape: undefined,
+ color: 'white',
};
export default IconBackground;
diff --git a/app/component/itinerary/ItineraryPageControls.js b/app/component/itinerary/ItineraryPageControls.js
index c67c4961df..f6a0882731 100644
--- a/app/component/itinerary/ItineraryPageControls.js
+++ b/app/component/itinerary/ItineraryPageControls.js
@@ -1,4 +1,3 @@
-import cx from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
import { matchShape, routerShape } from 'found';
@@ -59,7 +58,6 @@ class ItineraryPageControls extends React.Component {
}
render() {
- const className = cx({ 'bp-large': this.props.breakpoint === 'large' });
const { params } = this.props;
return (
@@ -89,11 +87,9 @@ class ItineraryPageControls extends React.Component {
/>
diff --git a/app/component/itinerary/OriginDestinationBar.js b/app/component/itinerary/OriginDestinationBar.js
index b11a1c80fc..f38f537aaf 100644
--- a/app/component/itinerary/OriginDestinationBar.js
+++ b/app/component/itinerary/OriginDestinationBar.js
@@ -22,7 +22,6 @@ import {
} from '../../util/queryUtils';
import { getIntermediatePlaces, locationToOTP } from '../../util/otpStrings';
import { setViaPoints } from '../../action/ViaPointActions';
-import { LightenDarkenColor } from '../../util/colorUtils';
import { getRefPoint } from '../../util/apiUtils';
const DTAutosuggestPanelWithSearchContext =
@@ -30,7 +29,6 @@ const DTAutosuggestPanelWithSearchContext =
class OriginDestinationBar extends React.Component {
static propTypes = {
- className: PropTypes.string,
origin: locationShape.isRequired,
destination: locationShape.isRequired,
language: PropTypes.string,
@@ -38,7 +36,6 @@ class OriginDestinationBar extends React.Component {
showFavourites: PropTypes.bool.isRequired,
viaPoints: PropTypes.arrayOf(locationShape),
locationState: locationStateShape.isRequired,
- modeSet: PropTypes.string,
};
static contextTypes = {
@@ -51,11 +48,9 @@ class OriginDestinationBar extends React.Component {
};
static defaultProps = {
- className: undefined,
language: 'fi',
isMobile: false,
viaPoints: [],
- modeSet: undefined,
};
constructor(props) {
@@ -137,11 +132,9 @@ class OriginDestinationBar extends React.Component {
: undefined;
return (
{}}
showSwapControl
showViapointControl={config.viaPointsEnabled}
@@ -186,7 +175,7 @@ const connectedComponent = connectToStores(
['PreferencesStore', 'FavouriteStore', 'ViaPointStore', 'PositionStore'],
({ getStore }) => ({
language: getStore('PreferencesStore').getLanguage(),
- showFavourites: getStore('FavouriteStore').getStatus() === 'has-data',
+ showFavourites: getStore('FavouriteStore').getLocationCount() > 0,
viaPoints: getStore('ViaPointStore').getViaPoints(),
locationState: getStore('PositionStore').getLocationState(),
}),
diff --git a/app/component/itinerary/StartNavi.js b/app/component/itinerary/StartNavi.js
index c691cdffd0..676ac95c3e 100644
--- a/app/component/itinerary/StartNavi.js
+++ b/app/component/itinerary/StartNavi.js
@@ -7,16 +7,13 @@ import Icon from '../Icon';
const StartNavi = ({ startNavigation }, context) => {
const { config, intl } = context;
- const color =
- config.colors?.accessiblePrimary || config.colors?.primary || 'black';
-
return (
@@ -621,7 +612,7 @@ class DTAutosuggestPanel extends React.Component {
-
+
}
onSlackTimeSelected={this.handleViaPointSlackTimeSelected}
@@ -642,7 +633,7 @@ class DTAutosuggestPanel extends React.Component {
lng,
})}
>
-
+
))}
@@ -671,12 +662,10 @@ class DTAutosuggestPanel extends React.Component {
targets={this.props.targets}
filterResults={this.props.filterResults}
isMobile={this.props.isMobile}
- color={this.props.color}
- hoverColor={this.props.hoverColor}
mobileLabel={destinationMobileLabel}
fontWeights={this.props.fontWeights}
modeSet={this.props.modeSet}
- modeIconColors={this.props.modeIconColors}
+ colors={this.props.colors}
showScroll={this.props.showScroll}
isEmbedded={this.props.isEmbedded}
/>
@@ -696,7 +685,7 @@ class DTAutosuggestPanel extends React.Component {
img="viapoint"
width={1.25}
height={1.375}
- color={this.props.color}
+ color={primary}
/>
)}
diff --git a/digitransit-component/packages/digitransit-component-autosuggest/package.json b/digitransit-component/packages/digitransit-component-autosuggest/package.json
index 0436c09123..60713e06e6 100644
--- a/digitransit-component/packages/digitransit-component-autosuggest/package.json
+++ b/digitransit-component/packages/digitransit-component-autosuggest/package.json
@@ -1,6 +1,6 @@
{
"name": "@digitransit-component/digitransit-component-autosuggest",
- "version": "7.0.0",
+ "version": "7.1.0",
"description": "digitransit-component autosuggest module",
"main": "index.js",
"files": [
@@ -35,9 +35,9 @@
"@hsl-fi/hooks": "^1.2.4"
},
"peerDependencies": {
- "@digitransit-component/digitransit-component-dialog-modal": "^2.0.0",
- "@digitransit-component/digitransit-component-icon": "^1.2.0",
- "@digitransit-component/digitransit-component-suggestion-item": "^2.3.1",
+ "@digitransit-component/digitransit-component-dialog-modal": "^3.0.0",
+ "@digitransit-component/digitransit-component-icon": "^2.0.0",
+ "@digitransit-component/digitransit-component-suggestion-item": "^3.0.0",
"@hsl-fi/sass": "^0.2.0",
"classnames": "2.5.1",
"downshift": "9.0.10",
diff --git a/digitransit-component/packages/digitransit-component-autosuggest/src/components/MobileSearch.scss b/digitransit-component/packages/digitransit-component-autosuggest/src/components/MobileSearch.scss
index b3f460ff07..9ba846b45a 100644
--- a/digitransit-component/packages/digitransit-component-autosuggest/src/components/MobileSearch.scss
+++ b/digitransit-component/packages/digitransit-component-autosuggest/src/components/MobileSearch.scss
@@ -1,4 +1,3 @@
-$primary-color: #007ac9;
$font-weight-medium: 500;
$search-result-text-highlight-background-color: #f2f5f7;
$zindex: base, map-container, map-gradient, map-fullscreen-toggle, map-buttons,
@@ -52,7 +51,6 @@ input[type='text'] {
background: none;
svg {
- fill: $primary-color;
width: 14px;
height: 21px;
transform: rotate(-180deg);
diff --git a/digitransit-component/packages/digitransit-component-autosuggest/src/components/MobileView.js b/digitransit-component/packages/digitransit-component-autosuggest/src/components/MobileView.js
index 8bcaa10c4b..eb08cc6f5a 100644
--- a/digitransit-component/packages/digitransit-component-autosuggest/src/components/MobileView.js
+++ b/digitransit-component/packages/digitransit-component-autosuggest/src/components/MobileView.js
@@ -29,13 +29,10 @@ import {
* @property {function} onSelectedItemChange
* @property {object} fontWeights
* @property {function} clearOldSearches
- * @property {object} itemProps
- * @property {string} color
- * @property {string} accessiblePrimaryColor
- * @property {string} hoverColor
+ * @property {object} suggestionProps
+ * @property {object} colors
* @property {string} lng
* @property {object} ariaProps
- * @property {string} clearButtonColor
* @property {string} value
* @property {string} inputClassName
* @property {boolean} required
@@ -55,13 +52,9 @@ const MobileView = ({
onSelectedItemChange,
fontWeights,
clearOldSearches,
- itemProps,
- color,
- accessiblePrimaryColor,
- hoverColor,
+ suggestionProps,
lng,
ariaProps,
- clearButtonColor,
value,
inputClassName,
required,
@@ -69,6 +62,7 @@ const MobileView = ({
showScroll,
state,
dispatch,
+ colors,
}) => {
const [t] = useTranslation();
const { lock, unlock } = hooks.useScrollLock();
@@ -171,9 +165,9 @@ const MobileView = ({
@@ -194,7 +188,7 @@ const MobileView = ({
aria-label={t('cancel', { lng })}
tabIndex={0}
>
-
+
setDialogOpen(true)}
+ {...suggestionProps}
/>
@@ -253,8 +247,7 @@ const MobileView = ({
setDialogOpen(false);
}}
secondaryButtonOnClick={() => setDialogOpen(false)}
- color={color}
- hoverColor={hoverColor}
+ colors={colors}
fontWeights={fontWeights}
lang={lng}
/>
@@ -270,14 +263,11 @@ MobileView.propTypes = {
clearOldSearches: PropTypes.func.isRequired,
onSelectedItemChange: PropTypes.func.isRequired,
value: PropTypes.string.isRequired,
- color: PropTypes.string.isRequired,
- accessiblePrimaryColor: PropTypes.string.isRequired,
- clearButtonColor: PropTypes.string.isRequired,
- hoverColor: PropTypes.string.isRequired,
+ colors: PropTypes.objectOf(PropTypes.string).isRequired,
fontWeights: PropTypes.shape({
medium: PropTypes.number.isRequired,
}).isRequired,
- itemProps: PropTypes.shape({}).isRequired,
+ suggestionProps: PropTypes.shape({}).isRequired,
ariaProps: PropTypes.shape({
ariaRequiredText: PropTypes.string.isRequired,
SearchBarId: PropTypes.string.isRequired,
diff --git a/digitransit-component/packages/digitransit-component-autosuggest/src/components/Suggestions.js b/digitransit-component/packages/digitransit-component-autosuggest/src/components/Suggestions.js
index fbd095e477..54696a880e 100644
--- a/digitransit-component/packages/digitransit-component-autosuggest/src/components/Suggestions.js
+++ b/digitransit-component/packages/digitransit-component-autosuggest/src/components/Suggestions.js
@@ -12,10 +12,10 @@ function Suggestion({
item,
lng,
getItemProps,
- suggestionItemProps,
highlightedIndex,
itemIndex,
styles,
+ ...rest
}) {
const [t] = useTranslation();
const newItem =
@@ -34,12 +34,7 @@ function Suggestion({
)}
{...getItemProps({ index: itemIndex })}
>
-
+
);
}
@@ -73,7 +68,6 @@ Suggestion.propTypes = {
item: itemShape.isRequired,
lng: PropTypes.string.isRequired,
getItemProps: PropTypes.func.isRequired,
- suggestionItemProps: PropTypes.shape({}).isRequired,
highlightedIndex: PropTypes.number.isRequired,
itemIndex: PropTypes.number.isRequired,
styles: PropTypes.objectOf(PropTypes.string).isRequired,
@@ -83,13 +77,12 @@ export function Suggestions({
suggestions,
getMenuProps,
getItemProps,
- itemProps: suggestionItemProps,
- highlightedIndex,
lng,
styles,
hidden,
renderClearHistoryButton,
handleClearHistory,
+ ...rest
}) {
const [t] = useTranslation();
return (
@@ -109,13 +102,12 @@ export function Suggestions({
suggestion.properties.name ||
suggestion.properties.gtfsId
}`}
- highlightedIndex={highlightedIndex}
- itemIndex={i}
- suggestionItemProps={suggestionItemProps}
getItemProps={getItemProps}
+ itemIndex={i}
item={suggestion}
lng={lng}
styles={styles}
+ {...rest}
/>
);
})}
@@ -139,8 +131,6 @@ Suggestions.propTypes = {
suggestions: PropTypes.arrayOf(itemShape).isRequired,
getMenuProps: PropTypes.func.isRequired,
getItemProps: PropTypes.func.isRequired,
- itemProps: PropTypes.shape({}).isRequired,
- highlightedIndex: PropTypes.number.isRequired,
lng: PropTypes.string.isRequired,
styles: PropTypes.objectOf(PropTypes.string).isRequired,
hidden: PropTypes.bool.isRequired,
diff --git a/digitransit-component/packages/digitransit-component-autosuggest/src/index.js b/digitransit-component/packages/digitransit-component-autosuggest/src/index.js
index 2e1076514a..ca918334be 100644
--- a/digitransit-component/packages/digitransit-component-autosuggest/src/index.js
+++ b/digitransit-component/packages/digitransit-component-autosuggest/src/index.js
@@ -5,7 +5,9 @@ import { I18nextProvider, useTranslation } from 'react-i18next';
import cx from 'classnames';
import { executeSearch } from '@digitransit-search-util/digitransit-search-util-execute-search-immidiate';
import { useCombobox } from 'downshift';
-import Icon from '@digitransit-component/digitransit-component-icon';
+import Icon, {
+ defaultColors,
+} from '@digitransit-component/digitransit-component-icon';
import i18n from './utils/i18n';
import styles from './components/styles.scss';
import { getSuggestionValue, suggestionAsAriaContent } from './utils/utils';
@@ -214,11 +216,8 @@ const getNewTargets = ({
* @property {string} [inputClassName]
* @property {string} [translatedPlaceholder]
* @property {boolean} [required]
- * @property {string} [color]
- * @property {string} [hoverColor]
- * @property {string} [accessiblePrimaryColor]
* @property {Object} [fontWeights]
- * @property {Object} [modeIconColors]
+ * @property {Object} [colors]
* @property {string} [modeSet]
* @property {boolean} [showScroll]
* @property {boolean} [isEmbedded]
@@ -252,12 +251,9 @@ function DTAutosuggest({
inputClassName,
translatedPlaceholder,
required,
- color,
- hoverColor,
ariaLabel,
- accessiblePrimaryColor,
fontWeights,
- modeIconColors,
+ colors,
modeSet,
showScroll,
isEmbedded,
@@ -544,11 +540,9 @@ function DTAutosuggest({
loading: state.loading,
isMobile,
ariaFavouriteString: t('favourite', { lng }),
- color,
- accessiblePrimaryColor,
fontWeights,
getAutoSuggestIcons,
- modeIconColors,
+ colors,
modeSet,
};
@@ -604,12 +598,9 @@ function DTAutosuggest({
onSelectedItemChange={onSelectedItemChange}
value={state.value}
clearInput={clearInput}
- itemProps={baseItemProps}
+ suggestionProps={baseItemProps}
showScroll={!!showScroll}
- color={color}
- hoverColor={hoverColor}
- clearButtonColor={color}
- accessiblePrimaryColor={accessiblePrimaryColor}
+ colors={colors}
inputClassName={inputClassName}
required={required}
state={state}
@@ -624,8 +615,8 @@ function DTAutosuggest({
state.renderMobile && 'hidden',
])}
style={{
- '--color': color,
- '--hover-color': hoverColor,
+ '--color': colors.primary,
+ '--hover-color': colors.hover,
}}
>
{icon && (
@@ -662,7 +653,7 @@ function DTAutosuggest({
clearInput={clearInput}
inputRef={inputRef}
styles={styles}
- clearButtonColor={color}
+ clearButtonColor={colors.primary}
placeholder={translatedPlaceholder || t(placeholder, { lng })}
required={required}
transportMode={transportMode}
@@ -676,9 +667,9 @@ function DTAutosuggest({
getItemProps={getItemProps}
getMenuProps={getMenuProps}
suggestions={state.suggestions}
- itemProps={baseItemProps}
lng={lng}
styles={styles}
+ {...baseItemProps}
/>
>
@@ -712,9 +703,6 @@ DTAutosuggest.propTypes = {
focusChange: PropTypes.func,
lang: PropTypes.string,
isMobile: PropTypes.bool,
- color: PropTypes.string,
- hoverColor: PropTypes.string,
- accessiblePrimaryColor: PropTypes.string,
pathOpts: PropTypes.shape({
routesPrefix: PropTypes.string,
stopsPrefix: PropTypes.string,
@@ -729,7 +717,7 @@ DTAutosuggest.propTypes = {
fontWeights: PropTypes.shape({
medium: PropTypes.number,
}),
- modeIconColors: PropTypes.objectOf(PropTypes.string),
+ colors: PropTypes.objectOf(PropTypes.string),
getAutoSuggestIcons: PropTypes.objectOf(PropTypes.func),
required: PropTypes.bool,
modeSet: PropTypes.string,
@@ -753,9 +741,6 @@ DTAutosuggest.defaultProps = {
isMobile: false,
isEmbedded: false,
geocodingSize: undefined,
- color: '#007ac9',
- hoverColor: '#0062a1',
- accessiblePrimaryColor: '#0074be',
pathOpts: {
routesPrefix: 'linjat',
stopsPrefix: 'pysakit',
@@ -767,7 +752,7 @@ DTAutosuggest.defaultProps = {
fontWeights: {
medium: 500,
},
- modeIconColors: undefined,
+ colors: defaultColors,
required: false,
modeSet: undefined,
showScroll: false,
diff --git a/digitransit-component/packages/digitransit-component-autosuggest/src/utils/translations.js b/digitransit-component/packages/digitransit-component-autosuggest/src/utils/translations.js
index 0daf347166..a594a2694d 100644
--- a/digitransit-component/packages/digitransit-component-autosuggest/src/utils/translations.js
+++ b/digitransit-component/packages/digitransit-component-autosuggest/src/utils/translations.js
@@ -145,7 +145,9 @@ const translations = {
stop: 'Stop',
'stop-near-you': 'Search stops and routes',
'stop-near-you-airplane': 'Search flights or airports',
+ 'stop-near-you-bikepark': 'Search bike parks',
'stop-near-you-bus': 'Search bus routes or stops',
+ 'stop-near-you-carpark': 'Search car parks',
'stop-near-you-citybike': 'Search city bike stations',
'stop-near-you-rail': 'Search train routes or stations',
'stop-near-you-subway': 'Search metro routes or stations ',
@@ -230,7 +232,9 @@ const translations = {
stop: 'Pysäkki',
'stop-near-you': 'Linja, pysäkki tai asema',
'stop-near-you-airplane': 'Hae lentoja tai lentoasemaa',
+ 'stop-near-you-bikepark': 'Hae pyöräparkkia',
'stop-near-you-bus': 'Hae bussilinjaa tai pysäkkiä',
+ 'stop-near-you-carpark': 'Hae autoparkkia',
'stop-near-you-citybike': 'Hae kaupunkipyöräasemaa',
'stop-near-you-rail': 'Hae lähijunaa tai asemaa',
'stop-near-you-subway': 'Hae metrolinjaa tai asemaa',
@@ -401,7 +405,9 @@ const translations = {
stop: 'Hållplats',
'stop-near-you': 'Sök hållplatser eller linjer',
'stop-near-you-airplane': 'Sök flyg eller flygplatser',
+ 'stop-near-you-bikepark': 'Sök cykelparkering',
'stop-near-you-bus': 'Sök busslinjer eller hållplatser',
+ 'stop-near-you-carpark': 'Sök anslutningsparkering',
'stop-near-you-citybike': 'Sök stadscykelstationer',
'stop-near-you-rail': 'Sök närtåger eller stationer',
'stop-near-you-subway': 'Sök metrolinjer eller stationer',
diff --git a/digitransit-component/packages/digitransit-component-control-panel/package.json b/digitransit-component/packages/digitransit-component-control-panel/package.json
index 4c8a39abf7..74afcef98e 100644
--- a/digitransit-component/packages/digitransit-component-control-panel/package.json
+++ b/digitransit-component/packages/digitransit-component-control-panel/package.json
@@ -1,6 +1,6 @@
{
"name": "@digitransit-component/digitransit-component-control-panel",
- "version": "6.0.2",
+ "version": "7.0.0",
"description": "digitransit-component control-panel module",
"main": "index.js",
"files": [
@@ -29,7 +29,8 @@
"author": "Digitransit Authors",
"license": "(AGPL-3.0 OR EUPL-1.2)",
"peerDependencies": {
- "@digitransit-component/digitransit-component-icon": "^1.2.0",
+ "@digitransit-component/digitransit-component-icon": "^2.0.0",
+ "@hsl-fi/modal": "^0.3.2",
"@hsl-fi/sass": "^0.2.0",
"classnames": "2.5.1",
"i18next": "^22.5.1",
diff --git a/digitransit-component/packages/digitransit-component-control-panel/src/helpers/AllModesModal.js b/digitransit-component/packages/digitransit-component-control-panel/src/helpers/AllModesModal.js
new file mode 100644
index 0000000000..e8d728d134
--- /dev/null
+++ b/digitransit-component/packages/digitransit-component-control-panel/src/helpers/AllModesModal.js
@@ -0,0 +1,74 @@
+import PropTypes from 'prop-types';
+import React from 'react';
+import { useTranslation } from 'react-i18next';
+import Modal from '@hsl-fi/modal';
+import styles from './styles.scss';
+
+export default function AllModesModal({
+ appElement,
+ modalOpen,
+ closeModal,
+ isMobile,
+ language,
+ fontWeights,
+ colors,
+ children,
+}) {
+ const [t] = useTranslation();
+
+ return (
+
+
+
+ {t('title', { lng: language })}
+
+ {!isMobile && (
+
+ {t('description', { lng: language })}
+
+ )}
+
+
+ {children}
+
+ {!isMobile && (
+
+ )}
+
+
+ {t('close', { lng: language })}
+
+
+
+
+ );
+}
+
+AllModesModal.propTypes = {
+ appElement: PropTypes.string.isRequired,
+ language: PropTypes.string.isRequired,
+ modalOpen: PropTypes.bool.isRequired,
+ closeModal: PropTypes.func.isRequired,
+ isMobile: PropTypes.bool.isRequired,
+ fontWeights: PropTypes.shape({ medium: PropTypes.number }).isRequired,
+ colors: PropTypes.objectOf(PropTypes.string).isRequired,
+ children: PropTypes.arrayOf(PropTypes.node).isRequired,
+};
diff --git a/digitransit-component/packages/digitransit-component-control-panel/src/helpers/NearYouButton.js b/digitransit-component/packages/digitransit-component-control-panel/src/helpers/NearYouButton.js
new file mode 100644
index 0000000000..9e8062cb1c
--- /dev/null
+++ b/digitransit-component/packages/digitransit-component-control-panel/src/helpers/NearYouButton.js
@@ -0,0 +1,109 @@
+import PropTypes from 'prop-types';
+import React from 'react';
+import Icon from '@digitransit-component/digitransit-component-icon';
+import styles from './styles.scss';
+
+export default function NearYouButton({
+ mode,
+ modeSet,
+ colors,
+ getIconName,
+ title,
+ srMsg,
+ withAlert,
+ boxed,
+ withBorder,
+ withArrow,
+ margin,
+ padding,
+ iconSize,
+}) {
+ let iconProps;
+
+ if (mode === 'favorite') {
+ iconProps = { img: 'star' };
+ } else if (mode === 'more') {
+ iconProps = {
+ img: 'arrow',
+ color: colors.primary,
+ width: 1.2,
+ height: 1.2,
+ };
+ } else {
+ iconProps = {
+ img: getIconName(mode, modeSet, boxed),
+ color: colors[mode],
+ };
+ }
+
+ if (!boxed) {
+ iconProps = {
+ ...iconProps,
+ width: 1.4,
+ height: 1.4,
+ };
+ }
+ const buttonStyle = { '--margin': margin, '--padding': padding };
+ let iconContainerStyle = { '--iconSize': iconSize, '--iconMargin': padding };
+ if (!boxed) {
+ iconContainerStyle = {
+ ...iconContainerStyle,
+ '--bckColor': colors[mode],
+ '--borderRadius': '50%',
+ '--iconMargin': '17px',
+ };
+ }
+
+ const buttonClass = withBorder
+ ? 'near-you-button-with-border'
+ : 'near-you-button';
+ return (
+ <>
+ {srMsg && {srMsg}}
+
+
+
+ {withAlert && (
+
+
+
+ )}
+
+ {title}
+ {withArrow && (
+
+
+
+ )}
+
+ >
+ );
+}
+
+NearYouButton.propTypes = {
+ mode: PropTypes.string.isRequired,
+ modeSet: PropTypes.string.isRequired,
+ colors: PropTypes.objectOf(PropTypes.string).isRequired,
+ getIconName: PropTypes.func.isRequired,
+ title: PropTypes.node,
+ srMsg: PropTypes.string,
+ withAlert: PropTypes.bool,
+ boxed: PropTypes.bool,
+ withBorder: PropTypes.bool,
+ withArrow: PropTypes.bool,
+ margin: PropTypes.string,
+ padding: PropTypes.string,
+ iconSize: PropTypes.string,
+};
+
+NearYouButton.defaultProps = {
+ title: '',
+ srMsg: undefined,
+ withAlert: false,
+ boxed: false,
+ withBorder: false,
+ withArrow: false,
+ margin: '8px',
+ padding: '8px',
+ iconSize: '30px',
+};
diff --git a/digitransit-component/packages/digitransit-component-control-panel/src/helpers/styles.js b/digitransit-component/packages/digitransit-component-control-panel/src/helpers/styles.js
deleted file mode 100644
index b15437b041..0000000000
--- a/digitransit-component/packages/digitransit-component-control-panel/src/helpers/styles.js
+++ /dev/null
@@ -1,64 +0,0 @@
-export function getStyleInput() {
- return {
- width: 200,
- };
-}
-
-export function getStyleMain() {
- return {
- display: 'flex',
- order: 1,
- flexDirection: 'column',
- alignItems: 'stretch',
- backgroundColor: '#ffffff',
- height: '100%',
- width: 'calc(100% - 2em)',
- maxWidth: 400,
- zIndex: 20,
- margin: '0 auto',
- };
-}
-
-export function getStyleMainBottom() {
- return {
- backgroundColor: '#ffffff',
- width: 'calc(100% - 2em)',
- margin: '0 auto',
- paddingBottom: 32,
- };
-}
-
-export function getStyleSeparatorDiv() {
- return {
- position: 'relative',
- display: 'block',
- width: '100%',
- // marginTop: 20,
- marginBottom: 19,
- paddingBottom: 29,
- };
-}
-
-export function getStyleSeparatorDiv2() {
- return {
- position: 'relative',
- display: 'block',
- width: '100%',
- // marginTop: 20,
- marginBottom: 19,
- paddingBottom: 20,
- };
-}
-
-export function getStyleSeparatorLine() {
- return {
- backgroundColor: '#ccc',
- content: '',
- display: 'block',
- height: 1,
- position: 'absolute',
- bottom: 0,
- right: -5,
- left: -5,
- };
-}
diff --git a/digitransit-component/packages/digitransit-component-control-panel/src/helpers/styles.scss b/digitransit-component/packages/digitransit-component-control-panel/src/helpers/styles.scss
index 07ca2afa22..a090f2782a 100644
--- a/digitransit-component/packages/digitransit-component-control-panel/src/helpers/styles.scss
+++ b/digitransit-component/packages/digitransit-component-control-panel/src/helpers/styles.scss
@@ -68,19 +68,63 @@
}
}
+.separator {
+ background-color: #ccc;
+ width: var(--width);
+ margin-left: var(--margin);
+ margin-right: var(--margin);
+ height: 1px;
+}
+
.near-you-container {
font-size: 16px;
+ .modal-desc {
+ font-weight: 325;
+ }
+
+ .close-container {
+ display: flex;
+ width: 100%;
+ height: 42px;
+ justify-content: right;
+ }
+
+ .close,
+ .close-mobile {
+ display: flex;
+ height: 40px;
+ color: var(--color);
+ font-size: 16px;
+ border-style: solid;
+ border-width: 1px;
+ border-radius: 20px;
+ background-color: white;
+ border-color: #888;
+ align-items: center;
+ justify-content: center;
+ margin-top: 20px;
+ }
+
+ .close {
+ width: 86px;
+
+ &:hover {
+ box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
+ }
+ }
+
+ .close-mobile {
+ width: 100%;
+ }
+
.near-you-title {
font-family: 'Gotham Rounded A', 'Gotham Rounded B', Roboto, Arial, Georgia,
serif;
- font-weight: var(--font-weight-medium);
- font-stretch: normal;
- font-style: normal;
+ font-weight: var(--font-weight);
line-height: normal;
letter-spacing: -0.67px;
color: #333;
- margin: 0 0 15px 0;
font-size: 1.125em;
@include min-width(tablet) {
@@ -130,82 +174,57 @@
white-space: nowrap;
width: 1px;
}
+ }
- .transport-mode-icon-container {
- cursor: pointer;
- border-radius: 10px;
- border: solid 1px #d9d9d9;
- background-color: white;
- display: flex;
- flex: 1;
- width: 100%;
- justify-content: center;
- max-width: 72px;
- height: 100%;
-
- .transport-mode-icon-with-icon {
- display: flex;
- position: relative;
- }
-
- span.transport-mode-alert-icon {
- position: absolute;
- bottom: -4px;
- right: -5px;
+ .near-you-button-with-border {
+ border: solid 1px #d9d9d9;
+ border-radius: 5px;
+ cursor: pointer;
+ background-color: white;
+ display: flex;
+ flex: 1;
+ width: 100%;
+ justify-content: center;
+ max-width: 72px;
+ height: 100%;
- svg {
- height: 15px !important;
- width: 15px !important;
+ .icon-container {
+ display: flex;
+ }
- @include min-width(tablet) {
- width: 18px !important;
- height: 18px !important;
- }
- }
- }
+ span.transport-mode-alert-icon {
+ position: absolute;
+ bottom: -4px;
+ right: -5px;
svg {
- width: 30px;
- height: 30px;
- margin: auto;
+ height: 15px !important;
+ width: 15px !important;
@include min-width(tablet) {
- width: 34px;
- height: 34px;
+ width: 18px !important;
+ height: 18px !important;
}
}
-
- &:hover {
- box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
- }
}
- }
- .near-you-buttons-container-wide {
- & > a:not(:last-child),
- & > div:not(:last-child) {
- margin-right: 9px;
+ svg {
+ width: 30px;
+ height: 30px;
+ margin: auto;
@include min-width(tablet) {
- margin-right: 10px;
+ width: 34px;
+ height: 34px;
}
}
- & > a:last-child,
- & > div:last-child {
- margin-bottom: 24px;
- }
-
- & > a,
- & > div {
- width: 100%;
- height: 48px;
-
- @include min-width(tablet) {
- margin-bottom: 8px;
- }
+ &:hover {
+ box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}
+ }
+ .near-you-buttons-container-wide {
.sr-only:not(:focus, :active) {
clip: rect(0 0 0 0);
clip-path: inset(50%);
@@ -216,26 +235,26 @@
width: 1px;
}
- .transport-mode-icon-container {
+ .near-you-button,
+ .near-you-button-with-border {
+ margin-bottom: var(--margin);
+ margin-top: var(--margin);
+ padding-bottom: var(--padding);
+ padding-top: var(--padding);
cursor: pointer;
- position: relative;
display: flex;
- border-radius: 5px;
- border: solid 1px #ddd;
background-color: white;
flex: 1;
min-width: 100%;
- height: 48px;
- .transport-mode-icon-with-icon {
+ .icon-container {
cursor: pointer;
display: flex;
- position: relative;
- left: 17px;
+ margin-left: var(--iconMargin);
border-radius: var(--borderRadius);
background-color: var(--bckColor);
- height: 30px;
- width: 30px;
+ height: var(--iconSize);
+ width: var(--iconSize);
align-items: center;
align-self: center;
justify-content: center;
@@ -259,141 +278,34 @@
.transport-mode-title {
cursor: pointer;
- position: relative;
font-style: normal;
- font-weight: var(--font-weight-medium);
+ font-weight: var(--font-weight);
font-size: 15px;
line-height: 18px;
+ margin-left: 9px;
align-self: center;
- left: 26px;
+ text-align: left;
width: calc(100% - 58px);
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
-
- &:hover {
- box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
- }
}
- }
-}
-.nearby-stops-bubble-dialog {
- position: relative;
- width: 100%;
- z-index: 23;
- margin-bottom: 10px;
-
- @keyframes appear {
- 0% {
- opacity: 0;
- transform: translateY(-15px);
+ .near-you-button-caret {
+ align-self: center;
}
- 100% {
- opacity: 1;
- transform: translateY(0);
+ .near-you-button:hover .near-you-button-caret {
+ transform: translateX(4px);
+ transition: transform 0.1s;
}
- }
-
- opacity: 0;
-
- &.visible {
- opacity: 1;
- animation: appear 0.5s;
- }
-
- @include min-width(tablet) {
- position: absolute;
- width: 0;
- height: 0;
- margin: 0;
- }
-
- .nearby-stops-bubble-dialog-container {
- display: flex;
- position: relative;
- border-radius: 5px;
- background: #ffefe8;
- font-size: 15px;
- line-height: 18px;
- letter-spacing: -0.03em;
- padding: 15px 0 17px 0;
-
- @include min-width(tablet) {
- position: absolute;
- padding: 12px 0 11px 0;
- min-height: 80px;
- width: 300px;
- left: 230px;
- transform: translateY(-100%);
- top: -6px;
- }
-
- .nearby-stops-bubble-dialog-header {
- font-weight: var(--font-weight-medium);
- padding: 0 49px 4px 20px;
-
- &.fi {
- min-height: 19.2px;
- }
-
- &.sv,
- &.en {
- min-height: 39.2px;
- }
- @include min-width(tablet) {
- padding: 0 44px 3px 20px;
- }
- }
-
- .nearby-stops-bubble-dialog-content {
- font-weight: 400;
- padding: 0 49px 0 20px;
- min-height: 35.2px;
-
- @include min-width(tablet) {
- padding: 0 57px 0 20px;
- }
- }
-
- .nearby-stops-bubble-dialog-close {
- display: flex;
- position: absolute;
- right: 15px;
- top: 14px;
- padding: 0;
- margin: 0;
- cursor: pointer;
- border: none;
- background: transparent;
-
- @include min-width(tablet) {
- top: 16px;
- }
-
- svg {
- fill: #333;
- width: 16px;
- height: 16px;
- }
- }
-
- .nearby-stops-bubble-dialog-tip-container {
- position: absolute;
- height: 42px;
- overflow: hidden;
- width: 42px;
- background-color: #ffefe8;
- transform: rotate(45deg);
- z-index: -1;
- bottom: -4px;
- left: 52px;
+ .near-you-button-with-border {
+ border: solid 1px #d9d9d9;
- @include min-width(tablet) {
- left: 18px;
+ &:hover {
+ box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}
}
}
diff --git a/digitransit-component/packages/digitransit-component-control-panel/src/helpers/translations.js b/digitransit-component/packages/digitransit-component-control-panel/src/helpers/translations.js
index 94900029fe..252054974a 100644
--- a/digitransit-component/packages/digitransit-component-control-panel/src/helpers/translations.js
+++ b/digitransit-component/packages/digitransit-component-control-panel/src/helpers/translations.js
@@ -1,117 +1,120 @@
const translations = {
de: {
translation: {
- 'close-teaser-modal': 'Schließen',
- 'pick-mode': 'Wählen Sie ein Verkehrsmittel',
- 'pick-mode-airplane': 'Flug',
- 'pick-mode-bus': 'Bus',
- 'pick-mode-citybike': 'Leihrad',
- 'pick-mode-favorite': 'Favoriten',
- 'pick-mode-ferry': 'Fähre',
- 'pick-mode-rail': 'Zug',
- 'pick-mode-subway': 'U-Bahn',
- 'pick-mode-tram': 'Straßenbahn',
- 'placeholder-destination': 'Geben Sie Ihren Zielort ein',
- 'placeholder-origin': 'Geben Sie Ihren Abfahrtsort ein',
- 'placeholder-route-stop-station': 'Enter route, stop or station',
- 'title-route-stop-station': 'Haltestellen und Linien in der Nähe',
- 'title-origin-to-destination': 'Wohin?',
- 'use-own-position': 'Verwende aktuelle Position',
+ airplane: 'Flug',
+ bus: 'Bus',
+ citybike: 'Leihrad',
+ favorite: 'Favoriten',
+ ferry: 'Fähre',
+ rail: 'Zug',
+ subway: 'U-Bahn',
+ tram: 'Straßenbahn',
+ title: 'Haltestellen und Linien in der Nähe',
+ close: 'Schließen',
},
},
en: {
translation: {
- 'close-teaser-modal': 'Close',
- 'pick-mode': 'Select a transport mode',
- 'pick-mode-airplane': 'Flight',
- 'pick-mode-bus': 'Bus',
- 'pick-mode-citybike': 'Citybike',
- 'pick-mode-favorite': 'Stops nearby me',
- 'pick-mode-ferry': 'Ferry',
- 'pick-mode-rail': 'Rail',
- 'pick-mode-subway': 'Metro',
- 'pick-mode-tram': 'Tram',
- 'placeholder-destination': 'Enter destination',
- 'placeholder-origin': 'Enter origin',
- 'placeholder-route-stop-station': 'Enter route, stop or station',
- 'title-route-stop-station': 'Nearby stops and routes',
- 'title-origin-to-destination': 'Where to?',
- 'use-own-position': 'Use current location',
- 'nearby-stops-teaser-header':
- 'Try the new map views showing nearby stops',
- 'nearby-stops-teaser-content':
- 'Real-time timetables for nearby stops and vehicles on map.',
+ airplane: 'The closest airports',
+ airplane_short: 'Airport',
+ bus: 'Buses and nearby stops on map',
+ bus_short: 'Bus',
+ citybike: 'The closest city bike stations',
+ citybike_short: 'City bike',
+ favorite: 'Favorites near you',
+ favorite_short: 'Favorites',
+ ferry: 'The closest ferry piers',
+ ferry_short: 'Ferry',
+ rail: 'Trains and nearby stations on map',
+ rail_short: 'Train',
+ rail_local: 'Commuter train',
+ subway: 'Metro and nearby stations on map',
+ subway_short: 'Metro',
+ tram: 'Trams and nearby stops on map',
+ tram_short: 'Tram',
+ bikepark: 'The closest bike parks',
+ bikepark_short: 'Bike parking',
+ carpark: 'The closest car parks',
+ carpark_short: 'Car parking',
+ more: 'Show more',
+ title: 'Near you',
+ description:
+ 'The Near You view shows stops and lines near you at a glance',
+ close: 'Close',
},
},
fi: {
translation: {
- 'close-teaser-modal': 'Sulje',
- 'pick-mode': 'Valitse joukkoliikennevälineistä',
- 'pick-mode-airplane': 'Lentokone',
- 'pick-mode-bus': 'Bussi',
- 'pick-mode-citybike': 'Kaupunkipyörä',
- 'pick-mode-favorite': 'Omat lähipysäkit',
- 'pick-mode-ferry': 'Lautta',
- 'pick-mode-rail': 'Juna',
- 'pick-mode-subway': 'Metro',
- 'pick-mode-tram': 'Raitiovaunu',
- 'placeholder-destination': 'Syötä määränpää',
- 'placeholder-origin': 'Syötä lähtöpaikka',
- 'placeholder-route-stop-station': 'Syötä linja, pysäkki tai asema',
- 'title-route-stop-station': 'Lähipysäkit ja linjat',
- 'title-origin-to-destination': 'Minne mennään?',
- 'use-own-position': 'Käytä nykyistä sijaintia',
- 'nearby-stops-teaser-header': 'Kokeile uusia lähipysäkkinäkymiä',
- 'nearby-stops-teaser-content':
- 'Reaaliaikaiset lähipysäkkiesi aikataulut ja ajoneuvot kartalla.',
+ airplane: 'Lähimmät lentoasemat',
+ airplane_short: 'Lentoasema',
+ bus: 'Bussit ja lähipysäkit kartalla',
+ bus_short: 'Bussi',
+ citybike: 'Lähimmät kaupunkipyöräasemat',
+ citybike_short: 'Kaupunkipyörä',
+ favorite: 'Lähimmät suosikit',
+ favorite_short: 'Suosikit',
+ ferry: 'Lähimmät lauttalaiturit',
+ ferry_short: 'Lautta',
+ rail: 'Junat ja lähiasemat kartalla',
+ rail_short: 'Juna',
+ rail_local: 'Lähijuna',
+ subway: 'Metrot ja lähiasemat kartalla',
+ subway_short: 'Metro',
+ tram: 'Raitiovaunut ja lähipysäkit kartalla',
+ tram_short: 'Raitiovaunu',
+ bikepark: 'Lähimmät liityntäpysäköinnit pyörille',
+ bikepark_short: 'Liityntäpysäköinti pyörille',
+ carpark: 'Lähimmät liityntäpysäköinnit autoille',
+ carpark_short: 'Liityntäpysäköinti autoille',
+ more: 'Näytä lisää',
+ title: 'Lähelläsi',
+ description:
+ 'Lähelläsi -näkymä näyttää yhdellä kertaa pysäkit ja linjat lähelläsi',
+ close: 'Sulje',
},
},
pl: {
translation: {
- 'close-teaser-modal': 'Zamknij',
- 'pick-mode': 'Wybierz typ transportu',
- 'pick-mode-airplane': 'Lot',
- 'pick-mode-bus': 'Autobus',
- 'pick-mode-citybike': 'Rower miejski',
- 'pick-mode-favorite': 'Przystanki w pobliżu',
- 'pick-mode-ferry': 'Prom',
- 'pick-mode-rail': 'Kolej',
- 'pick-mode-subway': 'Metro',
- 'pick-mode-tram': 'Tramwaj',
- 'placeholder-destination': 'Wprowadź cel',
- 'placeholder-origin': 'Wprowadź początek',
- 'placeholder-route-stop-station': 'Wprowadź trasę, przystanek lub stację',
- 'title-route-stop-station': 'Przystanki i trasy w pobliżu',
- 'title-origin-to-destination': 'Dokąd?',
- 'use-own-position': 'Użyj obecnej lokalizacji',
- 'nearby-stops-teaser-header':
- 'Wypróbuj nowy widok mapy pokazujący przystanki w pobliżu',
- 'nearby-stops-teaser-content':
- 'Rozkłady jazdy w czasie rzeczywistym dla pobliskich przystanków i pojazdów na mapie.',
+ airplane: 'Lot',
+ bus: 'Autobus',
+ citybike: 'Rower miejski',
+ favorite: 'Przystanki w pobliżu',
+ ferry: 'Prom',
+ rail: 'Kolej',
+ subway: 'Metro',
+ tram: 'Tramwaj',
+ title: 'Przystanki i trasy w pobliżu',
+ sulje: 'Zamknij',
},
},
sv: {
translation: {
- 'close-teaser-modal': 'Stäng',
- 'pick-mode': 'Välj ett transportläge',
- 'pick-mode-airplane': 'Flyg',
- 'pick-mode-bus': 'Buss',
- 'pick-mode-citybike': 'Stadscykel',
- 'pick-mode-favorite': 'Hållplatser nära mig',
- 'pick-mode-ferry': 'Färja',
- 'pick-mode-rail': 'Tåg',
- 'pick-mode-subway': 'Metro',
- 'pick-mode-tram': 'Spårvagn',
- 'placeholder-destination': 'Skriv destination',
- 'placeholder-origin': 'Skriv avfärdsplats',
- 'placeholder-route-stop-station': 'Skriv linje, hållplats eller station',
- 'title-route-stop-station': 'Hållplatser och linjer nära dig',
- 'title-origin-to-destination': 'Var till?',
- 'use-own-position': 'Använd min position',
- 'nearby-stops-teaser-header':
- 'Prova de nya kartavyerna som visar hållplatserna i närheten',
- 'nearby-stops-teaser-content':
- 'Fordonen och tidtabellerna i realtid för hållplatserna nära dig på kartan.',
+ airplane: 'Närmaste flygplatser',
+ airplane_short: 'Flygplats',
+ bus: 'Bussar och hållplatser på kartan',
+ bus_short: 'Bus',
+ citybike: 'Närmaste cykelstationer',
+ citybike_short: 'Cykelstation',
+ favorite: 'Hållplatser nära mig',
+ favorite_short: 'Favoriter',
+ ferry: 'Närmaste färjekajer',
+ ferry_short: 'Färja',
+ rail: 'Tåg och stationer på kartan',
+ rail_short: 'Tåg',
+ rail_local: 'Närtåg',
+ subway: 'Metro och stationer på kartan',
+ subway_short: 'Metro',
+ tram: 'Spårvagnar och hållplatser på kartan',
+ tram_short: 'Spårvagn',
+ bikepark: 'Närmaste anslutningsparkering för cyklar',
+ bikepark_short: 'Anslutningsparkering för cyklar',
+ carpark: 'Närmaste anslutningsparkering för bilar',
+ carpark_short: 'Anslutningsparkering för bilar',
+ more: 'Visa flera',
+ title: 'Nära dig',
+ description:
+ 'Vyn Nära dig visar hållplatser och linjer nära dig i ett ögonkast',
+ close: 'Stäng',
},
},
};
diff --git a/digitransit-component/packages/digitransit-component-control-panel/src/index.js b/digitransit-component/packages/digitransit-component-control-panel/src/index.js
index e7265a2801..019342115b 100644
--- a/digitransit-component/packages/digitransit-component-control-panel/src/index.js
+++ b/digitransit-component/packages/digitransit-component-control-panel/src/index.js
@@ -4,7 +4,9 @@
import PropTypes from 'prop-types';
import React, { useEffect, useState } from 'react';
import { useTranslation, I18nextProvider } from 'react-i18next';
-import Icon from '@digitransit-component/digitransit-component-icon';
+import { defaultColors } from '@digitransit-component/digitransit-component-icon';
+import NearYouButton from './helpers/NearYouButton';
+import AllModesModal from './helpers/AllModesModal';
import styles from './helpers/styles.scss';
import i18n from './helpers/i18n';
@@ -45,15 +47,13 @@ SeparatorLine.defaultProps = {
* @param {Object} props
* @param {string[]} props.modeArray - Names of transport modes to show buttons for. Should be in lower case. Also defines button order
* @param {string} props.language - Language used for accessible labels
- * @param {string} props.urlPrefix - URL prefix for links. Must end with /lahellasi
- * @param {boolean} props.showTitle - Show title, default is false
+ * @param {boolean} props.title - Custom titles per language
* @param {Object} props.alertsContext
* @param {function} props.alertsContext.getModesWithAlerts - Function which should return an array of transport modes that have active alerts (e.g. [BUS, SUBWAY])
* @param {Number} props.alertsContext.currentTime - Time stamp with which the returned alerts are validated with
* @param {Number} props.alertsContext.feedIds - feedIds for which the alerts are fetched for
- * @param {element} props.LinkComponent - React component for creating a link, default is undefined and normal anchor tags are used
- * @param {element} props.modeIconColors - object of mode icon colors used for transport mode icons
- *
+ * @param {element} props.colors - theme color configuration
+ * @param {string} props.urlPrefix - URL prefix for links
* @example
* const alertsContext = {
* getModesWithAlerts: () => ({}),
@@ -63,8 +63,6 @@ SeparatorLine.defaultProps = {
*
*
@@ -79,32 +77,49 @@ const validNearYouModes = [
'airplane',
'ferry',
'citybike',
+ 'bikepark',
+ 'carpark',
];
-function getIconName(mode, modeSet) {
- return modeSet === 'default' ? `mode-${mode}` : `mode-${modeSet}-${mode}`;
+const noTheme = ['bikepark', 'carpark', 'subway', 'airplane']; // common icon in all themes
+
+function getIconName(mode, modeSet, boxed) {
+ const theme = noTheme.includes(mode) ? '' : `-${modeSet}`;
+ const fill = boxed ? '' : '-fill'; // do not render boxed icon for vertical
+ return `${mode}${fill}${theme}`;
}
+const MAX_VISIBLE_MODES = 7;
+
function NearStopsAndRoutes({
+ appElement,
+ horizontal,
modeArray,
- urlPrefix,
language,
- showTitle,
+ title,
alertsContext,
- LinkComponent,
origin,
- omitLanguageUrl,
onClick,
- buttonStyle,
- title,
- modes,
modeSet,
- modeIconColors,
+ colors,
fontWeights,
+ isMobile,
+ urlPrefix,
+ omitLanguageUrl,
}) {
const [modesWithAlerts, setModesWithAlerts] = useState([]);
+ const [modalOpen, setModalOpen] = useState(false);
const [t] = useTranslation();
+ let urlStart;
+ if (omitLanguageUrl) {
+ urlStart = urlPrefix;
+ } else {
+ const urlParts = urlPrefix.split('/');
+ urlParts.splice(urlParts.length - 1, 0, language);
+ urlStart = urlParts.join('/');
+ }
+
useEffect(() => {
if (alertsContext) {
alertsContext
@@ -115,182 +130,182 @@ function NearStopsAndRoutes({
}
}, []);
- let urlStart;
- if (omitLanguageUrl) {
- urlStart = urlPrefix;
- } else {
- const urlParts = urlPrefix.split('/');
- urlParts.splice(urlParts.length - 1, 0, language);
- urlStart = urlParts.join('/');
- }
- const buttons = modeArray
- .filter(mode => validNearYouModes.includes(mode))
- .map(mode => {
- const withAlert = modesWithAlerts.includes(mode.toUpperCase());
- let url = `${urlStart}/${mode.toUpperCase()}/POS`;
- if (origin.lat && origin.lon) {
- url += `/${encodeURIComponent(origin.address)}::${origin.lat},${
+ const urlPostfix =
+ origin.lat && origin.lon
+ ? `/POS/${encodeURIComponent(origin.address)}::${origin.lat},${
origin.lon
- }`;
- }
+ }`
+ : '/POS';
+ const linkedButtonProps = { role: 'link', tabIndex: '0' };
- const modeButton = !modes ? (
- <>
-
- {t(`pick-mode-${mode}`, { lng: language })}
-
-
-
-
- {withAlert && (
-
-
-
- )}
-
-
- >
- ) : (
- <>
-
- {t(`pick-mode-${mode}`, { lng: language })}
-
-
-
-
- {withAlert && (
-
-
-
- )}
-
-
- {modes[mode]['nearYouLabel'][language]}
-
-
- >
- );
+ // line between buttons
+ const separator = (
+
+ );
+ const renderButtons = (modes, forModal) =>
+ modes.map(mode => {
+ const withAlert = modesWithAlerts.includes(mode.toUpperCase());
+ const url = `${urlStart}/${mode.toUpperCase()}${urlPostfix}`;
+ const boxed = forModal || horizontal; // squared icon or interior only
+ const buttonProps = {
+ mode,
+ modeSet,
+ colors,
+ withAlert,
+ boxed,
+ getIconName,
+ };
- if (onClick) {
- return (
- {
- if (isKeyboardSelectionEvent(e)) {
- onClick(url, e);
- }
- }}
- onClick={() => onClick(url)}
+ if (forModal || !horizontal) {
+ let key = mode;
+ if (forModal) {
+ key =
+ modeSet === 'hsl' && mode === 'rail'
+ ? 'rail_local'
+ : `${mode}_short`;
+ }
+ buttonProps.title = (
+
- {modeButton}
-
+ {t(key, { lng: language })}
+
);
+ } else {
+ buttonProps.srMsg = t(mode, { lng: language });
}
- if (LinkComponent) {
- return (
-
- {modeButton}
-
- );
+ if (!forModal) {
+ buttonProps.withBorder = true;
+ } else {
+ buttonProps.withArrow = true;
+ buttonProps.margin = '0';
+ buttonProps.iconSize = '35px';
+ buttonProps.padding = '6px';
}
- return (
-
- {modeButton}
-
+ const clickProps =
+ mode === 'more'
+ ? {
+ onKeyDown: e => {
+ if (isKeyboardSelectionEvent(e)) {
+ setModalOpen(true);
+ }
+ },
+ onClick: () => setModalOpen(true),
+ }
+ : {
+ onKeyDown: e => {
+ if (isKeyboardSelectionEvent(e)) {
+ onClick(url, e);
+ }
+ },
+ onClick: () => onClick(url),
+ };
+
+ const button = (
+
+
+
+ );
+
+ // add separator line into modal button array
+ return forModal && mode !== modes[modes.length - 1] ? (
+
+ {button}
+ {separator}
+
+ ) : (
+ button
);
});
+ const modes = modeArray.filter(mode => validNearYouModes.includes(mode));
+ const useModal = horizontal && modes.length > MAX_VISIBLE_MODES;
+ let visibleModes = modes;
+
+ if (useModal) {
+ visibleModes = modes.slice(0, MAX_VISIBLE_MODES - 1);
+ visibleModes.push('more');
+ }
+
return (
- {showTitle && (
-
- {!modes
- ? t('title-route-stop-station', { lng: language })
- : title[language]}
-
+ {useModal && (
+ setModalOpen(false)}
+ colors={colors}
+ >
+ {renderButtons(modes, true)}
+
)}
+
+ {title?.[language] || t('title', { lng: language })}
+
- {buttons}
+ {renderButtons(visibleModes, false)}
);
}
NearStopsAndRoutes.propTypes = {
+ appElement: PropTypes.string.isRequired,
modeArray: PropTypes.arrayOf(PropTypes.string).isRequired,
- urlPrefix: PropTypes.string.isRequired,
+ title: PropTypes.objectOf(PropTypes.string),
language: PropTypes.string,
- showTitle: PropTypes.bool,
+ horizontal: PropTypes.bool,
alertsContext: PropTypes.shape({
getModesWithAlerts: PropTypes.func,
currentTime: PropTypes.number,
feedIds: PropTypes.arrayOf(PropTypes.string),
}),
- LinkComponent: PropTypes.object,
origin: PropTypes.shape({
address: PropTypes.string,
lat: PropTypes.number,
lon: PropTypes.number,
}),
- omitLanguageUrl: PropTypes.bool,
- onClick: PropTypes.func,
- buttonStyle: PropTypes.objectOf(PropTypes.string),
- title: PropTypes.objectOf(PropTypes.string),
- modes: PropTypes.object,
- modeIconColors: PropTypes.objectOf(PropTypes.string),
+ onClick: PropTypes.func.isRequired,
+ colors: PropTypes.objectOf(PropTypes.string),
modeSet: PropTypes.string,
fontWeights: PropTypes.shape({
medium: PropTypes.number,
}),
+ isMobile: PropTypes.bool,
+ urlPrefix: PropTypes.string.isRequired,
+ omitLanguageUrl: PropTypes.bool,
};
NearStopsAndRoutes.defaultProps = {
- showTitle: false,
+ horizontal: true,
language: 'fi',
- LinkComponent: undefined,
origin: undefined,
- omitLanguageUrl: undefined,
- buttonStyle: undefined,
alertsContext: undefined,
- onClick: undefined,
title: undefined,
- modes: undefined,
- modeIconColors: {
- 'mode-bus': '#007ac9',
- 'mode-rail': '#8c4799',
- 'mode-tram': '#008151',
- 'mode-subway': '#ed8c00',
- 'mode-ferry': '#007A97',
- 'mode-citybike': '#F2B62D',
- },
- modeSet: 'default',
- fontWeights: {
- medium: 500,
- },
+ colors: defaultColors,
+ modeSet: 'hsl',
+ fontWeights: { medium: 500 },
+ isMobile: false,
+ omitLanguageUrl: false,
};
/**
@@ -302,8 +317,6 @@ NearStopsAndRoutes.defaultProps = {
*
*
*/
@@ -337,7 +350,7 @@ class CtrlPanel extends React.Component {
{this.props.children}
diff --git a/digitransit-component/packages/digitransit-component-datetimepicker/package.json b/digitransit-component/packages/digitransit-component-datetimepicker/package.json
index a07bfd3af3..fdc86d1bb6 100644
--- a/digitransit-component/packages/digitransit-component-datetimepicker/package.json
+++ b/digitransit-component/packages/digitransit-component-datetimepicker/package.json
@@ -1,6 +1,6 @@
{
"name": "@digitransit-component/digitransit-component-datetimepicker",
- "version": "4.0.2",
+ "version": "5.0.0",
"description": "digitransit-component datetimepicker module",
"main": "index.js",
"files": [
@@ -29,7 +29,7 @@
"author": "Digitransit Authors",
"license": "(AGPL-3.0 OR EUPL-1.2)",
"peerDependencies": {
- "@digitransit-component/digitransit-component-icon": "^1.2.0",
+ "@digitransit-component/digitransit-component-icon": "^2.0.0",
"classnames": "2.5.1",
"i18next": "^22.5.1",
"lodash": "4.17.21",
diff --git a/digitransit-component/packages/digitransit-component-dialog-modal/package.json b/digitransit-component/packages/digitransit-component-dialog-modal/package.json
index fcaa7ce5d7..d673b92d23 100644
--- a/digitransit-component/packages/digitransit-component-dialog-modal/package.json
+++ b/digitransit-component/packages/digitransit-component-dialog-modal/package.json
@@ -1,6 +1,6 @@
{
"name": "@digitransit-component/digitransit-component-dialog-modal",
- "version": "2.0.0",
+ "version": "3.0.0",
"description": "digitransit-component dialog-modal module",
"main": "index.js",
"files": [
@@ -32,6 +32,7 @@
"@hsl-fi/modal": "^0.3.2"
},
"peerDependencies": {
+ "@digitransit-component/digitransit-component-icon": "^2.0.0",
"@hsl-fi/sass": "^0.2.0",
"classnames": "2.5.1",
"i18next": "^22.5.1",
diff --git a/digitransit-component/packages/digitransit-component-dialog-modal/src/index.js b/digitransit-component/packages/digitransit-component-dialog-modal/src/index.js
index 26297f8cc9..cf13337120 100644
--- a/digitransit-component/packages/digitransit-component-dialog-modal/src/index.js
+++ b/digitransit-component/packages/digitransit-component-dialog-modal/src/index.js
@@ -5,6 +5,7 @@ import React from 'react';
import cx from 'classnames';
import { I18nextProvider, useTranslation } from 'react-i18next';
import Modal from '@hsl-fi/modal';
+import { defaultColors } from '@digitransit-component/digitransit-component-icon';
import styles from './helpers/styles.scss';
import i18n from './helpers/i18n';
@@ -38,8 +39,7 @@ const DialogModal = ({
appElement,
isModalOpen,
modalAriaLabel,
- color,
- hoverColor,
+ colors,
fontWeights,
}) => {
const [t] = useTranslation();
@@ -55,8 +55,8 @@ const DialogModal = ({
>
@@ -125,8 +125,7 @@ DialogModal.propTypes = {
lang: PropTypes.string.isRequired,
modalAriaLabel: PropTypes.string,
href: PropTypes.string,
- color: PropTypes.string,
- hoverColor: PropTypes.string,
+ colors: PropTypes.objectOf(PropTypes.string),
fontWeights: PropTypes.shape({
medium: PropTypes.number,
}),
@@ -139,17 +138,12 @@ DialogModal.defaultProps = {
secondaryButtonOnClick: undefined,
href: undefined,
modalAriaLabel: '',
- color: '#007ac9',
- hoverColor: '#0062a1',
+ colors: defaultColors,
fontWeights: {
medium: 500,
},
};
-DialogModal.contextTypes = {
- config: PropTypes.object,
-};
-
export default props => (
diff --git a/digitransit-component/packages/digitransit-component-favourite-bar/package.json b/digitransit-component/packages/digitransit-component-favourite-bar/package.json
index c0574f197c..f65c2495ab 100644
--- a/digitransit-component/packages/digitransit-component-favourite-bar/package.json
+++ b/digitransit-component/packages/digitransit-component-favourite-bar/package.json
@@ -1,6 +1,6 @@
{
"name": "@digitransit-component/digitransit-component-favourite-bar",
- "version": "4.0.3",
+ "version": "5.0.0",
"description": "digitransit-component favourite-bar module",
"main": "index.js",
"files": [
@@ -32,8 +32,8 @@
"@digitransit-search-util/digitransit-search-util-uniq-by-label": "^2.1.0"
},
"peerDependencies": {
- "@digitransit-component/digitransit-component-icon": "^1.2.0",
- "@digitransit-component/digitransit-component-suggestion-item": "^2.3.2",
+ "@digitransit-component/digitransit-component-icon": "^2.0.0",
+ "@digitransit-component/digitransit-component-suggestion-item": "^3.0.0",
"@hsl-fi/sass": "^0.2.0",
"@hsl-fi/shimmer": "0.1.2",
"classnames": "2.5.1",
diff --git a/digitransit-component/packages/digitransit-component-favourite-bar/src/index.js b/digitransit-component/packages/digitransit-component-favourite-bar/src/index.js
index bbcd4c9734..1093ac0845 100644
--- a/digitransit-component/packages/digitransit-component-favourite-bar/src/index.js
+++ b/digitransit-component/packages/digitransit-component-favourite-bar/src/index.js
@@ -11,7 +11,9 @@ import isEqual from 'lodash/isEqual';
import isEmpty from 'lodash/isEmpty';
import Shimmer from '@hsl-fi/shimmer';
import SuggestionItem from '@digitransit-component/digitransit-component-suggestion-item';
-import Icon from '@digitransit-component/digitransit-component-icon';
+import Icon, {
+ defaultColors,
+} from '@digitransit-component/digitransit-component-icon';
import { formatFavouritePlaceLabel } from '@digitransit-search-util/digitransit-search-util-uniq-by-label';
import styles from './helpers/styles.scss';
import i18n from './helpers/i18n';
@@ -139,8 +141,8 @@ class FavouriteBar extends React.Component {
lang: PropTypes.string,
/** Optional. Whether to show loading animation, true or false. */
isLoading: PropTypes.bool,
- /** Optional. Default value is '#007ac9'. */
- color: PropTypes.string,
+ /** Optional color palette */
+ colors: PropTypes.objectOf(PropTypes.string),
/** Optional. */
fontWeights: PropTypes.shape({
/** Default value is 500. */
@@ -158,7 +160,7 @@ class FavouriteBar extends React.Component {
onAddWork: () => ({}),
lang: 'fi',
isLoading: false,
- color: '#007ac9',
+ colors: defaultColors,
fontWeights: {
medium: 500,
},
@@ -286,12 +288,7 @@ class FavouriteBar extends React.Component {
}
};
- renderSuggestion = (
- item,
- index,
- ariaLabelSuffix = '',
- className = undefined,
- ) => {
+ renderSuggestion = (item, index, ariaLabelSuffix = '') => {
const id = `favourite-suggestion-list--item-${index}`;
return (
@@ -312,8 +309,7 @@ class FavouriteBar extends React.Component {
>
@@ -342,6 +338,7 @@ class FavouriteBar extends React.Component {
render() {
const { onClickFavourite, isLoading, fontWeights } = this.props;
+ const { primary } = this.props.colors;
const { listOpen, favourites, firstFavourite, secondFavourite } =
this.state;
const expandIcon = this.props.favourites.length === 0 ? 'plus' : 'arrow';
@@ -368,7 +365,7 @@ class FavouriteBar extends React.Component {
: 'home'
}
isLoading={isLoading}
- color={this.props.color}
+ color={primary}
lang={this.props.lang}
/>
{/* eslint-disable jsx-a11y/role-supports-aria-props */}
@@ -404,7 +401,7 @@ class FavouriteBar extends React.Component {
aria-label={this.translate('open-favourites')}
>
-
+
{/* eslint-enable jsx-a11y/role-supports-aria-props */}
@@ -441,7 +438,6 @@ class FavouriteBar extends React.Component {
item,
favourites.length + index,
undefined,
- 'favouriteCustom',
),
)}
diff --git a/digitransit-component/packages/digitransit-component-favourite-editing-modal/package.json b/digitransit-component/packages/digitransit-component-favourite-editing-modal/package.json
index d8366dc0a8..d64b7994c4 100644
--- a/digitransit-component/packages/digitransit-component-favourite-editing-modal/package.json
+++ b/digitransit-component/packages/digitransit-component-favourite-editing-modal/package.json
@@ -1,6 +1,6 @@
{
"name": "@digitransit-component/digitransit-component-favourite-editing-modal",
- "version": "4.0.1",
+ "version": "5.0.0",
"description": "digitransit-component favourite-editing-modal module",
"main": "index.js",
"files": [
@@ -32,8 +32,8 @@
"@digitransit-search-util/digitransit-search-util-uniq-by-label": "^2.1.0"
},
"peerDependencies": {
- "@digitransit-component/digitransit-component-dialog-modal": "^2.0.0",
- "@digitransit-component/digitransit-component-icon": "^1.2.0",
+ "@digitransit-component/digitransit-component-dialog-modal": "^3.0.0",
+ "@digitransit-component/digitransit-component-icon": "^2.0.0",
"@hsl-fi/container-spinner": "0.3.2",
"@hsl-fi/modal": "^0.3.2",
"@hsl-fi/sass": "^0.2.0",
diff --git a/digitransit-component/packages/digitransit-component-favourite-editing-modal/src/helpers/ModalContent.js b/digitransit-component/packages/digitransit-component-favourite-editing-modal/src/helpers/ModalContent.js
index 48ed1b7d2f..360a2b80a9 100644
--- a/digitransit-component/packages/digitransit-component-favourite-editing-modal/src/helpers/ModalContent.js
+++ b/digitransit-component/packages/digitransit-component-favourite-editing-modal/src/helpers/ModalContent.js
@@ -1,4 +1,3 @@
-/* eslint-disable jsx-a11y/click-events-have-key-events */
import React from 'react';
import PropTypes from 'prop-types';
import styles from './modal-content.scss';
diff --git a/digitransit-component/packages/digitransit-component-favourite-editing-modal/src/index.js b/digitransit-component/packages/digitransit-component-favourite-editing-modal/src/index.js
index 85d88424bf..39c9e21191 100644
--- a/digitransit-component/packages/digitransit-component-favourite-editing-modal/src/index.js
+++ b/digitransit-component/packages/digitransit-component-favourite-editing-modal/src/index.js
@@ -10,7 +10,9 @@ import isEmpty from 'lodash/isEmpty';
import omit from 'lodash/omit';
import ContainerSpinner from '@hsl-fi/container-spinner';
import Modal from '@hsl-fi/modal';
-import Icon from '@digitransit-component/digitransit-component-icon';
+import Icon, {
+ defaultColors,
+} from '@digitransit-component/digitransit-component-icon';
import DialogModal from '@digitransit-component/digitransit-component-dialog-modal';
import { formatFavouritePlaceLabel } from '@digitransit-search-util/digitransit-search-util-uniq-by-label';
import ModalContent from './helpers/ModalContent';
@@ -76,8 +78,7 @@ class FavouriteEditingModal extends React.Component {
isModalOpen: PropTypes.bool.isRequired,
isMobile: PropTypes.bool,
isLoading: PropTypes.bool.isRequired,
- color: PropTypes.string,
- hoverColor: PropTypes.string,
+ colors: PropTypes.objectOf(PropTypes.string),
/** Optional. */
fontWeights: PropTypes.shape({
/** Default value is 500. */
@@ -88,8 +89,7 @@ class FavouriteEditingModal extends React.Component {
static defaultProps = {
lang: 'fi',
isMobile: false,
- color: '#007ac9',
- hoverColor: '#0062a1',
+ colors: defaultColors,
fontWeights: {
medium: 500,
},
@@ -194,7 +194,7 @@ class FavouriteEditingModal extends React.Component {
styles[iconId],
)}
>
-
+
@@ -302,8 +302,7 @@ class FavouriteEditingModal extends React.Component {
showDeletePlaceModal: false,
})
}
- color={this.props.color}
- hoverColor={this.props.hoverColor}
+ colors={this.props.colors}
fontWeights={this.props.fontWeights}
lang={this.props.lang}
/>
@@ -321,19 +320,19 @@ class FavouriteEditingModal extends React.Component {
};
renderModalContent = () => {
- const { color, hoverColor, fontWeights } = this.props;
+ const { fontWeights } = this.props;
+ const { primary, hover } = this.props.colors;
const modalProps = {
headerText: this.translate('edit-places'),
- renderList: () => this.renderFavouriteList(),
+ renderList: this.renderFavouriteList,
+ };
+ const style = {
+ '--color': primary,
+ '--hover-color': hover,
+ '--font-weight-medium': fontWeights.medium,
};
return (
-
+
);
@@ -343,34 +342,17 @@ class FavouriteEditingModal extends React.Component {
const { isMobile } = this.props;
const { showDeletePlaceModal, selectedFavourite } = this.state;
return (
-
- {isMobile && (
-
- {this.renderDeleteFavouriteModal(selectedFavourite)}
- {this.renderModalContent()}
-
- )}
- {!isMobile && (
-
- {this.renderDeleteFavouriteModal(selectedFavourite)}
- {!showDeletePlaceModal && this.renderModalContent()}
-
- )}
-
+
+ {this.renderDeleteFavouriteModal(selectedFavourite)}
+ {!showDeletePlaceModal && this.renderModalContent()}
+
);
}
}
diff --git a/digitransit-component/packages/digitransit-component-favourite-modal/package.json b/digitransit-component/packages/digitransit-component-favourite-modal/package.json
index 5b0f4fa7e6..be0c8240a3 100644
--- a/digitransit-component/packages/digitransit-component-favourite-modal/package.json
+++ b/digitransit-component/packages/digitransit-component-favourite-modal/package.json
@@ -1,6 +1,6 @@
{
"name": "@digitransit-component/digitransit-component-favourite-modal",
- "version": "3.0.1",
+ "version": "4.0.0",
"description": "digitransit-component favourite-modal module",
"main": "index.js",
"files": [
@@ -29,7 +29,7 @@
"author": "Digitransit Authors",
"license": "(AGPL-3.0 OR EUPL-1.2)",
"peerDependencies": {
- "@digitransit-component/digitransit-component-icon": "^1.2.0",
+ "@digitransit-component/digitransit-component-icon": "^2.0.0",
"@hsl-fi/modal": "^0.3.2",
"@hsl-fi/sass": "^0.2.0",
"classnames": "2.5.1",
diff --git a/digitransit-component/packages/digitransit-component-favourite-modal/src/index.js b/digitransit-component/packages/digitransit-component-favourite-modal/src/index.js
index 968249fe9a..ec23d58211 100644
--- a/digitransit-component/packages/digitransit-component-favourite-modal/src/index.js
+++ b/digitransit-component/packages/digitransit-component-favourite-modal/src/index.js
@@ -10,7 +10,9 @@ import {
import isEmpty from 'lodash/isEmpty';
import isNumber from 'lodash/isNumber';
import Modal from '@hsl-fi/modal';
-import Icon from '@digitransit-component/digitransit-component-icon';
+import Icon, {
+ defaultColors,
+} from '@digitransit-component/digitransit-component-icon';
import styles from './helpers/styles.scss';
import i18n from './helpers/i18n';
import DesktopModal from './helpers/DesktopModal';
@@ -61,26 +63,21 @@ const FavouriteIconTableButton = ({
FavouriteIconTableButton.propTypes = {
handleClick: PropTypes.func.isRequired,
value: PropTypes.string.isRequired,
- selectedIconId: PropTypes.string.isRequired,
+ selectedIconId: PropTypes.string,
color: PropTypes.string.isRequired,
lang: PropTypes.string.isRequired,
};
-const FavouriteIconTable = ({
- favouriteIconIds,
- selectedIconId,
- handleClick,
- color,
- lang,
-}) => {
+FavouriteIconTableButton.defaultProps = {
+ selectedIconId: '',
+};
+
+const FavouriteIconTable = ({ favouriteIconIds, ...rest }) => {
const columns = favouriteIconIds.map(value => (
));
@@ -92,15 +89,7 @@ const FavouriteIconTable = ({
};
FavouriteIconTable.propTypes = {
- handleClick: PropTypes.func.isRequired,
favouriteIconIds: PropTypes.arrayOf(PropTypes.string).isRequired,
- selectedIconId: PropTypes.string,
- color: PropTypes.string.isRequired,
- lang: PropTypes.string.isRequired,
-};
-
-FavouriteIconTable.defaultProps = {
- selectedIconId: '',
};
/**
@@ -182,8 +171,7 @@ class FavouriteModal extends React.Component {
/** Optional. */
isMobile: PropTypes.bool,
appElement: PropTypes.string.isRequired,
- color: PropTypes.string,
- hoverColor: PropTypes.string,
+ colors: PropTypes.objectOf(PropTypes.string),
/** Optional. */
fontWeights: PropTypes.shape({
/** Default value is 500. */
@@ -198,8 +186,7 @@ class FavouriteModal extends React.Component {
favourite: null,
autosuggestComponent: undefined,
addAnalyticsEvent: undefined,
- color: '#007ac9',
- hoverColor: '#0062a1',
+ colors: defaultColors,
fontWeights: {
medium: 500,
},
@@ -331,7 +318,9 @@ class FavouriteModal extends React.Component {
render() {
const { favourite } = this.state;
- const { color, hoverColor, fontWeights, lang, t } = this.props;
+ const { fontWeights, lang, t } = this.props;
+ const { primary, hover } = this.props.colors;
+
const headerText = this.isEdit()
? t('edit-place', { lng: lang })
: t('save-place', { lng: lang });
@@ -339,8 +328,6 @@ class FavouriteModal extends React.Component {
headerText,
autosuggestComponent: {
...this.props.autosuggestComponent,
- color,
- hoverColor,
},
inputPlaceholder: t('input-placeholder', { lng: lang }),
specifyName: this.specifyName,
@@ -356,7 +343,7 @@ class FavouriteModal extends React.Component {
})()}
favouriteIconIds={FavouriteModal.favouriteIconIds}
handleClick={this.selectIcon}
- color={color}
+ color={primary}
lang={lang}
/>
),
@@ -366,8 +353,8 @@ class FavouriteModal extends React.Component {
isEdit: this.isEdit(),
cancelText: t('cancel', { lng: lang }),
cancelSelected: () => this.cancelSelected(),
- color,
- hoverColor,
+ color: primary,
+ hoverColor: hover,
savePlaceText: t('save-place', { lng: lang }),
cantSaveText: t('cannot-save-place', { lng: lang }),
requiredText: t('required-text', { lng: lang }),
diff --git a/digitransit-component/packages/digitransit-component-icon/package.json b/digitransit-component/packages/digitransit-component-icon/package.json
index 7e3287b913..1f3c59aac6 100644
--- a/digitransit-component/packages/digitransit-component-icon/package.json
+++ b/digitransit-component/packages/digitransit-component-icon/package.json
@@ -1,6 +1,6 @@
{
"name": "@digitransit-component/digitransit-component-icon",
- "version": "1.2.0",
+ "version": "2.0.0",
"description": "digitransit-component icon module",
"main": "index.js",
"files": [
diff --git a/digitransit-component/packages/digitransit-component-icon/src/assets/airplane.svg b/digitransit-component/packages/digitransit-component-icon/src/assets/airplane.svg
index a7075ad7a6..5e563003bc 100644
--- a/digitransit-component/packages/digitransit-component-icon/src/assets/airplane.svg
+++ b/digitransit-component/packages/digitransit-component-icon/src/assets/airplane.svg
@@ -1,3 +1,4 @@
- |