diff --git a/README.md b/README.md index 132aa1ff78..4d1fe2a525 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ const App = () => { | `onShowConnectSuccessSurvey` | [`AnalyticContextType`](./typings/connectProps.d.ts#L100) | The connect widget provides a way to let your analytics provider know that the connect success survey was shown. [More details](./docs/ANALYTICS.md#onShowConnectSuccessSurvey) | | `onSubmitConnectSuccessSurvey` | [`AnalyticContextType`](./typings/connectProps.d.ts#L101) | The connect widget provides a way to submit connect success survey responses using your own analytics provider. [More details](./docs/ANALYTICS.md#onSubmitConnectSuccessSurvey) | | | `profiles` | [`ProfilesTypes`](./typings/connectProps.d.ts) | The connect widget uses the profiles to set the initial state of the widget. [More details](./docs/PROFILES.md) | See more details | -| `userFeatures` | [`UserFeaturesType`](./typings/connectProps.d.ts) | The connect widget uses user features to determine the behavior of the widget. [More details](./docs/USER_FEATURES.md) | See more details +| `userFeatures` | [`UserFeaturesType`](./typings/connectProps.d.ts) | The connect widget uses user features to determine the behavior of the widget. [More details](./docs/USER_FEATURES.md) | See more details | | `webSocketConnection` | `object` | An object containing `isConnected()` function and `webSocketMessages$` observable for real-time updates. | `null` | | `experimentalFeatures` | `object` | An object to enable or disable experimental features like `useWebSockets: true`. | `null` | diff --git a/src/components/ConnectNavigationHeader.js b/src/components/ConnectNavigationHeader.js index 6afe618fd0..193b6e786e 100644 --- a/src/components/ConnectNavigationHeader.js +++ b/src/components/ConnectNavigationHeader.js @@ -1,29 +1,21 @@ import React, { useContext, useState, useEffect, useRef } from 'react' import PropTypes from 'prop-types' import { useSelector } from 'react-redux' -import { useTokens } from '@kyper/tokenprovider' - -import AppBar from '@mui/material/AppBar' -import Box from '@mui/material/Box' -import Toolbar from '@mui/material/Toolbar' -import IconButton from '@mui/material/IconButton' -import { Icon } from '@mxenabled/mxui' - import { __ } from 'src/utilities/Intl' import { STEPS } from 'src/const/Connect' import { PostMessageContext } from 'src/ConnectWidget' +import { GoBackButtonHeader } from 'src/components/GoBackButtonHeader' +import styles from 'src/components/ConnectNavigationHeader.module.css' export const ConnectNavigationHeader = (props) => { const goBackButtonContainerRef = useRef() const postMessageFunctions = useContext(PostMessageContext) - const tokens = useTokens() - const sx = getStyles(tokens) const step = useSelector( (state) => state.connect.location[state.connect.location.length - 1]?.step ?? STEPS.SEARCH, ) - const showMobileBackButton = useSelector( - (state) => state.config.show_back_button && state.connect.location.length === 1, - ) + const showMobileBackButton = + useSelector((state) => state.config.show_back_button && state.connect.location.length === 1) || + false const [shouldShowGlobalBackButton, setShouldShowGlobalBackButton] = useState(false) useEffect(() => { @@ -65,24 +57,12 @@ export const ConnectNavigationHeader = (props) => { } return ( - - - - {shouldShowGlobalBackButton || showMobileBackButton ? ( - - - - ) : null} - - - + ) } @@ -90,15 +70,3 @@ ConnectNavigationHeader.propTypes = { connectGoBack: PropTypes.func.isRequired, stepComponentRef: PropTypes.object, } - -const getStyles = (tokens) => ({ - container: { flexGrow: 1 }, - appBar: { backgroundColor: tokens.BackgroundColor.Container, display: 'flex' }, - toolbar: { - padding: `0 ${tokens.Spacing.Medium}px`, - maxWidth: '368px', - left: '50%', - transform: 'translateX(-50%)', - }, - button: { color: tokens.TextColor.Default }, -}) diff --git a/src/components/ConnectNavigationHeader.module.css b/src/components/ConnectNavigationHeader.module.css new file mode 100644 index 0000000000..4f2682bbd4 --- /dev/null +++ b/src/components/ConnectNavigationHeader.module.css @@ -0,0 +1,4 @@ +.toolbar.toolbar:global(.MuiToolbar-root) { + left: 50%; + transform: translateX(-50%); +} diff --git a/src/components/DayOfMonthPicker.module.css b/src/components/DayOfMonthPicker.module.css new file mode 100644 index 0000000000..2e40aeb8c4 --- /dev/null +++ b/src/components/DayOfMonthPicker.module.css @@ -0,0 +1,7 @@ +.textGroup:global(.MuiStack-root) { + margin-bottom: var(--spacing-3); +} + +.button:global(.MuiButton-root) { + width: 14.25%; +} diff --git a/src/components/DayOfMonthPicker.tsx b/src/components/DayOfMonthPicker.tsx index 253a181e21..923f13eda6 100644 --- a/src/components/DayOfMonthPicker.tsx +++ b/src/components/DayOfMonthPicker.tsx @@ -2,17 +2,18 @@ import React, { MutableRefObject } from 'react' import _range from 'lodash/range' -import { useTokens } from '@kyper/tokenprovider' -import { Button } from '@mui/material' +import { Button, Stack } from '@mui/material' import { Text } from '@mxenabled/mxui' import { fadeOut } from 'src/utilities/Animation' import { __ } from 'src/utilities/Intl' -import { GoBackButton } from 'src/components/GoBackButton' +import { GoBackButtonHeader } from 'src/components/GoBackButtonHeader' import { SlideDown } from 'src/components/SlideDown' import { getDelay } from 'src/utilities/getDelay' +import styles from './DayOfMonthPicker.module.css' + interface DayOfMonthPicker { handleClose: () => void handleSelect: (e: React.MouseEvent) => void @@ -21,8 +22,6 @@ interface DayOfMonthPicker { export const DayOfMonthPicker = React.forwardRef( (props, ref) => { - const tokens = useTokens() - const styles = getStyles(tokens) const getNextDelay = getDelay() const days = _range(1, 32) const containerRef = ref as MutableRefObject @@ -30,64 +29,47 @@ export const DayOfMonthPicker = React.forwardRef - fadeOut(containerRef?.current, 'up', 300).then(props.handleClose)} /> - - {__('Payment due day')} - - - {__('Choose what day of the month your payment is due.')} - + + + {__('Payment due day')} + + + {__('Choose what day of the month your payment is due.')} + + -
+ {days.map((day: number) => ( ))} -
+
) }, ) -// eslint-disable-next-line @typescript-eslint/no-explicit-any -const getStyles = (tokens: any) => ({ - buttons: { - display: 'flex', - flexWrap: 'wrap' as const, - marginTop: tokens.Spacing.XSmall, - }, - button: { - width: '14.25%', - }, -}) - DayOfMonthPicker.displayName = 'DayOfMonthPicker' diff --git a/src/components/GoBackButton.tsx b/src/components/GoBackButton.tsx deleted file mode 100644 index 7ed18fa92d..0000000000 --- a/src/components/GoBackButton.tsx +++ /dev/null @@ -1,48 +0,0 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -import React, { forwardRef, useRef } from 'react' -import PropTypes from 'prop-types' -import { useTokens } from '@kyper/tokenprovider' -import { IconButton } from '@mui/material' -import { ChevronLeft } from '@kyper/icon/ChevronLeft' - -import { __ } from 'src/utilities/Intl' - -interface GoBackButtonProps { - handleGoBack: () => void -} - -export const GoBackButton = forwardRef((props, ref) => { - const defaultRef = useRef(null) - const { handleGoBack } = props - const tokens = useTokens() - const styles = getStyles(tokens) - - return ( - - - - ) -}) - -const getStyles = (tokens: any) => ({ - height: '44px', - margin: `0px ${tokens.Spacing.XSmall}px ${tokens.Spacing.XSmall}px -${tokens.Spacing.Medium}px`, - padding: `0px 8px`, - width: '44px', -}) - -GoBackButton.propTypes = { - handleGoBack: PropTypes.func.isRequired, -} - -GoBackButton.displayName = 'GoBackButton' diff --git a/src/components/__tests__/GoBackButton-test.tsx b/src/components/GoBackButtonHeader-test.tsx similarity index 61% rename from src/components/__tests__/GoBackButton-test.tsx rename to src/components/GoBackButtonHeader-test.tsx index 7c30c69efd..5c366ede7d 100644 --- a/src/components/__tests__/GoBackButton-test.tsx +++ b/src/components/GoBackButtonHeader-test.tsx @@ -1,26 +1,29 @@ import React from 'react' import { render, screen, fireEvent } from 'src/utilities/testingLibrary' -import { GoBackButton } from '../GoBackButton' +import { GoBackButtonHeader } from 'src/components/GoBackButtonHeader' describe('GoBackButton', () => { - const handleGoBack = vi.fn() + const defaultProps = { + handleGoBack: vi.fn(), + shouldShowBackButton: true, + } it('renders the go back button', () => { - render() + render() const button = screen.getByRole('button', { name: /back/i }) expect(button).toBeInTheDocument() }) it('navigates back when clicked', () => { - render() + render() const button = screen.getByRole('button', { name: /back/i }) fireEvent.click(button) - expect(handleGoBack).toHaveBeenCalled() + expect(defaultProps.handleGoBack).toHaveBeenCalled() }) it('is accessible', () => { - render() + render() const button = screen.getByRole('button', { name: /back/i }) expect(button).toHaveAttribute('aria-label', 'Go Back') }) diff --git a/src/components/GoBackButtonHeader.module.css b/src/components/GoBackButtonHeader.module.css new file mode 100644 index 0000000000..6b9489ce3c --- /dev/null +++ b/src/components/GoBackButtonHeader.module.css @@ -0,0 +1,18 @@ +.container:global(.MuiBox-root) { + flex-grow: 1; +} + +.appBar:global(.MuiAppBar-root) { + background-color: var(--mui-palette-background-paper); + display: flex; +} + +.toolbar:global(.MuiToolbar-root) { + left: 0; + max-width: 368px; + transform: translateX(-10%); +} + +.button:global(.MuiIconButton-root) { + color: var(--mui-palette-text-primary); +} diff --git a/src/components/GoBackButtonHeader.tsx b/src/components/GoBackButtonHeader.tsx new file mode 100644 index 0000000000..39707f34a0 --- /dev/null +++ b/src/components/GoBackButtonHeader.tsx @@ -0,0 +1,42 @@ +import React, { forwardRef, useRef } from 'react' +import { AppBar, Box, IconButton, Toolbar } from '@mui/material' +import { Icon } from '@mxenabled/mxui' +import clsx from 'clsx' + +import { __ } from 'src/utilities/Intl' + +import styles from 'src/components/GoBackButtonHeader.module.css' + +interface GoBackButtonProps { + handleGoBack: () => void + shouldShowBackButton?: boolean + toolbarClassName?: string +} + +export const GoBackButtonHeader = forwardRef((props, ref) => { + const defaultRef = useRef(null) + const { handleGoBack, shouldShowBackButton = true, toolbarClassName } = props + + return ( + + + + {shouldShowBackButton ? ( + + + + ) : null} + + + + ) +}) + +GoBackButtonHeader.displayName = 'GoBackButtonHeader' diff --git a/src/components/LeavingNoticeFlat.js b/src/components/LeavingNoticeFlat.js index 35b118d90b..2e8d251fda 100644 --- a/src/components/LeavingNoticeFlat.js +++ b/src/components/LeavingNoticeFlat.js @@ -8,7 +8,7 @@ import { Text, Icon } from '@mxenabled/mxui' import { Button, Stack } from '@mui/material' import { SlideDown } from 'src/components/SlideDown' -import { GoBackButton } from 'src/components/GoBackButton' +import { GoBackButtonHeader } from 'src/components/GoBackButtonHeader' import { getDelay } from 'src/utilities/getDelay' import styles from 'src/components/LeavingNoticeFlat.module.css' @@ -20,7 +20,7 @@ export const LeavingNoticeFlat = ({ onContinue, onCancel, portalTo = 'connect-wr
- + diff --git a/src/views/microdeposits/SharedRoutingNumber.js b/src/views/microdeposits/SharedRoutingNumber.js index a5efb3b592..ee2eec1ffc 100644 --- a/src/views/microdeposits/SharedRoutingNumber.js +++ b/src/views/microdeposits/SharedRoutingNumber.js @@ -14,7 +14,7 @@ import { PageviewInfo } from 'src/const/Analytics' import { SlideDown } from 'src/components/SlideDown' import { InstitutionTile } from 'src/components/InstitutionTile' import { getDelay } from 'src/utilities/getDelay' -import { GoBackButton } from 'src/components/GoBackButton' +import { GoBackButtonHeader } from 'src/components/GoBackButtonHeader' import { ActionTile } from 'src/components/ActionTile' import { fadeOut } from 'src/utilities/Animation' @@ -29,7 +29,7 @@ export const SharedRoutingNumber = (props) => { return (
- + {__('Select how to connect your account')} diff --git a/typings/kyper.d.ts b/typings/kyper.d.ts index e9b6e8122a..70d635e1d7 100644 --- a/typings/kyper.d.ts +++ b/typings/kyper.d.ts @@ -17,7 +17,6 @@ declare module '@kyper/icon/Image' declare module '@kyper/icon/Health' declare module '@kyper/icon/Grid' declare module '@kyper/progressindicators' -declare module '@kyper/icon/ChevronLeft' declare module '@kyper/icon/Lock' declare module '@kyper/utilityrow' declare module '@kyper/hooks'