1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 04:46:40 +07:00

displaying profile photo

This commit is contained in:
Fedor Katurov 2019-10-12 14:51:05 +07:00
parent a27ff0f52a
commit 6c1e88804b
7 changed files with 24 additions and 15 deletions

View file

@ -15,12 +15,13 @@
.thumb { .thumb {
flex: 0 0 $comment_height; flex: 0 0 $comment_height;
background: transparentize(black, 0.9);
border-radius: $panel_radius 0 0 $panel_radius; border-radius: $panel_radius 0 0 $panel_radius;
background-color: transparentize(black, 0.9);
} }
.thumb_image { .thumb_image {
height: $comment_height; height: $comment_height;
background: transparentize(white, 0.97); background: transparentize(white, 0.97) no-repeat 50% 50%;
border-radius: $panel_radius 0 0 $panel_radius; border-radius: $panel_radius 0 0 $panel_radius;
background-size: cover;
} }

View file

@ -1,6 +1,4 @@
import React, { import React, { FC, useCallback, ChangeEventHandler, DragEventHandler } from 'react';
FC, useCallback, ChangeEventHandler, DragEventHandler,
} from 'react';
import { SortableContainer, SortableElement } from 'react-sortable-hoc'; import { SortableContainer, SortableElement } from 'react-sortable-hoc';
import * as styles from './styles.scss'; import * as styles from './styles.scss';
import { ImageUpload } from '~/components/upload/ImageUpload'; import { ImageUpload } from '~/components/upload/ImageUpload';
@ -31,7 +29,7 @@ const SortableList = SortableContainer(
<div className={styles.grid}> <div className={styles.grid}>
{items.map((file, index) => ( {items.map((file, index) => (
<SortableItem key={file.id} index={index} collection={0}> <SortableItem key={file.id} index={index} collection={0}>
<ImageUpload id={file.id} thumb={getURL(file.url)} /> <ImageUpload id={file.id} thumb={getURL(file)} />
</SortableItem> </SortableItem>
))} ))}
@ -44,9 +42,7 @@ const SortableList = SortableContainer(
) )
); );
const ImageGrid: FC<IProps> = ({ const ImageGrid: FC<IProps> = ({ items, locked, onFileMove, onUpload }) => {
items, locked, onFileMove, onUpload,
}) => {
const onMove = useCallback(({ oldIndex, newIndex }) => onFileMove(oldIndex, newIndex), [ const onMove = useCallback(({ oldIndex, newIndex }) => onFileMove(oldIndex, newIndex), [
onFileMove, onFileMove,
]); ]);

View file

@ -43,7 +43,7 @@ const Comment: FC<IProps> = ({ comment, is_empty, is_loading, className, photo,
<div className={styles.images}> <div className={styles.images}>
{groupped.image.map(file => ( {groupped.image.map(file => (
<div key={file.id}> <div key={file.id}>
<img src={getURL(file.url)} alt={file.name} /> <img src={getURL(file)} alt={file.name} />
</div> </div>
))} ))}
</div> </div>
@ -55,7 +55,7 @@ const Comment: FC<IProps> = ({ comment, is_empty, is_loading, className, photo,
<div <div
key={file.id} key={file.id}
onClick={() => { onClick={() => {
Player.set(getURL(file.url)); Player.set(getURL(file));
Player.load(); Player.load();
Player.play(); Player.play();
}} }}

View file

@ -17,9 +17,12 @@ import * as UPLOAD_ACTIONS from '~/redux/uploads/actions';
import { selectUploads } from '~/redux/uploads/selectors'; import { selectUploads } from '~/redux/uploads/selectors';
import { IState } from '~/redux/store'; import { IState } from '~/redux/store';
import { getFileType } from '~/utils/uploader'; import { getFileType } from '~/utils/uploader';
import { selectUser } from '~/redux/auth/selectors';
import { getURL } from '~/utils/dom';
const mapStateToProps = (state: IState) => ({ const mapStateToProps = (state: IState) => ({
node: selectNode(state), node: selectNode(state),
user: selectUser(state),
uploads: selectUploads(state), uploads: selectUploads(state),
}); });
@ -37,6 +40,7 @@ type IProps = ReturnType<typeof mapStateToProps> &
const CommentFormUnconnected: FC<IProps> = ({ const CommentFormUnconnected: FC<IProps> = ({
node: { comment_data, is_sending_comment }, node: { comment_data, is_sending_comment },
uploads: { statuses, files }, uploads: { statuses, files },
user: { photo },
id, id,
nodePostComment, nodePostComment,
nodeSetCommentData, nodeSetCommentData,
@ -116,7 +120,7 @@ const CommentFormUnconnected: FC<IProps> = ({
const comment = comment_data[id]; const comment = comment_data[id];
return ( return (
<CommentWrapper> <CommentWrapper photo={getURL(photo)}>
<form onSubmit={onSubmit}> <form onSubmit={onSubmit}>
<div className={styles.input}> <div className={styles.input}>
<Textarea <Textarea

View file

@ -35,6 +35,7 @@ export const EMPTY_USER: IUser = {
name: null, name: null,
username: null, username: null,
photo: null, photo: null,
cover: null,
is_activated: false, is_activated: false,
is_user: false, is_user: false,
}; };

View file

@ -1,3 +1,5 @@
import { IFile } from '../types';
export interface IToken { export interface IToken {
access: string; access: string;
refresh: string; refresh: string;
@ -8,7 +10,8 @@ export interface IUser {
username: string; username: string;
email: string; email: string;
role: string; role: string;
photo: string; photo: IFile;
cover: IFile;
name: string; name: string;
is_activated: boolean; is_activated: boolean;

View file

@ -1,3 +1,5 @@
import { IFile } from '~/redux/types';
export const getStyle = (oElm: any, strCssRule: string) => { export const getStyle = (oElm: any, strCssRule: string) => {
if (document.defaultView && document.defaultView.getComputedStyle) { if (document.defaultView && document.defaultView.getComputedStyle) {
return document.defaultView.getComputedStyle(oElm, '').getPropertyValue(strCssRule); return document.defaultView.getComputedStyle(oElm, '').getPropertyValue(strCssRule);
@ -52,8 +54,10 @@ export const describeArc = (
].join(' '); ].join(' ');
}; };
export const getURL = url => { export const getURL = (file: IFile) => {
return url if (!file || !file.url) return null;
return file.url
.replace('REMOTE_OLD://', process.env.REMOTE_OLD) .replace('REMOTE_OLD://', process.env.REMOTE_OLD)
.replace('REMOTE_CURRENT://', process.env.REMOTE_CURRENT); .replace('REMOTE_CURRENT://', process.env.REMOTE_CURRENT);
}; };