From 6267208024300eb070dbcf60ed88a1a99e3bed7c Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Thu, 13 Apr 2023 16:36:11 -0500 Subject: [PATCH 1/6] Add icon for link that opens a new window --- i18n/en-US.yml | 1 + lib/components/admin/field-trip-details.js | 7 +++ lib/components/admin/field-trip-list.js | 9 ++- lib/components/user/terms-of-use-pane.js | 17 ++++-- lib/components/util/externalLink.tsx | 64 ++++++++++++++++++++++ lib/components/viewers/route-details.js | 22 +++----- 6 files changed, 100 insertions(+), 20 deletions(-) create mode 100644 lib/components/util/externalLink.tsx diff --git a/i18n/en-US.yml b/i18n/en-US.yml index 2cbfbe8ed..2a014600b 100644 --- a/i18n/en-US.yml +++ b/i18n/en-US.yml @@ -154,6 +154,7 @@ common: tripDurationFormat: >- {hours, plural, =0 {} other {# hr }}{minutes} min { seconds, plural, =0 {} other {# sec}} + linkOpensNewWindow: "(Opens new window)" components: A11yPrefs: accessibilityRoutingByDefault: Prefer accessible trips by default diff --git a/lib/components/admin/field-trip-details.js b/lib/components/admin/field-trip-details.js index 6d4aef155..01f6e54e6 100644 --- a/lib/components/admin/field-trip-details.js +++ b/lib/components/admin/field-trip-details.js @@ -42,6 +42,7 @@ import { Text, Val } from './styled' +import { NewWindowIconA11y } from '../util/externalLink' import DraggableWindow from './draggable-window' import EditableSection from './editable-section' import FieldTripNotes from './field-trip-notes' @@ -98,6 +99,9 @@ class FieldTripDetails extends Component { const { request, sessionId } = this.props const cancelled = request.status === 'cancelled' const printFieldTripLink = `/#/printFieldTrip/?requestId=${request.id}&sessionId=${sessionId}` + const newWindowIconStyles = ( + + ) return (
Feedback link + {newWindowIconStyles} Receipt link + {newWindowIconStyles} Printable trip plan + {newWindowIconStyles} } diff --git a/lib/components/user/terms-of-use-pane.js b/lib/components/user/terms-of-use-pane.js index 6f883bc54..38da55ba4 100644 --- a/lib/components/user/terms-of-use-pane.js +++ b/lib/components/user/terms-of-use-pane.js @@ -3,6 +3,7 @@ import { connect } from 'react-redux' import { Checkbox, ControlLabel, FormGroup } from 'react-bootstrap' import { FormattedMessage, useIntl } from 'react-intl' +import { LinkOpensNewWindow } from '../util/externalLink' import { TERMS_OF_SERVICE_PATH, TERMS_OF_STORAGE_PATH } from '../../util/constants' /** @@ -37,8 +38,12 @@ const TermsOfUsePane = ({ ( - {contents} + termsOfUseLink: (contents) => ( + ) }} /> @@ -64,8 +69,12 @@ const TermsOfUsePane = ({ ( - {contents} + termsOfStorageLink: (contents) => ( + ) }} /> diff --git a/lib/components/util/externalLink.tsx b/lib/components/util/externalLink.tsx new file mode 100644 index 000000000..9ff459e25 --- /dev/null +++ b/lib/components/util/externalLink.tsx @@ -0,0 +1,64 @@ +import { ExternalLinkAlt } from '@styled-icons/fa-solid' +import { useIntl } from 'react-intl' +import React, { HTMLAttributes } from 'react' + +interface LinkProps extends HTMLAttributes { + contents: JSX.Element | string + gap?: number + inline?: boolean + size?: number + style?: React.CSSProperties + url: string +} + +interface IconProps extends HTMLAttributes { + size?: number + style?: React.CSSProperties +} + +export const NewWindowIconA11y = ({ + size = 14, + style +}: IconProps): JSX.Element => { + const intl = useIntl() + return ( + + ) +} + +export const LinkOpensNewWindow = ({ + contents, + gap = 6, + inline, + size = 14, + style, + url +}: LinkProps): JSX.Element => { + console.log(size) + return ( + + {contents} + + + ) +} diff --git a/lib/components/viewers/route-details.js b/lib/components/viewers/route-details.js index cd04acb1f..38f218489 100644 --- a/lib/components/viewers/route-details.js +++ b/lib/components/viewers/route-details.js @@ -3,7 +3,7 @@ import { connect } from 'react-redux' import { FormattedMessage, injectIntl } from 'react-intl' import { getMostReadableTextColor } from '@opentripplanner/core-utils/lib/route' -import { Link } from '@styled-icons/fa-solid/Link' +import { LinkOpensNewWindow } from '../util/externalLink' import PropTypes from 'prop-types' import React, { Component } from 'react' @@ -14,7 +14,6 @@ import { import { findStopsForPattern } from '../../actions/api' import { getOperatorName } from '../../util/state' import { setHoveredStop, setViewedRoute, setViewedStop } from '../../actions/ui' -import { StyledIconWrapper } from '../util/styledIcon' import { Container, @@ -145,20 +144,15 @@ class RouteDetails extends Component { )} {url && ( - + } style={{ - color: getMostReadableTextColor(routeColor, route?.textColor), - whiteSpace: 'nowrap' + color: getMostReadableTextColor(routeColor, route?.textColor) }} - target="_blank" - > - - - - - + url={url} + /> )} From 5be3a31346c9f51e75299c403b4226dd2d2ac0ff Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Fri, 14 Apr 2023 14:23:19 -0500 Subject: [PATCH 2/6] resolve linting errors --- lib/components/user/terms-of-use-pane.js | 36 +++++++++++++++--------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/lib/components/user/terms-of-use-pane.js b/lib/components/user/terms-of-use-pane.js index 38da55ba4..c42fe9b73 100644 --- a/lib/components/user/terms-of-use-pane.js +++ b/lib/components/user/terms-of-use-pane.js @@ -1,42 +1,43 @@ -import React from 'react' -import { connect } from 'react-redux' import { Checkbox, ControlLabel, FormGroup } from 'react-bootstrap' +import { connect } from 'react-redux' import { FormattedMessage, useIntl } from 'react-intl' +import React from 'react' import { LinkOpensNewWindow } from '../util/externalLink' -import { TERMS_OF_SERVICE_PATH, TERMS_OF_STORAGE_PATH } from '../../util/constants' +import { + TERMS_OF_SERVICE_PATH, + TERMS_OF_STORAGE_PATH +} from '../../util/constants' /** * User terms of use pane. */ +/* eslint-disable react/prop-types */ +/* TODO: Prop Types */ const TermsOfUsePane = ({ disableCheckTerms, handleBlur, handleChange, - termsOfStorageSet, values: userData }) => { const intl = useIntl() - const { - hasConsentedToTerms, - storeTripHistory - } = userData + const { hasConsentedToTerms, storeTripHistory } = userData return (
- + ( { // Show alert when user is unchecking the checkbox if (storeTripHistory) { // Do nothing if the user hits cancel - if (!confirm(intl.formatMessage({id: 'components.TermsOfUsePane.confirmDeletionPrompt'}))) { + if ( + // eslint-disable-next-line no-restricted-globals + !confirm( + intl.formatMessage({ + id: 'components.TermsOfUsePane.confirmDeletionPrompt' + }) + ) + ) { return } } @@ -67,7 +75,7 @@ const TermsOfUsePane = ({ }} > ( Date: Tue, 18 Apr 2023 16:16:19 -0500 Subject: [PATCH 3/6] refactor: address feedback --- lib/components/admin/field-trip-details.js | 8 ++++---- lib/components/user/terms-of-use-pane.js | 4 ++-- lib/components/util/externalLink.tsx | 7 +++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/components/admin/field-trip-details.js b/lib/components/admin/field-trip-details.js index 01f6e54e6..3781fa391 100644 --- a/lib/components/admin/field-trip-details.js +++ b/lib/components/admin/field-trip-details.js @@ -99,7 +99,7 @@ class FieldTripDetails extends Component { const { request, sessionId } = this.props const cancelled = request.status === 'cancelled' const printFieldTripLink = `/#/printFieldTrip/?requestId=${request.id}&sessionId=${sessionId}` - const newWindowIconStyles = ( + const newWindowIconWithStyles = ( ) return ( @@ -116,15 +116,15 @@ class FieldTripDetails extends Component { target="_blank" > Feedback link - {newWindowIconStyles} + {newWindowIconWithStyles} Receipt link - {newWindowIconStyles} + {newWindowIconWithStyles} Printable trip plan - {newWindowIconStyles} + {newWindowIconWithStyles}
) } -const mapStateToProps = (state) => { +const mapStateToProps = (state: any) => { return { termsOfStorageSet: state.otp.config.persistence?.terms_of_storage } diff --git a/lib/components/util/externalLink.tsx b/lib/components/util/externalLink.tsx index 4b27e8cca..ce7a8d422 100644 --- a/lib/components/util/externalLink.tsx +++ b/lib/components/util/externalLink.tsx @@ -5,7 +5,7 @@ import React, { HTMLAttributes } from 'react' interface LinkProps extends HTMLAttributes { contents: JSX.Element | string gap?: number - isInline?: boolean + inline?: boolean size?: number style?: React.CSSProperties url: string @@ -36,7 +36,7 @@ export const NewWindowIconA11y = ({ export const LinkOpensNewWindow = ({ contents, gap = 6, - isInline, + inline, size = 14, style, url @@ -47,10 +47,9 @@ export const LinkOpensNewWindow = ({ rel="noreferrer" style={{ alignItems: 'center', - display: `${isInline ? 'inline-flex' : 'flex'}`, + display: `${inline ? 'inline-flex' : 'flex'}`, flexDirection: 'row', - gap: `${gap}px`, - textDecoration: 'underline', + gap, whiteSpace: 'nowrap', ...style }} From 6c6a2c7f64344a19b193f414a91bd3c4e3226bc3 Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Mon, 1 May 2023 14:12:53 -0500 Subject: [PATCH 5/6] refactor: small react, typescript, and import adjustments --- lib/components/admin/field-trip-details.js | 6 +++--- lib/components/user/new-account-wizard.js | 2 +- lib/components/user/terms-of-use-pane.tsx | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/components/admin/field-trip-details.js b/lib/components/admin/field-trip-details.js index 50501d1e2..63ca823a9 100644 --- a/lib/components/admin/field-trip-details.js +++ b/lib/components/admin/field-trip-details.js @@ -116,15 +116,15 @@ class FieldTripDetails extends Component { target="_blank" > Feedback link - {StyledNewWindowIcon} + Receipt link - {StyledNewWindowIcon} + Printable trip plan - {StyledNewWindowIcon} +