This file contains hidden or 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
withContext( | |
{ updateFunctions: PropTypes.object, user: PropTypes.object }, | |
({ selectedUser, addLike, addDislike, deleteLike, deleteDislike }) => ({ | |
user: selectedUser, | |
updateFunctions: { addLike, addDislike, deleteLike, deleteDislike } | |
}) | |
) |
This file contains hidden or 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
const StreamIndex = compose( | |
withState('userList', 'updateUserList', []), | |
withHandlers({ | |
setUserList: ({ updateUserList }) => users => updateUserList(state => users), | |
addLike: ({ updateUserList }) => (user, like) => addUserLike(user, like), | |
addDislike: ({ updateUserList }) => (user, dislike) => addUserDislike(user, dislike), | |
deleteLike: ({ updateUserList }) => (user, like) => | |
deleteUserLike(user, like.id).then(() => | |
updateUserList(state => [ | |
...state.map(i => { |
This file contains hidden or 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
const LikesList = ({ | |
user: { likes, user }, | |
updateFunctions: { addLike, deleteLike } | |
}) => ( | |
<Fragment> | |
<ListHeader> | |
<h3 style={{ margin: 0 }}>Likes</h3> | |
<i className="material-icons" style={{ cursor: 'pointer' }} > | |
add | |
</i> |
This file contains hidden or 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
const modalHandler = mapPropsStream(props$ => { | |
const { stream: isOpen$, handler: toggleModal } = createEventHandler() | |
return props$.pipe( | |
switchMap(props => | |
isOpen$.pipe( | |
startWith(false), | |
scan(bool => !bool), | |
map(isOpen => ({ ...props, isOpen, toggleModal })) | |
) | |
) |
This file contains hidden or 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
const textHandler = mapPropsStream(props$ => { | |
const { stream: onInput$, handler: handleChange } = createEventHandler() | |
const text$ = onInput$.pipe(map(e => e.target.value), startWith('')) | |
return props$.pipe( | |
switchMap(props => text$.pipe(map(text => ({ ...props, text, handleChange })))) | |
) | |
}) |
This file contains hidden or 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
const textHandler = mapPropsStream(props$ => { | |
const { stream: onInput$, handler: handleChange } = createEventHandler() | |
const text$ = onInput$.pipe(map(e => e.target.value), startWith('')) | |
return props$.pipe( | |
switchMap(props => text$.pipe(map(text => ({ ...props, text, handleChange })))) | |
) | |
}) |
This file contains hidden or 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
const Likes = compose( | |
modalHandler, | |
textHandler, | |
getContext({ updateFunctions: PropTypes.object, user: PropTypes.object }) | |
)(LikesList) |
This file contains hidden or 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
const LikesList = ({ | |
user: { likes, user }, | |
updateFunctions: { addLike, deleteLike }, | |
isOpen, | |
text, | |
handleChange, | |
toggleModal | |
}) => ( | |
<Fragment> | |
<ListHeader> |
This file contains hidden or 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
export const AddPopup = ({ open, onChange, handleSubmit, text, closeModal }) => ( | |
<Popup | |
open={open} | |
onSubmit={e => { | |
e.preventDefault() | |
handleSubmit().then(() => closeModal()) | |
}} | |
> | |
<StyledInput autoFocus value={text} onChange={onChange} /> | |
<Button style={{ float: 'right' }} type="submit"> |
This file contains hidden or 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
import * as React from "react" | |
import { voronoi } from "@vx/voronoi" | |
class Voronoi extends React.Component { | |
tile = null | |
componentDidMount() { | |
this.renderPoints() | |
} |