From 623c32a0024337a48f759bd21dac5bdc164d21fe Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 6 Dec 2016 12:18:29 -0300 Subject: [PATCH] Configure Stream Ready, Checkbox Coral UI --- .../components/CloseCommentsInfo.js | 0 .../components/ConfigureCommentStream.css | 37 ++++++++++ .../components/ConfigureCommentStream.js | 49 +++++++++++++ .../containers/ConfigureStreamContainer.js | 66 +++++++++++++++++ .../translations.js} | 0 .../coral-embed-stream/src/CommentStream.js | 26 +++---- client/coral-ui/components/Button.css | 10 +++ client/coral-ui/components/Checkbox.css | 70 +++++++++++++++++++ client/coral-ui/components/Checkbox.js | 16 +++++ client/coral-ui/index.js | 1 + 10 files changed, 259 insertions(+), 16 deletions(-) rename client/{coral-framework => coral-configure}/components/CloseCommentsInfo.js (100%) create mode 100644 client/coral-configure/components/ConfigureCommentStream.css create mode 100644 client/coral-configure/components/ConfigureCommentStream.js create mode 100644 client/coral-configure/containers/ConfigureStreamContainer.js rename client/{coral-settings/index.js => coral-configure/translations.js} (100%) create mode 100644 client/coral-ui/components/Checkbox.css create mode 100644 client/coral-ui/components/Checkbox.js diff --git a/client/coral-framework/components/CloseCommentsInfo.js b/client/coral-configure/components/CloseCommentsInfo.js similarity index 100% rename from client/coral-framework/components/CloseCommentsInfo.js rename to client/coral-configure/components/CloseCommentsInfo.js diff --git a/client/coral-configure/components/ConfigureCommentStream.css b/client/coral-configure/components/ConfigureCommentStream.css new file mode 100644 index 000000000..8526edc09 --- /dev/null +++ b/client/coral-configure/components/ConfigureCommentStream.css @@ -0,0 +1,37 @@ +.container { + position: relative; +} + +.apply { + position: absolute; + top: 38%; + transform: translateX(-50%); + right: 0; +} + +ul { + list-style: none; + padding: 0; +} + +ul ul { + padding-left: 20px +} + +.checkbox { + vertical-align: top; + margin: 12px 12px 12px 0; +} + +h4 { + font-size: 14px; + margin-bottom: 5px; +} + +p { + max-width: 380px; +} + +.wrapper { + margin-bottom: 20px; +} diff --git a/client/coral-configure/components/ConfigureCommentStream.js b/client/coral-configure/components/ConfigureCommentStream.js new file mode 100644 index 000000000..4be5714c7 --- /dev/null +++ b/client/coral-configure/components/ConfigureCommentStream.js @@ -0,0 +1,49 @@ +import React from 'react'; +import {Button, Checkbox} from 'coral-ui'; +import styles from './ConfigureCommentStream.css'; + +export default ({handleChange, handleApply, changed}) => ( +
+
+

Configure Comment Stream

+

+ As an admin you may customize the settings for the comment stream for this article +

+ +
+ +
+); diff --git a/client/coral-configure/containers/ConfigureStreamContainer.js b/client/coral-configure/containers/ConfigureStreamContainer.js new file mode 100644 index 000000000..4da5a266d --- /dev/null +++ b/client/coral-configure/containers/ConfigureStreamContainer.js @@ -0,0 +1,66 @@ +import React, {Component} from 'react'; +import {connect} from 'react-redux'; + +import {updateOpenStatus} from '../../coral-framework/actions/config'; + +import CloseCommentsInfo from '../components/CloseCommentsInfo'; +import ConfigureCommentStream from '../components/ConfigureCommentStream'; + +class ConfigureStreamContainer extends Component { + constructor (props) { + super(props); + + this.state = { + premod: false, + premodLinks: false + }; + + this.toggleStatus = this.toggleStatus.bind(this); + this.handleChange = this.handleChange.bind(this); + } + + handleChange (e) { + const {name, checked} = e.target; + this.setState({ + [name]: checked, + changed: true + }); + } + + toggleStatus () { + this.props.updateStatus(this.props.config.status === 'open' ? 'closed' : 'open'); + } + + render () { + const {status} = this.props; + return ( +
+ +
+

{status === 'open' ? 'Close' : 'Open'} Comment Stream

+ +
+ ); + } +} + +const mapStateToProps = (state) => ({ + config: state.config.toJS() +}); + +const mapDispatchToProps = dispatch => ({ + updateStatus: status => dispatch(updateOpenStatus(status)), + handleApply: () => {} +}); + +export default connect( + mapStateToProps, + mapDispatchToProps +)(ConfigureStreamContainer); diff --git a/client/coral-settings/index.js b/client/coral-configure/translations.js similarity index 100% rename from client/coral-settings/index.js rename to client/coral-configure/translations.js diff --git a/client/coral-embed-stream/src/CommentStream.js b/client/coral-embed-stream/src/CommentStream.js index 0fda9444d..8ab7e8d1a 100644 --- a/client/coral-embed-stream/src/CommentStream.js +++ b/client/coral-embed-stream/src/CommentStream.js @@ -6,8 +6,7 @@ import { itemActions, Notification, notificationActions, - authActions, - configActions + authActions } from '../../coral-framework'; import CommentBox from '../../coral-plugin-commentbox/CommentBox'; @@ -27,12 +26,12 @@ import {TabBar, Tab, TabContent, Spinner} from '../../coral-ui'; import SettingsContainer from '../../coral-settings/containers/SettingsContainer'; import RestrictedContent from '../../coral-framework/components/RestrictedContent'; import SuspendedAccount from '../../coral-framework/components/SuspendedAccount'; -import CloseCommentsInfo from '../../coral-framework/components/CloseCommentsInfo'; + +import ConfigureStreamContainer from '../../coral-configure/containers/ConfigureStreamContainer'; const {addItem, updateItem, postItem, getStream, postAction, deleteAction, appendItemArray} = itemActions; const {addNotification, clearNotification} = notificationActions; const {logout, showSignInDialog} = authActions; -const {updateOpenStatus} = configActions; class CommentStream extends Component { @@ -44,7 +43,6 @@ class CommentStream extends Component { }; this.changeTab = this.changeTab.bind(this); - this.toggleStatus = this.toggleStatus.bind(this); } changeTab (tab) { @@ -53,10 +51,6 @@ class CommentStream extends Component { }); } - toggleStatus () { - this.props.updateStatus(this.props.config.status === 'open' ? 'closed' : 'open'); - } - static propTypes = { items: PropTypes.object.isRequired, addItem: PropTypes.func.isRequired, @@ -66,10 +60,9 @@ class CommentStream extends Component { componentDidMount () { // Set up messaging between embedded Iframe an parent component this.pym = new Pym.Child({polling: 100}); - const path = /https?\:\/\/([^?#]+)/.exec(this.pym.parentUrl); + this.props.getStream(window.location); - this.props.getStream(path[1] || window.location); this.path = path; this.pym.sendMessage('childReady'); @@ -92,7 +85,7 @@ class CommentStream extends Component { Settings Configure Stream - {loggedIn && } + {loggedIn && } {/* Add to the restricted param a boolean if the user is suspended*/} }> @@ -238,9 +231,11 @@ class CommentStream extends Component { /> -

{status === 'open' ? 'Close' : 'Open'} Comment Stream

- +
@@ -277,8 +272,7 @@ const mapDispatchToProps = (dispatch) => ({ deleteAction: (item, action, user, itemType) => dispatch(deleteAction(item, action, user, itemType)), appendItemArray: (item, property, value, addToFront, itemType) => dispatch(appendItemArray(item, property, value, addToFront, itemType)), handleSignInDialog: () => dispatch(authActions.showSignInDialog()), - logout: () => dispatch(logout()), - updateStatus: status => dispatch(updateOpenStatus(status)) + logout: () => dispatch(logout()) }); export default connect(mapStateToProps, mapDispatchToProps)(CommentStream); diff --git a/client/coral-ui/components/Button.css b/client/coral-ui/components/Button.css index 3a3a4221e..e36f55886 100644 --- a/client/coral-ui/components/Button.css +++ b/client/coral-ui/components/Button.css @@ -77,6 +77,16 @@ background: #696969; } +.type--green { + color: white; + background: #00897B; +} + +.type--green:hover { + color: white; + background: #00a291; +} + .full { width: 100%; margin: 0; diff --git a/client/coral-ui/components/Checkbox.css b/client/coral-ui/components/Checkbox.css new file mode 100644 index 000000000..d20886689 --- /dev/null +++ b/client/coral-ui/components/Checkbox.css @@ -0,0 +1,70 @@ +.label { + position: relative; + display: inline-block; +} + +.label input { + visibility: hidden; + position: absolute; + left: 7px; + bottom: 7px; + margin: 0; + padding: 0; + outline: none; + cursor: pointer; + opacity: 0; +} + +.checkbox { + cursor: pointer; +} + +.label input[type="checkbox"]:checked + .checkbox:before { + content: "\e834"; +} + +.label input[type="checkbox"] + .checkbox:before { + content: "\e835"; + color: #717171; +} + +.label.type--green input[type="checkbox"] + .checkbox:before { + color: #00a291; +} + +.label input[type="checkbox"] + .checkbox:before { + position: absolute; + left: 4px; + top: 0px; + width: 18px; + height: 18px; + font-family: 'Material Icons'; + font-weight: normal; + font-style: normal; + font-size: 24px; + line-height: 1; + text-transform: none; + letter-spacing: normal; + word-wrap: normal; + white-space: nowrap; + direction: ltr; + vertical-align: -6px; + -webkit-font-smoothing: antialiased; + text-rendering: optimizeLegibility; + -moz-osx-font-smoothing: grayscale; + -webkit-font-feature-settings: 'liga'; + font-feature-settings: 'liga'; + -webkit-transition: all .2s ease; + transition: all .2s ease; + z-index: 1; +} + +.checkboxInfo { + display: inline-block; + max-width: 360px; + margin-left: 50px; +} + +.checkboxInfo h4 { + margin: 0 0 5px; +} diff --git a/client/coral-ui/components/Checkbox.js b/client/coral-ui/components/Checkbox.js new file mode 100644 index 000000000..c4cf6363d --- /dev/null +++ b/client/coral-ui/components/Checkbox.js @@ -0,0 +1,16 @@ +import React from 'react'; +import styles from './Checkbox.css'; + +export default ({name, cStyle = 'base', onChange, label, className, info}) => ( + +); diff --git a/client/coral-ui/index.js b/client/coral-ui/index.js index ffdb3bbd2..afcce7354 100644 --- a/client/coral-ui/index.js +++ b/client/coral-ui/index.js @@ -7,3 +7,4 @@ export {default as TabContent} from './components/TabContent'; export {default as Button} from './components/Button'; export {default as Spinner} from './components/Spinner'; export {default as Tooltip} from './components/Tooltip'; +export {default as Checkbox} from './components/Checkbox';