Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes#412: user can now add background image to message section #415

Merged
merged 2 commits into from
Jul 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 31 additions & 8 deletions src/components/ChatApp/MessageSection/MessageSection.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function getStateFromStores() {
composer:'',
body:'',
bodyBackgroundImage:'',
messageBackgroundImage:'',
searchState: {
markedMsgs: [],
markedIDs: [],
Expand Down Expand Up @@ -157,9 +158,15 @@ class MessageSection extends Component {
// Current Changes
}
handleChangeBackgroundImage(backImage){
document.body.style.setProperty('background', 'url('+ backImage+')');
document.body.style.setProperty('background-image', 'url('+ backImage+')');
document.body.style.setProperty('background-repeat', 'no-repeat');
document.body.style.setProperty('background-size', 'cover');
this.setState({bodyBackgroundImage:backImage});
}

handleChangeMessageBackground(backImage){
this.setState({messageBackgroundImage:backImage});
}
handleChangeComplete = (name, color) => {
// Send these Settings to Server
let state = this.state;
Expand Down Expand Up @@ -406,6 +413,12 @@ class MessageSection extends Component {
textAlign: 'center'
}

const messageBackgroundStyles = {
backgroundImage: `url(${this.state.messageBackgroundImage})`,
backgroundRepeat: 'no-repeat',
backgroundSize: '100% 100%'
}

const {
dream
} = this.props;
Expand Down Expand Up @@ -484,19 +497,29 @@ class MessageSection extends Component {
const components = componentsList.map((component) => {
return <div key={component.id} className='circleChoose'>
<h4>Change color of {component.name}:</h4>
<CirclePicker color={component} width={'100%'}
onChangeComplete={ this.handleChangeComplete.bind(this,
component.component) }
onChange={this.handleColorChange.bind(this,component.id)}>
<CirclePicker color={component} width={'100%'}
onChangeComplete={ this.handleChangeComplete.bind(this,
component.component) }
onChange={this.handleColorChange.bind(this,component.id)}>
</CirclePicker>
<TextField name="backgroundImg"
<TextField
name="backgroundImg"
style={{display:component.component==='body'?'block':'none'}}
ref={(input) => { this.backImage = input }}
onChange={
(e,value)=>
this.handleChangeBackgroundImage(value) }
value={this.state.bodyBackgroundImage}
floatingLabelText="Background Image URL" />
floatingLabelText="Body Background Image URL" />
<TextField
name="messageImg"
style={{display:component.component==='body'?'block':'none'}}
ref={(input) => { this.backImage = input }}
onChange={
(e,value)=>
this.handleChangeMessageBackground(value) }
value={this.state.messageBackgroundImage}
floatingLabelText="Message Background Image URL" />
</div>
})

Expand Down Expand Up @@ -546,7 +569,7 @@ class MessageSection extends Component {
<ul
className='message-list'
ref={(c) => { this.messageList = c; }}
style={{background:pane}}>
style={messageBackgroundStyles}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have the background-repeat:none property as well to the styles. @madhavrathi


<Scrollbars
ref={(ref) => { this.scrollarea = ref; }}
Expand Down