Skip to content

Commit

Permalink
publish: Merge pull request #281 from cozy/feat/add-translate-apps
Browse files Browse the repository at this point in the history
generated from commit 7e07ec9
  • Loading branch information
Travis CI User committed Oct 8, 2024
1 parent 004add2 commit 19a6643
Show file tree
Hide file tree
Showing 14 changed files with 565 additions and 490 deletions.
20 changes: 20 additions & 0 deletions en/cozy-home/src/assistant/AssistantWrapperDesktop.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react'
import flag from 'cozy-flags'

import { useBreakpoints } from 'cozy-ui/transpiled/react/providers/Breakpoints'

import AssistantBar from 'assistant/AssistantBar'

const AssistantWrapperDesktop = () => {
const { isMobile } = useBreakpoints()

if (!flag('cozy.assistant.enabled') || isMobile) return null

return (
<div className="app-list-wrapper u-mb-3 u-mh-auto u-w-100">
<AssistantBar />
</div>
)
}

export default AssistantWrapperDesktop
38 changes: 38 additions & 0 deletions en/cozy-home/src/assistant/AssistantWrapperMobile.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react'
import flag from 'cozy-flags'
import cx from 'classnames'

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 AssistantBar from 'assistant/AssistantBar'

import styles from './styles.styl'

export const AssistantWrapperMobile = () => {
const { isMobile } = useBreakpoints()
const { type } = useCozyTheme()

if (!flag('cozy.assistant.enabled') || !isMobile) return null

return (
<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
}
)}
>
<AssistantBar />
</div>
)
}

export default AssistantWrapperMobile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const ConversationSearchBar = ({ assistantStatus, conversationId }) => {
useTimeoutWhen(() => setShowSuggestions(true), 2000)

useEventListener(inputRef.current, 'input', () => {
// TODO: hack found on internet, we could try remove the auto assignment to see if it still works without it
inputRef.current.style.height = 'auto'
inputRef.current.style.height = `${inputRef.current.scrollHeight}px`
})
Expand Down
8 changes: 4 additions & 4 deletions en/cozy-home/src/assistant/Conversations/styles.styl
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
@require 'settings/breakpoints.styl'

.conversationSearchBar
max-height 178px
max-height 95px
z-index calc(var(--zIndex-modal) + 15)

+gt-mobile()
max-height 95px
max-height 178px

.conversationSearchBar-input
max-height 155px
max-height 80px

+gt-mobile()
max-height 80px
max-height 155px

&--startAdornment
position absolute
Expand Down
18 changes: 18 additions & 0 deletions en/cozy-home/src/assistant/styles.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.assistantWrapper-mobile
position fixed
bottom 0
right 0
left 0
padding 1rem

&--light
background-color #E9F4FF

&--dark
background-color #142536

&--offset
padding-right 4.5rem

&--immersive
padding-bottom calc(1rem + var(--flagship-bottom-height))
5 changes: 3 additions & 2 deletions en/cozy-home/src/assistant/useFetchResult.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,14 @@ export const useFetchResult = searchValue => {
}

if (searchValue) {
if (searchValue !== state.searchValue) {
// !state.results below is a quick fix condition to avoid triggering the skeleton at each search. Don't know if it's the best approach, we should maybe remove it when working on the search correctly
if (searchValue !== state.searchValue && !state.results) {
fetch(searchValue)
}
} else {
setState({ isLoading: true, results: null, searchValue: null })
}
}, [searchValue, state.searchValue, setState])
}, [searchValue, state.searchValue, state.results, setState])

return {
isLoading: state.isLoading,
Expand Down
2 changes: 2 additions & 0 deletions en/cozy-home/src/components/AddButton/AddButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const styles = {
right: '1rem',
bottom: '1rem',
position: 'fixed',
zIndex: 'var(--zIndex-low)',
marginBottom: immersive ? 'var(--flagship-bottom-height)' : 0
})
}
Expand Down Expand Up @@ -53,6 +54,7 @@ export const AddButton = () => {
<Fab
color="primary"
aria-label="add"
size="medium"
ref={anchorRef}
style={styles.fab(getFlagshipMetadata().immersive)}
onClick={showMenu}
Expand Down
25 changes: 0 additions & 25 deletions en/cozy-home/src/components/AssistantWrapper.jsx

This file was deleted.

17 changes: 14 additions & 3 deletions en/cozy-home/src/components/Home.jsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,41 @@
import React from 'react'
import cx from 'classnames'
import { Outlet, useLocation } from 'react-router-dom'

import flag from 'cozy-flags'
import CozyDevTools from 'cozy-client/dist/devtools'
import { CozyConfirmDialogProvider } from 'cozy-harvest-lib'
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 Applications from 'components/Applications'
import ScrollToTopOnMount from 'components/ScrollToTopOnMount'
import Services from 'components/Services'
import Shortcuts from 'components/Shortcuts'
import GroupedServices from 'components/GroupedServices'
import { Announcements } from 'components/Announcements/Announcements'
import AssistantWrapper from 'components/AssistantWrapper'

import styles from './styles.styl'

const Home = ({ setAppsReady, wrapper }) => {
const { pathname } = useLocation()
const { isMobile } = useBreakpoints()

return (
<CozyConfirmDialogProvider>
<Main className="u-flex-grow-1">
<ScrollToTopOnMount target={wrapper} />
{pathname === '/connected' && <Announcements />}
<Content className="u-flex u-flex-column u-ph-1">
<Content
className={cx('u-flex u-flex-column u-ph-1', {
[styles['homeMainContent--withAssistant']]:
isMobile && flag('cozy.assistant.enabled'),
[styles['homeMainContent--immersive']]:
getFlagshipMetadata().immersive
})}
>
{flag('debug') && <CozyDevTools />}
<AssistantWrapper />
<Applications onAppsFetched={setAppsReady} />
<Shortcuts />
{flag('home.detailed-services-dev') ? (
Expand Down
6 changes: 6 additions & 0 deletions en/cozy-home/src/components/styles.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.homeMainContent
&--withAssistant
padding-bottom 2rem

&--immersive
padding-bottom calc(2rem + var(--flagship-bottom-height))
5 changes: 4 additions & 1 deletion en/cozy-home/src/containers/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ 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 AssistantWrapperDesktop from 'assistant/AssistantWrapperDesktop'
import AddButton from 'components/AddButton/AddButton'
import Corner from 'components/HeroHeader/Corner'
import Failure from 'components/Failure'
Expand Down Expand Up @@ -151,6 +153,7 @@ const App = ({ accounts, konnectors, triggers }) => {
<Spinner size="xxlarge" />
</Main>
)}
<AssistantWrapperDesktop />
{!isFetching && (
<>
<SentryRoutes>
Expand Down Expand Up @@ -181,13 +184,13 @@ const App = ({ accounts, konnectors, triggers }) => {
</SentryRoutes>
</>
)}

<IconSprite />
</div>
<FooterLogo />
</MainView>
{isFlagshipApp() && <DefaultRedirectionSnackbar />}
{flag(FLAG_FAB_BUTTON_ENABLED) && isMobile && <AddButton />}
<AssistantWrapperMobile />
</>
)
}
Expand Down
2 changes: 1 addition & 1 deletion en/cozy-home/src/locales/fr.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"assistant": {
"search": {
"placeholder": "Une question ?"
"placeholder": "Une question ?"
},
"dialog": {
"close": "Fermer"
Expand Down
Loading

0 comments on commit 19a6643

Please sign in to comment.