Vulcan/packages/vulcan-base-components/lib/posts/PostsNewButton.jsx

30 lines
989 B
React
Raw Normal View History

2017-03-23 16:27:59 +09:00
import { Components, registerComponent, withCurrentUser } from 'meteor/vulcan:core';
2017-05-19 14:42:43 -06:00
import React from 'react';
import PropTypes from 'prop-types';
2017-06-01 11:42:30 +09:00
import { FormattedMessage, intlShape } from 'meteor/vulcan:i18n';
2017-06-02 07:19:39 +09:00
import Button from 'react-bootstrap/lib/Button';
const PostsNewButton = (props, context) => {
2016-03-25 10:45:28 +09:00
2017-05-19 14:42:43 -06:00
const size = props.currentUser ? 'large' : 'small';
2017-05-16 11:04:43 +09:00
const button = <Button className="posts-new-button" bsStyle="primary"><Components.Icon name="new"/> <FormattedMessage id="posts.new_post"/></Button>;
2016-03-25 10:45:28 +09:00
return (
2017-05-19 14:42:43 -06:00
<Components.ModalTrigger size={size} title={context.intl.formatMessage({ id: 'posts.new_post' })} component={button}>
<Components.PostsNewForm />
</Components.ModalTrigger>
2016-03-25 10:45:28 +09:00
)
}
2017-05-19 14:42:43 -06:00
PostsNewButton.displayName = 'PostsNewButton';
2016-11-15 18:33:16 +01:00
PostsNewButton.propTypes = {
2017-05-19 14:42:43 -06:00
currentUser: PropTypes.object,
2016-11-15 18:33:16 +01:00
};
PostsNewButton.contextTypes = {
2017-05-19 14:42:43 -06:00
messages: PropTypes.object,
2016-06-09 17:42:20 +09:00
intl: intlShape
2016-11-15 18:33:16 +01:00
};
2016-06-09 17:42:20 +09:00
registerComponent('PostsNewButton', PostsNewButton, withCurrentUser);