-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'client-web/master' of https://github.com/connect-founda…
…tion/2019-20 into client-web/search-view
- Loading branch information
Showing
43 changed files
with
2,386 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const imageHandleURI = 'http://localhost:5000/products/picture'; | ||
const productHandleURI = 'http://localhost:5000/products'; | ||
const loginStatusHandleURI = 'http://localhost:5001/myInfo'; | ||
export {imageHandleURI, productHandleURI, loginStatusHandleURI}; |
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,83 @@ | ||
import React from 'react'; | ||
import {bool, string} from 'prop-types'; | ||
|
||
// material ui | ||
import Paper from '@material-ui/core/Paper'; | ||
import Grid from '@material-ui/core/Grid'; | ||
import Avatar from '@material-ui/core/Avatar'; | ||
import Typography from '@material-ui/core/Typography'; | ||
import {makeStyles} from '@material-ui/core/styles'; | ||
|
||
// utils | ||
import {getKoKRFormatDayOfWeek, getISOCurrentDate} from '../utils'; | ||
|
||
// material ui style | ||
const useStyles = makeStyles((theme) => ({ | ||
root: { | ||
flexGrow: 1, | ||
overflow: 'hidden', | ||
padding: theme.spacing(0, 3), | ||
}, | ||
paper: { | ||
maxWidth: 400, | ||
margin: `${theme.spacing(1)}px`, | ||
padding: theme.spacing(1), | ||
fontWeight: 'bold', | ||
}, | ||
colorPaper: { | ||
backgroundColor: 'grey', | ||
color: 'white', | ||
}, | ||
})); | ||
|
||
// component | ||
const ChatBox = ({content, isMyChat, timestamp}) => { | ||
const classes = useStyles({}); | ||
|
||
return ( | ||
<div className={classes.root}> | ||
<Grid container alignItems='center'> | ||
{!isMyChat && ( | ||
<Grid item> | ||
<Avatar>상대방</Avatar> | ||
</Grid> | ||
)} | ||
<Grid item> | ||
<Grid | ||
container | ||
direction={!isMyChat ? 'row' : 'row-reverse'} | ||
alignItems='flex-end' | ||
> | ||
<Grid item> | ||
<Paper | ||
className={`${classes.paper} ${!isMyChat && | ||
classes.colorPaper}`} | ||
> | ||
<Typography>{content}</Typography> | ||
</Paper> | ||
</Grid> | ||
<Grid item> | ||
<Typography variant='caption'> | ||
{getKoKRFormatDayOfWeek(timestamp)} | ||
</Typography> | ||
</Grid> | ||
</Grid> | ||
</Grid> | ||
</Grid> | ||
</div> | ||
); | ||
}; | ||
|
||
ChatBox.propTypes = { | ||
content: string, | ||
isMyChat: bool, | ||
timestamp: string, | ||
}; | ||
|
||
ChatBox.defaultProps = { | ||
content: '', | ||
isMyChat: false, | ||
timestamp: getISOCurrentDate(), | ||
}; | ||
|
||
export default ChatBox; |
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,69 @@ | ||
import React from 'react'; | ||
import {func} from 'prop-types'; | ||
|
||
// material ui | ||
import {makeStyles} from '@material-ui/core/styles'; | ||
import Paper from '@material-ui/core/Paper'; | ||
import InputBase from '@material-ui/core/InputBase'; | ||
import IconButton from '@material-ui/core/IconButton'; | ||
import SendIcon from '@material-ui/icons/Send'; | ||
|
||
// types | ||
import {refType} from '../types'; | ||
|
||
// material ui style | ||
const useStyles = makeStyles((theme) => ({ | ||
root: { | ||
padding: '2px 4px', | ||
display: 'flex', | ||
alignItems: 'center', | ||
width: '100%', | ||
position: 'fixed', | ||
bottom: '0', | ||
right: '0', | ||
zIndex: 100, | ||
backgroundColor: 'lightgreen', | ||
}, | ||
input: { | ||
marginLeft: theme.spacing(1), | ||
flex: 1, | ||
}, | ||
iconButton: { | ||
padding: 10, | ||
color: 'white', | ||
}, | ||
})); | ||
|
||
// component | ||
const ChatInputField = ({onMessageSubmit, chatInputRef}) => { | ||
const classes = useStyles({}); | ||
|
||
return ( | ||
<Paper component='form' className={classes.root} onSubmit={onMessageSubmit}> | ||
<InputBase | ||
className={classes.input} | ||
placeholder='메세지를 입력하세요.' | ||
inputRef={chatInputRef} | ||
/> | ||
<IconButton | ||
type='submit' | ||
className={classes.iconButton} | ||
aria-label='search' | ||
> | ||
<SendIcon /> | ||
</IconButton> | ||
</Paper> | ||
); | ||
}; | ||
|
||
ChatInputField.propTypes = { | ||
onMessageSubmit: func, | ||
chatInputRef: refType, | ||
}; | ||
|
||
ChatInputField.defaultProps = { | ||
onMessageSubmit: () => {}, | ||
chatInputRef: null, | ||
}; | ||
|
||
export default ChatInputField; |
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,55 @@ | ||
import React from 'react'; | ||
import {arrayOf} from 'prop-types'; | ||
|
||
// material ui | ||
import {makeStyles} from '@material-ui/core/styles'; | ||
|
||
// components | ||
import ChatRow from './ChatRow'; | ||
|
||
// types | ||
import {uIdType, messageShape} from '../types'; | ||
|
||
// utils | ||
import {getISOCurrentDate} from '../utils'; | ||
|
||
// material ui style | ||
const useStyles = makeStyles(() => ({ | ||
ul: { | ||
backgroundColor: 'inherit', | ||
padding: 0, | ||
}, | ||
})); | ||
|
||
// component | ||
export default function ChatList({messages, currentUser}) { | ||
const classes = useStyles({}); | ||
|
||
return ( | ||
<ul className={classes.ul}> | ||
{messages.map((message) => ( | ||
<ChatRow | ||
key={`item-${message.timestamp}`} | ||
message={message} | ||
currentUser={currentUser} | ||
/> | ||
))} | ||
</ul> | ||
); | ||
} | ||
|
||
ChatList.propTypes = { | ||
messages: arrayOf(messageShape), | ||
currentUser: uIdType, | ||
}; | ||
|
||
ChatList.defaultProps = { | ||
messages: [ | ||
{ | ||
timestamp: getISOCurrentDate(), | ||
content: '', | ||
userId: null, | ||
}, | ||
], | ||
currentUser: null, | ||
}; |
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,50 @@ | ||
import React from 'react'; | ||
|
||
// material ui | ||
import ListItem from '@material-ui/core/ListItem'; | ||
import Grid from '@material-ui/core/Grid'; | ||
|
||
// components | ||
import ChatBox from './ChatBox'; | ||
|
||
// utils | ||
import {getISOCurrentDate} from '../utils'; | ||
|
||
// types | ||
import {uIdType, messageShape} from '../types'; | ||
|
||
// component | ||
const ChatRow = ({message: {userId, content, timestamp}, currentUser}) => ( | ||
<ListItem> | ||
<Grid | ||
container | ||
direction='row' | ||
justify={currentUser === userId ? 'flex-end' : 'flex-start'} | ||
alignItems='center' | ||
> | ||
<Grid item> | ||
<ChatBox | ||
content={content} | ||
timestamp={timestamp} | ||
isMyChat={currentUser === userId} | ||
/> | ||
</Grid> | ||
</Grid> | ||
</ListItem> | ||
); | ||
|
||
ChatRow.propTypes = { | ||
message: messageShape, | ||
currentUser: uIdType, | ||
}; | ||
|
||
ChatRow.defaultProps = { | ||
message: { | ||
timestamp: getISOCurrentDate(), | ||
content: '', | ||
userId: null, | ||
}, | ||
currentUser: null, | ||
}; | ||
|
||
export default ChatRow; |
Oops, something went wrong.