This repository was archived by the owner on May 27, 2022. It is now read-only.
forked from peerplays-network/peerplays-core-gui
-
Notifications
You must be signed in to change notification settings - Fork 1
Wal 123 common msg component removing all msgs #46
Open
MuffinLightning
wants to merge
20
commits into
develop
Choose a base branch
from
WAL-123-Common-msg-component-removing-all-msgs
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
d37dc77
- Fixed filter function within CommonMessageReducer
MuffinLightning a5d7c11
fixed notification sitting behind the aside
aametzler bdeff72
Merge branch 'WAL-59-port-bookie-common-message-component' of https:/…
MuffinLightning c4dbc79
common message now pushes down all pages
aametzler 53f65b2
fixed notification to bottom of header
aametzler 77a15e3
common message component now only renders when location is called + f…
aametzler 74e7e27
resolved merge conflicts
aametzler e145b3a
removed console logs
aametzler 16a8bba
added ability for multiple messages to be displayed below one another
aametzler 6e17133
Modify classnames to be abbreviated better.
mseaward 541592b
Remove mixin as it was uneccessary
mseaward ce2d084
Change message component to use flexbox.
mseaward eaf6ab6
Move cmn-msg wrapper
mseaward 0a15e1e
Fix flexbook multiple declarations.
mseaward 408a365
Modify display of common message to use css-grid
mseaward 3788872
Change styles to optimize display. Remove ignored rules.
mseaward ffa6ad1
Modify hover style of message.
mseaward dcb38e7
Delete Message.js constants file.
mseaward d7a0aed
Update domLoaded to include aside.
MuffinLightning 98de8ff
Ported CommonMessage timer update from BookiePro.
MuffinLightning File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| .header { | ||
| position: fixed; | ||
| //overflow: hidden; | ||
| top: 0; | ||
| left: 0; | ||
| width: 100%; | ||
|
|
||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ import Config from '../../../config/Config'; | |
| import MessageType from '../../constants/MessageTypes'; | ||
| import _ from 'lodash'; | ||
| import './CommonMessage.scss'; | ||
| import Immutable from 'immutable'; | ||
|
|
||
| const compileMessage = (props) => { | ||
| let messageList; | ||
|
|
@@ -14,10 +15,6 @@ const compileMessage = (props) => { | |
| messageList = props.headerMessages; | ||
| } | ||
|
|
||
| if (props.location === 'sideBar') { | ||
| messageList = props.sideBarMessages; | ||
| } | ||
|
|
||
| // Filter the message list to only show the number of messages configured. | ||
| messageList = messageList.slice(0, props.numOfCommonMessageToDisplay); | ||
|
|
||
|
|
@@ -27,19 +24,18 @@ const compileMessage = (props) => { | |
|
|
||
| return ( | ||
| <div | ||
| className={ 'c-common-message__background ' + messageType } | ||
| className={ 'cmn-msg__bkg cmn-msg__bkg--' + messageType } | ||
| key={ key } | ||
| id={ id } | ||
| > | ||
| <div className='c-common-message__content'> | ||
| <span>{pair.get('content') } | ||
| <p onClick={ () => props.clearMessage(id) }>X</p> | ||
| </span> | ||
| <div className='cmn-msg__cont'> | ||
| <span className='cmn-msg__cont-txt'>{pair.get('content') }</span> | ||
| <p className='cmn-msg__cont-dismiss'onClick={ () => props.clearMessage(id) }>X</p> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if this is a modifier, shouldn't it be 'cmn-msg__cont--dismiss'?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it isn't a modifier |
||
| </div> | ||
| </div> | ||
| ); | ||
| }); | ||
| return <div>{messages}</div>; | ||
| return messages; | ||
| }; | ||
|
|
||
| class CommonMessage extends PureComponent { | ||
|
|
@@ -50,43 +46,52 @@ class CommonMessage extends PureComponent { | |
| timeout: null | ||
| }; | ||
|
|
||
| this.timerList = Immutable.List(); | ||
| this.checkToAssignTimer = this.checkToAssignTimer.bind(this); | ||
| } | ||
|
|
||
| setTimer(id) { | ||
| const {timeout} = this.state; | ||
| clearTimeout(timeout); | ||
|
|
||
| this.setState({ | ||
| timeout: setTimeout( | ||
| // Only the most recent message has an associated timer. | ||
| // Other messages will not have a timer until they are shown. | ||
| setTimer(id, index) { | ||
| if (index === 0) { | ||
| this.timerList = this.timerList.push(setTimeout( | ||
| this.props.clearMessage.bind(this, id), Config.commonMessageModule.timeout | ||
| ) | ||
| }); | ||
| )); | ||
| } else { | ||
| this.timerList.forEach((timer, index) => { | ||
| if (index !== this.timerList.size-1) { | ||
| clearTimeout(timer); | ||
| } | ||
| }); | ||
|
|
||
| } | ||
| } | ||
|
|
||
| checkToAssignTimer(messages) { | ||
| messages.forEach((msg) => { | ||
| messages.forEach((msg, index) => { | ||
| let msgType = msg.get('messageType'); | ||
|
|
||
| if (msgType === MessageType.SUCCESS || msgType === MessageType.INFO) { | ||
| this.setTimer(msg.get('id')); | ||
| this.setTimer(msg.get('id'), index); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| componentDidUpdate(prevProps) { | ||
| let propsMerged = this.props.headerMessages.concat(this.props.sideBarMessages); | ||
| let prevPropsMerged = prevProps.headerMessages.concat(prevProps.sideBarMessages); | ||
|
|
||
| componentDidUpdate(prevProps) { | ||
| // Use lodash for a deep comparison of the merged messages. | ||
| if (!_.isEqual(propsMerged, prevPropsMerged)) { | ||
| this.checkToAssignTimer(propsMerged); | ||
| if (!_.isEqual(this.props.headerMessages, prevProps.headerMessages)) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Common Message no longer displays under the header. Looks like something broke in this commit. |
||
| this.checkToAssignTimer(this.props.headerMessages); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| componentDidMount() { | ||
| this.checkToAssignTimer(this.props.headerMessages); | ||
| } | ||
|
|
||
| render() { | ||
| return ( | ||
| <div> | ||
| <div className='cmn-msg'> | ||
| {compileMessage(this.props)} | ||
| </div> | ||
| ); | ||
|
|
@@ -98,47 +103,34 @@ const mapStateToProps = (state) => { | |
|
|
||
| const messages = state.commonMessage; | ||
| let headerMessages = messages.get('headerMessages'); | ||
| let sideBarMessages = messages.get('sideBarMessages'); | ||
| const numOfCommonMessageToDisplay = Config.commonMessageModule.numOfCommonMessageToDisplay; | ||
|
|
||
| if (reverse) { | ||
| headerMessages = headerMessages.reverse(); | ||
| sideBarMessages = sideBarMessages.reverse(); | ||
| } | ||
|
|
||
| // Determine the number of messages for calculating the heigh offset needed. | ||
| let numOfheaderMessages = headerMessages.size; | ||
| let numOfsideBarMessages = sideBarMessages.size; | ||
|
|
||
| if (numOfheaderMessages > numOfCommonMessageToDisplay) { | ||
| numOfheaderMessages = numOfCommonMessageToDisplay; | ||
| } | ||
|
|
||
| if (numOfsideBarMessages > numOfCommonMessageToDisplay) { | ||
| numOfsideBarMessages = numOfCommonMessageToDisplay; | ||
| } | ||
|
|
||
| //Calculate the heights of the exchange child div and the betslip child div. | ||
| const exchangeMessagingHeight = 36 * numOfheaderMessages; | ||
|
|
||
|
|
||
| // Dynamically apply a style to the split panes. | ||
| const messagingDivExist = document.getElementsByClassName('messaging').length > 0; | ||
| //Calculate the heights of the header child div and the betslip child div. | ||
| const messagingHeight = 35 * numOfheaderMessages; | ||
| const domLoaded = document.getElementsByClassName('main').length > 0 && | ||
| document.getElementsByClassName('aside').length > 0; | ||
|
|
||
| if (messagingDivExist) { | ||
| const messagingExchange = document.getElementsByClassName('messaging')[0] | ||
| .children[1].children[0]; | ||
|
|
||
| const messagingBetslip = document.getElementsByClassName('messaging')[0] | ||
| .children[1].children[2]; | ||
| if (domLoaded) { | ||
| // Add padding to the main. | ||
| document.getElementsByClassName('main')[0].style.paddingTop = messagingHeight + 'px'; | ||
|
|
||
| messagingExchange.style.height = 'calc(100% - ' + exchangeMessagingHeight + 'px)'; | ||
| messagingBetslip.style.height = 'calc(100% - ' + exchangeMessagingHeight + 'px)'; | ||
| // Due to the nature of the aside, we need to modify the top value. | ||
| document.getElementsByClassName('aside')[0].style.marginTop = messagingHeight + 'px'; | ||
| } | ||
|
|
||
| return { | ||
| headerMessages, | ||
| sideBarMessages, | ||
| numOfCommonMessageToDisplay | ||
| }; | ||
| }; | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,57 +1,58 @@ | ||
| .c-common-message { | ||
| &__background{ | ||
| position: fixed; | ||
| margin-top: 54px; | ||
| width: 100%; | ||
| top: -36px; | ||
| height: 36px; | ||
| padding: 5px 0; | ||
| display: table; | ||
| z-index: 1; | ||
| color: white; | ||
| animation-name: slideDown; | ||
| animation-duration: 0.2s; | ||
| animation-timing-function: ease-in-out; | ||
| animation-fill-mode: forwards; | ||
| p { | ||
| float: right; | ||
| &:hover { | ||
| cursor: pointer; | ||
| } | ||
| } | ||
| &.info { | ||
| background-color: fade-in(#204496, 1); | ||
| } | ||
| &.error { | ||
| background-color: fade-in(#D60D2E, 1); | ||
| } | ||
| &.warning { | ||
| background-color: fade-in(#FF9603, 1); | ||
| } | ||
| &.success { | ||
| background-color: fade-in(#02A04A, 1); | ||
| } | ||
| &.none { | ||
| display: none; | ||
| } | ||
| } | ||
| &__content { | ||
| text-align: left; | ||
| display: table-cell; | ||
| vertical-align: middle; | ||
| padding: 0 1vw; | ||
| } | ||
| .cmn-msg { | ||
| position: fixed; | ||
| top: 55px; | ||
| width: 100%; | ||
| height: 35px; | ||
| z-index: 1; | ||
| color: white; | ||
|
|
||
| &__bkg{ | ||
| animation-name: slideDown; | ||
| animation-duration: 0.2s; | ||
| animation-timing-function: ease-in-out; | ||
| animation-fill-mode: forwards; | ||
|
|
||
| &--info { | ||
| background-color: fade-in(#204496, 1); | ||
| } | ||
| &--error { | ||
| background-color: fade-in(#D60D2E, 1); | ||
| } | ||
| &--warning { | ||
| background-color: fade-in(#FF9603, 1); | ||
| } | ||
| &--success { | ||
| background-color: fade-in(#02A04A, 1); | ||
| } | ||
| &--none { | ||
| display: none; | ||
| } | ||
| } | ||
|
|
||
| &__cont { | ||
| display: grid; | ||
| grid-template-columns: auto 30px; | ||
| grid-template-areas: 'msg dismiss'; | ||
| padding: 7.25px 1vw; | ||
|
|
||
| &-dismiss { | ||
| justify-self: end; | ||
| &:hover { | ||
| cursor: pointer; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @keyframes slideDown { | ||
| 0% { | ||
| transform: translateY(0%); | ||
| opacity: 0; | ||
| } | ||
| 30% { | ||
| opacity: 1; | ||
| } | ||
| 100% { | ||
| transform: translateY(100%); | ||
| } | ||
| } | ||
| 0% { | ||
| transform: translateY(-100%); | ||
| opacity: 0; | ||
| } | ||
| 30% { | ||
| opacity: 1; | ||
| } | ||
| 100% { | ||
| transform: translateY(0%); | ||
| } | ||
| } |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is a modifier, shouldn't it be 'cmn-msg__cont--text'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it isn't a modifier