Skip to content

Commit

Permalink
feat(Assistant): Add FAB on search page for mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
JF-Cozy committed Oct 23, 2024
1 parent d32a2f0 commit 1fe8219
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 1 deletion.
38 changes: 38 additions & 0 deletions src/assistant/Search/SearchSubmitFab.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react'

import Fab from 'cozy-ui/transpiled/react/Fab'
import Icon from 'cozy-ui/transpiled/react/Icon'
import PaperplaneIcon from 'cozy-ui/transpiled/react/Icons/Paperplane'
import { makeStyles } from 'cozy-ui/transpiled/react/styles'
import { getFlagshipMetadata } from 'cozy-device-helper'
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'

const useStyles = makeStyles({
root: {
right: '1rem',
bottom: '1rem',
position: 'fixed',
marginBottom: ({ immersive }) =>
immersive ? 'var(--flagship-bottom-height)' : 0
}
})

const SearchSubmitFab = ({ searchValue, onClick }) => {
const { t } = useI18n()
const styles = useStyles({ immersive: getFlagshipMetadata().immersive })

return (
<Fab
aria-label={t('assistant.search.send')}
color="primary"
size="medium"
classes={styles}
disabled={!searchValue}
onClick={onClick}
>
<Icon icon={PaperplaneIcon} />
</Fab>
)
}

export default SearchSubmitFab
6 changes: 5 additions & 1 deletion src/assistant/Views/SearchDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useAssistant } from '../AssistantProvider'
import ResultMenuContent from '../ResultMenu/ResultMenuContent'
import { useSearch } from '../Search/SearchProvider'
import SearchBar from '../Search/SearchBar'
import SearchSubmitFab from '../Search/SearchSubmitFab'

const SearchDialog = () => {
const { onAssistantExecute } = useAssistant()
Expand Down Expand Up @@ -37,7 +38,10 @@ const SearchDialog = () => {
}}
title={<SearchBar />}
content={
searchValue !== '' && <ResultMenuContent onClick={handleClick} />
<>
{searchValue !== '' && <ResultMenuContent onClick={handleClick} />}
<SearchSubmitFab searchValue={searchValue} onClick={handleClick} />
</>
}
onClose={handleClose}
/>
Expand Down
1 change: 1 addition & 0 deletions src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"assistant": {
"search": {
"placeholder": "Eine Frage?",
"send": "Senden",
"result": "Den Assistenten fragen"
},
"dialog": {
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"assistant": {
"search": {
"placeholder": "Any question?",
"send": "Send",
"result": "Ask the assistant"
},
"dialog": {
Expand Down
1 change: 1 addition & 0 deletions src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"assistant": {
"search": {
"placeholder": "¿Tiene alguna pregunta?",
"send": "Enviar",
"result": "Pregunte al asistente"
},
"dialog": {
Expand Down
1 change: 1 addition & 0 deletions src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"assistant": {
"search": {
"placeholder": "Une question ?",
"send": "Envoyer",
"result": "Demander à l'assistant"
},
"dialog": {
Expand Down
1 change: 1 addition & 0 deletions src/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"assistant": {
"search": {
"placeholder": "Avete una domanda?",
"send": "Inviare",
"result": "Chiedete all'assistente"
},
"dialog": {
Expand Down
1 change: 1 addition & 0 deletions src/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"assistant": {
"search": {
"placeholder": "質問はありますか?",
"send": "送る",
"result": "アシスタントに聞く"
},
"dialog": {
Expand Down
1 change: 1 addition & 0 deletions src/locales/nl_NL.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"assistant": {
"search": {
"placeholder": "Heb je een vraag?",
"send": "Verzenden",
"result": "Vraag het de assistent"
},
"dialog": {
Expand Down

0 comments on commit 1fe8219

Please sign in to comment.