-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: redesign 'add text' modal (#1117)
* feat: modify 'add text' title text * feat: add helper text * Revert "feat: modify 'add text' title text" This reverts commit 8d34688. * feat: change 'add text' title * feat: add helper text in NameForm * feat: change 'add text' tab text * feat: change 'add text' title style * feat: add clear button to name form * feat: add display name form * feat: change helper text wording * feat: autocomplete displayName * feat: change document form ui * feat: add tests * fix: update comment Co-authored-by: Basile Spaenlehauer <[email protected]> * fix: update DocumentForm Co-authored-by: Basile Spaenlehauer <[email protected]> * fix: update yarn.lock * fix: code matches * feat: change document form select styles * fix: add comment * fix: menu item background color * fix: helper text and style * feat: add tooltip * fix: disable DisplayNameForm autofocus * feat: add geolocation modal (#1112) * refactor: add geolocation modal * refactor: add translations * refactor: update fr trans * refactor: upgrade query client * fix: update yarn.lock * feat: update yarn.lock * fix: add select of flavors * fix: update styles * fix: display name was erased in edit * fix: make new item modal the same and udpate deps * fix: update deps * fix: remove semi-colon --------- Co-authored-by: Basile Spaenlehauer <[email protected]> Co-authored-by: Kim Lan Phan Hoang <[email protected]>
- Loading branch information
1 parent
23bb83d
commit 514fbaf
Showing
22 changed files
with
913 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { ChangeEvent } from 'react'; | ||
|
||
import ClearIcon from '@mui/icons-material/Clear'; | ||
import InfoIcon from '@mui/icons-material/Info'; | ||
import { | ||
IconButton, | ||
Stack, | ||
TextField, | ||
Tooltip, | ||
useMediaQuery, | ||
useTheme, | ||
} from '@mui/material'; | ||
|
||
import { useBuilderTranslation } from '../../../config/i18n'; | ||
import { ITEM_FORM_DISPLAY_NAME_INPUT_ID } from '../../../config/selectors'; | ||
import { BUILDER } from '../../../langs/constants'; | ||
import type { EditModalContentPropType } from './EditModalWrapper'; | ||
|
||
export type DisplayNameFormProps = EditModalContentPropType; | ||
|
||
const DisplayNameForm = ({ | ||
updatedProperties, | ||
setChanges, | ||
}: DisplayNameFormProps): JSX.Element => { | ||
const { t: translateBuilder } = useBuilderTranslation(); | ||
const theme = useTheme(); | ||
// when the screen is large, use only half of the width for the input. | ||
const largeScreen = useMediaQuery(theme.breakpoints.up('sm')); | ||
|
||
const handleDisplayNameInput = (event: ChangeEvent<{ value: string }>) => { | ||
setChanges({ displayName: event.target.value }); | ||
}; | ||
|
||
const handleClearClick = () => { | ||
setChanges({ displayName: '' }); | ||
}; | ||
|
||
return ( | ||
<TextField | ||
variant="standard" | ||
id={ITEM_FORM_DISPLAY_NAME_INPUT_ID} | ||
label={ | ||
<Stack direction="row" alignItems="center"> | ||
{translateBuilder(BUILDER.CREATE_NEW_ITEM_DISPLAY_NAME_LABEL)} | ||
<Tooltip | ||
title={translateBuilder( | ||
BUILDER.CREATE_NEW_ITEM_DISPLAY_NAME_HELPER_TEXT, | ||
)} | ||
> | ||
<IconButton size="small"> | ||
<InfoIcon fontSize="small" color="primary" /> | ||
</IconButton> | ||
</Tooltip> | ||
</Stack> | ||
} | ||
value={updatedProperties?.displayName} | ||
onChange={handleDisplayNameInput} | ||
// always shrink because setting name from defined app does not shrink automatically | ||
InputLabelProps={{ shrink: true }} | ||
// add a clear icon button | ||
InputProps={{ | ||
endAdornment: ( | ||
<IconButton | ||
onClick={handleClearClick} | ||
sx={{ | ||
visibility: updatedProperties?.displayName ? 'visible' : 'hidden', | ||
}} | ||
> | ||
<ClearIcon fontSize="small" /> | ||
</IconButton> | ||
), | ||
}} | ||
// only take full width when on small screen size | ||
fullWidth={!largeScreen} | ||
sx={{ my: 1, width: largeScreen ? '50%' : undefined }} | ||
/> | ||
); | ||
}; | ||
|
||
export default DisplayNameForm; |
Oops, something went wrong.