From 7a227dff9180bac37dcf81f7cebf22c0e988e909 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 30 Jan 2017 15:11:16 -0300 Subject: [PATCH] Notification in the CommentStream Working --- client/coral-embed-stream/src/Embed.js | 24 +++++------------ client/coral-embed-stream/style/default.css | 4 +-- .../coral-framework/actions/notification.js | 5 ++-- .../modules/notification/Notification.js | 18 +++++++------ .../coral-framework/reducers/notification.js | 17 ++++++++---- .../containers/SettingsContainer.js | 3 ++- client/coral-ui/components/SnackBar.css | 3 ++- client/coral-ui/components/SnackBar.js | 10 ++++--- views/article.ejs | 26 ++++++++++++++++++- 9 files changed, 70 insertions(+), 40 deletions(-) diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js index de4f7cc8e..03631fe4f 100644 --- a/client/coral-embed-stream/src/Embed.js +++ b/client/coral-embed-stream/src/Embed.js @@ -42,15 +42,6 @@ class Embed extends Component { } componentDidMount () { - - // stream id, logged in user, settings - - // Set up messaging between embedded Iframe an parent component - - // this.props.getStream(path || window.location); - // this.path = window.location.href.split('#')[0]; - // - pym.sendMessage('childReady'); pym.onMessage('DOMContentLoaded', hash => { @@ -69,13 +60,6 @@ class Embed extends Component { } }, 100); }); - console.log(document.documentElement); - document.documentElement.addEventListener('scroll', this.handleScroll); - } - - handleScroll = () => { - const doc = document.documentElement; - console.log((window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0)); } componentWillReceiveProps (nextProps) { @@ -192,7 +176,13 @@ const mapStateToProps = state => ({ const mapDispatchToProps = dispatch => ({ loadAsset: (asset) => dispatch(fetchAssetSuccess(asset)), - addNotification: (type, text) => dispatch(addNotification(type, text)), + addNotification: (type, text) => { + pym.sendMessage('getPosition'); + + pym.onMessage('position', position => { + dispatch(addNotification(type, text, position)); + }); + }, clearNotification: () => dispatch(clearNotification()), showSignInDialog: (offset) => dispatch(showSignInDialog(offset)), logout: () => dispatch(logout()), diff --git a/client/coral-embed-stream/style/default.css b/client/coral-embed-stream/style/default.css index b8592b925..551bc6287 100644 --- a/client/coral-embed-stream/style/default.css +++ b/client/coral-embed-stream/style/default.css @@ -51,7 +51,6 @@ hr { /* Notification styles */ #coral-notif { position: fixed; - bottom: 0; border: 0; background: rgb(105,105,105); color: white; @@ -81,7 +80,8 @@ hr { .commentStream { /* prevent absolutely positioned final permalink popover from being clipped */ padding-bottom: 50px; - /*height: 100vh;*/ + min-height: 775px; + position: relative; } /* Comment Box Styles */ diff --git a/client/coral-framework/actions/notification.js b/client/coral-framework/actions/notification.js index 4edc17601..f0ac4d951 100644 --- a/client/coral-framework/actions/notification.js +++ b/client/coral-framework/actions/notification.js @@ -1,11 +1,12 @@ export const ADD_NOTIFICATION = 'ADD_NOTIFICATION'; export const CLEAR_NOTIFICATION = 'CLEAR_NOTIFICATION'; -export const addNotification = (notifType, text) => { +export const addNotification = (notifType, text, position) => { return { type: ADD_NOTIFICATION, notifType, - text + text, + position }; }; diff --git a/client/coral-framework/modules/notification/Notification.js b/client/coral-framework/modules/notification/Notification.js index 08a5ecbca..5ae8d94d7 100644 --- a/client/coral-framework/modules/notification/Notification.js +++ b/client/coral-framework/modules/notification/Notification.js @@ -8,14 +8,16 @@ const Notification = (props) => { // props.clearNotification(); // }, props.notifLength); } - return
- { - props.notification.text && - - {props.notification.text} - - } -
; + return ( +
+ { + props.notification.text && + + {props.notification.text} + + } +
+ ); }; export default Notification; diff --git a/client/coral-framework/reducers/notification.js b/client/coral-framework/reducers/notification.js index ea8b4889d..fbc58230f 100644 --- a/client/coral-framework/reducers/notification.js +++ b/client/coral-framework/reducers/notification.js @@ -1,14 +1,21 @@ -/* Items Notifications */ - import * as actions from '../actions/notification'; -import {fromJS} from 'immutable'; +import {Map} from 'immutable'; -const initialState = fromJS({}); +const initialState = Map({ + text: '', + type: '', + position: 400 +}); export default (state = initialState, action) => { switch (action.type) { case actions.ADD_NOTIFICATION: - return state.set('text', action.text).set('type', action.notifType); + return state + .merge({ + type: action.notifType, + text: action.text, + position: action.position + }); case actions.CLEAR_NOTIFICATION: return initialState; default: diff --git a/client/coral-settings/containers/SettingsContainer.js b/client/coral-settings/containers/SettingsContainer.js index f02badd80..665ba5e4c 100644 --- a/client/coral-settings/containers/SettingsContainer.js +++ b/client/coral-settings/containers/SettingsContainer.js @@ -1,6 +1,7 @@ import {connect} from 'react-redux'; import {compose} from 'react-apollo'; import React, {Component} from 'react'; +import {addNotification} from '../actions/notification'; import I18n from 'coral-framework/modules/i18n/i18n'; import {myCommentHistory} from 'coral-framework/graphql/queries'; @@ -65,7 +66,7 @@ class SettingsContainer extends Component { } - + ); diff --git a/client/coral-ui/components/SnackBar.css b/client/coral-ui/components/SnackBar.css index 0daf9a152..d973844e4 100644 --- a/client/coral-ui/components/SnackBar.css +++ b/client/coral-ui/components/SnackBar.css @@ -13,6 +13,7 @@ border-radius: 3px; text-align: center; left: 50%; - bottom: 0; transform: translate(-50%, 0); + top: 0; + bottom: auto; } diff --git a/client/coral-ui/components/SnackBar.js b/client/coral-ui/components/SnackBar.js index 380613f4c..9948eaa24 100644 --- a/client/coral-ui/components/SnackBar.js +++ b/client/coral-ui/components/SnackBar.js @@ -1,8 +1,12 @@ import React from 'react'; import styles from './SnackBar.css'; -const SnackBar = ({children}) => ( -
{children}
-); +const SnackBar = ({children, className, position, ...attrs}) => { + return ( +
+ {children} +
+ ); +}; export default SnackBar; diff --git a/views/article.ejs b/views/article.ejs index d0b468cf2..8aaaa1207 100644 --- a/views/article.ejs +++ b/views/article.ejs @@ -28,6 +28,7 @@