diff --git a/client/coral-framework/actions/auth.js b/client/coral-framework/actions/auth.js
index fb5e8d3d7..805f9f412 100644
--- a/client/coral-framework/actions/auth.js
+++ b/client/coral-framework/actions/auth.js
@@ -1,6 +1,14 @@
import * as actions from '../constants/auth';
import {base, handleResp, getInit} from '../helpers';
+export const showSignInDialog = () => ({
+ type: actions.SHOW_SIGNIN_DIALOG
+});
+
+export const hideSignInDialog = () => ({
+ type: actions.HIDE_SIGNIN_DIALOG
+});
+
export const loginFacebook = () => dispatch => {
dispatch(loginFacebookRequest());
window.open(
diff --git a/client/coral-framework/constants/auth.js b/client/coral-framework/constants/auth.js
index 7f93a51fe..c69bad344 100644
--- a/client/coral-framework/constants/auth.js
+++ b/client/coral-framework/constants/auth.js
@@ -7,3 +7,5 @@ export const USER_FACEBOOK_FAILURE = 'USER_FACEBOOK_FAILURE';
export const USER_LOGOUT_REQUEST = 'USER_LOGOUT_REQUEST';
export const USER_LOGOUT_SUCCESS = 'USER_LOGOUT_SUCCESS';
export const USER_LOGOUT_FAILURE = 'USER_LOGOUT_FAILURE';
+export const SHOW_SIGNIN_DIALOG = 'SHOW_SIGNIN_DIALOG';
+export const HIDE_SIGNIN_DIALOG = 'HIDE_SIGNIN_DIALOG';
\ No newline at end of file
diff --git a/client/coral-framework/reducers/auth.js b/client/coral-framework/reducers/auth.js
index c585ea237..a6c4369f9 100644
--- a/client/coral-framework/reducers/auth.js
+++ b/client/coral-framework/reducers/auth.js
@@ -1,21 +1,26 @@
import {Map} from 'immutable';
-//
-//import {
-// FETCH_COMMENTERS_REQUEST,
-// FETCH_COMMENTERS_FAILURE,
-// FETCH_COMMENTERS_SUCCESS,
-// SORT_UPDATE
-//} from '../constants/community';
-//
+
+import {
+ SHOW_SIGNIN_DIALOG,
+ HIDE_SIGNIN_DIALOG
+} from '../constants/auth';
+
const initialState = Map({
auth: Map(),
loggedIn: false,
error: '',
- user: {}
+ user: {},
+ showSignInDialog: false
});
export default function community (state = initialState, action) {
switch (action.type) {
+ case SHOW_SIGNIN_DIALOG :
+ return state
+ .set('showSignInDialog', true)
+ case HIDE_SIGNIN_DIALOG :
+ return state
+ .set('showSignInDialog', false)
default :
return state;
}
diff --git a/client/coral-sign-in/components/SignIn.js b/client/coral-sign-in/components/SignIn.js
index 52b6ba19d..ad0fb5ca3 100644
--- a/client/coral-sign-in/components/SignIn.js
+++ b/client/coral-sign-in/components/SignIn.js
@@ -1,18 +1,11 @@
import React from 'react';
-import Button from './Button';
-import I18n from 'coral-framework/modules/i18n/i18n';
-import translations from '../translations';
-const lang = new I18n(translations);
-
-const SignIn = ({openFacebookWindow, logout}) => (
+const SignIn = ({openSignInDialog, children}) => (
);
diff --git a/client/coral-sign-in/components/SignInDialog.js b/client/coral-sign-in/components/SignInDialog.js
new file mode 100644
index 000000000..f4f089a19
--- /dev/null
+++ b/client/coral-sign-in/components/SignInDialog.js
@@ -0,0 +1,37 @@
+import React, {Component} from 'react';
+import { Dialog } from 'coral-ui';
+import styles from './styles.css';
+import Button from './Button';
+import I18n from 'coral-framework/modules/i18n/i18n';
+import translations from '../translations';
+const lang = new I18n(translations);
+
+const SignInDialog = ({open, openFacebookWindow}) => (
+
+);
+
+export default SignInDialog;
diff --git a/client/coral-sign-in/components/styles.css b/client/coral-sign-in/components/styles.css
index 6dbbd5b2f..594b2e701 100644
--- a/client/coral-sign-in/components/styles.css
+++ b/client/coral-sign-in/components/styles.css
@@ -40,4 +40,9 @@
.facebook:hover {
background-color: #365899;
border-color: #365899;
+}
+
+.dialog {
+ width: 400px;
+ border: none;
}
\ No newline at end of file
diff --git a/client/coral-sign-in/containers/SignInContainer.js b/client/coral-sign-in/containers/SignInContainer.js
index 72b46536e..4df96c49a 100644
--- a/client/coral-sign-in/containers/SignInContainer.js
+++ b/client/coral-sign-in/containers/SignInContainer.js
@@ -2,11 +2,14 @@ import React, {Component} from 'react';
import {connect} from 'react-redux';
import SignIn from '../components/SignIn';
+import SignInDialog from '../components/SignInDialog';
+import Button from '../components/Button';
import {
loginFacebookCallback,
loginFacebook,
- logout
+ logout,
+ showSignInDialog
} from '../../coral-framework/actions/auth';
class SignInContainer extends Component {
@@ -14,6 +17,7 @@ class SignInContainer extends Component {
super(props);
this.openFacebookWindow = this.openFacebookWindow.bind(this);
+ this.openSignInDialog = this.openSignInDialog.bind(this);
this.logout = this.logout.bind(this);
}
@@ -29,8 +33,23 @@ class SignInContainer extends Component {
this.props.dispatch(logout());
}
+ openSignInDialog() {
+ this.props.dispatch(showSignInDialog());
+ }
+
render() {
- return ;
+ const {auth} = this.props;
+ return (
+
+
+
+
+ );
}
}
diff --git a/client/coral-ui/components/Dialog.js b/client/coral-ui/components/Dialog.js
new file mode 100644
index 000000000..54f0723e6
--- /dev/null
+++ b/client/coral-ui/components/Dialog.js
@@ -0,0 +1,62 @@
+import React, {Component, PropTypes} from 'react';
+import ReactDOM from 'react-dom';
+import dialogPolyfill from 'dialog-polyfill';
+import 'dialog-polyfill/dialog-polyfill.css';
+
+export default class Dialog extends Component {
+ static propTypes = {
+ className: PropTypes.string,
+ title: PropTypes.string,
+ onCancel: PropTypes.func,
+ onClose: PropTypes.func,
+ open: PropTypes.bool,
+ style: PropTypes.object
+ };
+
+ static defaultProps = {
+ onCancel: e => e.preventDefault(),
+ onClose: e => e.preventDefault()
+ };
+
+ componentDidMount(){
+ const dialog = ReactDOM.findDOMNode(this.refs.dialog);
+ dialogPolyfill.registerDialog(dialog);
+
+ if (this.props.open) {
+ dialog.showModal();
+ }
+
+ dialog.addEventListener('close', this.props.onClose);
+ dialog.addEventListener('cancel', this.props.onCancel);
+ }
+
+ componentDidUpdate(prevProps) {
+ const dialog = ReactDOM.findDOMNode(this.refs.dialog);
+ if (this.props.open !== prevProps.open) {
+ if (this.props.open) {
+ dialog.showModal();
+ } else {
+ dialog.close();
+ }
+ }
+ }
+
+ componentWillUnmount() {
+ const dialog = ReactDOM.findDOMNode(this.refs.dialog);
+ dialog.removeEventListener('cancel', this.props.onCancel);
+ }
+
+ render() {
+ const { children, className = '', onClose, onCancel, open, ...rest } = this.props;
+
+ return (
+
+ )
+ }
+}
\ No newline at end of file
diff --git a/client/coral-ui/index.js b/client/coral-ui/index.js
new file mode 100644
index 000000000..3d76a5912
--- /dev/null
+++ b/client/coral-ui/index.js
@@ -0,0 +1 @@
+export { default as Dialog } from './components/Dialog';
\ No newline at end of file
diff --git a/package.json b/package.json
index 6312e51ff..4341483af 100644
--- a/package.json
+++ b/package.json
@@ -16,8 +16,13 @@
"config": {
"pre-git": {
"commit-msg": [],
- "pre-commit": ["npm run lint", "npm test"],
- "pre-push": ["npm test"],
+ "pre-commit": [
+ "npm run lint",
+ "npm test"
+ ],
+ "pre-push": [
+ "npm test"
+ ],
"post-commit": [],
"post-merge": []
}
@@ -26,7 +31,12 @@
"type": "git",
"url": "git+https://github.com/coralproject/talk.git"
},
- "keywords": ["talk", "coral", "coralproject", "ask"],
+ "keywords": [
+ "talk",
+ "coral",
+ "coralproject",
+ "ask"
+ ],
"author": "",
"license": "Apache-2.0",
"bugs": {
@@ -72,6 +82,7 @@
"chai-http": "^3.0.0",
"copy-webpack-plugin": "^4.0.0",
"css-loader": "^0.25.0",
+ "dialog-polyfill": "^0.4.4",
"eslint": "^3.9.1",
"eslint-config-postcss": "^2.0.2",
"eslint-config-standard": "^6.2.1",