Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Assistant): Add FAB on search page for mobile #2224

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Make a FixedFab to factorize the code with the AddButton (code)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

je n'irai pas jusque là... Le composant vient directement de la doc cozy-ui donc pas besoin de mutualiser les props je pense. Reste le style par contre avec la petite astuce pour flagship app, à voir 🤔

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
Loading