Skip to content
Snippets Groups Projects
Commit c278d8b5 authored by Chris Lawton's avatar Chris Lawton
Browse files

style messages

parent d3959254
No related branches found
No related tags found
No related merge requests found
......@@ -4,12 +4,15 @@ import PropTypes from 'prop-types'
import { MESSAGE_TYPES } from '@actions/messages'
const MessageBar = ({ message, type, onDismiss }) => {
const modifierClass = type ? `messages__text--${type}` : '';
return (
<div className={type}>
<p>{message}</p>
{onDismiss && <button onClick={onDismiss}>[X]</button>}
</div>
<li className={`messages__text ${modifierClass}`}>
<div className="messages__inner">
<p className="messages__copy">{message}</p>
{onDismiss && <button className="messages__button" onClick={onDismiss}>Ok</button>}
</div>
</li>
)
}
......
import React from 'react'
import { connect } from 'react-redux'
import PropTypes from 'prop-types'
import MessageBar from '@components/MessageBar'
import { getMessages } from '@selectors/messages'
import { dismissMessage } from '@actions/messages'
const MessagesContainer = ({ messages, dismiss }) => {
return Object.values(messages).map(({ message, type, id}) =>
<MessageBar key={id} message={message} type={type}
onDismiss={() => dismiss(id)} />
return (
<ul className="messages">
{Object.values(messages).map(({ message, type, id}) =>
<MessageBar key={id} message={message} type={type}
onDismiss={() => dismiss(id)} />
)}
</ul>
)
}
......@@ -20,4 +25,9 @@ const mapDispatchToProps = dispatch => ({
dismiss: id => dispatch(dismissMessage(id)),
})
MessagesContainer.propTypes = {
messages: PropTypes.object,
dismiss: PropTypes.func,
}
export default connect(mapStateToProps, mapDispatchToProps)(MessagesContainer)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment