const ImageSelect: React.FC<{
max?: number;
}> = ({ max = 4 }) => {
const [images, setImages] = React.useState<ImageObj[]>([])
const onSelectImage = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
const files = Array.from(e.target.files || []).slice(0, max);
setImages(files.map((file) => ({
file,
blobUrl: URL.createObjectURL(new Blob([file]))
})));
}, [])
return <input type="file" accept="image/*" onChange={(e) => { onSelectImage(e) }} />
}
const ClickableArea = ({ component: Component = 'div', to, children, ...props }) => {
const history = useHistory();
const control = useRef(null);
const handleClick = useCallback((event) => {
if (event.target === control.current) {
history.push(to);
}
}, [history, control, to]);
return (
<Component ref={control} onClick={handleClick} tabIndex={-1} {...props}>
{children}
</Component>
);
};
<ClickableArea
className={classes.tweet}
component={Paper}
variant="outlined"
to={`/home/tweet/${_id}`}
>...</ClickableArea>
::after
на ссылке растянуть её на весь контейнер. При помощи display: grid/flex
на родителе можно будет поправить всем остальным элементам z-index
. export const ModalBlock: React.FC<ModalBlockProps> = ({
title,
onClose,
isOpen = false,
children,
}: ModalBlockProps): React.ReactElement | null => {
const [closing, setClosing] = useState(false);
const handleClose = () => setClosing(true);
useEffect(() => {
if (isOpen) {
setClosing(false);
}
}, [isOpen]);
if (!isOpen) {
return null;
}
return (
<Dialog TransitionComponent={Transition} open={!closing && isOpen} onExited={onClose} aria-labelledby='form-dialog-title'>
<DialogTitle id='form-dialog-title'>
<IconButton onClick={handleClose} color='secondary' aria-label='close'>
<CloseIcon style={{ fontSize: 26 }} color='secondary' />
</IconButton>
{title}
</DialogTitle>
<DialogContent>{children}</DialogContent>
</Dialog>
);
};
{Object.keys(profile.contacts).map((key) => {
return (
<React.Fragment>
<TextField
key={key}
className={classes.gutters}
margin='dense'
fullWidth
variant='outlined'
id='standard-basic'
name={`contacts.${key}`}
label={key}
value={`values.contacts.${key}`}
onBlur={handleBlur}
onChange={handleChange}
error={`touched.contacts?.${key}` && Boolean(`errors.contacts?.${key}`)}
helperText={`touched.contacts?.${key}` && `errors.contacts?.${key}`}
/>
</React.Fragment>
)
})}
case 'SN/PROFILE/ADD_POST': {
let newPost = {
id: 1,
postMessage: action.post.postMessage,
file: action.post.file,
}
+ let previousPost = state.posts[state.posts.length - 1] || null;
+ if (previousPost !== null) {
+ newPost.id = previousPost.id + 1;
+ }
return {
...state,
posts: [...state.posts, newPost],
}
}
getIcon = key => {
switch(key) {
case: 'facebook':
return {
<MaterialUiComponent {...rest} />
}
}
}
const Contact: React.FC<ContactPropsType> = ({ key, contactTitle, contactLink }) => {
return (
<div>
<span>
{getIcon(key)}
{contactTitle}: {contactLink}
</span>
</div>
)
}