Skip to content

Commit

Permalink
마지막 Develop (#204)
Browse files Browse the repository at this point in the history
마지막 Develop
  • Loading branch information
Junow authored Dec 20, 2019
2 parents 3c57aca + bf18ecb commit f2aa299
Show file tree
Hide file tree
Showing 135 changed files with 18,329 additions and 16,172 deletions.
30,281 changes: 15,448 additions & 14,833 deletions client/package-lock.json

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
"dependencies": {
"@material-ui/core": "^4.7.1",
"@material-ui/icons": "^4.5.1",
"animate.css": "^3.7.2",
"axios": "^0.19.0",
"dotenv": "^8.2.0",
"emotion": "^10.0.23",
"is-hotkey": "^0.1.6",
"js-cookie": "^2.2.1",
"moment": "^2.24.0",
"react": "^16.11.0",
"react-cookie": "^4.0.1",
"react-dom": "^16.11.0",
Expand All @@ -18,14 +20,14 @@
"react-redux": "^7.1.3",
"react-router": "^5.1.2",
"react-router-dom": "^5.1.2",
"react-scripts": "3.2.0",
"react-scripts": "^3.3.0",
"react-select": "^3.0.8",
"reactjs-popup": "^1.5.0",
"redux": "^4.0.4",
"shortid": "^2.2.15",
"slate-history": "^0.52.5",
"socket.io-client": "^2.3.0",
"styled-components": "^4.4.1",
"sweetalert2": "^9.5.3",
"typescript": "3.7.2",
"uuid": "^3.3.3"
},
Expand Down Expand Up @@ -53,6 +55,7 @@
"devDependencies": {
"@types/jest": "24.0.23",
"@types/js-cookie": "^2.2.4",
"@types/moment": "^2.13.0",
"@types/node": "12.12.7",
"@types/react": "^16.9.11",
"@types/react-dom": "16.9.4",
Expand All @@ -65,7 +68,6 @@
"@types/socket.io-client": "^1.4.32",
"@types/styled-components": "^4.4.0",
"@types/uuid": "^3.4.6",
"eslint": "^6.1.0",
"eslint-config-airbnb": "^18.0.1",
"eslint-plugin-import": "^2.19.1",
"eslint-plugin-jsx-a11y": "^6.2.3",
Expand Down
Binary file added client/src/assets/MusicFeedPlayIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions client/src/basics/PURPLE_Button/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ export const Button = styled.button`
display: inline-block;
border: none;
margin: 0;
margin-top: 10px;
margin-top: 0.8rem;
text-decoration: none;
background: ${theme.CRA_PURPLE};
color: #ffffff;
font-size: 13px;
font-size: 0.8rem;
cursor: pointer;
text-align: center;
width: 180px;
height: 40px;
width: 10rem;
height: 2.5rem;
:hover{
background: ${theme.PALE_CRA_PURPLE};
};
Expand Down
37 changes: 27 additions & 10 deletions client/src/commons/PopupFollowers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,49 @@ import { API_SERVER } from '../../utils/constants';
type PopupProps ={
closePopup: (e: React.MouseEvent<HTMLButtonElement>)=>void;
initialFollowList: any,
myFollow: any,
text:string,
}
const LOGIN_PROFILE_THUMBNAIL = 'https://kr.object.ncloudstorage.com/crafolio/user/origin/iu-profile-origin.png';

const PopupFollowers:React.FC<PopupProps> = ({ text, closePopup, initialFollowList }) => {
const PopupFollowers:React.FC<PopupProps> = ({
text, closePopup, initialFollowList, myFollow,
}) => {
const [followers, setFollowers] = useState(initialFollowList);
const followDeleteURL = `${API_SERVER}/follow/delete`;
const followAddURL = `${API_SERVER}/follow/add`;

useEffect(() => {
setFollowers(initialFollowList.map((initF:any) => {
if (myFollow.some((myF:any) => (myF._id === initF._id))) {
return { ...initF, follow: true, originFollow: true };
}
return { ...initF, follow: false, originFollow: false };
}));
}, []);
const toggleFollow = (id:string) => {
setFollowers(followers.map((value:any) => {
if (id === value.id) { return ({ ...value, follow: !value.follow }); }
if (id === value._id) { return ({ ...value, follow: !value.follow }); }
return value;
}));
};
const returnToggleFollow = (id:string) => () => {
toggleFollow(id);
};

const SyncFollowers = (followers:any) => {
followers.forEach((value:any) => {
if (!value.follow) {
fetch(`${followDeleteURL}/${value.id}`, {
const SyncFollowers = async (followers:any) => {
followers.reduce(async (acc:any, value:any) => {
await acc;
if (value.follow !== value.originFollow) {
const callURL = value.follow ? followAddURL : followDeleteURL;
await fetch(`${callURL}/${value._id}`, {
method: 'post',
credentials: 'include',
headers: { 'Content-Type': 'application/json' },
});
}
});
return acc;
}, []);
};
const SyncandClose = (e:React.MouseEvent<HTMLButtonElement>) => {
SyncFollowers(followers);
Expand All @@ -48,14 +63,16 @@ const PopupFollowers:React.FC<PopupProps> = ({ text, closePopup, initialFollowLi
<S.Subject>{text}</S.Subject>
</S.SubjectArea>
<S.FollowArea>
{ initialFollowList.map(
{ followers.map(
(value:any) => (
<S.FollowMember key={value.id}>
<S.FollowMember key={value._id}>
<S.ProfileImage src={value.thumbnailUrl} />
<S.FollowName>
{value.name}
</S.FollowName>
<S.FollowButton value={value.id} onClick={returnToggleFollow(value.id)}>팔로우</S.FollowButton>
{value.follow
? <S.UnFollowButton value={value._id} onClick={returnToggleFollow(value._id)}>언팔로우</S.UnFollowButton>
: <S.FollowButton value={value._id} onClick={returnToggleFollow(value._id)}>팔로우</S.FollowButton>}
</S.FollowMember>
),
)}
Expand Down
6 changes: 6 additions & 0 deletions client/src/commons/PopupFollowers/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ export const FollowButton = styled(EmptyButton)`
margin:auto 0;
margin-left:auto;
`;
export const UnFollowButton = styled(EmptyButton)`
margin:auto 0;
margin-left:auto;
color:red;
border-color:red;
`;
export const ProfileImage = styled(Img)`
width: 30px;
height: 30px;
Expand Down
7 changes: 4 additions & 3 deletions client/src/commons/Popup_warn/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ export const Inner = styled.div`
flex-direction: column;
align-items: center;
position: absolute;
width: 300px;
width: 20rem;
height: auto;
background: ${theme.background};
padding: 30px 20px;
padding: 2rem 1rem;
font-size: 1rem;
label{
margin-bottom: 10px;
margin-bottom: 1rem;
}
`;
45 changes: 45 additions & 0 deletions client/src/components/Alarm/NotificationItem/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React from 'react';
import * as S from './styles';
import { getTimeSimple } from '../../../utils';
import { ISender, IRef } from '../../../modules/notification';

interface NotificationItemProp {
sender: ISender;
type: string;
createdAt: number;
refPost: IRef;
}

const NotificationItem: React.FC<NotificationItemProp> = ({
sender, type, createdAt, refPost,
}) => {
const getRefAddr = () => {
if (type === 'works' || type === 'wallpapers') {
return `/home/detail-image/${refPost._id}`;
}
return `/home/detail-music/${refPost._id}`;
};

return (
<S.Container>
<S.Thumbnail src={sender.thumbnailUrl} />
<S.ContentWrapper>
<S.Content>
<S.Strong to={`/creator/${sender._id}`}>
{sender.name}
</S.Strong>
님이 새로운 &nbsp;
<S.Strong to={getRefAddr()}>
{type}
</S.Strong>
을 업로드 하였습니다. 지금 감상해보세요!
</S.Content>
<S.Time>
{getTimeSimple(createdAt)}
</S.Time>
</S.ContentWrapper>
</S.Container>
);
};

export default NotificationItem;
36 changes: 36 additions & 0 deletions client/src/components/Alarm/NotificationItem/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import styled from 'styled-components';
import { Link } from 'react-router-dom';
import { theme } from '../../../style/theme';

export const Container = styled.div`
display: flex;
padding: 1rem;
border-top: 1px solid ${theme.BORDER_GRAY};
`;

export const Thumbnail = styled.img`
width: 2rem;
border-radius: 3rem;
margin: auto 1rem;
margin-left: 0;
`;

export const ContentWrapper = styled.div`
display: flex;
flex-direction: column;
`;

export const Content = styled.div`
`;

export const Time = styled.span`
color: ${theme.AMERICAN_RIVER};
margin: .5rem 0;
`;

export const Strong = styled(Link)`
font-weight: ${theme.WEIGHT.STRONG};
color: black;
text-decoration: none;
`;
32 changes: 32 additions & 0 deletions client/src/components/Alarm/Notifications/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';
import * as S from './styles';
import { getShortId } from '../../../utils';
import { INoti } from '../../../modules/notification';
import NotificationItem from '../NotificationItem';


interface NotificationsProp{
notifications: INoti[];
}

const Notifications: React.FC<NotificationsProp> = ({
notifications,
}) => (
<S.Container>
<S.Header>
새로운 작품
</S.Header>
{
notifications.map((noti:INoti) => (
<NotificationItem
key={getShortId()}
sender={noti.sender}
type={noti.type}
createdAt={noti.createdAt}
refPost={noti.ref}
/>
))
}
</S.Container>
);
export default Notifications;
24 changes: 24 additions & 0 deletions client/src/components/Alarm/Notifications/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import styled from 'styled-components';
import { theme } from '../../../style/theme';
import TextWithImg from '../../../commons/TextWithImg';

export const Container = styled.div`
display: flex;
flex-direction: column;
width: 30rem;
height: 20rem;
align-items: center;
`;

export const Header = styled.div`
display: flex;
height: 3rem;
width: 100%;
justify-content: center;
align-items: center;
font-weight: ${theme.WEIGHT.STRONG};
border-bottom: 1px solid ${theme.BORDER_GRAY};
padding: 1rem 0;
`;

export { TextWithImg };
74 changes: 64 additions & 10 deletions client/src/components/Alarm/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,73 @@
import React from 'react';
import AlarmImg from '../../assets/alarm.png';
import AlarmColorImg from '../../assets/alarm_color.png';
import React, { useState, useEffect } from 'react';
import Popover from '@material-ui/core/Popover';
import NotificationsIcon from '@material-ui/icons/Notifications';
import Notifications from './Notifications';
import { INoti } from '../../modules/notification';
import * as S from './styles';

const Alarm: React.FC = () => {
const alarmNum = 5;
const img = alarmNum > 0 ? AlarmColorImg : AlarmImg;
interface AlarmProp {
notifications: INoti[];
alarmRef: React.RefObject<HTMLButtonElement>;
notiNum: number;
}
const Alarm: React.FC<AlarmProp> = ({
notifications,
alarmRef,
notiNum,
}) => {
const classes = S.useStyles();
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(
null,
);
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
setAnchorEl(event.currentTarget);
};

const handleClose = () => {
setAnchorEl(null);
};
const open = Boolean(anchorEl);
const id = open ? 'simple-popover' : undefined;
const alarmNum = 5;

return (
<S.AlarmContainer>
<S.Alarm src={img} />
{alarmNum < 10
? <S.AlarmNums>{alarmNum}</S.AlarmNums>
: <S.AlarmOverNums>...</S.AlarmOverNums>}
<S.AlarmWrapper
type="button"
onClick={handleClick}
ref={alarmRef}
>
<NotificationsIcon fontSize="large" />
</S.AlarmWrapper>

<Popover
id={id}
open={open}
anchorEl={anchorEl}
onClose={handleClose}
anchorOrigin={{
vertical: 'bottom',
horizontal: 'left',
}}
transformOrigin={{
vertical: 'top',
horizontal: 'center',
}}
classes={{
paper: classes.paper,
}}
>
<Notifications
notifications={notifications}
/>
</Popover>

<S.AlarmNums>
{notiNum < 100
? notiNum
: '99+'}
</S.AlarmNums>

</S.AlarmContainer>
);
};
Expand Down
Loading

0 comments on commit f2aa299

Please sign in to comment.