Skip to content

Commit

Permalink
feat(Assistant): Move AssistantWrapperMobile for better rendering wit…
Browse files Browse the repository at this point in the history
…h FAB
  • Loading branch information
JF-Cozy committed Oct 22, 2024
1 parent e3fb234 commit c7c33f7
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 32 deletions.
50 changes: 24 additions & 26 deletions src/assistant/AssistantWrapperMobile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { getFlagshipMetadata } from 'cozy-device-helper'
import { useBreakpoints } from 'cozy-ui/transpiled/react/providers/Breakpoints'
import { useCozyTheme } from 'cozy-ui/transpiled/react/providers/CozyTheme'
import SearchBar from 'cozy-ui/transpiled/react/SearchBar'
import Portal from 'cozy-ui/transpiled/react/Portal'
import Icon from 'cozy-ui/transpiled/react/Icon'
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'

import AssistantIcon from 'assets/images/icon-assistant.png'
import { FLAG_FAB_BUTTON_ENABLED } from 'components/AddButton/helpers'

import styles from './styles.styl'

Expand All @@ -24,31 +24,29 @@ export const AssistantWrapperMobile = () => {
if (!flag('cozy.assistant.enabled') || !isMobile) return null

return (
<Portal into="body">
<div
className={cx(
styles['assistantWrapper-mobile'],
styles[`assistantWrapper-mobile--${type}`],
{
[styles['assistantWrapper-mobile--offset']]: flag(
'home.fab.button.enabled'
),
[styles['assistantWrapper-mobile--immersive']]:
getFlagshipMetadata().immersive
}
)}
>
<SearchBar
size="medium"
icon={
<Icon className="u-ml-1 u-mr-half" icon={AssistantIcon} size={24} />
}
type="button"
label={t('assistant.search.placeholder')}
onClick={() => navigate('search')}
/>
</div>
</Portal>
<div
className={cx(
styles['assistantWrapper-mobile'],
styles[`assistantWrapper-mobile--${type}`],
{
[styles['assistantWrapper-mobile--offset']]: flag(
FLAG_FAB_BUTTON_ENABLED
),
[styles['assistantWrapper-mobile--immersive']]:
getFlagshipMetadata().immersive
}
)}
>
<SearchBar
size="medium"
icon={
<Icon className="u-ml-1 u-mr-half" icon={AssistantIcon} size={24} />
}
type="button"
label={t('assistant.search.placeholder')}
onClick={() => navigate('connected/search')}
/>
</div>
)
}

Expand Down
1 change: 0 additions & 1 deletion src/components/AddButton/AddButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const styles = {
right: '1rem',
bottom: '1rem',
position: 'fixed',
zIndex: 'var(--zIndex-low)',
marginBottom: immersive ? 'var(--flagship-bottom-height)' : 0
})
}
Expand Down
2 changes: 0 additions & 2 deletions src/components/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { getFlagshipMetadata } from 'cozy-device-helper'
import { Main, Content } from 'cozy-ui/transpiled/react/Layout'
import { useBreakpoints } from 'cozy-ui/transpiled/react/providers/Breakpoints'

import AssistantWrapperMobile from 'assistant/AssistantWrapperMobile'
import AssistantWrapperDesktop from 'assistant/AssistantWrapperDesktop'
import Applications from 'components/Applications'
import ScrollToTopOnMount from 'components/ScrollToTopOnMount'
Expand All @@ -30,7 +29,6 @@ const Home = ({ setAppsReady, wrapper }) => {
<ScrollToTopOnMount target={wrapper} />
{pathname === '/connected' && <Announcements />}
<AssistantWrapperDesktop />
<AssistantWrapperMobile />
<Content
className={cx('u-flex u-flex-column u-ph-1', {
[styles['homeMainContent--withAssistant']]:
Expand Down
2 changes: 2 additions & 0 deletions src/containers/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Spinner from 'cozy-ui/transpiled/react/Spinner'
import { Main } from 'cozy-ui/transpiled/react/Layout'
import { useCozyTheme } from 'cozy-ui/transpiled/react/providers/CozyTheme'

import AssistantWrapperMobile from 'assistant/AssistantWrapperMobile'
import AssistantDialog from 'assistant/Views/AssistantDialog'
import SearchDialog from 'assistant/Views/SearchDialog'
import AddButton from 'components/AddButton/AddButton'
Expand Down Expand Up @@ -190,6 +191,7 @@ const App = ({ accounts, konnectors, triggers }) => {
</div>
<FooterLogo />
</MainView>
<AssistantWrapperMobile />
{isFlagshipApp() && <DefaultRedirectionSnackbar />}
{flag(FLAG_FAB_BUTTON_ENABLED) && isMobile && <AddButton />}
</>
Expand Down
1 change: 1 addition & 0 deletions src/containers/App.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
// eslint-disable-next-line react/display-name
Routes: jest.fn(),
useNavigate: () => () => {},
// eslint-disable-next-line react/display-name
withRouter: Component => props => <Component {...props} />
}))
Expand Down
9 changes: 6 additions & 3 deletions test/AppLike.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import React from 'react'
import { createStore } from 'redux'
import { CozyProvider } from 'cozy-client'
import { createMockClient } from 'cozy-client/dist/mock'
import { Provider as ReduxProvider } from 'react-redux'
import PropTypes from 'prop-types'

import { CozyProvider } from 'cozy-client'
import { createMockClient } from 'cozy-client/dist/mock'
import { BreakpointsProvider } from 'cozy-ui/transpiled/react/providers/Breakpoints'
import CozyTheme from 'cozy-ui/transpiled/react/providers/CozyTheme'
import I18n from 'cozy-ui/transpiled/react/providers/I18n'
import { BackupDataProvider } from 'components/BackupNotification/useBackupData'
import AlertProvider from 'cozy-ui/transpiled/react/providers/Alert'

import { BackupDataProvider } from 'components/BackupNotification/useBackupData'

import enLocale from '../src/locales/en.json'

const fakeDefaultReduxState = {
Expand Down

0 comments on commit c7c33f7

Please sign in to comment.