diff --git a/src/components/ConnectNavigationHeader.js b/src/components/ConnectNavigationHeader.js index 6afe618fd0..cb55a1970e 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 { GoBackButton } from 'src/components/GoBackButton' +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..b4b15fb79b 100644 --- a/src/components/DayOfMonthPicker.tsx +++ b/src/components/DayOfMonthPicker.tsx @@ -2,8 +2,7 @@ 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' @@ -12,6 +11,7 @@ import { __ } from 'src/utilities/Intl' import { GoBackButton } from 'src/components/GoBackButton' import { SlideDown } from 'src/components/SlideDown' import { getDelay } from 'src/utilities/getDelay' +import styles from 'src/components/DayOfMonthPicker.module.css' interface DayOfMonthPicker { handleClose: () => void @@ -21,8 +21,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 @@ -35,59 +33,42 @@ export const DayOfMonthPicker = React.forwardRef - - {__('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.module.css b/src/components/GoBackButton.module.css new file mode 100644 index 0000000000..778a6e2969 --- /dev/null +++ b/src/components/GoBackButton.module.css @@ -0,0 +1,19 @@ +.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; + padding: 0 var(--spacing-2); + transform: translateX(-5%); +} + +.button:global(.MuiIconButton-root) { + color: var(--mui-palette-text-primary); +} diff --git a/src/components/GoBackButton.tsx b/src/components/GoBackButton.tsx index 7ed18fa92d..2be53df140 100644 --- a/src/components/GoBackButton.tsx +++ b/src/components/GoBackButton.tsx @@ -1,48 +1,42 @@ -/* 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 { AppBar, Box, IconButton, Toolbar } from '@mui/material' +import { Icon } from '@mxenabled/mxui' import { __ } from 'src/utilities/Intl' +import styles from 'src/components/GoBackButton.module.css' interface GoBackButtonProps { handleGoBack: () => void + shouldShowBackButton?: boolean + toolbarClassName?: string } export const GoBackButton = forwardRef((props, ref) => { const defaultRef = useRef(null) - const { handleGoBack } = props - const tokens = useTokens() - const styles = getStyles(tokens) + const { handleGoBack, shouldShowBackButton = true, toolbarClassName } = props return ( - - - + + + + {shouldShowBackButton ? ( + + + + ) : null} + + + ) }) - -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/__tests__/GoBackButton-test.tsx index 7c30c69efd..fdbc9a2157 100644 --- a/src/components/__tests__/GoBackButton-test.tsx +++ b/src/components/__tests__/GoBackButton-test.tsx @@ -3,24 +3,27 @@ import { render, screen, fireEvent } from 'src/utilities/testingLibrary' import { GoBackButton } from '../GoBackButton' 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/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'