mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 06:28:51 +00:00
Feat / Reusable SearchField + Fixed Messages align bottom flex with scroll (first message starts at bottom) (#151)
* feat(phone/ui): Make SearchField a reusable component * Fixed conversation scrolling and align bottom * feat(phone/ui): Autoscroll fix * feat(phone/ui): Autoscroll fix remove unused deps * feat(phone/ui): Autoscroll add needed dep for new messages
This commit is contained in:
1 parent
1659fa1654
commit
e56ae415dc
13 files changed
+162
-196
No files matched your search
@@ -0,0 +1,85 @@
|
||||
import React from 'react';
|
||||
import { emphasize, InputBase, makeStyles, Paper } from '@material-ui/core';
|
||||
import SearchIcon from '@material-ui/icons/Search';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
bg: {
|
||||
display: 'flex',
|
||||
height: '60px',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
},
|
||||
textFieldInput: {
|
||||
fontSize: 20,
|
||||
},
|
||||
inputRoot: {
|
||||
fontWeight: 400,
|
||||
fontSize: 18,
|
||||
border: '1px solid',
|
||||
borderColor: theme.palette.divider,
|
||||
},
|
||||
inputInput: {
|
||||
padding: theme.spacing(1, 4, 1, 4),
|
||||
// vertical padding + font size from searchIcon
|
||||
transition: theme.transitions.create(['width', 'border']),
|
||||
width: '16ch',
|
||||
'&:focus': {
|
||||
width: '24ch',
|
||||
borderLeft: `2px solid ${theme.palette.primary.main} `,
|
||||
},
|
||||
},
|
||||
search: {
|
||||
position: 'relative',
|
||||
borderRadius: theme.shape.borderRadius,
|
||||
backgroundColor: emphasize(theme.palette.background.paper, 0.21),
|
||||
'&:hover': {
|
||||
backgroundColor: emphasize(theme.palette.background.paper, 0.28),
|
||||
},
|
||||
marginLeft: theme.spacing(1),
|
||||
width: 'auto',
|
||||
},
|
||||
searchIcon: {
|
||||
padding: theme.spacing(0, 0.7),
|
||||
height: '100%',
|
||||
position: 'absolute',
|
||||
pointerEvents: 'none',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
},
|
||||
}));
|
||||
|
||||
interface IProps {
|
||||
onChange: (event: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>) => void;
|
||||
value: string;
|
||||
placeholder?: string;
|
||||
}
|
||||
|
||||
const DEFAULT_PROPS = {
|
||||
onChange: () => {},
|
||||
value: '',
|
||||
placeholder: 'Search...',
|
||||
};
|
||||
|
||||
export const SearchField = ({ value, onChange, placeholder }: IProps = DEFAULT_PROPS) => {
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<Paper elevation={24} variant="outlined" className={classes.bg}>
|
||||
<div className={classes.search}>
|
||||
<div className={classes.searchIcon}>
|
||||
<SearchIcon />
|
||||
</div>
|
||||
<InputBase
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
placeholder={placeholder}
|
||||
classes={{
|
||||
root: classes.inputRoot,
|
||||
input: classes.inputInput,
|
||||
}}
|
||||
inputProps={{ 'aria-label': 'search' }}
|
||||
/>
|
||||
</div>
|
||||
</Paper>
|
||||
);
|
||||
};
|
||||
Reference in new issue
Block a user